You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

231 lines
5.5 KiB

@a = global i32 0
@sum = global i32 0
@count = global i32 0
declare i32 @getint()
declare float @getfloat()
declare i32 @getarray(i32* %arg.a)
declare i32 @getfarray(float* %arg.a)
declare i32 @getch()
declare void @putint(i32 %arg.x)
declare void @putfloat(float %arg.x)
declare void @putarray(i32 %arg.n, i32* %arg.a)
declare void @putfarray(i32 %arg.n, float* %arg.a)
declare void @putch(i32 %arg.x)
declare void @starttime()
declare void @stoptime()
define i32 @getA() {
entry:
%t0 = load i32, i32* @count
%t1 = add i32 %t0, 1
store i32 %t1, i32* @count
%t2 = load i32, i32* @count
ret i32 %t2
}
define void @f1(i32 %arg.a) {
entry:
%t12 = alloca i32
%t3 = alloca i32
store i32 %arg.a, i32* %t3
%t4 = load i32, i32* @sum
%t5 = load i32, i32* %t3
%t6 = add i32 %t4, %t5
store i32 %t6, i32* @sum
%t7 = call i32 @getA()
store i32 %t7, i32* %t3
%t8 = load i32, i32* @sum
%t9 = load i32, i32* %t3
%t10 = add i32 %t8, %t9
store i32 %t10, i32* @sum
%t11 = icmp ne i32 1, 0
br i1 %t11, label %if.then.1, label %if.end.2
if.then.1:
%t13 = call i32 @getA()
store i32 %t13, i32* %t12
%t14 = load i32, i32* @sum
%t15 = load i32, i32* %t12
%t16 = add i32 %t14, %t15
store i32 %t16, i32* @sum
br label %if.end.2
if.end.2:
%t17 = load i32, i32* @sum
%t18 = load i32, i32* %t3
%t19 = add i32 %t17, %t18
store i32 %t19, i32* @sum
%t20 = load i32, i32* @sum
%t21 = load i32, i32* %t3
%t22 = add i32 %t20, %t21
store i32 %t22, i32* @sum
ret void
}
define void @f2() {
entry:
%t26 = alloca i32
%t23 = load i32, i32* @sum
%t24 = load i32, i32* @a
%t25 = add i32 %t23, %t24
store i32 %t25, i32* @sum
%t27 = call i32 @getA()
store i32 %t27, i32* %t26
%t28 = load i32, i32* @sum
%t29 = load i32, i32* @a
%t30 = add i32 %t28, %t29
store i32 %t30, i32* @sum
ret void
}
define void @f3() {
entry:
%t31 = alloca i32
%t40 = alloca i32
%t32 = call i32 @getA()
store i32 %t32, i32* %t31
%t33 = load i32, i32* @sum
%t34 = load i32, i32* %t31
%t35 = add i32 %t33, %t34
store i32 %t35, i32* @sum
%t36 = call i32 @getA()
store i32 %t36, i32* %t31
%t37 = load i32, i32* @sum
%t38 = load i32, i32* %t31
%t39 = add i32 %t37, %t38
store i32 %t39, i32* @sum
%t41 = call i32 @getA()
store i32 %t41, i32* %t40
%t42 = load i32, i32* @sum
%t43 = load i32, i32* %t31
%t44 = add i32 %t42, %t43
store i32 %t44, i32* @sum
ret void
}
define i32 @main() {
entry:
%t49 = alloca i32
%t59 = alloca i32
%t65 = alloca i32
%t67 = alloca i32
%t73 = alloca i32
%t90 = alloca i32
%t106 = alloca i32
store i32 0, i32* @sum
%t45 = call i32 @getA()
store i32 %t45, i32* @a
%t46 = load i32, i32* @sum
%t47 = load i32, i32* @a
%t48 = add i32 %t46, %t47
store i32 %t48, i32* @sum
%t50 = call i32 @getA()
store i32 %t50, i32* %t49
%t51 = load i32, i32* %t49
call void @f1(i32 %t51)
call void @f2()
call void @f3()
%t55 = load i32, i32* %t49
call void @f1(i32 %t55)
call void @f2()
call void @f3()
%t60 = call i32 @getA()
store i32 %t60, i32* %t59
%t61 = load i32, i32* %t49
call void @f1(i32 %t61)
call void @f2()
call void @f3()
%t66 = call i32 @getA()
store i32 %t66, i32* %t65
%t68 = call i32 @getA()
store i32 %t68, i32* %t67
%t69 = load i32, i32* %t67
call void @f1(i32 %t69)
call void @f2()
call void @f3()
%t74 = call i32 @getA()
store i32 %t74, i32* %t73
%t75 = load i32, i32* %t73
call void @f1(i32 %t75)
call void @f2()
call void @f3()
%t79 = call i32 @getA()
store i32 %t79, i32* %t73
%t80 = load i32, i32* %t73
call void @f1(i32 %t80)
call void @f2()
call void @f3()
%t84 = load i32, i32* %t49
call void @f1(i32 %t84)
call void @f2()
call void @f3()
br label %while.cond.3
while.cond.3:
%t88 = icmp ne i32 1, 0
br i1 %t88, label %while.body.4, label %while.end.5
while.body.4:
br label %while.cond.6
while.end.5:
%t121 = load i32, i32* @sum
call void @putint(i32 %t121)
ret i32 0
while.cond.6:
%t89 = icmp ne i32 1, 0
br i1 %t89, label %while.body.7, label %while.end.8
while.body.7:
store i32 0, i32* %t90
br label %while.cond.9
while.end.8:
br label %while.end.5
while.cond.9:
%t91 = load i32, i32* %t90
%t92 = icmp slt i32 %t91, 3
%t93 = zext i1 %t92 to i32
%t94 = icmp ne i32 %t93, 0
br i1 %t94, label %while.body.10, label %while.end.11
while.body.10:
br label %while.cond.12
while.end.11:
br label %while.end.8
while.cond.12:
%t95 = icmp ne i32 1, 0
br i1 %t95, label %while.body.13, label %while.end.14
while.body.13:
%t96 = icmp ne i32 1, 0
br i1 %t96, label %if.then.15, label %if.end.16
while.end.14:
%t102 = load i32, i32* %t90
%t103 = icmp eq i32 %t102, 1
%t104 = zext i1 %t103 to i32
%t105 = icmp ne i32 %t104, 0
br i1 %t105, label %if.then.17, label %if.else.18
if.then.15:
%t97 = load i32, i32* %t49
call void @f1(i32 %t97)
call void @f2()
call void @f3()
br label %while.end.14
if.end.16:
%t101 = call i32 @getA()
store i32 %t101, i32* %t49
br label %while.cond.12
if.then.17:
%t107 = call i32 @getA()
store i32 %t107, i32* %t106
%t108 = load i32, i32* %t106
call void @f1(i32 %t108)
call void @f2()
call void @f3()
%t112 = load i32, i32* %t90
%t113 = add i32 %t112, 1
store i32 %t113, i32* %t90
br label %while.cond.9
if.else.18:
%t114 = load i32, i32* %t49
call void @f1(i32 %t114)
call void @f2()
call void @f3()
br label %if.end.19
if.end.19:
%t118 = call i32 @getA()
store i32 %t118, i32* %t49
%t119 = load i32, i32* %t90
%t120 = add i32 %t119, 1
store i32 %t120, i32* %t90
br label %while.cond.9
}