modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/compile/20020706-1.c (about)

     1  // Contributed by Alexandre Oliva <aoliva@redhat.com>
     2  // From Red Hat case 106165.
     3  
     4  typedef struct s1
     5  {
     6    unsigned short v1;
     7    unsigned char *v2;
     8  } S1;
     9  
    10  extern void bar(const struct s1 *const hdb);
    11  extern unsigned char* foo ();
    12  
    13  unsigned int sn;
    14  S1 *hdb;
    15  S1 *pb;
    16  unsigned short len;
    17  
    18  unsigned int crashIt()
    19  {
    20    unsigned char *p;
    21    unsigned int nsn;
    22    unsigned short cnt;
    23  
    24    if (sn != 0) return 1;
    25  
    26    if ((len < 12) || ((p = (((pb->v1) >= 8) ? pb->v2 : foo() )) == 0))
    27      return 1;
    28  
    29    nsn = (
    30  	 (((*(unsigned int*)p) & 0x000000ff) << 24) |
    31  	 (((*(unsigned int*)p) & 0x0000ff00) << 8)  |
    32  	 (((*(unsigned int*)p) & 0x00ff0000) >> 8)  |
    33  	 (((*(unsigned int*)p) & 0xff000000) >> 24)  );
    34    p += 4;
    35  
    36    cnt = (unsigned short) ((
    37  			   (((*(unsigned int*)p) & 0x000000ff) << 24) |
    38  			   (((*(unsigned int*)p) & 0x0000ff00) << 8)  |
    39  			   (((*(unsigned int*)p) & 0x00ff0000) >> 8)  |
    40  			   (((*(unsigned int*)p) & 0xff000000) >> 24)  ) &
    41  			  0xffff);
    42  
    43    if ((len != 12 + (cnt * 56)) || (nsn == 0))
    44      {
    45        bar(hdb);
    46        return 1;
    47      }
    48  
    49    return 0;
    50  }