// File: /workspace/github_cpp_makefile_star2_O1/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 0x8651(%rip), %rbx      # 0x1bbe0
leaq 0x2383(%rip), %rsi      # 0x15919
movl $0x11, %edx
movq %rbx, %rdi
callq 0x2220
movq 0x8636(%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 0x2353(%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 0x2115(%rip), %r15      # 0x1572b
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2220
leaq 0x2304(%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 0x22d4(%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 0x228b(%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 0x2249(%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 0x1375e
movq %r14, %rdi
callq 0x1295d
movq 0x20(%r14), %r14
incl 0x86ea(%rip)            # 0x1be40
incl 0x86e8(%rip)            # 0x1be44
jmp 0x1373f
leaq 0x21f4(%rip), %rsi      # 0x15959
movl $0x33, %edx
movq %rbx, %rdi
callq 0x2220
movq 0x8467(%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 0x21e6(%rip), %rsi      # 0x1598d
movl $0x9, %edx
movq %rax, %rdi
callq 0x2220
leaq 0x1f70(%rip), %rsi      # 0x1572b
movl $0x1, %edx
movq %rbx, %rdi
callq 0x2220
leaq 0x21c8(%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 0x77c6(%rip), %rbx      # 0x1afd0
leaq 0x21a4(%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