1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
3 
4 extern void abort (void);
5 
6 struct node
7 {
8   struct node *next;
9   struct node *prev;
10 };
11 
12 struct node node;
13 
14 struct head
15 {
16   struct node *first;
17 };
18 
19 struct head heads[5];
20 
21 int k = 2;
22 
23 struct head *head = &heads[2];
24 
25 static int __attribute__((noinline))
foo(void)26 foo (void)
27 {
28   node.prev = (void *)head;
29   head->first = &node;
30 
31   struct node *n = head->first;
32   struct head *h = &heads[k];
33   struct node *next = n->next;
34 
35   if (n->prev == (void *)h)
36     h->first = next;
37   else
38     n->prev->next = next;
39 
40   n->next = h->first;
41   return n->next == &node;
42 }
43 
44 int
main(void)45 main (void)
46 {
47   if (foo ())
48     abort ();
49   return 0;
50 }
51