// File: /workspace/github_cpp_makefile_star2_O2/Mespyr[P]bop-lisp/src/main.cpp
// Function: REPL()
void REPL()
{  
    printf("Bop Version 1.0.0\n");
    printf("Press 'Ctrl+C' to exit.\n");

    rl_bind_key('\t', rl_insert);
    
    // Global Evaluator
    Evaluator eval;
    
    while (true) 
    {
        std::string buf = readline("$ ");
        if (buf.length() > 0) 
        {
            add_history(buf.c_str());
        }
        TokenList tokens = tokenize(buf+" ");
        AST ast = parse(tokens);

        if (ast.error_found) 
        {
            std::cout << ast.error.error() << std::endl;
            continue;
        }
        AST_Handler ast_buf{ast};

        while (!ast_buf.eof) 
        {
            Node node = ast_buf.next();
            // ast_out(node.nodes);
            object obj = eval.evaluate(node);
            if (eval.error_found) 
            {
                std::cout << eval.error.error() << std::endl;
                ast_buf.eof = true;
                eval.error_found = false;
            }
            else 
            {
                std::cout << "> " << repr(obj) << std::endl;
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3a8, %rsp            # imm = 0x3A8
leaq 0x3572(%rip), %rdi      # 0xde55
callq 0x2320
leaq 0x3578(%rip), %rdi      # 0xde67
callq 0x2320
movq 0x86ed(%rip), %rsi      # 0x12fe8
pushq $0x9
popq %rdi
callq 0x20e0
leaq -0x2f0(%rbp), %rdi
callq 0xad3c
leaq -0x3d0(%rbp), %r12
leaq -0x360(%rbp), %r14
leaq -0xf8(%rbp), %r13
leaq 0x3524(%rip), %rdi      # 0xde4f
callq 0x2200
leaq -0x48(%rbp), %rdi
movq %rax, %rsi
leaq -0xd8(%rbp), %rdx
callq 0x294e
cmpq $0x0, -0x40(%rbp)
je 0xa953
movq -0x48(%rbp), %rdi
callq 0x22c0
leaq -0x170(%rbp), %r15
movq %r15, %rdi
leaq -0x48(%rbp), %rsi
leaq 0x34e5(%rip), %rdx      # 0xde4d
callq 0xacc2
leaq -0x60(%rbp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xb248
movq %r15, %rdi
callq 0x2130
leaq -0x110(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0xada2
leaq -0x1e0(%rbp), %rdi
movq %r15, %rsi
callq 0xba71
movq %r15, %rdi
callq 0xaf54
cmpb $0x1, -0x1c8(%rbp)
jne 0xa9f4
leaq -0xd8(%rbp), %r15
movq %r15, %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x3924
movq 0x85f5(%rip), %rdi      # 0x12fc8
movq %r15, %rsi
callq 0x21e0
movq %rax, %rdi
callq 0x2140
leaq -0xd8(%rbp), %rdi
callq 0x2130
jmp 0xab1b
leaq -0xd8(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0xacfa
andl $0x0, -0x68(%rbp)
movb $0x0, -0x64(%rbp)
xorl %eax, %eax
testb $0x1, %al
jne 0xab0f
movq %r12, %rdi
leaq -0xd8(%rbp), %rsi
callq 0x3ffc
movq %r14, %rdi
movq %r12, %rsi
callq 0x97f0
leaq -0x150(%rbp), %rdi
leaq -0x2f0(%rbp), %rsi
movq %r14, %rdx
callq 0x460c
movq %r14, %rdi
callq 0x99c0
cmpb $0x1, -0x228(%rbp)
jne 0xaa95
movq %r13, %rdi
leaq -0x2d8(%rbp), %rsi
callq 0x3e36
movq 0x8558(%rip), %rdi      # 0x12fc8
movq %r13, %rsi
callq 0x21e0
movq %rax, %rdi
callq 0x2140
movq %r13, %rdi
callq 0x2130
movb $0x1, -0x64(%rbp)
movb $0x0, -0x228(%rbp)
jmp 0xaaf3
movq 0x852c(%rip), %rdi      # 0x12fc8
leaq 0x33af(%rip), %rsi      # 0xde52
callq 0x2210
movq %rax, %r15
leaq -0x220(%rbp), %rbx
movq %rbx, %rdi
leaq -0x150(%rbp), %rsi
callq 0x28f8
movq %r13, %rdi
movq %rbx, %rsi
callq 0xc43b
movq %r15, %rdi
movq %r13, %rsi
callq 0x21e0
movq %rax, %rdi
callq 0x2140
movq %r13, %rdi
callq 0x2130
leaq -0x220(%rbp), %rdi
callq 0x2a66
leaq -0x150(%rbp), %rdi
callq 0x2a66
movq %r12, %rdi
callq 0x99c0
movb -0x64(%rbp), %al
jmp 0xaa11
leaq -0xd8(%rbp), %rdi
callq 0xad82
leaq -0x1e0(%rbp), %rdi
callq 0xad82
leaq -0x60(%rbp), %rdi
callq 0xaf54
leaq -0x48(%rbp), %rdi
callq 0x2130
jmp 0xa924
jmp 0xab40
movq %rax, %rbx
jmp 0xac19
jmp 0xab8e
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
callq 0x2130
jmp 0xac19
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
callq 0xaf54
jmp 0xac25
movq %rax, %rbx
jmp 0xac25
movq %rax, %rbx
leaq -0x170(%rbp), %rdi
callq 0x2130
jmp 0xac2e
movq %rax, %rbx
jmp 0xac2e
jmp 0xab98
movq %rax, %rbx
jmp 0xac37
jmp 0xaba9
movq %rax, %rbx
jmp 0xabbd
jmp 0xaba9
movq %rax, %rbx
jmp 0xabda
movq %rax, %rbx
leaq -0xf8(%rbp), %rdi
callq 0x2130
leaq -0x220(%rbp), %rdi
callq 0x2a66
jmp 0xabda
movq %rax, %rbx
leaq -0xf8(%rbp), %rdi
callq 0x2130
leaq -0x150(%rbp), %rdi
callq 0x2a66
jmp 0xac01
movq %rax, %rbx
jmp 0xac0d
movq %rax, %rbx
jmp 0xac01
movq %rax, %rbx
leaq -0x360(%rbp), %rdi
callq 0x99c0
leaq -0x3d0(%rbp), %rdi
callq 0x99c0
leaq -0xd8(%rbp), %rdi
callq 0xad82
leaq -0x1e0(%rbp), %rdi
callq 0xad82
leaq -0x60(%rbp), %rdi
callq 0xaf54
leaq -0x48(%rbp), %rdi
callq 0x2130
leaq -0x2f0(%rbp), %rdi
callq 0xad62
movq %rbx, %rdi
callq 0x2380