1 /* { dg-do compile } */
2 /* { dg-options "-O2 -mjsr" } */
4 void *malloc (__SIZE_TYPE__
);
5 void *realloc (void *, __SIZE_TYPE__
);
7 struct A
{ double x
, y
; };
8 struct B
{ double x0
, y0
, x1
, y1
; };
9 struct C
{ int n_points
; int dir
; struct B bbox
; struct A
*points
; };
10 struct D
{ int n_segs
; struct C segs
[1]; };
12 void foo (int, int, int *, int, int *, struct A
**, int *, int *,
13 struct D
*, int *, struct D
**, int *, int **);
14 int baz (struct A
, struct A
, struct A
, struct A
);
17 bar (struct D
*svp
, int *n_points_max
,
18 struct A p
, int *seg_map
, int *active_segs
, int i
)
23 asi
= seg_map
[active_segs
[i
]];
24 seg
= &svp
->segs
[asi
];
25 n_points
= seg
->n_points
;
26 seg
->points
= ((struct A
*)
27 realloc (seg
->points
, (n_points_max
[asi
] <<= 1) * sizeof (struct A
)));
28 seg
->points
[n_points
] = p
;
36 int *active_segs
, n_active_segs
, *cursor
, seg_idx
;
38 int tmp1
, tmp2
, asi
, i
, j
, *n_ips
, *n_ips_max
, n_segs_max
;
39 struct A
**ips
, p_curs
, *pts
;
41 int *n_points_max
, *seg_map
, first_share
;
44 new_vp
= (struct D
*) malloc (sizeof (struct D
) +
45 (n_segs_max
- 1) * sizeof (struct C
));
51 active_segs
= ((int *) malloc ((vp
->n_segs
) * sizeof (int)));
52 cursor
= ((int *) malloc ((vp
->n_segs
) * sizeof (int)));
54 seg_map
= ((int *) malloc ((vp
->n_segs
) * sizeof (int)));
55 n_ips
= ((int *) malloc ((vp
->n_segs
) * sizeof (int)));
56 n_ips_max
= ((int *) malloc ((vp
->n_segs
) * sizeof (int)));
57 ips
= ((struct A
* *) malloc ((vp
->n_segs
) * sizeof (struct A
*)));
59 n_points_max
= ((int *) malloc ((n_segs_max
) * sizeof (int)));
63 y
= vp
->segs
[0].points
[0].y
;
64 while (seg_idx
< vp
->n_segs
|| n_active_segs
> 0)
66 for (i
= 0; i
< n_active_segs
; i
++)
69 if (vp
->segs
[asi
].n_points
- 1 == cursor
[asi
] &&
70 vp
->segs
[asi
].points
[cursor
[asi
]].y
== y
)
74 while (seg_idx
< vp
->n_segs
&& y
== vp
->segs
[seg_idx
].points
[0].y
)
78 n_ips_max
[seg_idx
] = 2;
80 ((struct A
*) malloc ((n_ips_max
[seg_idx
]) * sizeof (struct A
)));
81 ips
[seg_idx
][0] = vp
->segs
[seg_idx
].points
[0];
82 pts
= ((struct A
*) malloc ((16) * sizeof (struct A
)));
83 pts
[0] = vp
->segs
[seg_idx
].points
[0];
85 for (j
= i
; j
< n_active_segs
; j
++)
87 tmp2
= active_segs
[j
];
88 active_segs
[j
] = tmp1
;
91 active_segs
[n_active_segs
] = tmp1
;
98 for (i
= 0; i
< n_active_segs
; i
++)
100 asi
= active_segs
[i
];
101 p_curs
= ips
[asi
][1];
104 bar (new_vp
, n_points_max
,
105 p_curs
, seg_map
, active_segs
, i
);
108 for (j
= 0; j
< n_ips
[asi
]; j
++)
109 ips
[asi
][j
] = ips
[asi
][j
+ 1];
111 if (first_share
< 0 || p_curs
.x
!= share_x
)
114 active_segs
, n_active_segs
,
115 cursor
, ips
, n_ips
, n_ips_max
, vp
, seg_map
,
116 &new_vp
, &n_segs_max
, &n_points_max
);
124 active_segs
, n_active_segs
,
125 cursor
, ips
, n_ips
, n_ips_max
, vp
, seg_map
,
126 &new_vp
, &n_segs_max
, &n_points_max
);
134 /* { dg-final { scan-assembler-not "bsr" } } */