modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/execute/pr69691.c (about)

     1  /* PR rtl-optimization/69691 */
     2  
     3  char u[] = { 46, 97, 99, 104, 52, 0 };
     4  char *v[] = { u, 0 };
     5  struct S { char a[10]; struct S *b[31]; };
     6  struct S r[7], *r2 = r;
     7  static struct S *w = 0;
     8  
     9  __attribute__((noinline, noclone)) int
    10  fn (int x)
    11  {
    12    if (__builtin_strchr (u, x) || x == 96)
    13      return x;
    14    __builtin_abort ();
    15  }
    16  
    17  __attribute__((noinline, noclone)) int
    18  foo (char x)
    19  {
    20    if (x == 0)
    21      __builtin_abort ();
    22    if (fn (x) >= 96 && fn (x) <= 122)
    23      return (fn (x) - 96);
    24    else if (x == 46)
    25      return 0;
    26    else
    27      {
    28        __builtin_printf ("foo %d\n", x);
    29        return -1;
    30      }
    31  }
    32  
    33  __attribute__((noinline, noclone)) void
    34  bar (char **x)
    35  {
    36    char **b, c, *d, e[500], *f, g[10];
    37    int z, l, h, i;
    38    struct S *s;
    39  
    40    w = r2++;
    41    for (b = x; *b; b++)
    42      {
    43        __builtin_strcpy (e, *b);
    44        f = e;
    45        do
    46  	{
    47  	  d = __builtin_strchr (f, 32);
    48  	  if (d)
    49  	    *d = 0;
    50  	  l = __builtin_strlen (f);
    51  	  h = 0;
    52  	  s = w;
    53  	  __builtin_memset (g, 0, sizeof (g));
    54  	  for (z = 0; z < l; z++)
    55  	    {
    56  	      c = f[z];
    57  	      if (c >= 48 && c <= 57)
    58  		g[h] = c - 48;
    59  	      else
    60  		{
    61  		  i = foo (c);
    62  		  if (!s->b[i])
    63  		    {
    64  		      s->b[i] = r2++;
    65  		      if (r2 == &r[7])
    66  			__builtin_abort ();
    67  		    }
    68  		  s = s->b[i];
    69  		  h++;
    70  		}
    71  	    }
    72  	  __builtin_memcpy (s->a, g, 10);
    73  	  if (d)
    74  	    f = d + 1;
    75  	}
    76        while (d);
    77      }
    78  }
    79  
    80  __attribute__((noinline, noclone)) void
    81  baz (char *x)
    82  {
    83    char a[300], b[300];
    84    int z, y, t, l;
    85    struct S *s;
    86  
    87    l = __builtin_strlen (x);
    88    *a = 96;
    89    for (z = 0; z < l; z++)
    90      {
    91        a[z + 1] = fn ((unsigned int) x[z]);
    92        if (foo (a[z + 1]) <= 0)
    93  	return;
    94      }
    95    a[l + 1] = 96;
    96    l += 2;
    97    __builtin_memset (b, 0, l + 2);
    98  
    99    if (!w)
   100      return;
   101  
   102    for (z = 0; z < l; z++)
   103      {
   104        s = w;
   105        for (y = z; y < l; y++)
   106  	{
   107  	  s = s->b[foo (a[y])];
   108  	  if (!s)
   109  	    break;
   110  	  for (t = 0; t <= y - z + 2; t++)
   111  	    if (s->a[t] > b[z + t])
   112  	      b[z + t] = s->a[t];
   113  	}
   114      }
   115    for (z = 3; z < l - 2; z++)
   116      if ((b[z] & 1) == 1)
   117       asm ("");
   118  }
   119  
   120  int
   121  main ()
   122  {
   123    bar (v);
   124    char c[] = { 97, 97, 97, 97, 97, 0 };
   125    baz (c);
   126    return 0;
   127  }