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