1 /* PR rtl-optimization/25432 */
3 void *malloc (__SIZE_TYPE__);
4 void *realloc (void *, __SIZE_TYPE__);
6 struct A { double x, y; };
7 struct B { double x0, y0, x1, y1; };
8 struct C { int n_points; int dir; struct B bbox; struct A *points; };
9 struct D { int n_segs; struct C segs[1]; };
11 void foo (int, int, int *, int, int *, struct A **, int *, int *,
12 struct D *, int *, struct D **, int *, int **);
13 int baz (struct A, struct A, struct A, struct A);
16 bar (struct D *svp, int *n_points_max,
17 struct A p, int *seg_map, int *active_segs, int i)
22 asi = seg_map[active_segs[i]];
23 seg = &svp->segs[asi];
24 n_points = seg->n_points;
25 seg->points = ((struct A *)
26 realloc (seg->points, (n_points_max[asi] <<= 1) * sizeof (struct A)));
27 seg->points[n_points] = p;
35 int *active_segs, n_active_segs, *cursor, seg_idx;
37 int tmp1, tmp2, asi, i, j, *n_ips, *n_ips_max, n_segs_max;
38 struct A **ips, p_curs, *pts;
40 int *n_points_max, *seg_map, first_share;
43 new_vp = (struct D *) malloc (sizeof (struct D) +
44 (n_segs_max - 1) * sizeof (struct C));
50 active_segs = ((int *) malloc ((vp->n_segs) * sizeof (int)));
51 cursor = ((int *) malloc ((vp->n_segs) * sizeof (int)));
53 seg_map = ((int *) malloc ((vp->n_segs) * sizeof (int)));
54 n_ips = ((int *) malloc ((vp->n_segs) * sizeof (int)));
55 n_ips_max = ((int *) malloc ((vp->n_segs) * sizeof (int)));
56 ips = ((struct A * *) malloc ((vp->n_segs) * sizeof (struct A *)));
58 n_points_max = ((int *) malloc ((n_segs_max) * sizeof (int)));
62 y = vp->segs[0].points[0].y;
63 while (seg_idx < vp->n_segs || n_active_segs > 0)
65 for (i = 0; i < n_active_segs; i++)
68 if (vp->segs[asi].n_points - 1 == cursor[asi] &&
69 vp->segs[asi].points[cursor[asi]].y == y)
73 while (seg_idx < vp->n_segs && y == vp->segs[seg_idx].points[0].y)
77 n_ips_max[seg_idx] = 2;
79 ((struct A *) malloc ((n_ips_max[seg_idx]) * sizeof (struct A)));
80 ips[seg_idx][0] = vp->segs[seg_idx].points[0];
81 pts = ((struct A *) malloc ((16) * sizeof (struct A)));
82 pts[0] = vp->segs[seg_idx].points[0];
84 for (j = i; j < n_active_segs; j++)
86 tmp2 = active_segs[j];
87 active_segs[j] = tmp1;
90 active_segs[n_active_segs] = tmp1;
97 for (i = 0; i < n_active_segs; i++)
100 p_curs = ips[asi][1];
103 bar (new_vp, n_points_max,
104 p_curs, seg_map, active_segs, i);
107 for (j = 0; j < n_ips[asi]; j++)
108 ips[asi][j] = ips[asi][j + 1];
110 if (first_share < 0 || p_curs.x != share_x)
113 active_segs, n_active_segs,
114 cursor, ips, n_ips, n_ips_max, vp, seg_map,
115 &new_vp, &n_segs_max, &n_points_max);
123 active_segs, n_active_segs,
124 cursor, ips, n_ips, n_ips_max, vp, seg_map,
125 &new_vp, &n_segs_max, &n_points_max);