// File: /workspace/github_c_makefile_star2_O3/samsonjs[P]lake/src/repl.c
// Function: main
int main(int argc, char const *argv[])
{
    /* create an execution context */
    LakeCtx *ctx = lake_init();

    /* create and bind args */
    LakeVal **argVals = malloc(argc * sizeof(LakeVal *));
    int i;
    for (i = 0; i < argc; ++i)
    {
        argVals[i] = VAL(lake_str_from_c((char *)argv[i]));
    }
    LakeList *args = list_from_array(argc, argVals);
    free(argVals);
    env_define(ctx->toplevel, sym_intern(ctx, "args"), VAL(args));

    /* if a filename is given load the file */
    if (argc > 1)
    {
        char *text = read_file(argv[1]);
        if (text)
        {
            LakeList *exprs = parse_exprs(ctx, text, strlen(text));
            if (exprs)
            {
                eval_exprs(ctx, ctx->toplevel, exprs);
            }
        }
    }

    /* run the repl */
    run_repl(ctx, ctx->toplevel);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
movq %rsi, %r14
movl %edi, %ebp
callq 0x383c
movq %rax, %rbx
movl %ebp, 0xc(%rsp)
movslq %ebp, %r15
leaq (,%r15,8), %rdi
callq 0x11a0
movq %rax, %r12
testl %r15d, %r15d
jle 0x5a15
movl 0xc(%rsp), %r13d
xorl %ebp, %ebp
movq (%r14,%rbp,8), %rdi
callq 0x584a
movq %rax, (%r12,%rbp,8)
incq %rbp
cmpq %rbp, %r13
jne 0x5a00
movq %r15, %rdi
movq %r12, %rsi
callq 0x3a9d
movq %rax, %r15
movq %r12, %rdi
callq 0x1030
movq (%rbx), %r12
leaq 0xb8e(%rip), %rsi       # 0x65c3
movq %rbx, %rdi
callq 0x58f0
movq %r12, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x22ce
cmpl $0x2, 0xc(%rsp)
jl 0x5a8c
movq 0x8(%r14), %rdi
callq 0x5c8f
testq %rax, %rax
je 0x5a8c
movq %rax, %r14
movq %rax, %rdi
callq 0x10b0
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x3f7d
testq %rax, %rax
je 0x5a8c
movq (%rbx), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x2d89
movq (%rbx), %r14
leaq 0xb6c(%rip), %rdi       # 0x6602
callq 0x1070
leaq 0x5d8(%rip), %r15       # 0x607a
movq 0x452f(%rip), %r12      # 0x9fd8
leaq 0x10(%rsp), %r13
movq %r15, %rdi
leaq 0xb5b(%rip), %rsi       # 0x6613
xorl %eax, %eax
callq 0x10c0
movq (%r12), %rdx
movq %r13, %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x1140
testq %rax, %rax
je 0x5b11
movq %r13, %rdi
leaq 0x925(%rip), %rsi       # 0x6404
callq 0x1110
movb $0x0, 0x10(%rsp,%rax)
movb 0x10(%rsp), %cl
testb %cl, %cl
je 0x5b66
leaq 0x11(%rsp), %rax
movzbl %cl, %ecx
leal -0x9(%rcx), %edx
cmpl $0x2, %edx
jb 0x5b06
cmpl $0x20, %ecx
jne 0x5b43
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x5af6
jmp 0x5b66
movq (%r12), %r15
movq %r15, %rdi
callq 0x1080
testl %eax, %eax
jne 0x5c52
movq %r15, %rdi
callq 0x1180
negl %eax
movl $0x0, %ebp
sbbq %rbp, %rbp
leaq 0x53c(%rip), %r15       # 0x607a
jmp 0x5c07
cmpl $0x28, %ecx
jne 0x5b66
movq %r13, %rdi
callq 0x10b0
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x3d68
movq %rax, %rbp
jmp 0x5c07
movq %r13, %rdi
callq 0x10b0
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x3ff6
testq %rax, %rax
je 0x5c05
movq %rax, %rbp
cmpq $0x0, 0x18(%rax)
je 0x5c05
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2a1d
testl %eax, %eax
jne 0x5c07
movq 0x18(%rbp), %rax
cmpq $0x2, %rax
jb 0x5bf7
movq 0x20(%rbp), %rax
movq (%rax), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2a9d
testq %rax, %rax
je 0x5bec
movq %rax, %r15
movl $0x8, %edi
movq %rax, %rsi
callq 0x36a4
testl %eax, %eax
jne 0x5b37
movl $0x7, %edi
movq %r15, %rsi
callq 0x36a4
testl %eax, %eax
jne 0x5b37
movq 0x18(%rbp), %rax
leaq 0x483(%rip), %r15       # 0x607a
testq %rax, %rax
je 0x5c05
movq 0x20(%rbp), %rax
movq (%rax), %rbp
jmp 0x5c07
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x5aae
cmpq $-0x2, %rbp
je 0x5c48
cmpq $-0x1, %rbp
je 0x5c7b
movq %rbx, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x2a9d
testq %rax, %rax
je 0x5aae
movq %rax, %rdi
callq 0x36ac
movq %rax, %rdi
callq 0x1070
jmp 0x5aae
callq 0x1d94
jmp 0x5aae
movq 0x439f(%rip), %rax      # 0x9ff8
movq (%rax), %rcx
movl $0x1d, %esi
movl $0x1, %edx
leaq 0x9b5(%rip), %rdi       # 0x6622
callq 0x11e0
movq (%r12), %r15
jmp 0x5b25
xorl %eax, %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq