// File: /workspace/github_c_makefile_star2_O1/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 0x3885
movq %rax, %rbx
movl %ebp, 0x8(%rsp)
movslq %ebp, %r15
leaq (,%r15,8), %rdi
callq 0x11a0
movq %rax, %r12
testl %r15d, %r15d
jle 0x5b49
movl 0x8(%rsp), %r13d
xorl %ebp, %ebp
movq (%r14,%rbp,8), %rdi
callq 0x597e
movq %rax, (%r12,%rbp,8)
incq %rbp
cmpq %rbp, %r13
jne 0x5b34
movq %r15, %rdi
movq %r12, %rsi
callq 0x3b01
movq %rax, %r15
movq %r12, %rdi
callq 0x1030
movq (%rbx), %r12
leaq 0xa5a(%rip), %rsi       # 0x65c3
movq %rbx, %rdi
callq 0x5a24
movq %r12, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x22fe
cmpl $0x2, 0x8(%rsp)
jl 0x5bc0
movq 0x8(%r14), %rdi
callq 0x5d8a
testq %rax, %rax
je 0x5bc0
movq %rax, %r14
movq %rax, %rdi
callq 0x10b0
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x4001
testq %rax, %rax
je 0x5bc0
movq (%rbx), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x2db7
movq (%rbx), %r15
leaq 0xa38(%rip), %rdi       # 0x6602
callq 0x1070
movq 0x4402(%rip), %r12      # 0x9fd8
leaq 0x10(%rsp), %r13
movabsq $0x100000600, %r14      # imm = 0x100000600
leaq 0x48e(%rip), %rdi       # 0x607a
leaq 0xa20(%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 0x5d00
movq %r13, %rdi
leaq 0x7e6(%rip), %rsi       # 0x6404
callq 0x1110
movb $0x0, 0x10(%rsp,%rax)
movb 0x10(%rsp), %al
testb %al, %al
je 0x5c6d
leaq 0x11(%rsp), %rcx
cmpb $0x20, %al
ja 0x5c4b
movzbl %al, %edx
btq %rdx, %r14
jae 0x5c4b
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x5c35
cmpb $0x28, %al
jne 0x5c6d
movq %r13, %rdi
callq 0x10b0
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x3dd8
movq %rax, %rbp
jmp 0x5d24
movq %r13, %rdi
callq 0x10b0
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x407a
testq %rax, %rax
je 0x5d22
movq %rax, %rbp
cmpq $0x0, 0x18(%rax)
je 0x5d22
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2a2b
testl %eax, %eax
jne 0x5d24
cmpq $0x2, 0x18(%rbp)
jb 0x5cf0
movq 0x20(%rbp), %rax
movq (%rax), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2aab
testq %rax, %rax
je 0x5cf0
movl $0x8, %edi
movq %rax, 0x8(%rsp)
movq %rax, %rsi
callq 0x36e8
testl %eax, %eax
jne 0x5d24
movl $0x7, %edi
movq 0x8(%rsp), %rsi
callq 0x36e8
testl %eax, %eax
jne 0x5d24
cmpq $0x0, 0x18(%rbp)
je 0x5d22
movq 0x20(%rbp), %rax
movq (%rax), %rbp
jmp 0x5d24
movq (%r12), %rdi
callq 0x1080
testl %eax, %eax
jne 0x5d6f
movq (%r12), %rdi
callq 0x1180
negl %eax
movl $0x0, %ebp
sbbq %rbp, %rbp
jmp 0x5d24
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x5be5
cmpq $-0x2, %rbp
je 0x5d65
cmpq $-0x1, %rbp
je 0x5d76
movq %rbx, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x2aab
testq %rax, %rax
je 0x5be5
movq %rax, %rdi
callq 0x36f0
movq %rax, %rdi
callq 0x1070
jmp 0x5be5
callq 0x1db6
jmp 0x5be5
callq 0x1d94
jmp 0x5d0d
xorl %eax, %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq