// File: /workspace/github_cpp_makefile_star2_O2/CHEN-Zhihan[P]Compiler/Node.cpp
// Function: ExprNode::ex(std::vector<int, std::allocator<int>>&, int, int, int) const
void ExprNode::ex(vector<int>& sList, int functionID, int blbl, int clbl) const {
    unordered_set<int> uniOp{INTEGER, CHARACTER, STRING, BOOL, VAR, CALL};
    if (uniOp.count(oper) != 0) {
        op[0]->ex(sList, functionID, blbl, clbl);
        return;
    }
    switch (oper) {
        case '=': {
            op[1]->ex(sList, functionID, blbl, clbl);
            auto v = dynamic_pointer_cast<VarNode>(op[0]);
            v->pop(sList, functionID);
            if (!inStatement) {
                v->push(sList, functionID);
            }
            break;
        } case NOT: {
            printf("\tpush\t1\n");
            op[0]->ex(sList, functionID, blbl, clbl);
            printf("\tsub\n");
            break;

        } case UMINUS: {
            op[0]->ex(sList, functionID, blbl, clbl);
            printf("\tneg\n");
            break;
        } case POSINC: {
            if (!inStatement) {
                op[0]->ex(sList, functionID, blbl, clbl);
            }
            incdec(dynamic_pointer_cast<VarNode>(op[0]), blbl, clbl, sList, functionID, true);
            break;
        } case PREINC: {
            incdec(dynamic_pointer_cast<VarNode>(op[0]), blbl, clbl, sList, functionID, true);
            if (!inStatement) {
                op[0]->ex(sList, functionID, blbl, clbl);
            }
            break;
        } case POSDEC: {
            if (!inStatement) {
                op[0]->ex(sList, functionID, blbl, clbl);
            }
            incdec(dynamic_pointer_cast<VarNode>(op[0]), blbl, clbl, sList, functionID, false);
            break;
        } case PREDEC: {
            incdec(dynamic_pointer_cast<VarNode>(op[0]), blbl, clbl, sList, functionID, false);
            if (!inStatement) {
                op[0]->ex(sList, functionID, blbl, clbl);
            }
            break;
        } default: {
            op[0]->ex(sList, functionID, blbl, clbl);
            op[1]->ex(sList, functionID, blbl, clbl);
            if (operatorInstruction.count(oper) != 0) {
                cout << "\t" << operatorInstruction[oper] << "\n";
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %r8d, -0x30(%rbp)
movl %ecx, -0x2c(%rbp)
movl %edx, %r12d
movq %rsi, %r15
movq %rdi, %r13
movups 0x7ef5(%rip), %xmm0     # 0x13724
leaq -0x38(%rbp), %rdx
movaps %xmm0, -0x18(%rdx)
movabsq $-0x200000005, %rax     # imm = 0xFFFFFFFDFFFFFFFB
movq %rax, -0x8(%rdx)
leaq -0x31(%rbp), %rax
movq %rax, (%rsp)
leaq -0xc8(%rbp), %r14
leaq -0x50(%rbp), %rsi
leaq -0x33(%rbp), %r8
leaq -0x32(%rbp), %r9
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x10158
leaq 0x8(%r13), %rbx
movq %r14, %rdi
movl %r12d, %r14d
movq %rbx, %rsi
callq 0x1021c
testq %rax, %rax
je 0xb8bb
addq $0x18, %r13
movq %r13, %rbx
movq (%rbx), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movl %r14d, %edx
movl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %r8d
callq *(%rax)
leaq -0xc8(%rbp), %rdi
callq 0x96f6
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%rbx), %eax
leal -0x112(%rax), %ecx
cmpl $0x3, %ecx
jbe 0xb93a
cmpl $0x121, %eax            # imm = 0x121
je 0xb9fd
cmpl $0x120, %eax            # imm = 0x120
je 0xb9a1
cmpl $0x3d, %eax
jne 0xba7f
movq 0x28(%r13), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movl %r14d, %edx
movl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %r8d
callq *(%rax)
leaq 0x18(%r13), %rsi
leaq -0x50(%rbp), %rbx
movq %rbx, %rdi
callq 0x67f2
movq (%rbx), %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0xb762
cmpb $0x0, 0xc(%r13)
jne 0xb931
movq -0x50(%rbp), %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0xbba8
leaq -0x48(%rbp), %rdi
jmp 0xbb52
leaq 0x7d2b(%rip), %rax      # 0x1366c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
cmpb $0x0, 0xc(%r13)
jne 0xb967
movq 0x18(%r13), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movl %r14d, %edx
movl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %r8d
callq *(%rax)
addq $0x18, %r13
leaq -0x90(%rbp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x67f2
pushq $0x1
popq %r9
movq %rbx, %rdi
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %edx
movq %r15, %rcx
movl %r14d, %r8d
callq 0xb6fd
leaq -0x88(%rbp), %rdi
jmp 0xbb52
movq 0x18(%r13), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movl %r14d, %edx
movl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %r8d
callq *(%rax)
leaq 0x813c(%rip), %rdi      # 0x13afa
jmp 0xba26
leaq 0x18(%r13), %rbx
movq %r15, %r12
movl %r14d, %r15d
leaq -0x80(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x67f2
pushq $0x1
popq %r9
movq %r14, %rdi
movl %r15d, %r14d
movq %r12, %r15
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %edx
movq %r12, %rcx
movl %r14d, %r8d
callq 0xb6fd
leaq -0x78(%rbp), %rdi
jmp 0xba6a
leaq 0x80fb(%rip), %rdi      # 0x13aff
callq 0x3310
movq 0x18(%r13), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movl %r14d, %edx
movl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %r8d
callq *(%rax)
leaq 0x80e1(%rip), %rdi      # 0x13b07
callq 0x3310
jmp 0xb89d
leaq 0x18(%r13), %rbx
movq %r15, %r12
movl %r14d, %r15d
leaq -0x60(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x67f2
movq %r14, %rdi
movl %r15d, %r14d
movq %r12, %r15
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %edx
movq %r12, %rcx
movl %r14d, %r8d
xorl %r9d, %r9d
callq 0xb6fd
leaq -0x58(%rbp), %rdi
callq 0x6b76
cmpb $0x0, 0xc(%r13)
je 0xb888
jmp 0xb89d
movq 0x18(%r13), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movl %r14d, %edx
movl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %r8d
callq *(%rax)
movq 0x28(%r13), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movl %r14d, %edx
movl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %r8d
callq *(%rax)
leaq 0x1190e(%rip), %rdi     # 0x1d3c0
movq %rbx, %rsi
callq 0x10254
testq %rax, %rax
je 0xb89d
movq 0x114f6(%rip), %rdi     # 0x1cfc0
leaq 0x7d18(%rip), %rsi      # 0x137e9
callq 0x31e0
movq %rax, %r14
leaq 0x118e0(%rip), %rdi     # 0x1d3c0
movq %rbx, %rsi
callq 0x1028c
movq %r14, %rdi
movq %rax, %rsi
callq 0x31c0
leaq 0x76fb(%rip), %rsi      # 0x131f5
movq %rax, %rdi
callq 0x31e0
jmp 0xb89d
cmpb $0x0, 0xc(%r13)
jne 0xbb24
movq 0x18(%r13), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movl %r14d, %edx
movl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %r8d
callq *(%rax)
addq $0x18, %r13
leaq -0x70(%rbp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x67f2
movq %rbx, %rdi
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %edx
movq %r15, %rcx
movl %r14d, %r8d
xorl %r9d, %r9d
callq 0xb6fd
leaq -0x68(%rbp), %rdi
callq 0x6b76
jmp 0xb89d
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
jmp 0xbb8a
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
jmp 0xbb8a
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
jmp 0xbb8a
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
jmp 0xbb8a
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x6b76
jmp 0xbb94
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
callq 0x96f6
movq %rbx, %rdi
callq 0x3390