// File: /workspace/github_c_makefile_star2_O2/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 0x2c7d
movq %rax, %rbx
movslq %ebp, %r15
leaq (,%r15,8), %rdi
callq 0x11a0
movq %rax, %r12
xorl %r13d, %r13d
testl %r15d, %r15d
movl $0x0, %ebp
cmovgl %r15d, %ebp
cmpq %r13, %rbp
je 0x4d36
movq (%r14,%r13,8), %rdi
callq 0x4b86
movq %rax, (%r12,%r13,8)
incq %r13
jmp 0x4d1f
movq %r15, %rdi
movq %r12, %rsi
callq 0x2e4e
movq %rax, %r13
movq %r12, %rdi
callq 0x1030
movq (%rbx), %r12
leaq 0x186d(%rip), %rsi      # 0x65c3
movq %rbx, %rdi
callq 0x4c24
movq %r12, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x1600
cmpl $0x2, %r15d
jl 0x4dac
movq 0x8(%r14), %rdi
callq 0x4fba
testq %rax, %rax
je 0x4dac
movq %rax, %r14
movq %rax, %rdi
callq 0x10b0
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x3636
testq %rax, %rax
je 0x4dac
movq (%rbx), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x2279
movq (%rbx), %rax
movq %rax, (%rsp)
leaq 0x1848(%rip), %rdi      # 0x6602
callq 0x1070
leaq 0x12b4(%rip), %r15      # 0x607a
leaq 0x1846(%rip), %r12      # 0x6613
movq 0x5204(%rip), %r14      # 0x9fd8
leaq 0x10(%rsp), %r13
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x10c0
movq (%r14), %rdx
movq %r13, %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x1140
testq %rax, %rax
je 0x4e4a
movq %r13, %rdi
leaq 0x15ff(%rip), %rsi      # 0x6404
callq 0x1110
movb $0x0, 0x10(%rsp,%rax)
movq %r13, %rax
movzbl (%rax), %ecx
leal -0x9(%rcx), %edx
cmpl $0x2, %edx
jb 0x4e22
cmpl $0x20, %ecx
jne 0x4e27
incq %rax
jmp 0x4e12
movq %r13, %rdi
cmpl $0x28, %ecx
jne 0x4e74
callq 0x10b0
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x30c0
movq %rax, %rbp
jmp 0x4f00
movq (%r14), %rbp
movq %rbp, %rdi
callq 0x1080
testl %eax, %eax
jne 0x4f82
movq %rbp, %rdi
callq 0x1180
negl %eax
movl $0x0, %ebp
sbbq %rbp, %rbp
jmp 0x4f00
callq 0x10b0
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x36b7
testq %rax, %rax
je 0x4efe
movq %rax, %rbp
cmpq $0x0, 0x18(%rax)
je 0x4efe
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x1d2f
testl %eax, %eax
jne 0x4f00
movq 0x18(%rbp), %rax
cmpq $0x2, %rax
jb 0x4ef0
movq 0x20(%rbp), %rax
movq (%rax), %rdx
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0x1dad
testq %rax, %rax
je 0x4eec
pushq $0x8
popq %rdi
movq %rax, 0x8(%rsp)
movq %rax, %rsi
callq 0x2a6c
testl %eax, %eax
jne 0x4f00
pushq $0x7
popq %rdi
movq 0x8(%rsp), %rsi
callq 0x2a6c
testl %eax, %eax
jne 0x4f00
movq 0x18(%rbp), %rax
testq %rax, %rax
je 0x4efe
movq 0x20(%rbp), %rax
movq (%rax), %rbp
jmp 0x4f00
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x4dd9
cmpq $-0x2, %rbp
je 0x4f3e
cmpq $-0x1, %rbp
je 0x4fa6
movq %rbx, %rdi
movq (%rsp), %rsi
movq %rbp, %rdx
callq 0x1dad
testq %rax, %rax
je 0x4dd9
movq %rax, %rdi
callq 0x4cd0
jmp 0x4dd9
movq 0x50b3(%rip), %rbp      # 0x9ff8
movq (%rbp), %rcx
leaq 0x110e(%rip), %rdi      # 0x605e
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
callq 0x11f0
movq (%rbp), %rcx
leaq 0x16b0(%rip), %rdi      # 0x6616
pushq $0xb
popq %rsi
pushq $0x1
popq %rdx
callq 0x11f0
movq (%rbp), %rsi
pushq $0xa
popq %rdi
callq 0x1100
jmp 0x4dd9
movq 0x506f(%rip), %rax      # 0x9ff8
movq (%rax), %rcx
leaq 0x168f(%rip), %rdi      # 0x6622
pushq $0x1d
popq %rsi
pushq $0x1
popq %rdx
callq 0x11f0
movq (%r14), %rbp
jmp 0x4e5d
xorl %eax, %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq