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.

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