// File: /workspace/github_cpp_makefile_star2_O2/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 $0x278, %rsp            # imm = 0x278
movq %rdi, %rbx
leaq -0x32(%rbp), %rsi
movb $0x2b, (%rsi)
leaq 0xac47(%rip), %rdx      # 0x13659
leaq -0x290(%rbp), %r14
movq %r14, %rdi
callq 0x8fde
leaq -0x268(%rbp), %r15
leaq -0x31(%rbp), %rsi
movb $0x2d, (%rsi)
leaq 0xb0d2(%rip), %rdx      # 0x13b08
movq %r15, %rdi
callq 0x8fde
leaq -0x240(%rbp), %r15
leaq -0x30(%rbp), %rsi
movb $0x2a, (%rsi)
leaq 0xb0c2(%rip), %rdx      # 0x13b15
movq %r15, %rdi
callq 0x8fde
leaq -0x218(%rbp), %r15
leaq -0x2f(%rbp), %rsi
movb $0x2f, (%rsi)
leaq 0xab9c(%rip), %rdx      # 0x1360c
movq %r15, %rdi
callq 0x8fde
leaq -0x1f0(%rbp), %r15
leaq -0x2e(%rbp), %rsi
movb $0x25, (%rsi)
leaq 0xab83(%rip), %rdx      # 0x13610
movq %r15, %rdi
callq 0x8fde
leaq -0x1c8(%rbp), %r15
leaq -0x2d(%rbp), %rsi
movb $0x3c, (%rsi)
leaq 0xab6a(%rip), %rdx      # 0x13614
movq %r15, %rdi
callq 0x9004
leaq -0x1a0(%rbp), %r15
leaq -0x2c(%rbp), %rsi
movb $0x3e, (%rsi)
leaq 0xab54(%rip), %rdx      # 0x1361b
movq %r15, %rdi
callq 0x9004
leaq -0x178(%rbp), %r15
leaq -0x38(%rbp), %rsi
movl $0x11a, (%rsi)          # imm = 0x11A
leaq 0xab3b(%rip), %rdx      # 0x13622
movq %r15, %rdi
callq 0x902a
leaq -0x150(%rbp), %r15
leaq -0x3c(%rbp), %rsi
movl $0x11b, (%rsi)          # imm = 0x11B
leaq 0xab22(%rip), %rdx      # 0x13629
movq %r15, %rdi
callq 0x902a
leaq -0x128(%rbp), %r15
leaq -0x4c(%rbp), %rsi
movl $0x11d, (%rsi)          # imm = 0x11D
leaq 0xab09(%rip), %rdx      # 0x13630
movq %r15, %rdi
callq 0x902a
leaq -0x100(%rbp), %r15
leaq -0x48(%rbp), %rsi
movl $0x11c, (%rsi)          # imm = 0x11C
leaq 0xaaf0(%rip), %rdx      # 0x13637
movq %r15, %rdi
callq 0x902a
leaq -0xd8(%rbp), %r15
leaq -0x44(%rbp), %rsi
movl $0x118, (%rsi)          # imm = 0x118
leaq 0xaad7(%rip), %rdx      # 0x1363e
movq %r15, %rdi
callq 0x9050
leaq -0xb0(%rbp), %r15
leaq -0x40(%rbp), %rsi
movl $0x119, (%rsi)          # imm = 0x119
leaq 0x9975(%rip), %rdx      # 0x124fc
movq %r15, %rdi
callq 0x9076
leaq -0x88(%rbp), %rdx
leaq -0x29(%rbp), %rax
movq %rax, (%rsp)
leaq -0x88(%rbp), %rdi
leaq -0x290(%rbp), %rsi
leaq -0x2b(%rbp), %r8
leaq -0x2a(%rbp), %r9
xorl %ecx, %ecx
callq 0xa29a
leaq 0x147fe(%rip), %rdi     # 0x1d3c0
leaq -0x88(%rbp), %r14
movq %r14, %rsi
callq 0x9514
movq %r14, %rdi
callq 0x9226
movl $0x1e8, %r14d           # imm = 0x1E8
leaq (%r14,%rbp), %rdi
addq $-0x290, %rdi           # imm = 0xFD70
callq 0x3120
addq $-0x28, %r14
cmpq $-0x20, %r14
jne 0x8bdf
leaq -0x260(%rbp), %r15
andq $0x0, -0x10(%r15)
movq %r15, -0x30(%r15)
movq $0x1, -0x28(%r15)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%r15)
movl $0x3f800000, -0x10(%r15) # imm = 0x3F800000
movups %xmm0, -0x8(%r15)
leaq 0x1475b(%rip), %rdi     # 0x1d388
leaq 0x14878(%rip), %rsi     # 0x1d4ac
callq 0xa758
leaq -0x290(%rbp), %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x95e6
movq %r14, %rdi
callq 0x96f6
andq $0x0, 0x20(%r14)
movq %r15, (%r14)
movq $0x1, 0x8(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movl $0x3f800000, 0x20(%r14) # imm = 0x3F800000
movups %xmm0, 0x28(%r14)
leaq 0x146d1(%rip), %r15     # 0x1d350
leaq -0x290(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x975a
movq %r12, %rdi
callq 0x90c0
xorl %eax, %eax
leaq 0x146e6(%rip), %r13     # 0x1d388
leaq 0x14803(%rip), %r12     # 0x1d4ac
movl %eax, -0x290(%rbp)
cmpl $0x9, %eax
je 0x8ce3
movq %r13, %rdi
movq %r12, %rsi
callq 0xa758
movq %rax, %rdi
movq %r14, %rsi
callq 0xab0e
movq %r15, %rdi
movq %r14, %rsi
callq 0x9a14
andq $0x0, (%rax)
movl -0x290(%rbp), %eax
incl %eax
jmp 0x8ca9
movl (%r12), %eax
leaq -0x290(%rbp), %rsi
movl %eax, (%rsi)
leaq -0x88(%rbp), %rdi
pushq $0x1
popq %rdx
leaq -0x38(%rbp), %rcx
callq 0x8fa8
leaq -0x288(%rbp), %r14
andl $0x0, -0x8(%r14)
andq $0x0, 0x20(%r14)
leaq -0x258(%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 0x14728(%rip), %rdi     # 0x1d468
leaq 0x14765(%rip), %rsi     # 0x1d4ac
callq 0x9d9e
leaq -0x290(%rbp), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x909c
movq %r14, %rdi
callq 0x982c
xorps %xmm0, %xmm0
movaps %xmm0, (%r15)
andq $0x0, 0x10(%r15)
movq %r14, 0x18(%r15)
movq %r14, 0x20(%r15)
andq $0x0, 0x28(%r15)
leaq 0x146aa(%rip), %rdi     # 0x1d430
leaq 0x1471f(%rip), %r14     # 0x1d4ac
movq %r14, %rsi
callq 0xaf76
movq %rax, %rdi
movq %r15, %rsi
callq 0x98f0
movq %r15, %rdi
callq 0x99fc
movq (%rbx), %rdi
movl (%r14), %edx
movq (%rdi), %rax
leaq -0x88(%rbp), %rsi
callq *0x8(%rax)
leaq 0x146a6(%rip), %rdi     # 0x1d468
leaq 0x146e3(%rip), %r14     # 0x1d4ac
movq %r14, %rsi
callq 0x9d9e
cmpl $0x0, (%rax)
je 0x8e1d
leaq 0xa872(%rip), %rdi      # 0x1364f
callq 0x3310
leaq 0x1467f(%rip), %rdi     # 0x1d468
leaq 0x146bc(%rip), %rsi     # 0x1d4ac
callq 0x9d9e
movl (%rax), %esi
leaq 0xa804(%rip), %rdi      # 0x13602
xorl %eax, %eax
callq 0x3040
leaq 0xa84c(%rip), %rdi      # 0x13658
callq 0x3310
leaq 0xa845(%rip), %rdi      # 0x1365d
callq 0x3310
andl $0x0, 0x1467c(%rip)     # 0x1d4a0
movl (%r14), %eax
leaq -0x38(%rbp), %rsi
movl %eax, (%rsi)
leaq -0x290(%rbp), %rdi
pushq $0x1
popq %rdx
leaq -0x3c(%rbp), %rcx
callq 0x8fa8
leaq -0x88(%rbp), %r15
leaq -0x290(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0xb316
movq %r12, %rdi
callq 0xa21e
movq (%rbx), %rdi
movl (%r14), %edx
movq (%rdi), %rax
movq %r15, %rsi
movl $0x3e6, %ecx            # imm = 0x3E6
movl $0x3e6, %r8d            # imm = 0x3E6
callq *(%rax)
leaq 0xa7e4(%rip), %rdi      # 0x13665
callq 0x3310
callq 0x88d8
leaq -0x88(%rbp), %rdi
callq 0xa21e
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8f54
movq %rax, %rbx
leaq -0x290(%rbp), %rdi
callq 0x99fc
jmp 0x8f57
movq %rax, %rbx
movq %r14, %rdi
callq 0x982c
jmp 0x8f57
jmp 0x8f4f
movq %rax, %rbx
leaq -0x290(%rbp), %rdi
callq 0x96f6
jmp 0x8f63
movq %rax, %rbx
movl $0x1e8, %r12d           # imm = 0x1E8
leaq (%r12,%rbp), %rdi
addq $-0x290, %rdi           # imm = 0xFD70
callq 0x3120
addq $-0x28, %r12
cmpq $-0x20, %r12
jne 0x8eee
movb $0x1, %al
jmp 0x8f27
jmp 0x8f22
jmp 0x8f22
jmp 0x8f22
jmp 0x8f22
jmp 0x8f22
jmp 0x8f22
jmp 0x8f22
jmp 0x8f22
jmp 0x8f22
jmp 0x8f22
jmp 0x8f22
movq %rax, %rbx
xorl %eax, %eax
cmpq %r15, %r14
sete %cl
testb %al, %al
jne 0x8f63
testb %cl, %cl
jne 0x8f63
leaq -0x28(%r15), %r12
addq $-0x20, %r15
movq %r15, %rdi
callq 0x3120
movq %r12, %r15
cmpq %r14, %r12
jne 0x8f35
jmp 0x8f63
movq %rax, %rbx
jmp 0x8f63
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0xa21e
movq %rbx, %rdi
callq 0x3390
nop