// File: 0x0584[P]scmin-plus/src/builtin/arithmetic.cpp
// Function: builtin::_sub(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::_sub(const sexpr_t& args, env_t& bindings) {
    (void)bindings;
    if (not args->car()->isnum()) {
        cerr << "fatal: operand is not a number!" << endl;
        return nullptr;
    }
    double d = any_cast<sexpr_number>(*args->car()->blob).n;

    if (args->length() == 1)
        return num(-d);

    sexpr_t walk = args->cdr();

    while (not walk->isnil()) {
        if (not walk->car()->isnum()) {
            cerr << "fatal: operands are not numbers!" << endl;
            return nullptr;
        }
        d -= any_cast<sexpr_number>(*walk->car()->blob).n;
        walk = walk->cdr();
    }
    return num(d);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0xc8(%rbp)
movq %rdi, %rax
movq %rax, -0xc0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4400
movq %rax, %rsi
leaq -0x28(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0xb520
movq -0xb8(%rbp), %rdi
callq 0x4400
movq %rax, %rdi
callq 0x7430
movb %al, -0xa9(%rbp)
jmp 0x13d80
movb -0xa9(%rbp), %al
xorb $-0x1, %al
movb %al, -0xc9(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x4450
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x13da3
jmp 0x13df4
movq 0x1a246(%rip), %rdi     # 0x2dff0
leaq 0xd8c8(%rip), %rsi      # 0x21679
callq 0x32c0
movq %rax, %rdi
movq 0x1a1d0(%rip), %rsi     # 0x2df90
callq 0x32f0
movq -0xc8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4570
jmp 0x140df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x4450
jmp 0x140ef
movq -0x10(%rbp), %rdi
callq 0x4400
movq %rax, %rsi
leaq -0x58(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0xb520
movq -0xe0(%rbp), %rdi
callq 0x4400
movq %rax, %rdi
callq 0x4520
movq %rax, -0xd8(%rbp)
jmp 0x13e2d
movq -0xd8(%rbp), %rdi
callq 0x10fa0
movsd %xmm0, -0xe8(%rbp)
jmp 0x13e43
movsd -0xe8(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0xf0(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4450
movsd -0xf0(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4400
movq %rax, %rdi
callq 0x75d0
cmpq $0x1, %rax
jne 0x13ed1
movq -0xc8(%rbp), %rdi
movsd -0x40(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
callq 0x7990
jmp 0x140df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4450
jmp 0x140ef
movq -0x10(%rbp), %rdi
callq 0x4400
movq %rax, %rsi
leaq -0x68(%rbp), %rdi
callq 0xb440
leaq -0x68(%rbp), %rdi
callq 0x4400
movq %rax, %rdi
callq 0x7270
movb %al, -0xf1(%rbp)
jmp 0x13eff
movb -0xf1(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x13f10
jmp 0x140af
leaq -0x68(%rbp), %rdi
callq 0x4400
movq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0xb520
jmp 0x13f27
leaq -0x78(%rbp), %rdi
callq 0x4400
movq %rax, %rdi
callq 0x7430
movb %al, -0xf2(%rbp)
jmp 0x13f40
movb -0xf2(%rbp), %al
xorb $-0x1, %al
movb %al, -0xf3(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x4450
movb -0xf3(%rbp), %al
testb $0x1, %al
jne 0x13f63
jmp 0x13fdb
movq 0x1a086(%rip), %rdi     # 0x2dff0
leaq 0xd6e7(%rip), %rsi      # 0x21658
callq 0x32c0
movq %rax, -0x100(%rbp)
jmp 0x13f7f
movq -0x100(%rbp), %rdi
movq 0x1a003(%rip), %rsi     # 0x2df90
callq 0x32f0
jmp 0x13f94
movq -0xc8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4570
movl $0x1, -0x7c(%rbp)
jmp 0x140c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x140d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x4450
jmp 0x140d4
leaq -0x68(%rbp), %rdi
callq 0x4400
movq %rax, %rsi
leaq -0x98(%rbp), %rdi
callq 0xb520
jmp 0x13ff5
leaq -0x98(%rbp), %rdi
callq 0x4400
movq %rax, %rdi
callq 0x4520
movq %rax, -0x108(%rbp)
jmp 0x14012
movq -0x108(%rbp), %rdi
callq 0x10fa0
movsd %xmm0, -0x110(%rbp)
jmp 0x14028
movsd -0x110(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x88(%rbp), %xmm1
movsd -0x40(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x4450
leaq -0x68(%rbp), %rdi
callq 0x4400
movq %rax, %rsi
leaq -0xa8(%rbp), %rdi
callq 0xb440
jmp 0x14074
leaq -0x68(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x4420
leaq -0xa8(%rbp), %rdi
callq 0x4450
jmp 0x13ee6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x4450
jmp 0x140d4
movq -0xc8(%rbp), %rdi
movsd -0x40(%rbp), %xmm0
callq 0x7990
jmp 0x140c2
movl $0x1, -0x7c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x4450
jmp 0x140df
leaq -0x68(%rbp), %rdi
callq 0x4450
jmp 0x140ef
movq -0xc0(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x34f0
nopl (%rax,%rax)