// File: /workspace/github_cpp_makefile_star2_O1/CHEN-Zhihan[P]Compiler/Node.cpp
// Function: VarNode::pushPop(std::vector<int, std::allocator<int>>&, int, bool) const
void VarNode::pushPop(vector<int>&sList, int functionID, bool push) const {
    string instruction = push ? "push" : "pop";
    if (subscriptions.size() == 0) {
        if (global) {
            cout << "\t" << instruction << "\tsb[" <<  addressTable[GLOBAL].second[GLOBAL][i] << "]\n";
        } else if (functionID == GLOBAL) {
            cout << "\t" << instruction << "\tsb[" << addressTable[GLOBAL].second[getDefinitionScope(sList, GLOBAL)][i] << "]\n";
        } else {
            auto address = addressTable[functionID].second[getDefinitionScope(sList, functionID)][i];
            cout << "\t" << instruction << "\tfp[" << address << "]" << endl;
        }
        return;
    }
    getOffSet(sList, functionID, -1, -1);
    if (global) {
        printf("\tpush\t%d\n", addressTable[GLOBAL].second[GLOBAL][i]);
    } else if (functionID == GLOBAL) {
        auto address = addressTable[GLOBAL].second[getDefinitionScope(sList, functionID)][i];
        printf("\tpush\t%d\n", address);
    } else {
        auto address = addressTable[functionID].second[getDefinitionScope(sList, functionID)][i];        
        printf("\tpush\tfp[%d]\n", address);
        if (address >= 0) {
            printf("\tpush\tfp\n");
            printf("\tadd\n");
        }
    }
    printf("\tadd\n");
    printf("\tpop\tac\n");
    cout << "\t" << instruction << "\tsb[ac]\n";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl %edx, -0x2c(%rbp)
leaq 0x50a7(%rip), %rax      # 0x149e4
leaq 0x50a5(%rip), %rsi      # 0x149e9
testl %ecx, %ecx
cmovneq %rax, %rsi
leaq -0x40(%rbp), %r13
movq %r13, -0x10(%r13)
movl %ecx, %eax
leaq (%rax,%rsi), %rdx
addq $0x3, %rdx
leaq -0x50(%rbp), %rdi
callq 0xb0d6
movq 0x18(%rbx), %rax
cmpq 0x10(%rbx), %rax
je 0xf9cc
movl -0x2c(%rbp), %edx
movq %rbx, %rdi
movq %r14, %rsi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0xfd74
cmpb $0x1, 0xc(%rbx)
jne 0xfa69
leaq 0xcae7(%rip), %rdi      # 0x1c480
leaq 0xcb24(%rip), %rsi      # 0x1c4c4
callq 0xb5dc
addq $0x8, %rax
leaq 0xcb14(%rip), %rsi      # 0x1c4c4
movq %rax, %rdi
callq 0x11870
addq $0x8, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x12922
jmp 0xfabd
cmpb $0x1, 0xc(%rbx)
jne 0xfb42
movq 0xc5eb(%rip), %rdi      # 0x1bfc8
leaq 0x4e25(%rip), %rsi      # 0x14809
movl $0x1, %edx
callq 0x4260
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq 0xc5cb(%rip), %rdi      # 0x1bfc8
callq 0x4260
movq %rax, %r14
leaq 0x4fe1(%rip), %rsi      # 0x149ed
movl $0x4, %edx
movq %rax, %rdi
callq 0x4260
leaq 0xca60(%rip), %rdi      # 0x1c480
leaq 0xca9d(%rip), %rsi      # 0x1c4c4
callq 0xb5dc
addq $0x8, %rax
leaq 0xca8d(%rip), %rsi      # 0x1c4c4
movq %rax, %rdi
callq 0x11870
addq $0x8, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x12922
movl (%rax), %esi
movq %r14, %rdi
callq 0x4390
movl $0x2, %edx
leaq 0x4fa9(%rip), %rsi      # 0x14a0d
jmp 0xfb1d
movl -0x2c(%rbp), %eax
cmpl 0xca52(%rip), %eax      # 0x1c4c4
jne 0xfbff
leaq 0xca01(%rip), %rdi      # 0x1c480
leaq 0xca3e(%rip), %rsi      # 0x1c4c4
callq 0xb5dc
movq %rax, %r15
movl -0x2c(%rbp), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xd3b6
addq $0x8, %r15
leaq -0x30(%rbp), %rsi
movl %eax, (%rsi)
movq %r15, %rdi
callq 0x12a08
addq $0x8, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x12922
movl (%rax), %esi
leaq 0x4b5c(%rip), %rdi      # 0x14622
xorl %eax, %eax
callq 0x4050
leaq 0x4ba4(%rip), %rdi      # 0x14678
callq 0x4330
leaq 0x504c(%rip), %rdi      # 0x14b2c
callq 0x4330
movq 0xc4dc(%rip), %rdi      # 0x1bfc8
leaq 0x4d16(%rip), %rsi      # 0x14809
movl $0x1, %edx
callq 0x4260
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq 0xc4bc(%rip), %rdi      # 0x1bfc8
callq 0x4260
movl $0x8, %edx
leaq 0x4eea(%rip), %rsi      # 0x14a07
movq %rax, %rdi
callq 0x4260
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0xfb33
callq 0x41e0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl -0x2c(%rbp), %eax
cmpl 0xc979(%rip), %eax      # 0x1c4c4
jne 0xfc78
movq 0xc470(%rip), %rdi      # 0x1bfc8
leaq 0x4caa(%rip), %rsi      # 0x14809
movl $0x1, %edx
callq 0x4260
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq 0xc450(%rip), %rdi      # 0x1bfc8
callq 0x4260
movq %rax, %r15
leaq 0x4e66(%rip), %rsi      # 0x149ed
movl $0x4, %edx
movq %rax, %rdi
callq 0x4260
leaq 0xc8e5(%rip), %rdi      # 0x1c480
leaq 0xc922(%rip), %rsi      # 0x1c4c4
callq 0xb5dc
movq %rax, %r12
movl 0xc914(%rip), %edx      # 0x1c4c4
movq %rbx, %rdi
movq %r14, %rsi
callq 0xd3b6
addq $0x8, %r12
leaq -0x30(%rbp), %rsi
movl %eax, (%rsi)
movq %r12, %rdi
callq 0x12a08
addq $0x8, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x12922
movl (%rax), %esi
movq %r15, %rdi
callq 0x4390
leaq 0x4e20(%rip), %rsi      # 0x14a0d
movl $0x2, %edx
movq %rax, %rdi
callq 0x4260
jmp 0xfb25
leaq 0xc87a(%rip), %rdi      # 0x1c480
leaq -0x2c(%rbp), %rsi
callq 0xb5dc
movq %rax, %r15
movl -0x2c(%rbp), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xd3b6
addq $0x8, %r15
leaq -0x30(%rbp), %rsi
movl %eax, (%rsi)
movq %r15, %rdi
callq 0x12a08
addq $0x8, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x12922
movl (%rax), %ebx
leaq 0x4daf(%rip), %rdi      # 0x149f9
movl %ebx, %esi
xorl %eax, %eax
callq 0x4050
testl %ebx, %ebx
js 0xfacd
leaq 0x4ed7(%rip), %rdi      # 0x14b39
callq 0x4330
leaq 0x4a0a(%rip), %rdi      # 0x14678
callq 0x4330
jmp 0xfacd
leaq 0xc801(%rip), %rdi      # 0x1c480
leaq -0x2c(%rbp), %rsi
callq 0xb5dc
movq %rax, %r15
movl -0x2c(%rbp), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xd3b6
addq $0x8, %r15
leaq -0x30(%rbp), %rsi
movl %eax, (%rsi)
movq %r15, %rdi
callq 0x12a08
addq $0x8, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x12922
movl (%rax), %ebx
movq 0xc305(%rip), %rdi      # 0x1bfc8
leaq 0x4b3f(%rip), %rsi      # 0x14809
movl $0x1, %edx
callq 0x4260
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq 0xc2e5(%rip), %rdi      # 0x1bfc8
callq 0x4260
movq %rax, %r14
leaq 0x4d00(%rip), %rsi      # 0x149f2
movl $0x4, %edx
movq %rax, %rdi
callq 0x4260
movq %r14, %rdi
movl %ebx, %esi
callq 0x4390
movq %rax, %rbx
leaq 0x4ce4(%rip), %rsi      # 0x149f7
movl $0x1, %edx
movq %rax, %rdi
callq 0x4260
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x41f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4160
jmp 0xfb25
jmp 0xfd5a
jmp 0xfd5a
jmp 0xfd5a
jmp 0xfd5a
jmp 0xfd5a
jmp 0xfd5a
jmp 0xfd5a
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0xfd6b
callq 0x41e0
movq %rbx, %rdi
callq 0x43b0
nop