Skip to content

Instantly share code, notes, and snippets.

@uenoku
Last active Dec 24, 2018
Embed
What would you like to do?
"
let rec dbl f = f +. f in
let rec yloop y =
if y >= 100 then () else
let rec xloop x y =
if x >= 100 then () else
let cr = dbl (float_of_int x) /. 100.0 -. 1.5 in
let ci = dbl (float_of_int y) /. 100.0 -. 1.0 in
let rec iloop i zr zi zr2 zi2 cr ci =
if i = 0 then print_int 1 else
let tr = zr2 -. zi2 +. cr in
let ti = dbl zr *. zi +. ci in
let zr = tr in
let zi = ti in
let zr2 = zr *. zr in
let zi2 = zi *. zi in
if 4.0 >= (zr2 +. zi2) then
iloop (i - 1) zr zi zr2 zi2 cr ci else print_int 0 in
iloop 1000 0.0 0.0 0.0 0.0 cr ci;
xloop (x + 1) y in
xloop 0 y;
yloop (y + 1) in
yloop 0
"
.text
.file "mandelbrot.ml.ll"
.globl V95.V37.yloop # -- Begin function V95.V37.yloop
.p2align 2
.type V95.V37.yloop,@function
V95.V37.yloop: # @V95.V37.yloop
# %bb.0: # %entry
store %sp, %sp, -5
addi %sp, %sp, -5
store %lr, %sp, 4 # 4-byte Folded Spill
store %r3, %sp, 1 # 4-byte Folded Spill
cmpdi %r3,99
bgt .LBB0_9
jump .LBB0_1
.LBB0_1: # %else.i.preheader
# =>This Loop Header: Depth=1
# Child Loop BB0_2 Depth 2
# Child Loop BB0_5 Depth 3
li %r3, 0
.LBB0_2: # %else.i
# Parent Loop BB0_1 Depth=1
# => This Loop Header: Depth=2
# Child Loop BB0_5 Depth 3
store %r3, %sp, 3 # 4-byte Folded Spill
bl float_of_int
fadd %r3, %r3, %r3
liw %r4, 1120403456
fdiv %r3, %r3, %r4
liw %r4, -1077936128
fadd %r3, %r3, %r4
store %r3, %sp, 2 # 4-byte Folded Spill
load %r3, %sp, 1 # 4-byte Folded Reload
bl float_of_int
load %r11, %sp, 2 # 4-byte Folded Reload
fadd %r3, %r3, %r3
liw %r4, 1120403456
fdiv %r3, %r3, %r4
liw %r4, -1082130432
fadd %r3, %r3, %r4
li %r4, 1000
liw %r5, 0
liw %r6, 0
liw %r7, 0
liw %r8, 0
liw %r10, 1082130432
jump .LBB0_5
.LBB0_5: # %else.i.i
# Parent Loop BB0_1 Depth=1
# Parent Loop BB0_2 Depth=2
# => This Inner Loop Header: Depth=3
fadd %r8, %r8, %r8
fmul %r7, %r7, %r8
fadd %r7, %r3, %r7
fsub %r5, %r6, %r5
fadd %r8, %r11, %r5
fmul %r6, %r8, %r8
fmul %r5, %r7, %r7
fadd %r9, %r6, %r5
cmpf %r9,%r10
ble .LBB0_3
jump .LBB0_6
.LBB0_3: # %tailrecurse.i.i
# in Loop: Header=BB0_5 Depth=3
addi %r4, %r4, -1
cmpdi %r4,0
bne .LBB0_5
jump .LBB0_4
.LBB0_4: # %then.i.i
# in Loop: Header=BB0_2 Depth=2
li %r3, 1
bl print_int
jump .LBB0_7
.LBB0_6: # %else2.i.i
# in Loop: Header=BB0_2 Depth=2
li %r3, 0
bl print_int
.LBB0_7: # %V119.V51.iloop.exit.i
# in Loop: Header=BB0_2 Depth=2
load %r4, %sp, 3 # 4-byte Folded Reload
addi %r3, %r4, 1
cmpdi %r4,99
blt .LBB0_2
jump .LBB0_8
.LBB0_8: # %V99.V41.xloop.exit
# in Loop: Header=BB0_1 Depth=1
load %r4, %sp, 1 # 4-byte Folded Reload
addi %r3, %r4, 1
cmpdi %r4,99
store %r3, %sp, 1 # 4-byte Folded Spill
blt .LBB0_1
jump .LBB0_9
.LBB0_9: # %ifcont
load %lr, %sp, 4 # 4-byte Folded Reload
load %sp, %sp, 0
blr
.Lfunc_end0:
.size V95.V37.yloop, .Lfunc_end0-V95.V37.yloop
# -- End function
.globl V99.V41.xloop # -- Begin function V99.V41.xloop
.p2align 2
.type V99.V41.xloop,@function
V99.V41.xloop: # @V99.V41.xloop
# %bb.0: # %entry
store %sp, %sp, -5
addi %sp, %sp, -5
store %lr, %sp, 4 # 4-byte Folded Spill
store %r4, %sp, 1 # 4-byte Folded Spill
cmpdi %r3,99
bgt .LBB1_7
jump .LBB1_1
.LBB1_1: # %else
# =>This Loop Header: Depth=1
# Child Loop BB1_4 Depth 2
store %r3, %sp, 3 # 4-byte Folded Spill
bl float_of_int
fadd %r3, %r3, %r3
liw %r4, 1120403456
fdiv %r3, %r3, %r4
liw %r4, -1077936128
fadd %r3, %r3, %r4
store %r3, %sp, 2 # 4-byte Folded Spill
load %r3, %sp, 1 # 4-byte Folded Reload
bl float_of_int
load %r11, %sp, 2 # 4-byte Folded Reload
fadd %r3, %r3, %r3
liw %r4, 1120403456
fdiv %r3, %r3, %r4
liw %r4, -1082130432
fadd %r3, %r3, %r4
li %r4, 1000
liw %r5, 0
liw %r6, 0
liw %r7, 0
liw %r8, 0
liw %r10, 1082130432
jump .LBB1_4
.LBB1_4: # %else.i
# Parent Loop BB1_1 Depth=1
# => This Inner Loop Header: Depth=2
fadd %r8, %r8, %r8
fmul %r7, %r7, %r8
fadd %r7, %r3, %r7
fsub %r5, %r6, %r5
fadd %r8, %r11, %r5
fmul %r6, %r8, %r8
fmul %r5, %r7, %r7
fadd %r9, %r6, %r5
cmpf %r9,%r10
ble .LBB1_2
jump .LBB1_5
.LBB1_2: # %tailrecurse.i
# in Loop: Header=BB1_4 Depth=2
addi %r4, %r4, -1
cmpdi %r4,0
bne .LBB1_4
jump .LBB1_3
.LBB1_3: # %then.i
# in Loop: Header=BB1_1 Depth=1
li %r3, 1
bl print_int
jump .LBB1_6
.LBB1_5: # %else2.i
# in Loop: Header=BB1_1 Depth=1
li %r3, 0
bl print_int
.LBB1_6: # %V119.V51.iloop.exit
# in Loop: Header=BB1_1 Depth=1
load %r4, %sp, 3 # 4-byte Folded Reload
addi %r3, %r4, 1
cmpdi %r4,99
blt .LBB1_1
jump .LBB1_7
.LBB1_7: # %ifcont
load %lr, %sp, 4 # 4-byte Folded Reload
load %sp, %sp, 0
blr
.Lfunc_end1:
.size V99.V41.xloop, .Lfunc_end1-V99.V41.xloop
# -- End function
.globl V119.V51.iloop # -- Begin function V119.V51.iloop
.p2align 2
.type V119.V51.iloop,@function
V119.V51.iloop: # @V119.V51.iloop
# %bb.0: # %entry
store %sp, %sp, -2
addi %sp, %sp, -2
store %lr, %sp, 1 # 4-byte Folded Spill
cmpdi %r3,0
beq .LBB2_3
jump .LBB2_1
.LBB2_1: # %else.preheader
liw %r10, 1082130432
jump .LBB2_4
.LBB2_4: # %else
# =>This Inner Loop Header: Depth=1
fadd %r4, %r4, %r4
fmul %r4, %r4, %r5
fadd %r5, %r4, %r9
fsub %r4, %r6, %r7
fadd %r4, %r4, %r8
fmul %r6, %r4, %r4
fmul %r7, %r5, %r5
fadd %r11, %r7, %r6
cmpf %r11,%r10
ble .LBB2_2
jump .LBB2_5
.LBB2_2: # %tailrecurse
# in Loop: Header=BB2_4 Depth=1
addi %r3, %r3, -1
cmpdi %r3,0
bne .LBB2_4
jump .LBB2_3
.LBB2_3: # %then
li %r3, 1
bl print_int
jump .LBB2_6
.LBB2_5: # %else2
li %r3, 0
bl print_int
.LBB2_6: # %ifcont3
load %lr, %sp, 1 # 4-byte Folded Reload
load %sp, %sp, 0
blr
.Lfunc_end2:
.size V119.V51.iloop, .Lfunc_end2-V119.V51.iloop
# -- End function
.globl V94.V36.dbl # -- Begin function V94.V36.dbl
.p2align 2
.type V94.V36.dbl,@function
V94.V36.dbl: # @V94.V36.dbl
# %bb.0: # %entry
fadd %r3, %r3, %r3
blr
.Lfunc_end3:
.size V94.V36.dbl, .Lfunc_end3-V94.V36.dbl
# -- End function
.globl main # -- Begin function main
.p2align 2
.type main,@function
main: # @main
# %bb.0: # %entry
store %sp, %sp, -5
addi %sp, %sp, -5
store %lr, %sp, 4 # 4-byte Folded Spill
li %r3, 2
store %r3, %r0, 1
li %r3, 0
store %r3, %sp, 1 # 4-byte Folded Spill
.LBB4_1: # %else.i.preheader.i
# =>This Loop Header: Depth=1
# Child Loop BB4_2 Depth 2
# Child Loop BB4_5 Depth 3
li %r3, 0
.LBB4_2: # %else.i.i
# Parent Loop BB4_1 Depth=1
# => This Loop Header: Depth=2
# Child Loop BB4_5 Depth 3
store %r3, %sp, 3 # 4-byte Folded Spill
bl float_of_int
fadd %r3, %r3, %r3
liw %r4, 1120403456
fdiv %r3, %r3, %r4
liw %r4, -1077936128
fadd %r3, %r3, %r4
store %r3, %sp, 2 # 4-byte Folded Spill
load %r3, %sp, 1 # 4-byte Folded Reload
bl float_of_int
load %r11, %sp, 2 # 4-byte Folded Reload
fadd %r3, %r3, %r3
liw %r4, 1120403456
fdiv %r3, %r3, %r4
liw %r4, -1082130432
fadd %r3, %r3, %r4
li %r4, 1000
liw %r5, 0
liw %r6, 0
liw %r7, 0
liw %r8, 0
liw %r10, 1082130432
jump .LBB4_5
.LBB4_5: # %else.i.i.i
# Parent Loop BB4_1 Depth=1
# Parent Loop BB4_2 Depth=2
# => This Inner Loop Header: Depth=3
fadd %r8, %r8, %r8
fmul %r7, %r7, %r8
fadd %r7, %r3, %r7
fsub %r5, %r6, %r5
fadd %r8, %r11, %r5
fmul %r6, %r8, %r8
fmul %r5, %r7, %r7
fadd %r9, %r6, %r5
cmpf %r9,%r10
ble .LBB4_3
jump .LBB4_6
.LBB4_3: # %tailrecurse.i.i.i
# in Loop: Header=BB4_5 Depth=3
addi %r4, %r4, -1
cmpdi %r4,0
bne .LBB4_5
jump .LBB4_4
.LBB4_4: # %then.i.i.i
# in Loop: Header=BB4_2 Depth=2
li %r3, 1
bl print_int
jump .LBB4_7
.LBB4_6: # %else2.i.i.i
# in Loop: Header=BB4_2 Depth=2
li %r3, 0
bl print_int
.LBB4_7: # %V119.V51.iloop.exit.i.i
# in Loop: Header=BB4_2 Depth=2
load %r4, %sp, 3 # 4-byte Folded Reload
addi %r3, %r4, 1
cmpdi %r4,99
blt .LBB4_2
jump .LBB4_8
.LBB4_8: # %V99.V41.xloop.exit.i
# in Loop: Header=BB4_1 Depth=1
load %r4, %sp, 1 # 4-byte Folded Reload
addi %r3, %r4, 1
cmpdi %r4,99
store %r3, %sp, 1 # 4-byte Folded Spill
blt .LBB4_1
jump .LBB4_9
.LBB4_9: # %V95.V37.yloop.exit
load %lr, %sp, 4 # 4-byte Folded Reload
load %sp, %sp, 0
blr
.Lfunc_end4:
.size main, .Lfunc_end4-main
# -- End function
.section ".note.GNU-stack","",@progbits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment