// File: /workspace/github_cpp_makefile_star2_O1/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 0xeb4e
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rdi
addq $0x30, %rdi
leaq 0x68ad(%rip), %rsi      # 0x15216
callq 0x2090
testl %eax, %eax
je 0xeb4e
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 0xe9cd
movl $0xc0, %r15d
movq %rsp, %rbx
movq 0x8(%r14), %rsi
addq %r15, %rsi
movq %rbx, %rdi
callq 0x3bea
movq 0x20(%r14), %r14
testq %r14, %r14
jne 0xe9b5
movq (%rsp), %rax
cmpq 0x8(%rsp), %rax
je 0xeb1e
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 0xea41
movl $0x4, %r15d
movl %ebp, %eax
cmpl $0x63, %eax
jbe 0xea38
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0xea3e
cmpl $0x2710, %eax           # imm = 0x2710
jb 0xea41
movl %eax, %ecx
imulq %rbx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r15d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0xea08
addl $-0x3, %r15d
jmp 0xea41
addl $-0x2, %r15d
jmp 0xea41
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 0xb06f
movq %r14, %rdi
leaq 0x6caf(%rip), %rsi      # 0x1571e
callq 0x2340
movq %r13, 0x20(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xea97
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0xea9f
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 0xac76
movq %rax, %rdi
leaq 0x20(%rsp), %rsi
callq 0x2240
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0xeae9
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0xeb00
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21c0
movq (%rsp), %rsi
movq %rsp, %rdi
callq 0xc462
addl $0x4, %ebp
movq (%rsp), %rax
cmpq 0x8(%rsp), %rax
jne 0xe9f5
leaq 0xd2bb(%rip), %rdi      # 0x1bde0
movq 0x40(%rsp), %rsi
callq 0x13856
leaq 0x68(%rsp), %rsi
movq %rax, %rdi
callq 0x139ee
leaq 0x68(%rsp), %rdi
callq 0xabe4
movq %rsp, %rdi
callq 0x3b8e
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xeb9e
jmp 0xeb9e
movq %rax, %rbx
jmp 0xeb83
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0xeb83
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0xeba1
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0xeba1
jmp 0xeb9e
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xabe4
movq %rsp, %rdi
callq 0x3b8e
movq %rbx, %rdi
callq 0x2310