// File: /workspace/github_cpp_makefile_star2_O3/JameyWoo[P]csmile/assembly.cpp
// Function: genAssembly(TreeNode*)
void genAssembly(TreeNode* root) {
    // 汇编代码的头部
    assout << "\t.section\t.rodata" << endl
           << ".LC0:" << endl
           << "\t"
           << ".string \"%d\\n\"" << endl
           << ".LC1:" << endl
           << "\t"
           << ".string \"%d\"" << endl
           << "\t"
           << ".text" << endl;

    // 函数部分, 遍历每个 function, 单独处理
    TreeNode* func = root;
    while (func != NULL) {
        genFunc(func);
        func = func->sibling;
        LFB_id++;
        LFE_id++;
    }

    assout << "\t.ident	\"GCC: (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3\"" << endl
           << "\t.section"
           << "\t"
           << ".note.GNU-stack,\"\",@progbits " << endl;

    cout << "the end..." << endl;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
leaq 0x86e1(%rip), %rbx      # 0x1bbe0
leaq 0x2413(%rip), %rsi      # 0x15919
movl $0x11, %edx
movq %rbx, %rdi
callq 0x2220
movq 0x86c6(%rip), %rax      # 0x1bbe0
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq %rax, %r15
leaq 0x23e3(%rip), %rsi      # 0x1592b
movl $0x5, %edx
movq %rax, %rdi
callq 0x2220
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq %rax, %r12
leaq 0x21a5(%rip), %r15      # 0x1572b
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2220
leaq 0x2394(%rip), %rsi      # 0x15931
movl $0xe, %edx
movq %r12, %rdi
callq 0x2220
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq %rax, %r12
leaq 0x2364(%rip), %rsi      # 0x15940
movl $0x5, %edx
movq %rax, %rdi
callq 0x2220
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2220
leaq 0x231b(%rip), %rsi      # 0x15946
movl $0xc, %edx
movq %r12, %rdi
callq 0x2220
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2220
leaq 0x22d9(%rip), %rsi      # 0x15953
movl $0x5, %edx
movq %r12, %rdi
callq 0x2220
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
testq %r14, %r14
je 0x136ce
movq %r14, %rdi
callq 0x128cd
movq 0x20(%r14), %r14
incl 0x877a(%rip)            # 0x1be40
incl 0x8778(%rip)            # 0x1be44
jmp 0x136af
leaq 0x2284(%rip), %rsi      # 0x15959
movl $0x33, %edx
movq %rbx, %rdi
callq 0x2220
movq 0x84f7(%rip), %rax      # 0x1bbe0
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq %rax, %rbx
leaq 0x2276(%rip), %rsi      # 0x1598d
movl $0x9, %edx
movq %rax, %rdi
callq 0x2220
leaq 0x2000(%rip), %rsi      # 0x1572b
movl $0x1, %edx
movq %rbx, %rdi
callq 0x2220
leaq 0x2258(%rip), %rsi      # 0x15997
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x2220
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq 0x7856(%rip), %rbx      # 0x1afd0
leaq 0x2234(%rip), %rsi      # 0x159b5
movl $0xa, %edx
movq %rbx, %rdi
callq 0x2220
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2120