forked from NUDT-compiler/nudt-compiler-cpp
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.
346 lines
10 KiB
346 lines
10 KiB
@a = global [1000000 x i32] zeroinitializer
|
|
@b = global [1000000 x i32] zeroinitializer
|
|
@c = global [1000000 x i32] zeroinitializer
|
|
@MAX = global i32 2147483647
|
|
|
|
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
|
|
%t2 = alloca i32
|
|
%t3 = alloca i32
|
|
%t4 = alloca i32
|
|
%t52 = alloca i32
|
|
%t105 = alloca i32
|
|
%t146 = alloca i32
|
|
%t171 = alloca i32
|
|
store i32 0, i32* %t0
|
|
store i32 0, i32* %t1
|
|
store i32 0, i32* %t2
|
|
store i32 0, i32* %t3
|
|
store i32 0, i32* %t4
|
|
store i32 0, i32* %t1
|
|
br label %while.cond.1
|
|
while.cond.1:
|
|
%t5 = load i32, i32* %t1
|
|
%t6 = icmp slt i32 %t5, 1000
|
|
%t7 = zext i1 %t6 to i32
|
|
%t8 = icmp ne i32 %t7, 0
|
|
br i1 %t8, label %while.body.2, label %while.end.3
|
|
while.body.2:
|
|
%t9 = load i32, i32* %t1
|
|
%t10 = mul i32 %t9, 1000
|
|
%t11 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* @a, i32 0, i32 %t10
|
|
%t12 = call i32 @getarray(i32* %t11)
|
|
store i32 %t12, i32* %t0
|
|
%t13 = load i32, i32* %t0
|
|
%t14 = icmp ne i32 %t13, 1000
|
|
%t15 = zext i1 %t14 to i32
|
|
%t16 = icmp ne i32 %t15, 0
|
|
br i1 %t16, label %if.then.4, label %if.end.5
|
|
while.end.3:
|
|
call void @starttime()
|
|
store i32 0, i32* %t1
|
|
br label %while.cond.6
|
|
if.then.4:
|
|
%t17 = load i32, i32* %t0
|
|
ret i32 %t17
|
|
if.end.5:
|
|
%t18 = load i32, i32* %t1
|
|
%t19 = add i32 %t18, 1
|
|
store i32 %t19, i32* %t1
|
|
br label %while.cond.1
|
|
while.cond.6:
|
|
%t21 = load i32, i32* %t1
|
|
%t22 = icmp slt i32 %t21, 1000
|
|
%t23 = zext i1 %t22 to i32
|
|
%t24 = icmp ne i32 %t23, 0
|
|
br i1 %t24, label %while.body.7, label %while.end.8
|
|
while.body.7:
|
|
store i32 0, i32* %t2
|
|
br label %while.cond.9
|
|
while.end.8:
|
|
store i32 0, i32* %t1
|
|
br label %while.cond.12
|
|
while.cond.9:
|
|
%t25 = load i32, i32* %t2
|
|
%t26 = icmp slt i32 %t25, 1000
|
|
%t27 = zext i1 %t26 to i32
|
|
%t28 = icmp ne i32 %t27, 0
|
|
br i1 %t28, label %while.body.10, label %while.end.11
|
|
while.body.10:
|
|
%t29 = load i32, i32* %t1
|
|
%t30 = load i32, i32* %t2
|
|
%t31 = mul i32 %t29, 1000
|
|
%t32 = add i32 %t31, %t30
|
|
%t33 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* @b, i32 0, i32 %t32
|
|
%t34 = load i32, i32* %t2
|
|
%t35 = load i32, i32* %t1
|
|
%t36 = mul i32 %t34, 1000
|
|
%t37 = add i32 %t36, %t35
|
|
%t38 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* @a, i32 0, i32 %t37
|
|
%t39 = load i32, i32* %t38
|
|
store i32 %t39, i32* %t33
|
|
%t40 = load i32, i32* %t2
|
|
%t41 = add i32 %t40, 1
|
|
store i32 %t41, i32* %t2
|
|
br label %while.cond.9
|
|
while.end.11:
|
|
%t42 = load i32, i32* %t1
|
|
%t43 = add i32 %t42, 1
|
|
store i32 %t43, i32* %t1
|
|
br label %while.cond.6
|
|
while.cond.12:
|
|
%t44 = load i32, i32* %t1
|
|
%t45 = icmp slt i32 %t44, 1000
|
|
%t46 = zext i1 %t45 to i32
|
|
%t47 = icmp ne i32 %t46, 0
|
|
br i1 %t47, label %while.body.13, label %while.end.14
|
|
while.body.13:
|
|
store i32 0, i32* %t2
|
|
br label %while.cond.15
|
|
while.end.14:
|
|
store i32 0, i32* %t1
|
|
br label %while.cond.23
|
|
while.cond.15:
|
|
%t48 = load i32, i32* %t2
|
|
%t49 = icmp slt i32 %t48, 1000
|
|
%t50 = zext i1 %t49 to i32
|
|
%t51 = icmp ne i32 %t50, 0
|
|
br i1 %t51, label %while.body.16, label %while.end.17
|
|
while.body.16:
|
|
store i32 0, i32* %t3
|
|
store i32 0, i32* %t52
|
|
br label %while.cond.18
|
|
while.end.17:
|
|
%t99 = load i32, i32* %t1
|
|
%t100 = add i32 %t99, 1
|
|
store i32 %t100, i32* %t1
|
|
br label %while.cond.12
|
|
while.cond.18:
|
|
%t53 = load i32, i32* %t3
|
|
%t54 = icmp slt i32 %t53, 1000
|
|
%t55 = zext i1 %t54 to i32
|
|
%t56 = icmp ne i32 %t55, 0
|
|
br i1 %t56, label %while.body.19, label %while.end.20
|
|
while.body.19:
|
|
%t57 = load i32, i32* %t1
|
|
%t58 = load i32, i32* %t3
|
|
%t59 = mul i32 %t57, 1000
|
|
%t60 = add i32 %t59, %t58
|
|
%t61 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* @a, i32 0, i32 %t60
|
|
%t62 = load i32, i32* %t61
|
|
%t63 = load i32, i32* %t3
|
|
%t64 = load i32, i32* %t2
|
|
%t65 = mul i32 %t63, 1000
|
|
%t66 = add i32 %t65, %t64
|
|
%t67 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* @b, i32 0, i32 %t66
|
|
%t68 = load i32, i32* %t67
|
|
%t69 = mul i32 %t62, %t68
|
|
%t70 = srem i32 %t69, 2
|
|
%t71 = icmp eq i32 %t70, 0
|
|
%t72 = zext i1 %t71 to i32
|
|
%t73 = icmp ne i32 %t72, 0
|
|
br i1 %t73, label %if.then.21, label %if.end.22
|
|
while.end.20:
|
|
%t91 = load i32, i32* %t1
|
|
%t92 = load i32, i32* %t2
|
|
%t93 = mul i32 %t91, 1000
|
|
%t94 = add i32 %t93, %t92
|
|
%t95 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* @c, i32 0, i32 %t94
|
|
%t96 = load i32, i32* %t52
|
|
store i32 %t96, i32* %t95
|
|
%t97 = load i32, i32* %t2
|
|
%t98 = add i32 %t97, 1
|
|
store i32 %t98, i32* %t2
|
|
br label %while.cond.15
|
|
if.then.21:
|
|
%t74 = load i32, i32* %t52
|
|
%t75 = load i32, i32* %t1
|
|
%t76 = load i32, i32* %t3
|
|
%t77 = mul i32 %t75, 1000
|
|
%t78 = add i32 %t77, %t76
|
|
%t79 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* @a, i32 0, i32 %t78
|
|
%t80 = load i32, i32* %t79
|
|
%t81 = load i32, i32* %t3
|
|
%t82 = load i32, i32* %t2
|
|
%t83 = mul i32 %t81, 1000
|
|
%t84 = add i32 %t83, %t82
|
|
%t85 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* @b, i32 0, i32 %t84
|
|
%t86 = load i32, i32* %t85
|
|
%t87 = mul i32 %t80, %t86
|
|
%t88 = add i32 %t74, %t87
|
|
store i32 %t88, i32* %t52
|
|
br label %if.end.22
|
|
if.end.22:
|
|
%t89 = load i32, i32* %t3
|
|
%t90 = add i32 %t89, 1
|
|
store i32 %t90, i32* %t3
|
|
br label %while.cond.18
|
|
while.cond.23:
|
|
%t101 = load i32, i32* %t1
|
|
%t102 = icmp slt i32 %t101, 1000
|
|
%t103 = zext i1 %t102 to i32
|
|
%t104 = icmp ne i32 %t103, 0
|
|
br i1 %t104, label %while.body.24, label %while.end.25
|
|
while.body.24:
|
|
store i32 0, i32* %t2
|
|
store i32 2147483647, i32* %t105
|
|
br label %while.cond.26
|
|
while.end.25:
|
|
store i32 0, i32* %t1
|
|
br label %while.cond.34
|
|
while.cond.26:
|
|
%t106 = load i32, i32* %t2
|
|
%t107 = icmp slt i32 %t106, 1000
|
|
%t108 = zext i1 %t107 to i32
|
|
%t109 = icmp ne i32 %t108, 0
|
|
br i1 %t109, label %while.body.27, label %while.end.28
|
|
while.body.27:
|
|
%t110 = load i32, i32* %t1
|
|
%t111 = load i32, i32* %t2
|
|
%t112 = mul i32 %t110, 1000
|
|
%t113 = add i32 %t112, %t111
|
|
%t114 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* @c, i32 0, i32 %t113
|
|
%t115 = load i32, i32* %t114
|
|
%t116 = load i32, i32* %t105
|
|
%t117 = icmp slt i32 %t115, %t116
|
|
%t118 = zext i1 %t117 to i32
|
|
%t119 = icmp ne i32 %t118, 0
|
|
br i1 %t119, label %if.then.29, label %if.end.30
|
|
while.end.28:
|
|
store i32 0, i32* %t2
|
|
br label %while.cond.31
|
|
if.then.29:
|
|
%t120 = load i32, i32* %t1
|
|
%t121 = load i32, i32* %t2
|
|
%t122 = mul i32 %t120, 1000
|
|
%t123 = add i32 %t122, %t121
|
|
%t124 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* @c, i32 0, i32 %t123
|
|
%t125 = load i32, i32* %t124
|
|
store i32 %t125, i32* %t105
|
|
br label %if.end.30
|
|
if.end.30:
|
|
%t126 = load i32, i32* %t2
|
|
%t127 = add i32 %t126, 1
|
|
store i32 %t127, i32* %t2
|
|
br label %while.cond.26
|
|
while.cond.31:
|
|
%t128 = load i32, i32* %t2
|
|
%t129 = icmp slt i32 %t128, 1000
|
|
%t130 = zext i1 %t129 to i32
|
|
%t131 = icmp ne i32 %t130, 0
|
|
br i1 %t131, label %while.body.32, label %while.end.33
|
|
while.body.32:
|
|
%t132 = load i32, i32* %t1
|
|
%t133 = load i32, i32* %t2
|
|
%t134 = mul i32 %t132, 1000
|
|
%t135 = add i32 %t134, %t133
|
|
%t136 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* @c, i32 0, i32 %t135
|
|
%t137 = load i32, i32* %t105
|
|
store i32 %t137, i32* %t136
|
|
%t138 = load i32, i32* %t2
|
|
%t139 = add i32 %t138, 1
|
|
store i32 %t139, i32* %t2
|
|
br label %while.cond.31
|
|
while.end.33:
|
|
%t140 = load i32, i32* %t1
|
|
%t141 = add i32 %t140, 1
|
|
store i32 %t141, i32* %t1
|
|
br label %while.cond.23
|
|
while.cond.34:
|
|
%t142 = load i32, i32* %t1
|
|
%t143 = icmp slt i32 %t142, 1000
|
|
%t144 = zext i1 %t143 to i32
|
|
%t145 = icmp ne i32 %t144, 0
|
|
br i1 %t145, label %while.body.35, label %while.end.36
|
|
while.body.35:
|
|
store i32 0, i32* %t2
|
|
store i32 2147483647, i32* %t146
|
|
br label %while.cond.37
|
|
while.end.36:
|
|
store i32 0, i32* %t1
|
|
br label %while.cond.40
|
|
while.cond.37:
|
|
%t147 = load i32, i32* %t2
|
|
%t148 = icmp slt i32 %t147, 1000
|
|
%t149 = zext i1 %t148 to i32
|
|
%t150 = icmp ne i32 %t149, 0
|
|
br i1 %t150, label %while.body.38, label %while.end.39
|
|
while.body.38:
|
|
%t151 = load i32, i32* %t1
|
|
%t152 = load i32, i32* %t2
|
|
%t153 = mul i32 %t151, 1000
|
|
%t154 = add i32 %t153, %t152
|
|
%t155 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* @c, i32 0, i32 %t154
|
|
%t156 = load i32, i32* %t2
|
|
%t157 = load i32, i32* %t1
|
|
%t158 = mul i32 %t156, 1000
|
|
%t159 = add i32 %t158, %t157
|
|
%t160 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* @c, i32 0, i32 %t159
|
|
%t161 = load i32, i32* %t160
|
|
%t162 = sub i32 0, %t161
|
|
store i32 %t162, i32* %t155
|
|
%t163 = load i32, i32* %t2
|
|
%t164 = add i32 %t163, 1
|
|
store i32 %t164, i32* %t2
|
|
br label %while.cond.37
|
|
while.end.39:
|
|
%t165 = load i32, i32* %t1
|
|
%t166 = add i32 %t165, 1
|
|
store i32 %t166, i32* %t1
|
|
br label %while.cond.34
|
|
while.cond.40:
|
|
%t167 = load i32, i32* %t1
|
|
%t168 = icmp slt i32 %t167, 1000
|
|
%t169 = zext i1 %t168 to i32
|
|
%t170 = icmp ne i32 %t169, 0
|
|
br i1 %t170, label %while.body.41, label %while.end.42
|
|
while.body.41:
|
|
store i32 0, i32* %t2
|
|
store i32 2147483647, i32* %t171
|
|
br label %while.cond.43
|
|
while.end.42:
|
|
call void @stoptime()
|
|
%t189 = load i32, i32* %t4
|
|
call void @putint(i32 %t189)
|
|
ret i32 0
|
|
while.cond.43:
|
|
%t172 = load i32, i32* %t2
|
|
%t173 = icmp slt i32 %t172, 1000
|
|
%t174 = zext i1 %t173 to i32
|
|
%t175 = icmp ne i32 %t174, 0
|
|
br i1 %t175, label %while.body.44, label %while.end.45
|
|
while.body.44:
|
|
%t176 = load i32, i32* %t4
|
|
%t177 = load i32, i32* %t1
|
|
%t178 = load i32, i32* %t2
|
|
%t179 = mul i32 %t177, 1000
|
|
%t180 = add i32 %t179, %t178
|
|
%t181 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* @c, i32 0, i32 %t180
|
|
%t182 = load i32, i32* %t181
|
|
%t183 = add i32 %t176, %t182
|
|
store i32 %t183, i32* %t4
|
|
%t184 = load i32, i32* %t2
|
|
%t185 = add i32 %t184, 1
|
|
store i32 %t185, i32* %t2
|
|
br label %while.cond.43
|
|
while.end.45:
|
|
%t186 = load i32, i32* %t1
|
|
%t187 = add i32 %t186, 1
|
|
store i32 %t187, i32* %t1
|
|
br label %while.cond.40
|
|
}
|