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.

516 lines
16 KiB

@e = global float 0x4005BF0A80000000
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 float @my_fabs(float %arg.x) {
entry:
%t0 = alloca float
store float %arg.x, float* %t0
%t1 = load float, float* %t0
%t2 = fcmp ogt float %t1, 0x0000000000000000
%t3 = zext i1 %t2 to i32
%t4 = icmp ne i32 %t3, 0
br i1 %t4, label %if.then.1, label %if.end.2
if.then.1:
%t5 = load float, float* %t0
ret float %t5
if.end.2:
%t6 = load float, float* %t0
%t7 = fsub float 0x0000000000000000, %t6
ret float %t7
}
define float @my_pow(float %arg.a, i32 %arg.n) {
entry:
%t19 = alloca float
%t8 = alloca float
store float %arg.a, float* %t8
%t9 = alloca i32
store i32 %arg.n, i32* %t9
%t10 = load i32, i32* %t9
%t11 = icmp slt i32 %t10, 0
%t12 = zext i1 %t11 to i32
%t13 = icmp ne i32 %t12, 0
br i1 %t13, label %if.then.3, label %if.end.4
if.then.3:
%t14 = load float, float* %t8
%t15 = load i32, i32* %t9
%t16 = sub i32 0, %t15
%t17 = call float @my_pow(float %t14, i32 %t16)
%t18 = fdiv float 0x3FF0000000000000, %t17
ret float %t18
if.end.4:
store float 0x3FF0000000000000, float* %t19
br label %while.cond.5
while.cond.5:
%t20 = load i32, i32* %t9
%t21 = icmp ne i32 %t20, 0
br i1 %t21, label %while.body.6, label %while.end.7
while.body.6:
%t22 = load i32, i32* %t9
%t23 = srem i32 %t22, 2
%t24 = icmp ne i32 %t23, 0
br i1 %t24, label %if.then.8, label %if.end.9
while.end.7:
%t33 = load float, float* %t19
ret float %t33
if.then.8:
%t25 = load float, float* %t19
%t26 = load float, float* %t8
%t27 = fmul float %t25, %t26
store float %t27, float* %t19
br label %if.end.9
if.end.9:
%t28 = load float, float* %t8
%t29 = load float, float* %t8
%t30 = fmul float %t28, %t29
store float %t30, float* %t8
%t31 = load i32, i32* %t9
%t32 = sdiv i32 %t31, 2
store i32 %t32, i32* %t9
br label %while.cond.5
}
define float @my_sqrt(float %arg.x) {
entry:
%t43 = alloca float
%t53 = alloca i32
%t34 = alloca float
store float %arg.x, float* %t34
%t35 = load float, float* %t34
%t36 = fcmp ogt float %t35, 0x4059000000000000
%t37 = zext i1 %t36 to i32
%t38 = icmp ne i32 %t37, 0
br i1 %t38, label %if.then.10, label %if.end.11
if.then.10:
%t39 = load float, float* %t34
%t40 = fdiv float %t39, 0x4059000000000000
%t41 = call float @my_sqrt(float %t40)
%t42 = fmul float 0x4024000000000000, %t41
ret float %t42
if.end.11:
%t44 = load float, float* %t34
%t45 = fdiv float %t44, 0x4020000000000000
%t46 = fadd float %t45, 0x3FE0000000000000
%t47 = load float, float* %t34
%t48 = fmul float 0x4000000000000000, %t47
%t49 = load float, float* %t34
%t50 = fadd float 0x4010000000000000, %t49
%t51 = fdiv float %t48, %t50
%t52 = fadd float %t46, %t51
store float %t52, float* %t43
store i32 10, i32* %t53
br label %while.cond.12
while.cond.12:
%t54 = load i32, i32* %t53
%t55 = icmp ne i32 %t54, 0
br i1 %t55, label %while.body.13, label %while.end.14
while.body.13:
%t56 = load float, float* %t43
%t57 = load float, float* %t34
%t58 = load float, float* %t43
%t59 = fdiv float %t57, %t58
%t60 = fadd float %t56, %t59
%t61 = fdiv float %t60, 0x4000000000000000
store float %t61, float* %t43
%t62 = load i32, i32* %t53
%t63 = sub i32 %t62, 1
store i32 %t63, i32* %t53
br label %while.cond.12
while.end.14:
%t64 = load float, float* %t43
ret float %t64
}
define float @F1(float %arg.x) {
entry:
%t65 = alloca float
store float %arg.x, float* %t65
%t66 = load float, float* %t65
%t67 = fdiv float 0x3FF0000000000000, %t66
ret float %t67
}
define float @F2(float %arg.x) {
entry:
%t68 = alloca float
store float %arg.x, float* %t68
%t69 = load float, float* %t68
%t70 = load float, float* %t68
%t71 = fmul float %t69, %t70
%t72 = fsub float 0x3FF0000000000000, %t71
%t73 = call float @my_sqrt(float %t72)
%t74 = fdiv float 0x3FF0000000000000, %t73
ret float %t74
}
define float @simpson(float %arg.a, float %arg.b, i32 %arg.flag) {
entry:
%t78 = alloca float
%t75 = alloca float
store float %arg.a, float* %t75
%t76 = alloca float
store float %arg.b, float* %t76
%t77 = alloca i32
store i32 %arg.flag, i32* %t77
%t79 = load float, float* %t75
%t80 = load float, float* %t76
%t81 = load float, float* %t75
%t82 = fsub float %t80, %t81
%t83 = fdiv float %t82, 0x4000000000000000
%t84 = fadd float %t79, %t83
store float %t84, float* %t78
%t85 = load i32, i32* %t77
%t86 = icmp eq i32 %t85, 1
%t87 = zext i1 %t86 to i32
%t88 = icmp ne i32 %t87, 0
br i1 %t88, label %if.then.15, label %if.end.16
if.then.15:
%t89 = load float, float* %t75
%t90 = call float @F1(float %t89)
%t91 = load float, float* %t78
%t92 = call float @F1(float %t91)
%t93 = fmul float 0x4010000000000000, %t92
%t94 = fadd float %t90, %t93
%t95 = load float, float* %t76
%t96 = call float @F1(float %t95)
%t97 = fadd float %t94, %t96
%t98 = load float, float* %t76
%t99 = load float, float* %t75
%t100 = fsub float %t98, %t99
%t101 = fmul float %t97, %t100
%t102 = fdiv float %t101, 0x4018000000000000
ret float %t102
if.end.16:
%t103 = load i32, i32* %t77
%t104 = icmp eq i32 %t103, 2
%t105 = zext i1 %t104 to i32
%t106 = icmp ne i32 %t105, 0
br i1 %t106, label %if.then.17, label %if.end.18
if.then.17:
%t107 = load float, float* %t75
%t108 = call float @F2(float %t107)
%t109 = load float, float* %t78
%t110 = call float @F2(float %t109)
%t111 = fmul float 0x4010000000000000, %t110
%t112 = fadd float %t108, %t111
%t113 = load float, float* %t76
%t114 = call float @F2(float %t113)
%t115 = fadd float %t112, %t114
%t116 = load float, float* %t76
%t117 = load float, float* %t75
%t118 = fsub float %t116, %t117
%t119 = fmul float %t115, %t118
%t120 = fdiv float %t119, 0x4018000000000000
ret float %t120
if.end.18:
ret float 0x0000000000000000
}
define float @asr5(float %arg.a, float %arg.b, float %arg.eps, float %arg.A, i32 %arg.flag) {
entry:
%t126 = alloca float
%t133 = alloca float
%t138 = alloca float
%t121 = alloca float
store float %arg.a, float* %t121
%t122 = alloca float
store float %arg.b, float* %t122
%t123 = alloca float
store float %arg.eps, float* %t123
%t124 = alloca float
store float %arg.A, float* %t124
%t125 = alloca i32
store i32 %arg.flag, i32* %t125
%t127 = load float, float* %t121
%t128 = load float, float* %t122
%t129 = load float, float* %t121
%t130 = fsub float %t128, %t129
%t131 = fdiv float %t130, 0x4000000000000000
%t132 = fadd float %t127, %t131
store float %t132, float* %t126
%t134 = load float, float* %t121
%t135 = load float, float* %t126
%t136 = load i32, i32* %t125
%t137 = call float @simpson(float %t134, float %t135, i32 %t136)
store float %t137, float* %t133
%t139 = load float, float* %t126
%t140 = load float, float* %t122
%t141 = load i32, i32* %t125
%t142 = call float @simpson(float %t139, float %t140, i32 %t141)
store float %t142, float* %t138
%t143 = load float, float* %t133
%t144 = load float, float* %t138
%t145 = fadd float %t143, %t144
%t146 = load float, float* %t124
%t147 = fsub float %t145, %t146
%t148 = call float @my_fabs(float %t147)
%t149 = load float, float* %t123
%t150 = fmul float 0x402E000000000000, %t149
%t151 = fcmp ole float %t148, %t150
%t152 = zext i1 %t151 to i32
%t153 = icmp ne i32 %t152, 0
br i1 %t153, label %if.then.19, label %if.end.20
if.then.19:
%t154 = load float, float* %t133
%t155 = load float, float* %t138
%t156 = fadd float %t154, %t155
%t157 = load float, float* %t133
%t158 = load float, float* %t138
%t159 = fadd float %t157, %t158
%t160 = load float, float* %t124
%t161 = fsub float %t159, %t160
%t162 = fdiv float %t161, 0x402E000000000000
%t163 = fadd float %t156, %t162
ret float %t163
if.end.20:
%t164 = load float, float* %t121
%t165 = load float, float* %t126
%t166 = load float, float* %t123
%t167 = fdiv float %t166, 0x4000000000000000
%t168 = load float, float* %t133
%t169 = load i32, i32* %t125
%t170 = call float @asr5(float %t164, float %t165, float %t167, float %t168, i32 %t169)
%t171 = load float, float* %t126
%t172 = load float, float* %t122
%t173 = load float, float* %t123
%t174 = fdiv float %t173, 0x4000000000000000
%t175 = load float, float* %t138
%t176 = load i32, i32* %t125
%t177 = call float @asr5(float %t171, float %t172, float %t174, float %t175, i32 %t176)
%t178 = fadd float %t170, %t177
ret float %t178
}
define float @asr4(float %arg.a, float %arg.b, float %arg.eps, i32 %arg.flag) {
entry:
%t179 = alloca float
store float %arg.a, float* %t179
%t180 = alloca float
store float %arg.b, float* %t180
%t181 = alloca float
store float %arg.eps, float* %t181
%t182 = alloca i32
store i32 %arg.flag, i32* %t182
%t183 = load float, float* %t179
%t184 = load float, float* %t180
%t185 = load float, float* %t181
%t186 = load float, float* %t179
%t187 = load float, float* %t180
%t188 = load i32, i32* %t182
%t189 = call float @simpson(float %t186, float %t187, i32 %t188)
%t190 = load i32, i32* %t182
%t191 = call float @asr5(float %t183, float %t184, float %t185, float %t189, i32 %t190)
ret float %t191
}
define float @eee(float %arg.x) {
entry:
%t197 = alloca float
%t192 = alloca float
store float %arg.x, float* %t192
%t193 = load float, float* %t192
%t194 = fcmp ogt float %t193, 0x3F50624DE0000000
%t195 = zext i1 %t194 to i32
%t196 = icmp ne i32 %t195, 0
br i1 %t196, label %if.then.21, label %if.end.22
if.then.21:
%t198 = load float, float* %t192
%t199 = fdiv float %t198, 0x4000000000000000
%t200 = call float @eee(float %t199)
store float %t200, float* %t197
%t201 = load float, float* %t197
%t202 = load float, float* %t197
%t203 = fmul float %t201, %t202
ret float %t203
if.end.22:
%t204 = load float, float* %t192
%t205 = fadd float 0x3FF0000000000000, %t204
%t206 = load float, float* %t192
%t207 = load float, float* %t192
%t208 = fmul float %t206, %t207
%t209 = fdiv float %t208, 0x4000000000000000
%t210 = fadd float %t205, %t209
%t211 = load float, float* %t192
%t212 = call float @my_pow(float %t211, i32 3)
%t213 = fdiv float %t212, 0x4018000000000000
%t214 = fadd float %t210, %t213
%t215 = load float, float* %t192
%t216 = call float @my_pow(float %t215, i32 4)
%t217 = fdiv float %t216, 0x4038000000000000
%t218 = fadd float %t214, %t217
%t219 = load float, float* %t192
%t220 = call float @my_pow(float %t219, i32 5)
%t221 = fdiv float %t220, 0x405E000000000000
%t222 = fadd float %t218, %t221
ret float %t222
}
define float @my_exp(float %arg.x) {
entry:
%t232 = alloca i32
%t239 = alloca float
%t243 = alloca float
%t223 = alloca float
store float %arg.x, float* %t223
%t224 = load float, float* %t223
%t225 = fcmp olt float %t224, 0x0000000000000000
%t226 = zext i1 %t225 to i32
%t227 = icmp ne i32 %t226, 0
br i1 %t227, label %if.then.23, label %if.end.24
if.then.23:
%t228 = load float, float* %t223
%t229 = fsub float 0x0000000000000000, %t228
%t230 = call float @my_exp(float %t229)
%t231 = fdiv float 0x3FF0000000000000, %t230
ret float %t231
if.end.24:
%t233 = load float, float* %t223
%t234 = fptosi float %t233 to i32
store i32 %t234, i32* %t232
%t235 = load float, float* %t223
%t236 = load i32, i32* %t232
%t237 = sitofp i32 %t236 to float
%t238 = fsub float %t235, %t237
store float %t238, float* %t223
%t240 = load float, float* @e
%t241 = load i32, i32* %t232
%t242 = call float @my_pow(float %t240, i32 %t241)
store float %t242, float* %t239
%t244 = load float, float* %t223
%t245 = call float @eee(float %t244)
store float %t245, float* %t243
%t246 = load float, float* %t239
%t247 = load float, float* %t243
%t248 = fmul float %t246, %t247
ret float %t248
}
define float @my_ln(float %arg.x) {
entry:
%t249 = alloca float
store float %arg.x, float* %t249
%t250 = load float, float* %t249
%t251 = call float @asr4(float 0x3FF0000000000000, float %t250, float 0x3E45798EE0000000, i32 1)
ret float %t251
}
define float @my_log(float %arg.a, float %arg.N) {
entry:
%t252 = alloca float
store float %arg.a, float* %t252
%t253 = alloca float
store float %arg.N, float* %t253
%t254 = load float, float* %t253
%t255 = call float @my_ln(float %t254)
%t256 = load float, float* %t252
%t257 = call float @my_ln(float %t256)
%t258 = fdiv float %t255, %t257
ret float %t258
}
define float @my_powf(float %arg.a, float %arg.x) {
entry:
%t259 = alloca float
store float %arg.a, float* %t259
%t260 = alloca float
store float %arg.x, float* %t260
%t261 = load float, float* %t260
%t262 = load float, float* %t259
%t263 = call float @my_ln(float %t262)
%t264 = fmul float %t261, %t263
%t265 = call float @my_exp(float %t264)
ret float %t265
}
define i32 @main() {
entry:
%t266 = alloca i32
%t270 = alloca float
%t272 = alloca float
%t267 = call i32 @getint()
store i32 %t267, i32* %t266
br label %while.cond.25
while.cond.25:
%t268 = load i32, i32* %t266
%t269 = icmp ne i32 %t268, 0
br i1 %t269, label %while.body.26, label %while.end.27
while.body.26:
%t271 = call float @getfloat()
store float %t271, float* %t270
%t273 = call float @getfloat()
store float %t273, float* %t272
%t274 = load float, float* %t270
%t275 = call float @my_fabs(float %t274)
call void @putfloat(float %t275)
call void @putch(i32 32)
%t278 = load float, float* %t270
%t279 = call float @my_pow(float %t278, i32 2)
call void @putfloat(float %t279)
call void @putch(i32 32)
%t282 = load float, float* %t270
%t283 = call float @my_sqrt(float %t282)
call void @putfloat(float %t283)
call void @putch(i32 32)
%t286 = load float, float* %t270
%t287 = call float @my_exp(float %t286)
call void @putfloat(float %t287)
call void @putch(i32 32)
%t290 = load float, float* %t270
%t291 = fcmp ogt float %t290, 0x0000000000000000
%t292 = zext i1 %t291 to i32
%t293 = icmp ne i32 %t292, 0
br i1 %t293, label %if.then.28, label %if.else.29
while.end.27:
ret i32 0
if.then.28:
%t294 = load float, float* %t270
%t295 = call float @my_ln(float %t294)
call void @putfloat(float %t295)
br label %if.end.30
if.else.29:
call void @putch(i32 45)
br label %if.end.30
if.end.30:
call void @putch(i32 32)
%t299 = load float, float* %t270
%t300 = fcmp ogt float %t299, 0x0000000000000000
%t301 = zext i1 %t300 to i32
%t302 = icmp ne i32 %t301, 0
br i1 %t302, label %land.rhs.34, label %if.else.32
if.then.31:
%t307 = load float, float* %t270
%t308 = load float, float* %t272
%t309 = call float @my_log(float %t307, float %t308)
call void @putfloat(float %t309)
br label %if.end.33
if.else.32:
call void @putch(i32 45)
br label %if.end.33
if.end.33:
call void @putch(i32 32)
%t313 = load float, float* %t270
%t314 = fcmp ogt float %t313, 0x0000000000000000
%t315 = zext i1 %t314 to i32
%t316 = icmp ne i32 %t315, 0
br i1 %t316, label %if.then.35, label %if.else.36
land.rhs.34:
%t303 = load float, float* %t272
%t304 = fcmp ogt float %t303, 0x0000000000000000
%t305 = zext i1 %t304 to i32
%t306 = icmp ne i32 %t305, 0
br i1 %t306, label %if.then.31, label %if.else.32
if.then.35:
%t317 = load float, float* %t270
%t318 = load float, float* %t272
%t319 = call float @my_powf(float %t317, float %t318)
call void @putfloat(float %t319)
br label %if.end.37
if.else.36:
call void @putch(i32 45)
br label %if.end.37
if.end.37:
call void @putch(i32 10)
%t323 = load i32, i32* %t266
%t324 = sub i32 %t323, 1
store i32 %t324, i32* %t266
br label %while.cond.25
}