// File: CHEN-Zhihan[P]Compiler/Node.cpp
// Function: VarNode::ex(std::vector<int, std::allocator<int>>&, int, int, int) const
void VarNode::ex(vector<int>& sList, int functionID, int blbl, int clbl) const {
    int definitionScope = getDefinitionScope(sList, functionID);
    if (sizeMap[{definitionScope, i}].size() != 0 and subscriptions.size() == 0) { // pass by reference
        int address = addressTable[functionID].second[definitionScope][i];
        if (address < 0) { // is parameter
            printf("\tpush\tfp[%d]\n", address);
        } else {
            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 {
                printf("\tpush\t%d\n", addressTable[functionID].second[definitionScope][i]);
                printf("\tpush\tfp\n");
                printf("\tadd\n");
            }
        }
    } else {
        push(sList, functionID);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x40(%rbp)
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x230f0
movq -0x40(%rbp), %rdx
movl %eax, -0x20(%rbp)
addq $0x8, %rdx
leaq -0x28(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x29050
leaq 0x29963(%rip), %rdi     # 0x514e0
leaq -0x28(%rbp), %rsi
callq 0x28f70
movq %rax, %rdi
callq 0x29660
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, -0x35(%rbp)
je 0x27bb3
movq -0x40(%rbp), %rdi
addq $0x10, %rdi
callq 0x2a210
cmpq $0x0, %rax
sete %al
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %al
testb $0x1, %al
jne 0x27bbf
jmp 0x27d35
leaq 0x298d2(%rip), %rdi     # 0x51498
leaq -0x14(%rbp), %rsi
callq 0x16ef0
movq %rax, %rdi
addq $0x8, %rdi
leaq -0x20(%rbp), %rsi
callq 0x28f40
movq -0x40(%rbp), %rsi
movq %rax, %rdi
addq $0x8, %rsi
callq 0x2a760
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jge 0x27c10
movl -0x2c(%rbp), %esi
leaq 0xede6(%rip), %rdi      # 0x369ea
movb $0x0, %al
callq 0x4040
jmp 0x27d33
movq -0x40(%rbp), %rax
testb $0x1, 0xc(%rax)
je 0x27c65
leaq 0x29877(%rip), %rdi     # 0x51498
leaq 0x298b4(%rip), %rsi     # 0x514dc
callq 0x16ef0
movq %rax, %rdi
addq $0x8, %rdi
leaq 0x298a1(%rip), %rsi     # 0x514dc
callq 0x28f40
movq -0x40(%rbp), %rsi
movq %rax, %rdi
addq $0x8, %rsi
callq 0x2a760
movl (%rax), %esi
leaq 0xea03(%rip), %rdi      # 0x3665c
movb $0x0, %al
callq 0x4040
jmp 0x27d31
movl -0x14(%rbp), %eax
cmpl 0x2986e(%rip), %eax     # 0x514dc
jne 0x27cd3
leaq 0x29821(%rip), %rdi     # 0x51498
leaq 0x2985e(%rip), %rsi     # 0x514dc
callq 0x16ef0
movq -0x40(%rbp), %rdi
addq $0x8, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x230f0
movq -0x48(%rbp), %rdi
movl %eax, -0x34(%rbp)
leaq -0x34(%rbp), %rsi
callq 0x2a8d0
movq -0x40(%rbp), %rsi
movq %rax, %rdi
addq $0x8, %rsi
callq 0x2a760
movl (%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %esi
leaq 0xe992(%rip), %rdi      # 0x3665c
movb $0x0, %al
callq 0x4040
jmp 0x27d2f
leaq 0x297be(%rip), %rdi     # 0x51498
leaq -0x14(%rbp), %rsi
callq 0x16ef0
movq %rax, %rdi
addq $0x8, %rdi
leaq -0x20(%rbp), %rsi
callq 0x28f40
movq -0x40(%rbp), %rsi
movq %rax, %rdi
addq $0x8, %rsi
callq 0x2a760
movl (%rax), %esi
leaq 0xe950(%rip), %rdi      # 0x3665c
movb $0x0, %al
callq 0x4040
leaq 0xecde(%rip), %rdi      # 0x369f8
movb $0x0, %al
callq 0x4040
leaq 0xe948(%rip), %rdi      # 0x36670
movb $0x0, %al
callq 0x4040
jmp 0x27d31
jmp 0x27d33
jmp 0x27d45
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x22ec0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)