1/* PR target/65956 */
2
3struct A { char *a; int b; long long c; };
4char v[3];
5
6__attribute__((noinline, noclone)) void
7fn1 (char *x, char *y)
8{
9  if (x != &v[1] || y != &v[2])
10    __builtin_abort ();
11  v[1]++;
12}
13
14__attribute__((noinline, noclone)) int
15fn2 (char *x)
16{
17  asm volatile ("" : "+g" (x) : : "memory");
18  return x == &v[0];
19}
20
21__attribute__((noinline, noclone)) void
22fn3 (const char *x)
23{
24  if (x[0] != 0)
25    __builtin_abort ();
26}
27
28static struct A
29foo (const char *x, struct A y, struct A z)
30{
31  struct A r = { 0, 0, 0 };
32  if (y.b && z.b)
33    {
34      if (fn2 (y.a) && fn2 (z.a))
35	switch (x[0])
36	  {
37	  case '|':
38	    break;
39	  default:
40	    fn3 (x);
41	  }
42      fn1 (y.a, z.a);
43    }
44  return r;
45}
46
47__attribute__((noinline, noclone)) int
48bar (int x, struct A *y)
49{
50  switch (x)
51    {
52    case 219:
53      foo ("+", y[-2], y[0]);
54    case 220:
55      foo ("-", y[-2], y[0]);
56    }
57}
58
59int
60main ()
61{
62  struct A a[3] = { { &v[1], 1, 1LL }, { &v[0], 0, 0LL }, { &v[2], 2, 2LL } };
63  bar (220, a + 2);
64  if (v[1] != 1)
65    __builtin_abort ();
66  return 0;
67}
68