// File: JameyWoo[P]csmile/assembly.cpp
// Function: getParams(TreeNode*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void getParams(TreeNode* params, string func_name) {
    if (params == NULL) return;
    // debug("params->child[0]->nodekind : " + params->child[0]->nodekind);
    if (params->child[0]->nodekind == "void") {
        // debug("param void");
        return;
    }

    vector<string> param_stack;
    map<string, string> var2stack;
    // 接下来是有参数的
    TreeNode* param = params->child[0];
    while (param != NULL) {
        // debug("param: " + param->nodekind);
        // debug(param->child[0]->nodekind + " " + param->child[1]->name);
        param_stack.push_back(param->child[1]->name);
        param = param->sibling;
    }

    // * 给参数分配栈空间
    int bias = 8;
    while (not param_stack.empty()) {
        var2stack[param_stack.front()] = to_string(bias) + "(%ebp)";
        param_stack.erase(param_stack.begin());
        bias += 4;
    }

    fun2param[func_name] = var2stack;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rsi, -0xd0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x177f6
jmp 0x179e3
movq -0x8(%rbp), %rax
movq (%rax), %rdi
addq $0x30, %rdi
leaq 0x98f4(%rip), %rsi      # 0x210fc
callq 0x5e70
testb $0x1, %al
jne 0x17813
jmp 0x17818
jmp 0x179e3
leaq -0x28(%rbp), %rdi
callq 0x5d90
leaq -0x58(%rbp), %rdi
callq 0xee20
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x17875
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0xc0, %rsi
leaq -0x28(%rbp), %rdi
callq 0x5db0
jmp 0x17856
movq -0x60(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x17835
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x179ec
movl $0x8, -0x70(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x1be10
xorb $-0x1, %al
testb $0x1, %al
jne 0x17890
jmp 0x179a3
movl -0x70(%rbp), %esi
leaq -0xb0(%rbp), %rdi
callq 0xf460
jmp 0x178a1
leaq 0x9ddf(%rip), %rdx      # 0x21687
leaq -0x90(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xf3c0
jmp 0x178bd
leaq -0x28(%rbp), %rdi
callq 0x11550
movq %rax, %rsi
leaq -0x58(%rbp), %rdi
callq 0xf2e0
movq %rax, -0xd8(%rbp)
jmp 0x178db
movq -0xd8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movq %rsi, -0xf0(%rbp)
callq 0x3350
movq -0xf0(%rbp), %rdi
callq 0x34e8
leaq -0xb0(%rbp), %rdi
callq 0x34e8
leaq -0x28(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x5ef0
movq %rax, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x115f0
movq -0xe8(%rbp), %rdi
movq -0xb8(%rbp), %rsi
callq 0x11580
movq %rax, -0xe0(%rbp)
jmp 0x17953
movq -0xe0(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl -0x70(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x70(%rbp)
jmp 0x1787c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x17995
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x34e8
leaq -0xb0(%rbp), %rdi
callq 0x34e8
jmp 0x179ec
movq -0xd0(%rbp), %rsi
leaq 0x174f7(%rip), %rdi     # 0x2eea8
callq 0x1be50
movq %rax, -0xf8(%rbp)
jmp 0x179bf
movq -0xf8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x1bf30
jmp 0x179d1
leaq -0x58(%rbp), %rdi
callq 0xee40
leaq -0x28(%rbp), %rdi
callq 0x5d30
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
leaq -0x58(%rbp), %rdi
callq 0xee40
leaq -0x28(%rbp), %rdi
callq 0x5d30
movq -0x68(%rbp), %rdi
callq 0x3470
nopw (%rax,%rax)