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.

43 lines
1.1 KiB

@arr = global [6 x i32] [i32 1, i32 2, i32 33, i32 4, i32 5, i32 6]
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 @main() {
entry:
%t0 = alloca i32
%t1 = alloca i32
store i32 0, i32* %t0
store i32 0, i32* %t1
br label %while.cond.1
while.cond.1:
%t2 = load i32, i32* %t0
%t3 = icmp slt i32 %t2, 6
%t4 = zext i1 %t3 to i32
%t5 = icmp ne i32 %t4, 0
br i1 %t5, label %while.body.2, label %while.end.3
while.body.2:
%t6 = load i32, i32* %t1
%t7 = load i32, i32* %t0
%t8 = getelementptr inbounds [6 x i32], [6 x i32]* @arr, i32 0, i32 %t7
%t9 = load i32, i32* %t8
%t10 = add i32 %t6, %t9
store i32 %t10, i32* %t1
%t11 = load i32, i32* %t0
%t12 = add i32 %t11, 1
store i32 %t12, i32* %t0
br label %while.cond.1
while.end.3:
%t13 = load i32, i32* %t1
ret i32 %t13
}