// File: JameyWoo[P]csmile/assembly.cpp
// Function: genStmt(TreeNode*, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<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::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>)
void genStmt(TreeNode* stmts, map<string, string> var2stack) {
    if (stmts == NULL) return;
    TreeNode* stmt = stmts;
    while (stmt != NULL) {
        // debug(stmt->nodekind);

        if (stmt->nodekind == "Output") {
            genOutput(stmt, var2stack);
        } else if (stmt->nodekind == "Assign") {
            genAssign(stmt, var2stack, false);
        } else if (stmt->nodekind == "Selection") {
            genIfElse(stmt, var2stack);
        } else if (stmt->nodekind == "ReturnStmt") {
            genReturn(stmt, var2stack);
        } else if (stmt->nodekind == "Call") {
            genCall(stmt, var2stack);
        } else if (stmt->nodekind == "Iteration") {
            genWhile(stmt, var2stack);
        }

        stmt = stmt->sibling;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rsi, -0x150(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x18966
jmp 0x18c93
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x18c93
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
leaq 0x8877(%rip), %rsi      # 0x211ff
callq 0x5e70
testb $0x1, %al
jne 0x18993
jmp 0x189f2
movq -0x150(%rbp), %rsi
movq -0x18(%rbp), %rax
movq %rax, -0x160(%rbp)
leaq -0x48(%rbp), %rdi
movq %rdi, -0x158(%rbp)
callq 0x1c040
movq -0x160(%rbp), %rdi
movq -0x158(%rbp), %rsi
callq 0x17c70
jmp 0x189ca
leaq -0x48(%rbp), %rdi
callq 0xee40
jmp 0x18c82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xee40
jmp 0x18c9c
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
leaq 0x882d(%rip), %rsi      # 0x2122e
callq 0x5e70
testb $0x1, %al
jne 0x18a0c
jmp 0x18a76
movq -0x150(%rbp), %rsi
movq -0x18(%rbp), %rax
movq %rax, -0x170(%rbp)
leaq -0x88(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x1c040
movq -0x170(%rbp), %rdi
movq -0x168(%rbp), %rsi
xorl %edx, %edx
callq 0x18cb0
jmp 0x18a48
leaq -0x88(%rbp), %rdi
callq 0xee40
jmp 0x18c80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x88(%rbp), %rdi
callq 0xee40
jmp 0x18c9c
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
leaq 0x873c(%rip), %rsi      # 0x211c1
callq 0x5e70
testb $0x1, %al
jne 0x18a90
jmp 0x18af8
movq -0x150(%rbp), %rsi
movq -0x18(%rbp), %rax
movq %rax, -0x180(%rbp)
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x1c040
movq -0x180(%rbp), %rdi
movq -0x178(%rbp), %rsi
callq 0x19350
jmp 0x18aca
leaq -0xb8(%rbp), %rdi
callq 0xee40
jmp 0x18c7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0xee40
jmp 0x18c9c
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
leaq 0x86ff(%rip), %rsi      # 0x21206
callq 0x5e70
testb $0x1, %al
jne 0x18b12
jmp 0x18b7a
movq -0x150(%rbp), %rsi
movq -0x18(%rbp), %rax
movq %rax, -0x190(%rbp)
leaq -0xe8(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x1c040
movq -0x190(%rbp), %rdi
movq -0x188(%rbp), %rsi
callq 0x19880
jmp 0x18b4c
leaq -0xe8(%rbp), %rdi
callq 0xee40
jmp 0x18c7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0xee40
jmp 0x18c9c
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
leaq 0x8651(%rip), %rsi      # 0x211da
callq 0x5e70
testb $0x1, %al
jne 0x18b94
jmp 0x18bfc
movq -0x150(%rbp), %rsi
movq -0x18(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq -0x118(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x1c040
movq -0x1a0(%rbp), %rdi
movq -0x198(%rbp), %rsi
callq 0x18230
jmp 0x18bce
leaq -0x118(%rbp), %rdi
callq 0xee40
jmp 0x18c7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x118(%rbp), %rdi
callq 0xee40
jmp 0x18c9c
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
leaq 0x85c0(%rip), %rsi      # 0x211cb
callq 0x5e70
testb $0x1, %al
jne 0x18c16
jmp 0x18c78
movq -0x150(%rbp), %rsi
movq -0x18(%rbp), %rax
movq %rax, -0x1b0(%rbp)
leaq -0x148(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
callq 0x1c040
movq -0x1b0(%rbp), %rdi
movq -0x1a8(%rbp), %rsi
callq 0x19a70
jmp 0x18c50
leaq -0x148(%rbp), %rdi
callq 0xee40
jmp 0x18c78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x148(%rbp), %rdi
callq 0xee40
jmp 0x18c9c
jmp 0x18c7a
jmp 0x18c7c
jmp 0x18c7e
jmp 0x18c80
jmp 0x18c82
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x1896e
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x3470
nopw %cs:(%rax,%rax)