// File: /workspace/github_cpp_makefile_star2_O2/0x0584[P]scmin-plus/src/builtin/builtin.cpp
// Function: builtin::_let(std::shared_ptr<sexpr> const&, std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::shared_ptr<sexpr>, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::shared_ptr<sexpr>>>>&)
sexpr_t builtin::_let(const sexpr_t& args, env_t& bindings) {
    if (args->length() < 2) {
        cerr << "Err: let requires an env and sexpr(s)" << endl;
        return nullptr;
    }

    unordered_set<string> seen;
    bool labeled = args->car()->issymb();
    env_t local = bindings;
    sexpr_t walk = labeled ? args->cdr()->car(): args->car(),
        curr;
    sexpr_t let_args, let_args_tail;

    if (not (walk->islist() or walk->isnil())) {
        cerr << "Err: let is mal formatted" << endl;
        return nullptr;
    }
    while (not walk->isnil()) {
        curr = walk->car();
        if (not curr->islist() or curr->length() != 2) {
            cerr << "Err: let bound is mal formatted" << endl;
            return nullptr;
        }
        if (not curr->car()->issymb()) {
            cerr << "Err: cannot bind constant" << endl;
            return nullptr;
        }
        auto sy = any_cast<sexpr_text>(*curr->car()->blob).text();
        if (not seen.insert(sy).second) {
            cerr << "Err: variable appeared twice!" << endl;
            return nil();
        }
        if (labeled) {
            auto tmp = cons(curr->car(), nil());
            if (not let_args) {
                let_args_tail = let_args = tmp;
            } else {
                let_args_tail->setcdr(tmp);
                let_args_tail = let_args_tail->cdr();
            }
        }
        local[sy] = ::eval(curr->cdr()->car(), bindings);
        walk = walk->cdr();
    }
    if (labeled) {
        auto let_lambda = lambda(let_args, cons(symb("begin"),
                                                args->cdr()->cdr()));
        local[any_cast<sexpr_text>(*args->car()->blob).text()] = let_lambda;
    }
    return builtin::_begin(labeled ? args->cdr()->cdr() : args->cdr(), local) ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rdi
callq 0x4b80
cmpq $0x1, %rax
ja 0x7e66
movq 0x101a4(%rip), %rdi     # 0x17fe8
leaq 0x866c(%rip), %rsi      # 0x104b7
callq 0x31f0
movq %rax, %rdi
callq 0x3100
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq %rbx, %rax
jmp 0x83c1
leaq -0x150(%rbp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
movq (%r14), %rsi
leaq -0x148(%rbp), %rdi
callq 0x5fc6
movq -0x148(%rbp), %rdi
callq 0x4b10
movb %al, -0x29(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x3e82
leaq -0x148(%rbp), %rdi
movq %r15, %rsi
callq 0x591a
cmpb $0x0, -0x29(%rbp)
je 0x7ef1
movq (%r14), %rsi
leaq -0x80(%rbp), %rdi
callq 0x5f48
movq -0x80(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x5fc6
leaq -0x78(%rbp), %rdi
callq 0x3e82
jmp 0x7f00
movq (%r14), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x5fc6
xorps %xmm0, %xmm0
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0xe0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x49e0
testb %al, %al
movq %rbx, -0x38(%rbp)
jne 0x7f40
movq -0xa0(%rbp), %rdi
callq 0x49a8
testb %al, %al
je 0x81ef
movq %r15, -0xf0(%rbp)
movq %r14, -0xe8(%rbp)
leaq -0x80(%rbp), %r14
leaq -0x58(%rbp), %r15
leaq -0x48(%rbp), %r13
movq -0xa0(%rbp), %rdi
callq 0x49a8
testb %al, %al
jne 0x820f
movq -0xa0(%rbp), %rsi
movq %r14, %rdi
callq 0x5fc6
leaq -0x90(%rbp), %rdi
movq %r14, %rsi
callq 0x4354
leaq -0x78(%rbp), %rdi
callq 0x3e82
movq -0x90(%rbp), %rdi
callq 0x49e0
testb %al, %al
je 0x81cb
movq -0x90(%rbp), %rdi
callq 0x4b80
cmpq $0x2, %rax
jne 0x81cb
movq -0x90(%rbp), %rsi
movq %r14, %rdi
callq 0x5fc6
movq -0x80(%rbp), %rdi
callq 0x4b10
movl %eax, %ebx
leaq -0x78(%rbp), %rdi
callq 0x3e82
testb %bl, %bl
je 0x8350
movq -0x90(%rbp), %rsi
movq %r15, %rdi
callq 0x5fc6
movq -0x58(%rbp), %rax
movq (%rax), %rsi
movq %r14, %rdi
callq 0x3d07
leaq -0xd0(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x37cc
movq %r14, %rdi
callq 0x30f0
leaq -0x50(%rbp), %rdi
callq 0x3e82
leaq -0x180(%rbp), %rdi
movq %rbx, %rsi
callq 0x96d4
movl %edx, %ebx
testb $0x1, %dl
je 0x80ce
cmpb $0x0, -0x29(%rbp)
je 0x8121
movq -0x90(%rbp), %rsi
movq %r15, %rdi
callq 0x5fc6
movq %r13, %r12
movq %r13, %rdi
callq 0x4d18
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x4dd5
leaq -0x40(%rbp), %rdi
callq 0x3e82
leaq -0x50(%rbp), %rdi
callq 0x3e82
cmpq $0x0, -0xe0(%rbp)
je 0x80f7
movq -0xb0(%rbp), %rdi
movq %r14, %rsi
callq 0x5f06
movq -0xb0(%rbp), %rsi
movq %r15, %r12
movq %r15, %rdi
callq 0x5f48
leaq -0xb0(%rbp), %rdi
movq %r12, %rsi
callq 0x4354
leaq -0x50(%rbp), %rdi
callq 0x3e82
jmp 0x8118
movq 0xff13(%rip), %rdi      # 0x17fe8
leaq 0x8455(%rip), %rsi      # 0x10531
callq 0x31f0
movq %rax, %rdi
callq 0x3100
movq -0x38(%rbp), %rdi
callq 0x4d18
jmp 0x81b1
leaq -0xe0(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x6002
leaq -0xb0(%rbp), %rdi
movq %r12, %rsi
callq 0x6002
leaq -0x78(%rbp), %rdi
callq 0x3e82
movq -0x90(%rbp), %rsi
movq %r13, %rdi
callq 0x5f48
movq -0x48(%rbp), %rsi
movq %r15, %r12
movq %r15, %rdi
callq 0x5fc6
movq %r14, %rdi
movq %r12, %rsi
movq -0xf0(%rbp), %rdx
callq 0xc9d5
leaq -0x148(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x9466
movq %rax, %rdi
movq %r14, %rsi
callq 0x4354
leaq -0x78(%rbp), %rdi
callq 0x3e82
leaq -0x50(%rbp), %rdi
callq 0x3e82
leaq -0x40(%rbp), %rdi
callq 0x3e82
movq -0xa0(%rbp), %rsi
movq %r14, %rdi
callq 0x5f48
leaq -0xa0(%rbp), %rdi
movq %r14, %rsi
callq 0x4354
leaq -0x78(%rbp), %rdi
callq 0x3e82
leaq -0xd0(%rbp), %rdi
callq 0x30f0
testb $0x1, %bl
jne 0x7f5a
jmp 0x8375
movq 0xfe16(%rip), %rdi      # 0x17fe8
leaq 0x831e(%rip), %rsi      # 0x104f7
callq 0x31f0
movq -0x38(%rbp), %rbx
movq %rax, %rdi
callq 0x3100
jmp 0x836f
movq 0xfdf2(%rip), %rdi      # 0x17fe8
leaq 0x82e0(%rip), %rsi      # 0x104dd
callq 0x31f0
movq %rax, %rdi
callq 0x3100
jmp 0x836f
cmpb $0x0, -0x29(%rbp)
je 0x83d3
leaq 0x832f(%rip), %rsi      # 0x1054f
leaq -0x80(%rbp), %rdi
leaq -0x2a(%rbp), %rdx
callq 0x6608
movq -0x38(%rbp), %r14
movq -0xe8(%rbp), %r15
leaq -0x48(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x4d30
movq (%r15), %rsi
leaq -0x100(%rbp), %rdi
callq 0x5f48
movq -0x100(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x5f48
leaq -0xd0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x110(%rbp), %rdx
callq 0x4dd5
leaq -0x58(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x4d87
leaq -0xc8(%rbp), %rdi
callq 0x3e82
leaq -0x108(%rbp), %rdi
callq 0x3e82
leaq -0xf8(%rbp), %rdi
callq 0x3e82
leaq -0x40(%rbp), %rdi
callq 0x3e82
leaq -0x80(%rbp), %rdi
callq 0x30f0
movq (%r15), %rsi
leaq -0x48(%rbp), %rdi
callq 0x5fc6
movq -0x48(%rbp), %rax
movq (%rax), %rsi
leaq -0x80(%rbp), %rdi
callq 0x3d07
leaq -0xd0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x37cc
leaq -0x148(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x457e
leaq -0x58(%rbp), %rsi
movq %rax, %rdi
callq 0x6002
leaq -0xd0(%rbp), %rbx
movq %rbx, %rdi
callq 0x30f0
leaq -0x80(%rbp), %rdi
callq 0x30f0
leaq -0x40(%rbp), %rdi
callq 0x3e82
leaq -0x50(%rbp), %rdi
callq 0x3e82
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x5f48
jmp 0x83de
movq 0xfc91(%rip), %rdi      # 0x17fe8
leaq 0x81b9(%rip), %rsi      # 0x10517
callq 0x31f0
movq -0x38(%rbp), %rbx
movq %rax, %rdi
callq 0x3100
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
leaq -0xa8(%rbp), %rdi
callq 0x3e82
leaq -0xd8(%rbp), %rdi
callq 0x3e82
leaq -0x88(%rbp), %rdi
callq 0x3e82
leaq -0x98(%rbp), %rdi
callq 0x3e82
leaq -0x148(%rbp), %rdi
callq 0x3d38
leaq -0x180(%rbp), %rdi
callq 0x935a
movq -0x38(%rbp), %rax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x38(%rbp), %r14
movq -0xe8(%rbp), %rbx
movq (%rbx), %rsi
leaq -0x80(%rbp), %rdi
callq 0x5f48
leaq -0x80(%rbp), %rsi
leaq -0x148(%rbp), %rdx
movq %r14, %rdi
callq 0x7a26
leaq -0x78(%rbp), %rdi
callq 0x3e82
cmpb $0x0, -0x29(%rbp)
je 0x8375
leaq -0xc8(%rbp), %rdi
callq 0x3e82
jmp 0x8375
jmp 0x859a
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x30f0
jmp 0x843a
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x30f0
jmp 0x8448
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x3e82
jmp 0x856f
jmp 0x856c
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
callq 0x3e82
jmp 0x846f
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
callq 0x3e82
jmp 0x8480
movq %rax, %rbx
leaq -0xf8(%rbp), %rdi
callq 0x3e82
jmp 0x8491
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x3e82
jmp 0x849f
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
jmp 0x8593
jmp 0x859a
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x3e82
jmp 0x84be
movq %rax, %rbx
cmpb $0x0, -0x29(%rbp)
je 0x859d
leaq -0xc8(%rbp), %rdi
jmp 0x857e
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
jmp 0x85c8
jmp 0x84e2
movq %rax, %rbx
jmp 0x85cd
jmp 0x84ec
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
jmp 0x8553
jmp 0x850b
movq %rax, %rbx
leaq -0x140(%rbp), %rdi
callq 0x3e82
jmp 0x85d9
movq %rax, %rbx
jmp 0x85d9
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x3e82
jmp 0x8524
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
jmp 0x8553
jmp 0x8589
jmp 0x8589
jmp 0x8589
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x3e82
jmp 0x8541
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x3e82
jmp 0x854f
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x3e82
jmp 0x858c
jmp 0x859a
jmp 0x859a
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x30f0
jmp 0x856f
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
jmp 0x857e
jmp 0x8589
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x3e82
jmp 0x859d
jmp 0x859a
jmp 0x859a
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x30f0
jmp 0x859d
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x3e82
leaq -0xd8(%rbp), %rdi
callq 0x3e82
leaq -0x88(%rbp), %rdi
callq 0x3e82
leaq -0x98(%rbp), %rdi
callq 0x3e82
leaq -0x148(%rbp), %rdi
callq 0x3d38
leaq -0x180(%rbp), %rdi
callq 0x935a
movq %rbx, %rdi
callq 0x3330
nop