// File: /workspace/github_cpp_makefile_star2_O3/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 0x55cd(%rip), %rax      # 0x149e4
leaq 0x55cb(%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 0xacf6
movq 0x18(%rbx), %rax
cmpq 0x10(%rbx), %rax
je 0xf4a6
movl -0x2c(%rbp), %edx
movq %rbx, %rdi
movq %r14, %rsi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0xf84e
cmpb $0x1, 0xc(%rbx)
jne 0xf543
leaq 0xd00d(%rip), %rdi      # 0x1c480
leaq 0xd04a(%rip), %rsi      # 0x1c4c4
callq 0xb1ce
addq $0x8, %rax
leaq 0xd03a(%rip), %rsi      # 0x1c4c4
movq %rax, %rdi
callq 0x11302
addq $0x8, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1237e
jmp 0xf597
cmpb $0x1, 0xc(%rbx)
jne 0xf61c
movq 0xcb09(%rip), %rdi      # 0x1bfc0
leaq 0x534b(%rip), %rsi      # 0x14809
movl $0x1, %edx
callq 0x4260
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq 0xcae9(%rip), %rdi      # 0x1bfc0
callq 0x4260
movq %rax, %r14
leaq 0x5507(%rip), %rsi      # 0x149ed
movl $0x4, %edx
movq %rax, %rdi
callq 0x4260
leaq 0xcf86(%rip), %rdi      # 0x1c480
leaq 0xcfc3(%rip), %rsi      # 0x1c4c4
callq 0xb1ce
addq $0x8, %rax
leaq 0xcfb3(%rip), %rsi      # 0x1c4c4
movq %rax, %rdi
callq 0x11302
addq $0x8, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1237e
movl (%rax), %esi
movq %r14, %rdi
callq 0x4390
movl $0x2, %edx
leaq 0x54cf(%rip), %rsi      # 0x14a0d
jmp 0xf5f7
movl -0x2c(%rbp), %eax
cmpl 0xcf78(%rip), %eax      # 0x1c4c4
jne 0xf6d9
leaq 0xcf27(%rip), %rdi      # 0x1c480
leaq 0xcf64(%rip), %rsi      # 0x1c4c4
callq 0xb1ce
movq %rax, %r15
movl -0x2c(%rbp), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xce4e
addq $0x8, %r15
leaq -0x30(%rbp), %rsi
movl %eax, (%rsi)
movq %r15, %rdi
callq 0x124a0
addq $0x8, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1237e
movl (%rax), %esi
leaq 0x5082(%rip), %rdi      # 0x14622
xorl %eax, %eax
callq 0x4050
leaq 0x50ca(%rip), %rdi      # 0x14678
callq 0x4330
leaq 0x5572(%rip), %rdi      # 0x14b2c
callq 0x4330
movq 0xc9fa(%rip), %rdi      # 0x1bfc0
leaq 0x523c(%rip), %rsi      # 0x14809
movl $0x1, %edx
callq 0x4260
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq 0xc9da(%rip), %rdi      # 0x1bfc0
callq 0x4260
movl $0x8, %edx
leaq 0x5410(%rip), %rsi      # 0x14a07
movq %rax, %rdi
callq 0x4260
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0xf60d
callq 0x41e0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl -0x2c(%rbp), %eax
cmpl 0xce9f(%rip), %eax      # 0x1c4c4
jne 0xf752
movq 0xc98e(%rip), %rdi      # 0x1bfc0
leaq 0x51d0(%rip), %rsi      # 0x14809
movl $0x1, %edx
callq 0x4260
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq 0xc96e(%rip), %rdi      # 0x1bfc0
callq 0x4260
movq %rax, %r15
leaq 0x538c(%rip), %rsi      # 0x149ed
movl $0x4, %edx
movq %rax, %rdi
callq 0x4260
leaq 0xce0b(%rip), %rdi      # 0x1c480
leaq 0xce48(%rip), %rsi      # 0x1c4c4
callq 0xb1ce
movq %rax, %r12
movl 0xce3a(%rip), %edx      # 0x1c4c4
movq %rbx, %rdi
movq %r14, %rsi
callq 0xce4e
addq $0x8, %r12
leaq -0x30(%rbp), %rsi
movl %eax, (%rsi)
movq %r12, %rdi
callq 0x124a0
addq $0x8, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1237e
movl (%rax), %esi
movq %r15, %rdi
callq 0x4390
leaq 0x5346(%rip), %rsi      # 0x14a0d
movl $0x2, %edx
movq %rax, %rdi
callq 0x4260
jmp 0xf5ff
leaq 0xcda0(%rip), %rdi      # 0x1c480
leaq -0x2c(%rbp), %rsi
callq 0xb1ce
movq %rax, %r15
movl -0x2c(%rbp), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xce4e
addq $0x8, %r15
leaq -0x30(%rbp), %rsi
movl %eax, (%rsi)
movq %r15, %rdi
callq 0x124a0
addq $0x8, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1237e
movl (%rax), %ebx
leaq 0x52d5(%rip), %rdi      # 0x149f9
movl %ebx, %esi
xorl %eax, %eax
callq 0x4050
testl %ebx, %ebx
js 0xf5a7
leaq 0x53fd(%rip), %rdi      # 0x14b39
callq 0x4330
leaq 0x4f30(%rip), %rdi      # 0x14678
callq 0x4330
jmp 0xf5a7
leaq 0xcd27(%rip), %rdi      # 0x1c480
leaq -0x2c(%rbp), %rsi
callq 0xb1ce
movq %rax, %r15
movl -0x2c(%rbp), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xce4e
addq $0x8, %r15
leaq -0x30(%rbp), %rsi
movl %eax, (%rsi)
movq %r15, %rdi
callq 0x124a0
addq $0x8, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1237e
movl (%rax), %ebx
movq 0xc823(%rip), %rdi      # 0x1bfc0
leaq 0x5065(%rip), %rsi      # 0x14809
movl $0x1, %edx
callq 0x4260
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq 0xc803(%rip), %rdi      # 0x1bfc0
callq 0x4260
movq %rax, %r14
leaq 0x5226(%rip), %rsi      # 0x149f2
movl $0x4, %edx
movq %rax, %rdi
callq 0x4260
movq %r14, %rdi
movl %ebx, %esi
callq 0x4390
movq %rax, %rbx
leaq 0x520a(%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 0xf5ff
jmp 0xf834
jmp 0xf834
jmp 0xf834
jmp 0xf834
jmp 0xf834
jmp 0xf834
jmp 0xf834
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0xf845
callq 0x41e0
movq %rbx, %rdi
callq 0x43b0
nop