// File: /workspace/github_cpp_makefile_star2_O3/CHEN-Zhihan[P]Compiler/compiler.cpp
// Function: run(std::shared_ptr<Node>)
void run(shared_ptr<Node> p) {
    operatorInstruction = unordered_map<int, string> {{'+', "add"}, {'-', "sub"}, {'*', "mul"}, 
                                            {'/', "div"}, {'%', "mod"}, {'<', "compLT"},
                                            {'>', "compGT"}, {GE, "compGE"}, {LE, "compLE"},
                                            {NE, "compNE"}, {EQ, "compEQ"}, {AND, "and"},
                                            {OR, "or"}};
    variableTable[GLOBAL] = unordered_set<int>{};
    functionTable = unordered_map<int, const FunctionNode* >();
    for (auto i = 0; i != 9; ++i) {
        variableTable[GLOBAL].insert(i);
        functionTable[i] = nullptr;
    }
    vector<scope> sList{GLOBAL};
    #if DEBUG
        for (auto i = 0; i != reverseLookup.size(); ++i) {
            cerr << i << reverseLookup[i] << endl;
        }
    #endif
    addressTable[GLOBAL] = pair<int, unordered_map<scope, unordered_map<ID, address> > >();
    reusableAddress[GLOBAL] = set<pair<int, int> >();
    p->check(sList, GLOBAL);
    if (addressTable[GLOBAL].first != 0) {
        printf("\tpush\tsp\n");
        printf("\tpush\t%d\n", addressTable[GLOBAL].first);
        printf("\tadd\n");
        printf("\tpop\tsp\n");
    }
    scopeCounter = 0;
    sList = vector<scope>{GLOBAL};
    p->ex(sList, GLOBAL, 998, 998);
    printf("\tend\n");
    defineFunctions();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movq %rdi, %r13
leaq -0x278(%rbp), %rdi
movl $0x2b, -0x8(%rdi)
leaq -0x268(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xa4a5(%rip), %rsi      # 0x14679
leaq 0xa4a1(%rip), %rdx      # 0x1467c
callq 0xacf6
leaq -0x258(%rbp), %r15
movl $0x2d, (%r15)
leaq -0x250(%rbp), %r14
leaq -0x240(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xa921(%rip), %rsi      # 0x14b28
leaq 0xa91d(%rip), %rdx      # 0x14b2b
movq %r14, %rdi
callq 0xacf6
leaq -0x230(%rbp), %r15
movl $0x2a, (%r15)
leaq -0x228(%rbp), %rdi
leaq -0x218(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xa8f8(%rip), %rsi      # 0x14b35
leaq 0xa8f4(%rip), %rdx      # 0x14b38
callq 0xacf6
leaq -0x208(%rbp), %r15
movl $0x2f, (%r15)
leaq -0x200(%rbp), %rdi
leaq -0x1f0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xa3bc(%rip), %rsi      # 0x1462c
leaq 0xa3b8(%rip), %rdx      # 0x1462f
callq 0xacf6
leaq -0x1e0(%rbp), %r15
movl $0x25, (%r15)
leaq -0x1d8(%rbp), %rdi
leaq -0x1c8(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xa38d(%rip), %rsi      # 0x14630
leaq 0xa389(%rip), %rdx      # 0x14633
callq 0xacf6
leaq -0x1b8(%rbp), %r15
movl $0x3c, (%r15)
leaq -0x1b0(%rbp), %rdi
leaq -0x1a0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xa35e(%rip), %rsi      # 0x14634
leaq 0xa35d(%rip), %rdx      # 0x1463a
callq 0xacf6
leaq -0x190(%rbp), %r15
movl $0x3e, (%r15)
leaq -0x188(%rbp), %rdi
leaq -0x178(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xa332(%rip), %rsi      # 0x1463b
leaq 0xa331(%rip), %rdx      # 0x14641
callq 0xacf6
leaq -0x168(%rbp), %r15
movl $0x11a, (%r15)          # imm = 0x11A
leaq -0x160(%rbp), %rdi
leaq -0x150(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xa306(%rip), %rsi      # 0x14642
leaq 0xa305(%rip), %rdx      # 0x14648
callq 0xacf6
leaq -0x140(%rbp), %r15
movl $0x11b, (%r15)          # imm = 0x11B
leaq -0x138(%rbp), %rdi
leaq -0x128(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xa2da(%rip), %rsi      # 0x14649
leaq 0xa2d9(%rip), %rdx      # 0x1464f
callq 0xacf6
leaq -0x118(%rbp), %r15
movl $0x11d, (%r15)          # imm = 0x11D
leaq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xa2ae(%rip), %rsi      # 0x14650
leaq 0xa2ad(%rip), %rdx      # 0x14656
callq 0xacf6
leaq -0xf0(%rbp), %r15
movl $0x11c, (%r15)          # imm = 0x11C
leaq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xa282(%rip), %rsi      # 0x14657
leaq 0xa281(%rip), %rdx      # 0x1465d
callq 0xacf6
leaq -0xc8(%rbp), %r15
movl $0x118, (%r15)          # imm = 0x118
leaq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xa256(%rip), %rsi      # 0x1465e
leaq 0xa252(%rip), %rdx      # 0x14661
callq 0xacf6
leaq -0xa0(%rbp), %r15
movl $0x119, (%r15)          # imm = 0x119
leaq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x90c0(%rip), %rsi      # 0x134fc
leaq 0x90bb(%rip), %rdx      # 0x134fe
callq 0xacf6
leaq -0x78(%rbp), %rdx
leaq -0x2a(%rbp), %rax
movq %rax, (%rsp)
leaq -0x70(%rbp), %rdi
leaq -0x280(%rbp), %rsi
leaq -0x30(%rbp), %r8
leaq -0x29(%rbp), %r9
xorl %ecx, %ecx
callq 0xb566
leaq 0x11f63(%rip), %rdi     # 0x1c3d8
leaq -0x70(%rbp), %rsi
callq 0x477a
leaq -0x70(%rbp), %rdi
callq 0xaab4
leaq -0x88(%rbp), %rbx
xorl %r15d, %r15d
movq -0x98(%rbp,%r15), %rdi
leaq (%rbx,%r15), %rax
cmpq %rdi, %rax
je 0xa4a7
callq 0x41e0
addq $-0x28, %r15
cmpq $-0x208, %r15           # imm = 0xFDF8
jne 0xa491
movq $0x0, -0x260(%rbp)
movq %r14, -0x280(%rbp)
movq $0x1, -0x278(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, -0x270(%rbp)
movl $0x3f800000, -0x260(%rbp) # imm = 0x3F800000
movups %xmm0, -0x258(%rbp)
leaq 0x11ead(%rip), %rdi     # 0x1c3a0
leaq 0x11fca(%rip), %rsi     # 0x1c4c4
callq 0xb9ba
leaq -0x280(%rbp), %rsi
movq %rax, %rdi
callq 0x4820
movq %r13, -0x38(%rbp)
leaq -0x280(%rbp), %rbx
movq %rbx, %rdi
callq 0xad94
movq $0x0, 0x20(%rbx)
movq %r14, (%rbx)
movq $0x1, 0x8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movl $0x3f800000, 0x20(%rbx) # imm = 0x3F800000
movups %xmm0, 0x28(%rbx)
leaq 0x11e1b(%rip), %rdi     # 0x1c368
leaq -0x280(%rbp), %rsi
callq 0x48d6
leaq -0x280(%rbp), %r14
movq %r14, %rdi
callq 0xa9a8
leaq -0x70(%rbp), %r15
movl $0x0, (%r15)
leaq 0x11e26(%rip), %r13     # 0x1c3a0
leaq 0x11f43(%rip), %r12     # 0x1c4c4
leaq 0x11de0(%rip), %rbx     # 0x1c368
movq %r13, %rdi
movq %r12, %rsi
callq 0xb9ba
movq %rax, -0x280(%rbp)
movq %rax, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xbcaa
movq %rbx, %rdi
movq %r15, %rsi
callq 0xaf30
movq $0x0, (%rax)
movl -0x70(%rbp), %eax
incl %eax
movl %eax, -0x70(%rbp)
cmpl $0x9, %eax
jne 0xa588
movl (%r12), %eax
leaq -0x280(%rbp), %rsi
movl %eax, (%rsi)
leaq -0x70(%rbp), %rdi
leaq -0x30(%rbp), %rcx
movl $0x1, %edx
callq 0xa93e
leaq -0x278(%rbp), %r14
movl $0x0, -0x8(%r14)
movq $0x0, 0x20(%r14)
leaq -0x248(%rbp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
leaq 0x11e57(%rip), %rdi     # 0x1c480
leaq 0x11e94(%rip), %rsi     # 0x1c4c4
callq 0xb1ce
movq -0x38(%rbp), %r12
leaq -0x280(%rbp), %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0xa97c
movq %r14, %rdi
callq 0xae0a
xorl %eax, %eax
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
movq %r14, 0x18(%rbx)
movq %r14, 0x20(%rbx)
movq %rax, 0x28(%rbx)
leaq 0x11dd6(%rip), %rdi     # 0x1c448
leaq 0x11e4b(%rip), %r15     # 0x1c4c4
movq %r15, %rsi
callq 0xbf44
movq %rax, %rbx
movq %rax, %rdi
callq 0xaea0
movq -0x270(%rbp), %rax
testq %rax, %rax
je 0xa6ef
movq %rbx, %rcx
addq $0x8, %rcx
movl -0x278(%rbp), %edx
movl %edx, 0x8(%rbx)
movq %rax, 0x10(%rbx)
movq -0x268(%rbp), %rdx
movq %rdx, 0x18(%rbx)
movq -0x260(%rbp), %rdx
movq %rdx, 0x20(%rbx)
movq %rcx, 0x8(%rax)
movq -0x258(%rbp), %rax
movq %rax, 0x28(%rbx)
xorl %eax, %eax
movq %rax, -0x270(%rbp)
movq %r14, -0x268(%rbp)
movq %r14, -0x260(%rbp)
movq %rax, -0x258(%rbp)
leaq -0x280(%rbp), %rdi
callq 0xaf18
movq (%r12), %rdi
movl (%r15), %edx
movq (%rdi), %rax
leaq -0x70(%rbp), %rsi
callq *0x8(%rax)
leaq 0x11d6d(%rip), %rdi     # 0x1c480
leaq 0x11daa(%rip), %r14     # 0x1c4c4
movq %r14, %rsi
callq 0xb1ce
cmpl $0x0, (%rax)
je 0xa76e
leaq 0x9f41(%rip), %rdi      # 0x1466f
callq 0x4330
leaq 0x11d46(%rip), %rdi     # 0x1c480
leaq 0x11d83(%rip), %rsi     # 0x1c4c4
callq 0xb1ce
movl (%rax), %esi
leaq 0x9ed3(%rip), %rdi      # 0x14622
xorl %eax, %eax
callq 0x4050
leaq 0x9f1b(%rip), %rdi      # 0x14678
callq 0x4330
leaq 0x9f14(%rip), %rdi      # 0x1467d
callq 0x4330
movl $0x0, 0x11d40(%rip)     # 0x1c4b8
movl (%r14), %eax
leaq -0x30(%rbp), %rsi
movl %eax, (%rsi)
leaq -0x280(%rbp), %rdi
leaq -0x29(%rbp), %rcx
movl $0x1, %edx
callq 0xa93e
movq -0x70(%rbp), %rdi
movq -0x280(%rbp), %rax
movq %rax, -0x70(%rbp)
movups -0x278(%rbp), %xmm0
movups %xmm0, -0x68(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x280(%rbp)
movq $0x0, -0x270(%rbp)
testq %rdi, %rdi
je 0xa7e0
callq 0x41e0
movq -0x280(%rbp), %rdi
testq %rdi, %rdi
je 0xa7e0
callq 0x41e0
movq (%r12), %rdi
movl (%r14), %edx
movq (%rdi), %rax
leaq -0x70(%rbp), %rsi
movl $0x3e6, %ecx            # imm = 0x3E6
movl $0x3e6, %r8d            # imm = 0x3E6
callq *(%rax)
leaq 0x9e83(%rip), %rdi      # 0x14685
callq 0x4330
callq 0xa074
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0xa81a
callq 0x41e0
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa8e8
movq %rax, %rbx
leaq -0x280(%rbp), %rdi
callq 0xaf18
jmp 0xa8eb
movq %rax, %rbx
movq %r14, %rdi
callq 0xae0a
jmp 0xa8eb
jmp 0xa8e3
jmp 0xa872
jmp 0xa872
movq %rax, %rbx
leaq -0x280(%rbp), %rdi
callq 0xad94
jmp 0xa8f9
movq %rax, %rdi
callq 0x85ab
movq %rax, %rbx
movq $-0x208, %r14           # imm = 0xFDF8
movq -0x10(%r12), %rdi
cmpq %rdi, %r12
je 0xa893
callq 0x41e0
addq $-0x28, %r12
addq $0x28, %r14
jne 0xa884
jmp 0xa8f9
jmp 0xa8b5
jmp 0xa8b5
jmp 0xa8b5
jmp 0xa8b5
jmp 0xa8b5
jmp 0xa8b5
jmp 0xa8b5
jmp 0xa8b5
jmp 0xa8b5
jmp 0xa8b5
jmp 0xa8b5
movq %rax, %rbx
addq $-0x10, %r15
leaq -0x280(%rbp), %r14
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0xa8d1
callq 0x41e0
leaq -0x28(%r15), %rax
addq $-0x18, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0xa8c3
jmp 0xa8f9
movq %rax, %rbx
jmp 0xa8f9
movq %rax, %rbx
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0xa8f9
callq 0x41e0
movq %rbx, %rdi
callq 0x43b0
nop