// File: /workspace/github_c_makefile_star2_O0/samsonjs[P]lake/src/repl.c
// Function: prompt_read
static LakeVal *prompt_read(LakeCtx *ctx, Env *env, char *prompt)
{
    static int n = 1024;
    printf("%s", prompt);
    char buf[n];
    if (!fgets(buf, n, stdin))
    {
        if (ferror(stdin))
        {
            fprintf(stderr, "error: cannot read from stdin");
        }
        if (feof(stdin))
        {
            return VAL(EOF);
        }
        return NULL;
    }
    /* trim the newline if any */
    buf[strcspn(buf, "\n")] = '\0';

    /* parse list expressions */
    if (first_char(buf) == '(')
    {
        return parse_expr(ctx, buf, strlen(buf));
    }

    /* try to parse a naked call without parens
    (makes the repl more palatable) */
    LakeList *list = parse_naked_list(ctx, buf, strlen(buf));
    if (!list || LIST_N(list) == 0) return NULL;

    LakeVal *result;

    /* naked call */
    LakeVal *head;
    if (is_special_form(ctx, list) ||
        (LIST_N(list) > 1 && (head = eval(ctx, env, LIST_VAL(list, 0))) &&
         CALLABLE(head)))
    {
        result = VAL(list);
    }

    /* probably not function calls, just give the first expr
    (maybe do an implicit progn thing here) */
    else
    {
        result = LIST_VAL(list, 0);
    }

    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x20(%rbp), %rsi
leaq 0xa48(%rip), %rdi       # 0x907a
xorl %eax, %eax
callq 0x10d0
movl 0x4b1d(%rip), %eax      # 0xd15c
movq %rsp, %rcx
movq %rcx, -0x28(%rbp)
movq %rax, %rcx
addq $0xf, %rcx
andq $-0x10, %rcx
movq %rsp, %rdi
subq %rcx, %rdi
movq %rdi, -0x58(%rbp)
movq %rdi, %rsp
movq %rax, -0x30(%rbp)
movl 0x4af4(%rip), %esi      # 0xd15c
movq 0x4969(%rip), %rax      # 0xcfd8
movq (%rax), %rdx
callq 0x1130
cmpq $0x0, %rax
jne 0x86e8
movq 0x4954(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
callq 0x1080
cmpl $0x0, %eax
je 0x86a9
movq 0x4960(%rip), %rax      # 0xcff8
movq (%rax), %rdi
leaq 0xf5c(%rip), %rsi       # 0x95fe
movb $0x0, %al
callq 0x1160
movq 0x4928(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
callq 0x1170
cmpl $0x0, %eax
je 0x86d4
movq $-0x1, %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x34(%rbp)
jmp 0x8873
movq $0x0, -0x8(%rbp)
movl $0x1, -0x34(%rbp)
jmp 0x8873
movq -0x58(%rbp), %rdi
leaq 0xced(%rip), %rsi       # 0x93e0
callq 0x1110
movq -0x58(%rbp), %rdi
movb $0x0, (%rdi,%rax)
callq 0x8890
movsbl %al, %eax
cmpl $0x28, %eax
jne 0x873e
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
callq 0x10b0
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq %rax, %rdx
callq 0x4dd0
movq %rax, -0x8(%rbp)
movl $0x1, -0x34(%rbp)
jmp 0x8873
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
callq 0x10b0
movq -0x68(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq %rax, %rdx
callq 0x5110
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x8775
movq -0x40(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x8789
movq $0x0, -0x8(%rbp)
movl $0x1, -0x34(%rbp)
jmp 0x8873
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2750
cmpl $0x0, %eax
jne 0x8824
movq -0x40(%rbp), %rax
cmpq $0x1, 0x18(%rax)
jbe 0x882e
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x40(%rbp), %rcx
xorl %eax, %eax
cmpq 0x18(%rcx), %rax
jae 0x87db
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rax
movq %rax, -0x80(%rbp)
jmp 0x87e3
xorl %eax, %eax
movq %rax, -0x80(%rbp)
jmp 0x87e3
movq -0x70(%rbp), %rsi
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rdx
callq 0x2840
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x882e
movq -0x50(%rbp), %rsi
movl $0x8, %edi
callq 0x40d0
cmpl $0x0, %eax
jne 0x8824
movq -0x50(%rbp), %rsi
movl $0x7, %edi
callq 0x40d0
cmpl $0x0, %eax
je 0x882e
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x8864
movq -0x40(%rbp), %rcx
xorl %eax, %eax
cmpq 0x18(%rcx), %rax
jae 0x884e
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
jmp 0x8859
xorl %eax, %eax
movq %rax, -0x88(%rbp)
jmp 0x8859
movq -0x88(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x34(%rbp)
movq -0x28(%rbp), %rax
movq %rax, %rsp
movq -0x8(%rbp), %rax
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)