Skip to content

Instantly share code, notes, and snippets.

@kig
Created February 5, 2009 16:39
Show Gist options
  • Save kig/58809 to your computer and use it in GitHub Desktop.
Save kig/58809 to your computer and use it in GitHub Desktop.
#let fac_loop n =
# let s = ref 1 in
# for i=2 to n do s := !s * i done;
# !s
camlFoo__fac_loop_58:
.L104:
movq %rax, %rsi
movq $3, %rax
movq $5, %rbx
cmpq %rsi, %rbx
jg .L102
.L103:
movq %rbx, %rdi
sarq $1, %rdi
decq %rax
imulq %rdi, %rax
incq %rax
movq %rbx, %rdi
addq $2, %rbx
cmpq %rsi, %rdi
jne .L103
.L102:
ret
#let fac_rec n =
# let rec aux n i s = if i > n then s else aux n (i+1) (s*i) in
# aux n 2 1
camlFoo__fac_rec_62:
.L105:
movq camlFoo__3@GOTPCREL(%rip), %rbx
movq $3, %rdi
movq $5, %rbx
jmp camlFoo__aux_64@PLT
camlFoo__aux_64:
.L101:
cmpq %rax, %rbx
jle .L100
movq %rdi, %rax
ret
.align 4
.L100:
movq %rbx, %rsi
sarq $1, %rsi
decq %rdi
imulq %rsi, %rdi
incq %rdi
addq $2, %rbx
jmp .L101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment