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.

106 lines
3.4 KiB

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
%t2 = alloca i32, i32 20
%t23 = alloca i32
store i32 2, i32* %t0
%t1 = alloca i32
store i32 20, i32* %t1
%t3 = getelementptr inbounds i32, i32* %t2, i32 0
store i32 1, i32* %t3
%t4 = getelementptr inbounds i32, i32* %t2, i32 1
store i32 2, i32* %t4
%t5 = getelementptr inbounds i32, i32* %t2, i32 2
store i32 0, i32* %t5
%t6 = getelementptr inbounds i32, i32* %t2, i32 3
store i32 0, i32* %t6
%t7 = getelementptr inbounds i32, i32* %t2, i32 4
store i32 0, i32* %t7
%t8 = getelementptr inbounds i32, i32* %t2, i32 5
store i32 0, i32* %t8
%t9 = getelementptr inbounds i32, i32* %t2, i32 6
store i32 0, i32* %t9
%t10 = getelementptr inbounds i32, i32* %t2, i32 7
store i32 0, i32* %t10
%t11 = getelementptr inbounds i32, i32* %t2, i32 8
store i32 0, i32* %t11
%t12 = getelementptr inbounds i32, i32* %t2, i32 9
store i32 0, i32* %t12
%t13 = getelementptr inbounds i32, i32* %t2, i32 10
store i32 0, i32* %t13
%t14 = getelementptr inbounds i32, i32* %t2, i32 11
store i32 0, i32* %t14
%t15 = getelementptr inbounds i32, i32* %t2, i32 12
store i32 0, i32* %t15
%t16 = getelementptr inbounds i32, i32* %t2, i32 13
store i32 0, i32* %t16
%t17 = getelementptr inbounds i32, i32* %t2, i32 14
store i32 0, i32* %t17
%t18 = getelementptr inbounds i32, i32* %t2, i32 15
store i32 0, i32* %t18
%t19 = getelementptr inbounds i32, i32* %t2, i32 16
store i32 0, i32* %t19
%t20 = getelementptr inbounds i32, i32* %t2, i32 17
store i32 0, i32* %t20
%t21 = getelementptr inbounds i32, i32* %t2, i32 18
store i32 0, i32* %t21
%t22 = getelementptr inbounds i32, i32* %t2, i32 19
store i32 0, i32* %t22
store i32 0, i32* %t23
br label %while.cond.1
while.cond.1:
%t24 = load i32, i32* %t0
%t25 = load i32, i32* %t1
%t26 = icmp slt i32 %t24, %t25
%t27 = zext i1 %t26 to i32
%t28 = icmp ne i32 %t27, 0
br i1 %t28, label %while.body.2, label %while.end.3
while.body.2:
%t29 = load i32, i32* %t0
%t30 = getelementptr inbounds i32, i32* %t2, i32 %t29
%t31 = load i32, i32* %t0
%t32 = getelementptr inbounds i32, i32* %t2, i32 %t31
%t33 = load i32, i32* %t32
%t34 = load i32, i32* %t0
%t35 = sub i32 %t34, 1
%t36 = getelementptr inbounds i32, i32* %t2, i32 %t35
%t37 = load i32, i32* %t36
%t38 = add i32 %t33, %t37
%t39 = load i32, i32* %t0
%t40 = sub i32 %t39, 2
%t41 = getelementptr inbounds i32, i32* %t2, i32 %t40
%t42 = load i32, i32* %t41
%t43 = add i32 %t38, %t42
store i32 %t43, i32* %t30
%t44 = load i32, i32* %t23
%t45 = load i32, i32* %t0
%t46 = getelementptr inbounds i32, i32* %t2, i32 %t45
%t47 = load i32, i32* %t46
%t48 = add i32 %t44, %t47
store i32 %t48, i32* %t23
%t49 = load i32, i32* %t0
%t50 = getelementptr inbounds i32, i32* %t2, i32 %t49
%t51 = load i32, i32* %t50
call void @putint(i32 %t51)
call void @putch(i32 10)
%t54 = load i32, i32* %t0
%t55 = add i32 %t54, 1
store i32 %t55, i32* %t0
br label %while.cond.1
while.end.3:
%t56 = load i32, i32* %t23
ret i32 %t56
}