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.

226 lines
6.7 KiB

@x = global i32 0
@N = global i32 2010
@A = global [4040100 x i32] zeroinitializer
@B = global [2010 x i32] zeroinitializer
@C = global [2010 x i32] zeroinitializer
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 void @mv(i32 %arg.n, i32* %arg.A, i32* %arg.b, i32* %arg.res) {
entry:
%t1 = alloca i32
%t2 = alloca i32
%t3 = alloca i32
%t4 = alloca i32
%t0 = alloca i32
store i32 %arg.n, i32* %t0
store i32 0, i32* %t1
store i32 0, i32* %t2
store i32 0, i32* %t2
store i32 11, i32* %t1
store i32 0, i32* %t3
store i32 0, i32* %t4
store i32 0, i32* %t3
br label %while.cond.1
while.cond.1:
%t5 = load i32, i32* %t3
%t6 = load i32, i32* %t0
%t7 = icmp slt i32 %t5, %t6
%t8 = zext i1 %t7 to i32
%t9 = icmp ne i32 %t8, 0
br i1 %t9, label %while.body.2, label %while.end.3
while.body.2:
%t10 = load i32, i32* %t3
%t11 = getelementptr inbounds i32, i32* %arg.res, i32 %t10
store i32 0, i32* %t11
%t12 = load i32, i32* %t3
%t13 = add i32 %t12, 1
store i32 %t13, i32* %t3
br label %while.cond.1
while.end.3:
store i32 0, i32* %t3
store i32 0, i32* %t4
br label %while.cond.4
while.cond.4:
%t14 = load i32, i32* %t3
%t15 = load i32, i32* %t0
%t16 = icmp slt i32 %t14, %t15
%t17 = zext i1 %t16 to i32
%t18 = icmp ne i32 %t17, 0
br i1 %t18, label %while.body.5, label %while.end.6
while.body.5:
store i32 0, i32* %t4
br label %while.cond.7
while.end.6:
ret void
while.cond.7:
%t19 = load i32, i32* %t4
%t20 = load i32, i32* %t0
%t21 = icmp slt i32 %t19, %t20
%t22 = zext i1 %t21 to i32
%t23 = icmp ne i32 %t22, 0
br i1 %t23, label %while.body.8, label %while.end.9
while.body.8:
%t24 = load i32, i32* %t3
%t25 = load i32, i32* %t4
%t26 = mul i32 %t24, 2010
%t27 = add i32 %t26, %t25
%t28 = getelementptr inbounds i32, i32* %arg.A, i32 %t27
%t29 = load i32, i32* %t28
%t30 = icmp eq i32 %t29, 0
%t31 = zext i1 %t30 to i32
%t32 = icmp ne i32 %t31, 0
br i1 %t32, label %if.then.10, label %if.else.11
while.end.9:
%t63 = load i32, i32* %t3
%t64 = add i32 %t63, 1
store i32 %t64, i32* %t3
br label %while.cond.4
if.then.10:
%t33 = load i32, i32* %t1
%t34 = load i32, i32* %t3
%t35 = getelementptr inbounds i32, i32* %arg.b, i32 %t34
%t36 = load i32, i32* %t35
%t37 = mul i32 %t33, %t36
%t38 = load i32, i32* %t4
%t39 = getelementptr inbounds i32, i32* %arg.b, i32 %t38
%t40 = load i32, i32* %t39
%t41 = add i32 %t37, %t40
store i32 %t41, i32* %t1
%t42 = load i32, i32* %t2
%t43 = load i32, i32* %t1
%t44 = sub i32 %t42, %t43
store i32 %t44, i32* %t2
br label %if.end.12
if.else.11:
%t45 = load i32, i32* %t3
%t46 = getelementptr inbounds i32, i32* %arg.res, i32 %t45
%t47 = load i32, i32* %t3
%t48 = getelementptr inbounds i32, i32* %arg.res, i32 %t47
%t49 = load i32, i32* %t48
%t50 = load i32, i32* %t3
%t51 = load i32, i32* %t4
%t52 = mul i32 %t50, 2010
%t53 = add i32 %t52, %t51
%t54 = getelementptr inbounds i32, i32* %arg.A, i32 %t53
%t55 = load i32, i32* %t54
%t56 = load i32, i32* %t4
%t57 = getelementptr inbounds i32, i32* %arg.b, i32 %t56
%t58 = load i32, i32* %t57
%t59 = mul i32 %t55, %t58
%t60 = add i32 %t49, %t59
store i32 %t60, i32* %t46
br label %if.end.12
if.end.12:
%t61 = load i32, i32* %t4
%t62 = add i32 %t61, 1
store i32 %t62, i32* %t4
br label %while.cond.7
}
define i32 @main() {
entry:
%t65 = alloca i32
%t67 = alloca i32
%t68 = alloca i32
%t66 = call i32 @getint()
store i32 %t66, i32* %t65
store i32 0, i32* %t67
store i32 0, i32* %t68
store i32 0, i32* %t67
br label %while.cond.13
while.cond.13:
%t69 = load i32, i32* %t67
%t70 = load i32, i32* %t65
%t71 = icmp slt i32 %t69, %t70
%t72 = zext i1 %t71 to i32
%t73 = icmp ne i32 %t72, 0
br i1 %t73, label %while.body.14, label %while.end.15
while.body.14:
store i32 0, i32* %t68
br label %while.cond.16
while.end.15:
store i32 0, i32* %t67
br label %while.cond.19
while.cond.16:
%t74 = load i32, i32* %t68
%t75 = load i32, i32* %t65
%t76 = icmp slt i32 %t74, %t75
%t77 = zext i1 %t76 to i32
%t78 = icmp ne i32 %t77, 0
br i1 %t78, label %while.body.17, label %while.end.18
while.body.17:
%t79 = load i32, i32* %t67
%t80 = load i32, i32* %t68
%t81 = mul i32 %t79, 2010
%t82 = add i32 %t81, %t80
%t83 = getelementptr inbounds [4040100 x i32], [4040100 x i32]* @A, i32 0, i32 %t82
%t84 = call i32 @getint()
store i32 %t84, i32* %t83
%t85 = load i32, i32* %t68
%t86 = add i32 %t85, 1
store i32 %t86, i32* %t68
br label %while.cond.16
while.end.18:
%t87 = load i32, i32* %t67
%t88 = add i32 %t87, 1
store i32 %t88, i32* %t67
br label %while.cond.13
while.cond.19:
%t89 = load i32, i32* %t67
%t90 = load i32, i32* %t65
%t91 = icmp slt i32 %t89, %t90
%t92 = zext i1 %t91 to i32
%t93 = icmp ne i32 %t92, 0
br i1 %t93, label %while.body.20, label %while.end.21
while.body.20:
%t94 = load i32, i32* %t67
%t95 = getelementptr inbounds [2010 x i32], [2010 x i32]* @B, i32 0, i32 %t94
%t96 = call i32 @getint()
store i32 %t96, i32* %t95
%t97 = load i32, i32* %t67
%t98 = add i32 %t97, 1
store i32 %t98, i32* %t67
br label %while.cond.19
while.end.21:
call void @starttime()
store i32 0, i32* %t67
br label %while.cond.22
while.cond.22:
%t100 = load i32, i32* %t67
%t101 = icmp slt i32 %t100, 50
%t102 = zext i1 %t101 to i32
%t103 = icmp ne i32 %t102, 0
br i1 %t103, label %while.body.23, label %while.end.24
while.body.23:
%t104 = load i32, i32* %t65
%t105 = getelementptr inbounds [4040100 x i32], [4040100 x i32]* @A, i32 0, i32 0
%t106 = getelementptr inbounds [2010 x i32], [2010 x i32]* @B, i32 0, i32 0
%t107 = getelementptr inbounds [2010 x i32], [2010 x i32]* @C, i32 0, i32 0
call void @mv(i32 %t104, i32* %t105, i32* %t106, i32* %t107)
%t109 = load i32, i32* %t65
%t110 = getelementptr inbounds [4040100 x i32], [4040100 x i32]* @A, i32 0, i32 0
%t111 = getelementptr inbounds [2010 x i32], [2010 x i32]* @C, i32 0, i32 0
%t112 = getelementptr inbounds [2010 x i32], [2010 x i32]* @B, i32 0, i32 0
call void @mv(i32 %t109, i32* %t110, i32* %t111, i32* %t112)
%t114 = load i32, i32* %t67
%t115 = add i32 %t114, 1
store i32 %t115, i32* %t67
br label %while.cond.22
while.end.24:
call void @stoptime()
%t117 = load i32, i32* %t65
%t118 = getelementptr inbounds [2010 x i32], [2010 x i32]* @C, i32 0, i32 0
call void @putarray(i32 %t117, i32* %t118)
ret i32 0
}