Further comment changes for reformat
[openssl.git] / bugs / sgiccbug.c
1 /* NOCW */
2 /* sgibug.c */
3 /* bug found by Eric Young (eay@mincom.oz.au) May 95 */
4
5 #include <stdio.h>
6
7 /* This compiler bug it present on IRIX 5.3, 5.1 and 4.0.5 (these are
8  * the only versions of IRIX I have access to.
9  * defining FIXBUG removes the bug.
10  * (bug is still present in IRIX 6.3 according to
11  * Gage <agage@forgetmenot.Mines.EDU>
12  */
13  
14 /*-
15  * Compare the output from
16  * cc sgiccbug.c; ./a.out
17  * and
18  * cc -O sgiccbug.c; ./a.out
19  */
20
21 static unsigned long a[4]={0x01234567,0x89ABCDEF,0xFEDCBA98,0x76543210};
22 static unsigned long b[4]={0x89ABCDEF,0xFEDCBA98,0x76543210,0x01234567};
23 static unsigned long c[4]={0x77777778,0x8ACF1357,0x88888888,0x7530ECA9};
24
25 main()
26         {
27         unsigned long r[4];
28         sub(r,a,b);
29         fprintf(stderr,"input a= %08X %08X %08X %08X\n",a[3],a[2],a[1],a[0]);
30         fprintf(stderr,"input b= %08X %08X %08X %08X\n",b[3],b[2],b[1],b[0]);
31         fprintf(stderr,"output = %08X %08X %08X %08X\n",r[3],r[2],r[1],r[0]);
32         fprintf(stderr,"correct= %08X %08X %08X %08X\n",c[3],c[2],c[1],c[0]);
33         }
34
35 int sub(r,a,b)
36 unsigned long *r,*a,*b;
37         {
38         register unsigned long t1,t2,*ap,*bp,*rp;
39         int i,carry;
40 #ifdef FIXBUG
41         unsigned long dummy;
42 #endif
43
44         ap=a;
45         bp=b;
46         rp=r;
47         carry=0;
48         for (i=0; i<4; i++)
49                 {
50                 t1= *(ap++);
51                 t2= *(bp++);
52                 t1=(t1-t2);
53 #ifdef FIXBUG
54                 dummy=t1;
55 #endif
56                 *(rp++)=t1&0xffffffff;
57                 }
58         }