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