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.

82 lines
1.9 KiB

@a = global i32 7
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 @func() {
entry:
%t0 = alloca i32
%t2 = alloca i32
%t1 = load i32, i32* @a
store i32 %t1, i32* %t0
store i32 1, i32* %t2
%t3 = load i32, i32* %t2
%t4 = load i32, i32* %t0
%t5 = icmp eq i32 %t3, %t4
%t6 = zext i1 %t5 to i32
%t7 = icmp ne i32 %t6, 0
br i1 %t7, label %if.then.1, label %if.else.2
if.then.1:
%t8 = load i32, i32* %t2
%t9 = add i32 %t8, 1
store i32 %t9, i32* %t2
ret i32 1
if.else.2:
ret i32 0
if.end.3:
ret i32 0
}
define i32 @main() {
entry:
%t10 = alloca i32
%t11 = alloca i32
store i32 0, i32* %t10
store i32 0, i32* %t11
br label %while.cond.4
while.cond.4:
%t12 = load i32, i32* %t11
%t13 = icmp slt i32 %t12, 100
%t14 = zext i1 %t13 to i32
%t15 = icmp ne i32 %t14, 0
br i1 %t15, label %while.body.5, label %while.end.6
while.body.5:
%t16 = call i32 @func()
%t17 = icmp eq i32 %t16, 1
%t18 = zext i1 %t17 to i32
%t19 = icmp ne i32 %t18, 0
br i1 %t19, label %if.then.7, label %if.end.8
while.end.6:
%t24 = load i32, i32* %t10
%t25 = icmp slt i32 %t24, 100
%t26 = zext i1 %t25 to i32
%t27 = icmp ne i32 %t26, 0
br i1 %t27, label %if.then.9, label %if.else.10
if.then.7:
%t20 = load i32, i32* %t10
%t21 = add i32 %t20, 1
store i32 %t21, i32* %t10
br label %if.end.8
if.end.8:
%t22 = load i32, i32* %t11
%t23 = add i32 %t22, 1
store i32 %t23, i32* %t11
br label %while.cond.4
if.then.9:
call void @putint(i32 1)
br label %if.end.11
if.else.10:
call void @putint(i32 0)
br label %if.end.11
if.end.11:
ret i32 0
}