• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -inline -argpromotion -disable-output
2; ModuleID = '<stdin>'
3target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
4target triple = "i386-apple-darwin9.6"
5	%struct.quad_struct = type { i32, i32, %struct.quad_struct*, %struct.quad_struct*, %struct.quad_struct*, %struct.quad_struct*, %struct.quad_struct* }
6@NumNodes = external global i32		; <i32*> [#uses=0]
7@"\01LC" = external constant [43 x i8]		; <[43 x i8]*> [#uses=0]
8@"\01LC1" = external constant [19 x i8]		; <[19 x i8]*> [#uses=0]
9@"\01LC2" = external constant [17 x i8]		; <[17 x i8]*> [#uses=0]
10
11declare i32 @dealwithargs(i32, i8** nocapture) nounwind
12
13declare i32 @atoi(i8*)
14
15define internal fastcc i32 @adj(i32 %d, i32 %ct) nounwind readnone {
16entry:
17	switch i32 %d, label %return [
18		i32 0, label %bb
19		i32 1, label %bb10
20		i32 2, label %bb5
21		i32 3, label %bb15
22	]
23
24bb:		; preds = %entry
25	switch i32 %ct, label %bb3 [
26		i32 1, label %return
27		i32 0, label %return
28	]
29
30bb3:		; preds = %bb
31	ret i32 0
32
33bb5:		; preds = %entry
34	switch i32 %ct, label %bb8 [
35		i32 3, label %return
36		i32 2, label %return
37	]
38
39bb8:		; preds = %bb5
40	ret i32 0
41
42bb10:		; preds = %entry
43	switch i32 %ct, label %bb13 [
44		i32 1, label %return
45		i32 3, label %return
46	]
47
48bb13:		; preds = %bb10
49	ret i32 0
50
51bb15:		; preds = %entry
52	switch i32 %ct, label %bb18 [
53		i32 2, label %return
54		i32 0, label %return
55	]
56
57bb18:		; preds = %bb15
58	ret i32 0
59
60return:		; preds = %bb15, %bb15, %bb10, %bb10, %bb5, %bb5, %bb, %bb, %entry
61	ret i32 1
62}
63
64declare fastcc i32 @reflect(i32, i32) nounwind readnone
65
66declare i32 @CountTree(%struct.quad_struct* nocapture) nounwind readonly
67
68define internal fastcc %struct.quad_struct* @child(%struct.quad_struct* nocapture %tree, i32 %ct) nounwind readonly {
69entry:
70	switch i32 %ct, label %bb5 [
71		i32 0, label %bb1
72		i32 1, label %bb
73		i32 2, label %bb3
74		i32 3, label %bb2
75	]
76
77bb:		; preds = %entry
78	%0 = getelementptr %struct.quad_struct, %struct.quad_struct* %tree, i32 0, i32 3		; <%struct.quad_struct**> [#uses=1]
79	%1 = load %struct.quad_struct*, %struct.quad_struct** %0, align 4		; <%struct.quad_struct*> [#uses=1]
80	ret %struct.quad_struct* %1
81
82bb1:		; preds = %entry
83	%2 = getelementptr %struct.quad_struct, %struct.quad_struct* %tree, i32 0, i32 2		; <%struct.quad_struct**> [#uses=1]
84	%3 = load %struct.quad_struct*, %struct.quad_struct** %2, align 4		; <%struct.quad_struct*> [#uses=1]
85	ret %struct.quad_struct* %3
86
87bb2:		; preds = %entry
88	%4 = getelementptr %struct.quad_struct, %struct.quad_struct* %tree, i32 0, i32 5		; <%struct.quad_struct**> [#uses=1]
89	%5 = load %struct.quad_struct*, %struct.quad_struct** %4, align 4		; <%struct.quad_struct*> [#uses=1]
90	ret %struct.quad_struct* %5
91
92bb3:		; preds = %entry
93	%6 = getelementptr %struct.quad_struct, %struct.quad_struct* %tree, i32 0, i32 4		; <%struct.quad_struct**> [#uses=1]
94	%7 = load %struct.quad_struct*, %struct.quad_struct** %6, align 4		; <%struct.quad_struct*> [#uses=1]
95	ret %struct.quad_struct* %7
96
97bb5:		; preds = %entry
98	ret %struct.quad_struct* null
99}
100
101define internal fastcc %struct.quad_struct* @gtequal_adj_neighbor(%struct.quad_struct* nocapture %tree, i32 %d) nounwind readonly {
102entry:
103	%0 = getelementptr %struct.quad_struct, %struct.quad_struct* %tree, i32 0, i32 6		; <%struct.quad_struct**> [#uses=1]
104	%1 = load %struct.quad_struct*, %struct.quad_struct** %0, align 4		; <%struct.quad_struct*> [#uses=4]
105	%2 = getelementptr %struct.quad_struct, %struct.quad_struct* %tree, i32 0, i32 1		; <i32*> [#uses=1]
106	%3 = load i32, i32* %2, align 4		; <i32> [#uses=2]
107	%4 = icmp eq %struct.quad_struct* %1, null		; <i1> [#uses=1]
108	br i1 %4, label %bb3, label %bb
109
110bb:		; preds = %entry
111	%5 = call fastcc i32 @adj(i32 %d, i32 %3) nounwind		; <i32> [#uses=1]
112	%6 = icmp eq i32 %5, 0		; <i1> [#uses=1]
113	br i1 %6, label %bb3, label %bb1
114
115bb1:		; preds = %bb
116	%7 = call fastcc %struct.quad_struct* @gtequal_adj_neighbor(%struct.quad_struct* %1, i32 %d) nounwind		; <%struct.quad_struct*> [#uses=1]
117	br label %bb3
118
119bb3:		; preds = %bb1, %bb, %entry
120	%q.0 = phi %struct.quad_struct* [ %7, %bb1 ], [ %1, %bb ], [ %1, %entry ]		; <%struct.quad_struct*> [#uses=4]
121	%8 = icmp eq %struct.quad_struct* %q.0, null		; <i1> [#uses=1]
122	br i1 %8, label %bb7, label %bb4
123
124bb4:		; preds = %bb3
125	%9 = getelementptr %struct.quad_struct, %struct.quad_struct* %q.0, i32 0, i32 0		; <i32*> [#uses=1]
126	%10 = load i32, i32* %9, align 4		; <i32> [#uses=1]
127	%11 = icmp eq i32 %10, 2		; <i1> [#uses=1]
128	br i1 %11, label %bb5, label %bb7
129
130bb5:		; preds = %bb4
131	%12 = call fastcc i32 @reflect(i32 %d, i32 %3) nounwind		; <i32> [#uses=1]
132	%13 = call fastcc %struct.quad_struct* @child(%struct.quad_struct* %q.0, i32 %12) nounwind		; <%struct.quad_struct*> [#uses=1]
133	ret %struct.quad_struct* %13
134
135bb7:		; preds = %bb4, %bb3
136	ret %struct.quad_struct* %q.0
137}
138
139declare fastcc i32 @sum_adjacent(%struct.quad_struct* nocapture, i32, i32, i32) nounwind readonly
140
141define i32 @perimeter(%struct.quad_struct* nocapture %tree, i32 %size) nounwind readonly {
142entry:
143	%0 = getelementptr %struct.quad_struct, %struct.quad_struct* %tree, i32 0, i32 0		; <i32*> [#uses=1]
144	%1 = load i32, i32* %0, align 4		; <i32> [#uses=1]
145	%2 = icmp eq i32 %1, 2		; <i1> [#uses=1]
146	br i1 %2, label %bb, label %bb2
147
148bb:		; preds = %entry
149	%3 = getelementptr %struct.quad_struct, %struct.quad_struct* %tree, i32 0, i32 4		; <%struct.quad_struct**> [#uses=1]
150	%4 = load %struct.quad_struct*, %struct.quad_struct** %3, align 4		; <%struct.quad_struct*> [#uses=1]
151	%5 = sdiv i32 %size, 2		; <i32> [#uses=1]
152	%6 = call i32 @perimeter(%struct.quad_struct* %4, i32 %5) nounwind		; <i32> [#uses=1]
153	%7 = getelementptr %struct.quad_struct, %struct.quad_struct* %tree, i32 0, i32 5		; <%struct.quad_struct**> [#uses=1]
154	%8 = load %struct.quad_struct*, %struct.quad_struct** %7, align 4		; <%struct.quad_struct*> [#uses=1]
155	%9 = sdiv i32 %size, 2		; <i32> [#uses=1]
156	%10 = call i32 @perimeter(%struct.quad_struct* %8, i32 %9) nounwind		; <i32> [#uses=1]
157	%11 = add i32 %10, %6		; <i32> [#uses=1]
158	%12 = getelementptr %struct.quad_struct, %struct.quad_struct* %tree, i32 0, i32 3		; <%struct.quad_struct**> [#uses=1]
159	%13 = load %struct.quad_struct*, %struct.quad_struct** %12, align 4		; <%struct.quad_struct*> [#uses=1]
160	%14 = sdiv i32 %size, 2		; <i32> [#uses=1]
161	%15 = call i32 @perimeter(%struct.quad_struct* %13, i32 %14) nounwind		; <i32> [#uses=1]
162	%16 = add i32 %15, %11		; <i32> [#uses=1]
163	%17 = getelementptr %struct.quad_struct, %struct.quad_struct* %tree, i32 0, i32 2		; <%struct.quad_struct**> [#uses=1]
164	%18 = load %struct.quad_struct*, %struct.quad_struct** %17, align 4		; <%struct.quad_struct*> [#uses=1]
165	%19 = sdiv i32 %size, 2		; <i32> [#uses=1]
166	%20 = call i32 @perimeter(%struct.quad_struct* %18, i32 %19) nounwind		; <i32> [#uses=1]
167	%21 = add i32 %20, %16		; <i32> [#uses=1]
168	ret i32 %21
169
170bb2:		; preds = %entry
171	%22 = getelementptr %struct.quad_struct, %struct.quad_struct* %tree, i32 0, i32 0		; <i32*> [#uses=1]
172	%23 = load i32, i32* %22, align 4		; <i32> [#uses=1]
173	%24 = icmp eq i32 %23, 0		; <i1> [#uses=1]
174	br i1 %24, label %bb3, label %bb23
175
176bb3:		; preds = %bb2
177	%25 = call fastcc %struct.quad_struct* @gtequal_adj_neighbor(%struct.quad_struct* %tree, i32 0) nounwind		; <%struct.quad_struct*> [#uses=4]
178	%26 = icmp eq %struct.quad_struct* %25, null		; <i1> [#uses=1]
179	br i1 %26, label %bb8, label %bb4
180
181bb4:		; preds = %bb3
182	%27 = getelementptr %struct.quad_struct, %struct.quad_struct* %25, i32 0, i32 0		; <i32*> [#uses=1]
183	%28 = load i32, i32* %27, align 4		; <i32> [#uses=1]
184	%29 = icmp eq i32 %28, 1		; <i1> [#uses=1]
185	br i1 %29, label %bb8, label %bb6
186
187bb6:		; preds = %bb4
188	%30 = getelementptr %struct.quad_struct, %struct.quad_struct* %25, i32 0, i32 0		; <i32*> [#uses=1]
189	%31 = load i32, i32* %30, align 4		; <i32> [#uses=1]
190	%32 = icmp eq i32 %31, 2		; <i1> [#uses=1]
191	br i1 %32, label %bb7, label %bb8
192
193bb7:		; preds = %bb6
194	%33 = call fastcc i32 @sum_adjacent(%struct.quad_struct* %25, i32 3, i32 2, i32 %size) nounwind		; <i32> [#uses=1]
195	br label %bb8
196
197bb8:		; preds = %bb7, %bb6, %bb4, %bb3
198	%retval1.1 = phi i32 [ 0, %bb6 ], [ %33, %bb7 ], [ %size, %bb4 ], [ %size, %bb3 ]		; <i32> [#uses=3]
199	%34 = call fastcc %struct.quad_struct* @gtequal_adj_neighbor(%struct.quad_struct* %tree, i32 1) nounwind		; <%struct.quad_struct*> [#uses=4]
200	%35 = icmp eq %struct.quad_struct* %34, null		; <i1> [#uses=1]
201	br i1 %35, label %bb10, label %bb9
202
203bb9:		; preds = %bb8
204	%36 = getelementptr %struct.quad_struct, %struct.quad_struct* %34, i32 0, i32 0		; <i32*> [#uses=1]
205	%37 = load i32, i32* %36, align 4		; <i32> [#uses=1]
206	%38 = icmp eq i32 %37, 1		; <i1> [#uses=1]
207	br i1 %38, label %bb10, label %bb11
208
209bb10:		; preds = %bb9, %bb8
210	%39 = add i32 %retval1.1, %size		; <i32> [#uses=1]
211	br label %bb13
212
213bb11:		; preds = %bb9
214	%40 = getelementptr %struct.quad_struct, %struct.quad_struct* %34, i32 0, i32 0		; <i32*> [#uses=1]
215	%41 = load i32, i32* %40, align 4		; <i32> [#uses=1]
216	%42 = icmp eq i32 %41, 2		; <i1> [#uses=1]
217	br i1 %42, label %bb12, label %bb13
218
219bb12:		; preds = %bb11
220	%43 = call fastcc i32 @sum_adjacent(%struct.quad_struct* %34, i32 2, i32 0, i32 %size) nounwind		; <i32> [#uses=1]
221	%44 = add i32 %43, %retval1.1		; <i32> [#uses=1]
222	br label %bb13
223
224bb13:		; preds = %bb12, %bb11, %bb10
225	%retval1.2 = phi i32 [ %retval1.1, %bb11 ], [ %44, %bb12 ], [ %39, %bb10 ]		; <i32> [#uses=3]
226	%45 = call fastcc %struct.quad_struct* @gtequal_adj_neighbor(%struct.quad_struct* %tree, i32 2) nounwind		; <%struct.quad_struct*> [#uses=4]
227	%46 = icmp eq %struct.quad_struct* %45, null		; <i1> [#uses=1]
228	br i1 %46, label %bb15, label %bb14
229
230bb14:		; preds = %bb13
231	%47 = getelementptr %struct.quad_struct, %struct.quad_struct* %45, i32 0, i32 0		; <i32*> [#uses=1]
232	%48 = load i32, i32* %47, align 4		; <i32> [#uses=1]
233	%49 = icmp eq i32 %48, 1		; <i1> [#uses=1]
234	br i1 %49, label %bb15, label %bb16
235
236bb15:		; preds = %bb14, %bb13
237	%50 = add i32 %retval1.2, %size		; <i32> [#uses=1]
238	br label %bb18
239
240bb16:		; preds = %bb14
241	%51 = getelementptr %struct.quad_struct, %struct.quad_struct* %45, i32 0, i32 0		; <i32*> [#uses=1]
242	%52 = load i32, i32* %51, align 4		; <i32> [#uses=1]
243	%53 = icmp eq i32 %52, 2		; <i1> [#uses=1]
244	br i1 %53, label %bb17, label %bb18
245
246bb17:		; preds = %bb16
247	%54 = call fastcc i32 @sum_adjacent(%struct.quad_struct* %45, i32 0, i32 1, i32 %size) nounwind		; <i32> [#uses=1]
248	%55 = add i32 %54, %retval1.2		; <i32> [#uses=1]
249	br label %bb18
250
251bb18:		; preds = %bb17, %bb16, %bb15
252	%retval1.3 = phi i32 [ %retval1.2, %bb16 ], [ %55, %bb17 ], [ %50, %bb15 ]		; <i32> [#uses=3]
253	%56 = call fastcc %struct.quad_struct* @gtequal_adj_neighbor(%struct.quad_struct* %tree, i32 3) nounwind		; <%struct.quad_struct*> [#uses=4]
254	%57 = icmp eq %struct.quad_struct* %56, null		; <i1> [#uses=1]
255	br i1 %57, label %bb20, label %bb19
256
257bb19:		; preds = %bb18
258	%58 = getelementptr %struct.quad_struct, %struct.quad_struct* %56, i32 0, i32 0		; <i32*> [#uses=1]
259	%59 = load i32, i32* %58, align 4		; <i32> [#uses=1]
260	%60 = icmp eq i32 %59, 1		; <i1> [#uses=1]
261	br i1 %60, label %bb20, label %bb21
262
263bb20:		; preds = %bb19, %bb18
264	%61 = add i32 %retval1.3, %size		; <i32> [#uses=1]
265	ret i32 %61
266
267bb21:		; preds = %bb19
268	%62 = getelementptr %struct.quad_struct, %struct.quad_struct* %56, i32 0, i32 0		; <i32*> [#uses=1]
269	%63 = load i32, i32* %62, align 4		; <i32> [#uses=1]
270	%64 = icmp eq i32 %63, 2		; <i1> [#uses=1]
271	br i1 %64, label %bb22, label %bb23
272
273bb22:		; preds = %bb21
274	%65 = call fastcc i32 @sum_adjacent(%struct.quad_struct* %56, i32 1, i32 3, i32 %size) nounwind		; <i32> [#uses=1]
275	%66 = add i32 %65, %retval1.3		; <i32> [#uses=1]
276	ret i32 %66
277
278bb23:		; preds = %bb21, %bb2
279	%retval1.0 = phi i32 [ 0, %bb2 ], [ %retval1.3, %bb21 ]		; <i32> [#uses=1]
280	ret i32 %retval1.0
281}
282
283declare i32 @main(i32, i8** nocapture) noreturn nounwind
284
285declare i32 @printf(i8*, ...) nounwind
286
287declare void @exit(i32) noreturn nounwind
288
289declare fastcc i32 @CheckOutside(i32, i32) nounwind readnone
290
291declare fastcc i32 @CheckIntersect(i32, i32, i32) nounwind readnone
292
293declare %struct.quad_struct* @MakeTree(i32, i32, i32, i32, i32, %struct.quad_struct*, i32, i32) nounwind
294