gcd:
    iload_0
    iload_1
    ieq
    branch_f 10_end
    iload_0
    ireturn
10_end:
    iload_0
    iload_1
    igt
    branch_f 9_end
    isrg
    iload_0
    iload_1
    isub
    iload_1
    jsr 2 gcd
    ireturn
9_end:
    isrg
    iload_0
    iload_1
    iload_0
    isub
    jsr 2 gcd
    ireturn

fac:
    esr 1
    iloadc_1
    istore 1
7_while:
    iload_0
    iloadc_0
    ine
    branch_f 8_end
    iload_1
    iload_0
    imul
    istore 1
    idec_1 0               ; sub -> dec
    jump 7_while
8_end:
    iload_1
    ireturn

fib:
    iload_0
    iloadc_0
    ieq
    branch_f 5_false_expr
    bloadc_t
    jump 6_end
5_false_expr:
    iload_0
    iloadc_1
    ieq
6_end:
    branch_f 4_end
    iload_0
    ireturn
4_end:
    isrg
    iload_0
    iloadc_1
    isub
    jsr 1 fib
    isrg
    iload_0
    iloadc 0
    isub
    jsr 1 fib
    iadd
    ireturn

isprime:
    esr 2
    iloadc 0
    istore 1
    iload_0
    istore 2
1_while:
    iload_1
    iload_2
    ilt
    branch_f 2_end
    iload_0
    iload_1
    irem
    iloadc_0
    ieq
    branch_f 3_end
    bloadc_f
    breturn
3_end:
    iinc_1 1               ; add -> inc
    jump 1_while
2_end:
    bloadc_t
    breturn

puti:
    isrg
    iload_0
    jsre 0
    isrg
    iloadc_1
    jsre 5
    return

main:
    isrg
    isrg
    iloadc 1
    jsr 1 fac
    jsr 1 puti
    isrg
    isrg
    iloadc 2
    jsr 1 fib
    jsr 1 puti
    iloadc_0
    ireturn

.const int 2
.const int 6
.const int 8
.exportfun "main" int main
.importfun "printInt" void int
.importfun "printFloat" void float
.importfun "scanInt" int
.importfun "scanFloat" float
.importfun "printSpaces" void int
.importfun "printNewlines" void int
