// File: /workspace/github_cpp_makefile_star2_O1/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 0xa101(%rip), %rsi      # 0x14679
leaq 0xa0fd(%rip), %rdx      # 0x1467c
callq 0xb0d6
leaq -0x258(%rbp), %r15
movl $0x2d, (%r15)
leaq -0x250(%rbp), %r14
leaq -0x240(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xa57d(%rip), %rsi      # 0x14b28
leaq 0xa579(%rip), %rdx      # 0x14b2b
movq %r14, %rdi
callq 0xb0d6
leaq -0x230(%rbp), %r15
movl $0x2a, (%r15)
leaq -0x228(%rbp), %rdi
leaq -0x218(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xa554(%rip), %rsi      # 0x14b35
leaq 0xa550(%rip), %rdx      # 0x14b38
callq 0xb0d6
leaq -0x208(%rbp), %r15
movl $0x2f, (%r15)
leaq -0x200(%rbp), %rdi
leaq -0x1f0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xa018(%rip), %rsi      # 0x1462c
leaq 0xa014(%rip), %rdx      # 0x1462f
callq 0xb0d6
leaq -0x1e0(%rbp), %r15
movl $0x25, (%r15)
leaq -0x1d8(%rbp), %rdi
leaq -0x1c8(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x9fe9(%rip), %rsi      # 0x14630
leaq 0x9fe5(%rip), %rdx      # 0x14633
callq 0xb0d6
leaq -0x1b8(%rbp), %r15
movl $0x3c, (%r15)
leaq -0x1b0(%rbp), %rdi
leaq -0x1a0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x9fba(%rip), %rsi      # 0x14634
leaq 0x9fb9(%rip), %rdx      # 0x1463a
callq 0xb0d6
leaq -0x190(%rbp), %r15
movl $0x3e, (%r15)
leaq -0x188(%rbp), %rdi
leaq -0x178(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x9f8e(%rip), %rsi      # 0x1463b
leaq 0x9f8d(%rip), %rdx      # 0x14641
callq 0xb0d6
leaq -0x168(%rbp), %r15
movl $0x11a, (%r15)          # imm = 0x11A
leaq -0x160(%rbp), %rdi
leaq -0x150(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x9f62(%rip), %rsi      # 0x14642
leaq 0x9f61(%rip), %rdx      # 0x14648
callq 0xb0d6
leaq -0x140(%rbp), %r15
movl $0x11b, (%r15)          # imm = 0x11B
leaq -0x138(%rbp), %rdi
leaq -0x128(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x9f36(%rip), %rsi      # 0x14649
leaq 0x9f35(%rip), %rdx      # 0x1464f
callq 0xb0d6
leaq -0x118(%rbp), %r15
movl $0x11d, (%r15)          # imm = 0x11D
leaq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x9f0a(%rip), %rsi      # 0x14650
leaq 0x9f09(%rip), %rdx      # 0x14656
callq 0xb0d6
leaq -0xf0(%rbp), %r15
movl $0x11c, (%r15)          # imm = 0x11C
leaq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x9ede(%rip), %rsi      # 0x14657
leaq 0x9edd(%rip), %rdx      # 0x1465d
callq 0xb0d6
leaq -0xc8(%rbp), %r15
movl $0x118, (%r15)          # imm = 0x118
leaq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x9eb2(%rip), %rsi      # 0x1465e
leaq 0x9eae(%rip), %rdx      # 0x14661
callq 0xb0d6
leaq -0xa0(%rbp), %r15
movl $0x119, (%r15)          # imm = 0x119
leaq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x8d1c(%rip), %rsi      # 0x134fc
leaq 0x8d17(%rip), %rdx      # 0x134fe
callq 0xb0d6
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 0xb9be
leaq 0x11bbf(%rip), %rdi     # 0x1c3d8
leaq -0x70(%rbp), %rsi
callq 0x48b8
leaq -0x70(%rbp), %rdi
callq 0xae94
leaq -0x88(%rbp), %rbx
xorl %r15d, %r15d
movq -0x98(%rbp,%r15), %rdi
leaq (%rbx,%r15), %rax
cmpq %rdi, %rax
je 0xa84b
callq 0x41e0
addq $-0x28, %r15
cmpq $-0x208, %r15           # imm = 0xFDF8
jne 0xa835
xorps %xmm0, %xmm0
movaps %xmm0, -0x280(%rbp)
movaps %xmm0, -0x260(%rbp)
movaps %xmm0, -0x270(%rbp)
movq $0x0, -0x250(%rbp)
movq %r14, -0x280(%rbp)
movq $0x1, -0x278(%rbp)
movl $0x3f800000, -0x260(%rbp) # imm = 0x3F800000
movups %xmm0, -0x258(%rbp)
leaq 0x11afb(%rip), %rdi     # 0x1c3a0
leaq 0x11c18(%rip), %rsi     # 0x1c4c4
callq 0xbe56
leaq -0x280(%rbp), %rsi
movq %rax, %rdi
callq 0x4964
movq %r13, -0x38(%rbp)
leaq -0x280(%rbp), %rbx
movq %rbx, %rdi
callq 0xb170
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
movaps %xmm0, 0x20(%rbx)
movaps %xmm0, 0x10(%rbx)
movq $0x0, 0x30(%rbx)
movq %r14, (%rbx)
movq $0x1, 0x8(%rbx)
movl $0x3f800000, 0x20(%rbx) # imm = 0x3F800000
movups %xmm0, 0x28(%rbx)
leaq 0x11a62(%rip), %rdi     # 0x1c368
leaq -0x280(%rbp), %rsi
callq 0x4a20
leaq -0x280(%rbp), %r14
movq %r14, %rdi
callq 0xad88
leaq -0x70(%rbp), %r15
movl $0x0, (%r15)
leaq 0x11a6d(%rip), %r13     # 0x1c3a0
leaq 0x11b8a(%rip), %r12     # 0x1c4c4
leaq 0x11a27(%rip), %rbx     # 0x1c368
movq %r13, %rdi
movq %r12, %rsi
callq 0xbe56
movq %rax, -0x280(%rbp)
movq %rax, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xc186
movq %rbx, %rdi
movq %r15, %rsi
callq 0xb30c
movq $0x0, (%rax)
movl -0x70(%rbp), %eax
incl %eax
movl %eax, -0x70(%rbp)
cmpl $0x9, %eax
jne 0xa941
movl (%r12), %eax
leaq -0x280(%rbp), %rsi
movl %eax, (%rsi)
leaq -0x70(%rbp), %rdi
leaq -0x30(%rbp), %rcx
movl $0x1, %edx
callq 0xad1e
leaq -0x278(%rbp), %r14
movl $0x0, -0x8(%r14)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movups %xmm0, 0x20(%r14)
movq $0x0, 0x30(%r14)
leaq -0x248(%rbp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
leaq 0x11a95(%rip), %rdi     # 0x1c480
leaq 0x11ad2(%rip), %rsi     # 0x1c4c4
callq 0xb5dc
movq -0x38(%rbp), %r12
leaq -0x280(%rbp), %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0xad5c
movq %r14, %rdi
callq 0xb1e6
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rbx)
movaps %xmm0, 0x20(%rbx)
movaps %xmm0, (%rbx)
movq %r14, 0x18(%rbx)
movq %r14, 0x20(%rbx)
movq $0x0, 0x28(%rbx)
leaq 0x11a0e(%rip), %rdi     # 0x1c448
leaq 0x11a83(%rip), %r15     # 0x1c4c4
movq %r15, %rsi
callq 0xc456
movq %rax, %rbx
movq %rax, %rdi
callq 0xb27c
movq -0x270(%rbp), %rax
testq %rax, %rax
je 0xaab7
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 0xb2f4
movq (%r12), %rdi
movl (%r15), %edx
movq (%rdi), %rax
leaq -0x70(%rbp), %rsi
callq *0x8(%rax)
leaq 0x119a5(%rip), %rdi     # 0x1c480
leaq 0x119e2(%rip), %r14     # 0x1c4c4
movq %r14, %rsi
callq 0xb5dc
cmpl $0x0, (%rax)
je 0xab36
leaq 0x9b79(%rip), %rdi      # 0x1466f
callq 0x4330
leaq 0x1197e(%rip), %rdi     # 0x1c480
leaq 0x119bb(%rip), %rsi     # 0x1c4c4
callq 0xb5dc
movl (%rax), %esi
leaq 0x9b0b(%rip), %rdi      # 0x14622
xorl %eax, %eax
callq 0x4050
leaq 0x9b53(%rip), %rdi      # 0x14678
callq 0x4330
leaq 0x9b4c(%rip), %rdi      # 0x1467d
callq 0x4330
movl $0x0, 0x11978(%rip)     # 0x1c4b8
movl (%r14), %eax
leaq -0x30(%rbp), %rsi
movl %eax, (%rsi)
leaq -0x280(%rbp), %rdi
leaq -0x29(%rbp), %rcx
movl $0x1, %edx
callq 0xad1e
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 0xab97
callq 0x41e0
movq -0x280(%rbp), %rdi
testq %rdi, %rdi
je 0xaba8
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 0x9abb(%rip), %rdi      # 0x14685
callq 0x4330
callq 0xa418
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0xabe2
callq 0x41e0
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xacc8
movq %rax, %rbx
leaq -0x280(%rbp), %rdi
callq 0xb2f4
jmp 0xaccb
movq %rax, %rbx
movq %r14, %rdi
callq 0xb1e6
jmp 0xaccb
movq %rax, %rbx
jmp 0xacd9
jmp 0xac3d
jmp 0xac3d
movq %rax, %rbx
leaq -0x280(%rbp), %rdi
callq 0xb170
jmp 0xacd9
movq %rax, %rdi
callq 0x88cd
movq %rax, %rbx
movq $-0x208, %r14           # imm = 0xFDF8
movq -0x10(%r12), %rdi
cmpq %rdi, %r12
je 0xac5e
callq 0x41e0
addq $-0x28, %r12
addq $0x28, %r14
jne 0xac4f
movb $0x1, %al
jmp 0xac87
jmp 0xac82
jmp 0xac82
jmp 0xac82
jmp 0xac82
jmp 0xac82
jmp 0xac82
jmp 0xac82
jmp 0xac82
jmp 0xac82
jmp 0xac82
jmp 0xac82
movq %rax, %rbx
xorl %eax, %eax
leaq -0x280(%rbp), %r14
cmpq %r15, %r14
sete %cl
orb %al, %cl
jne 0xacd9
addq $-0x10, %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0xacaa
callq 0x41e0
leaq -0x28(%r15), %rax
addq $-0x18, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0xac9c
jmp 0xacd9
movq %rax, %rbx
leaq -0x280(%rbp), %r15
jmp 0xac85
movq %rax, %rbx
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0xacd9
callq 0x41e0
movq %rbx, %rdi
callq 0x43b0
nop