1/* PR tree-optimization/49419 */ 2 3extern void abort (void); 4 5struct S { int w, x, y; } *t; 6 7int 8foo (int n, int f, int *s, int m) 9{ 10 int x, i, a; 11 if (n == -1) 12 return 0; 13 for (x = n, i = 0; t[x].w == f && i < m; i++) 14 x = t[x].x; 15 if (i == m) 16 abort (); 17 a = i + 1; 18 for (x = n; i > 0; i--) 19 { 20 s[i] = t[x].y; 21 x = t[x].x; 22 } 23 s[0] = x; 24 return a; 25} 26 27int 28main (void) 29{ 30 int s[3], i; 31 struct S buf[3] = { { 1, 1, 2 }, { 0, 0, 0 }, { 0, 0, 0 } }; 32 t = buf; 33 if (foo (0, 1, s, 3) != 2) 34 abort (); 35 if (s[0] != 1 || s[1] != 2) 36 abort (); 37 return 0; 38} 39