// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
testq %rdi, %rdi
je 0xeabe
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rdi
addq $0x30, %rdi
leaq 0x6941(%rip), %rsi      # 0x15216
callq 0x2090
testl %eax, %eax
je 0xeabe
movq %r14, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
xorl %eax, %eax
movq %rax, 0x10(%rsp)
leaq 0x70(%rsp), %rcx
movl $0x0, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movq (%rbx), %r14
testq %r14, %r14
je 0xea8e
movl $0xc0, %r15d
movq %rsp, %rbx
movq 0x8(%r14), %rsi
addq %r15, %rsi
movq %rbx, %rdi
callq 0x3b9e
movq 0x20(%r14), %r14
testq %r14, %r14
jne 0xe925
movq (%rsp), %rax
cmpq 0x8(%rsp), %rax
je 0xea8e
leaq 0x58(%rsp), %r12
movl $0x8, %ebp
leaq 0x30(%rsp), %r13
leaq 0x48(%rsp), %r14
movl $0xd1b71759, %ebx       # imm = 0xD1B71759
movl $0x1, %r15d
cmpl $0xa, %ebp
jb 0xe9b1
movl $0x4, %r15d
movl %ebp, %eax
cmpl $0x63, %eax
jbe 0xe9a8
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0xe9ae
cmpl $0x2710, %eax           # imm = 0x2710
jb 0xe9b1
movl %eax, %ecx
imulq %rbx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r15d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0xe978
addl $-0x3, %r15d
jmp 0xe9b1
addl $-0x2, %r15d
jmp 0xe9b1
decl %r15d
movl %r15d, %esi
movq %r12, 0x48(%rsp)
movq %r14, %rdi
movl $0x2d, %edx
callq 0x2230
movq 0x48(%rsp), %rdi
movl %r15d, %esi
movl %ebp, %edx
callq 0xafe5
movq %r14, %rdi
leaq 0x6d3f(%rip), %rsi      # 0x1571e
callq 0x2340
movq %r13, 0x20(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xea07
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0xea0f
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, 0x28(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq (%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0xabec
movq %rax, %rdi
leaq 0x20(%rsp), %rsi
callq 0x2240
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0xea59
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0xea70
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21c0
movq (%rsp), %rsi
movq %rsp, %rdi
callq 0xc3d0
addl $0x4, %ebp
movq (%rsp), %rax
cmpq 0x8(%rsp), %rax
jne 0xe965
leaq 0xd34b(%rip), %rdi      # 0x1bde0
movq 0x40(%rsp), %rsi
callq 0x137c6
leaq 0x68(%rsp), %rsi
movq %rax, %rdi
callq 0x1395e
leaq 0x68(%rsp), %rdi
callq 0xab5a
movq %rsp, %rdi
callq 0x3b40
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xeb0e
jmp 0xeb0e
movq %rax, %rbx
jmp 0xeaf3
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0xeaf3
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0xeb11
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0xeb11
jmp 0xeb0e
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xab5a
movq %rsp, %rdi
callq 0x3b40
movq %rbx, %rdi
callq 0x2310