// File: CHEN-Zhihan[P]Compiler/Node.cpp
// Function: StmtNode::ex(std::vector<int, std::allocator<int>>&, int, int, int) const
void StmtNode::ex(vector<int>& sList, int functionID, int blbl, int clbl) const {
    int lblx, lbly, lblz;
    switch (oper) {
        case BREAK: {
            printf("\tjmp\tL%03d\n", blbl);
            break;
        } case CONTINUE: {
            printf("\tjmp\tL%03d\n", clbl);
            break;
        } case FOR: {
            lblx = lbl++;
            lbly = lbl++;
            lblz = lbl++;
            sList.push_back(scopes.back());
            op[0]->ex(sList, functionID, blbl, clbl);
            printf("L%03d:\n", lblx);
            op[1]->ex(sList, functionID, blbl, clbl);
            printf("\tj0\tL%03d\n", lbly);
            op[3]->ex(sList, functionID, lbly, lblz);
            printf("L%03d:\n", lblz);
            op[2]->ex(sList, functionID, blbl, clbl);
            sList.pop_back();
            printf("\tjmp\tL%03d\n", lblx);
            printf("L%03d:\n", lbly);
            break;
        } case WHILE: {
            lblx = lbl++;
            lbly = lbl++;
            printf("L%03d:\n", lblx);
            op[0]->ex(sList, functionID, blbl, clbl);
            printf("\tj0\tL%03d\n", lbly);
            sList.push_back(scopes.back());
            op[1]->ex(sList, functionID, lbly, lblx);
            sList.pop_back();
            printf("\tjmp\tL%03d\n", lblx);
            printf("L%03d:\n", lbly);
            break;
        } case IF: {
            op[0]->ex(sList, functionID, blbl, clbl);
            if (op.size() > 2) {
                /* if else */
                printf("\tj0\tL%03d\n", lblx = lbl++);
                sList.push_back(scopes[0]); // if has 2 scopes;
                op[1]->ex(sList, functionID, blbl, clbl);
                sList.pop_back();
                printf("\tjmp\tL%03d\n", lbly = lbl++);
                printf("L%03d:\n", lblx);
                sList.push_back(scopes[1]);
                op[2]->ex(sList, functionID, blbl, clbl);
                sList.pop_back();
                printf("L%03d:\n", lbly);
            } else {
                /* if */
                printf("\tj0\tL%03d\n", lblx = lbl++);
                sList.push_back(scopes.back());
                op[1]->ex(sList, functionID, blbl, clbl);
                sList.pop_back();
                printf("L%03d:\n", lblx);
            }
            break;
        } case RETURN: {
            if (op.size() == 0) {
                printf("\tpush\t0\n");
            } else {
                op[0]->ex(sList, functionID, blbl, clbl);
            }
            printf("\tret\n");
            break;
        } default: {
            for (const auto & i : op) {
                i->ex(sList, functionID, blbl, clbl);
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movl 0x8(%rax), %eax
addl $0xfffffef9, %eax       # imm = 0xFFFFFEF9
movl %eax, %ecx
movq %rcx, -0x50(%rbp)
subl $0x8, %eax
ja 0x24b67
movq -0x50(%rbp), %rax
leaq 0x12081(%rip), %rcx     # 0x366d8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x18(%rbp), %esi
leaq 0x121fe(%rip), %rdi     # 0x36868
movb $0x0, %al
callq 0x4040
jmp 0x24bd9
movl -0x1c(%rbp), %esi
leaq 0x121e8(%rip), %rdi     # 0x36868
movb $0x0, %al
callq 0x4040
jmp 0x24bd9
movq -0x58(%rbp), %rdi
movl 0x2ce7a(%rip), %eax     # 0x51510
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x2ce6f(%rip)     # 0x51510
movl %eax, -0x20(%rbp)
movl 0x2ce66(%rip), %eax     # 0x51510
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x2ce5b(%rip)     # 0x51510
movl %eax, -0x24(%rbp)
movl 0x2ce52(%rip), %eax     # 0x51510
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x2ce47(%rip)     # 0x51510
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
addq $0x10, %rdi
callq 0x29b70
movq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0x29b00
movq -0x58(%rbp), %rdi
addq $0x28, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x29440
movq %rax, %rdi
callq 0x17630
movq %rax, %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movq (%rdi), %rax
callq *(%rax)
movl -0x20(%rbp), %esi
leaq 0x11f32(%rip), %rdi     # 0x36654
movb $0x0, %al
callq 0x4040
movq -0x58(%rbp), %rdi
addq $0x28, %rdi
movl $0x1, %esi
callq 0x29440
movq %rax, %rdi
callq 0x17630
movq %rax, %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movq (%rdi), %rax
callq *(%rax)
movl -0x24(%rbp), %esi
leaq 0x12111(%rip), %rdi     # 0x36874
movb $0x0, %al
callq 0x4040
movq -0x58(%rbp), %rdi
addq $0x28, %rdi
movl $0x3, %esi
callq 0x29440
movq %rax, %rdi
callq 0x17630
movq %rax, %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x24(%rbp), %ecx
movl -0x28(%rbp), %r8d
movq (%rdi), %rax
callq *(%rax)
movl -0x28(%rbp), %esi
leaq 0x11eb0(%rip), %rdi     # 0x36654
movb $0x0, %al
callq 0x4040
movq -0x58(%rbp), %rdi
addq $0x28, %rdi
movl $0x2, %esi
callq 0x29440
movq %rax, %rdi
callq 0x17630
movq %rax, %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movq (%rdi), %rax
callq *(%rax)
movq -0x10(%rbp), %rdi
callq 0x29bb0
movl -0x20(%rbp), %esi
leaq 0x1207a(%rip), %rdi     # 0x36868
movb $0x0, %al
callq 0x4040
movl -0x24(%rbp), %esi
leaq 0x11e55(%rip), %rdi     # 0x36654
movb $0x0, %al
callq 0x4040
jmp 0x24bd9
movl 0x2ccff(%rip), %eax     # 0x51510
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x2ccf4(%rip)     # 0x51510
movl %eax, -0x20(%rbp)
movl 0x2cceb(%rip), %eax     # 0x51510
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x2cce0(%rip)     # 0x51510
movl %eax, -0x24(%rbp)
movl -0x20(%rbp), %esi
leaq 0x11e17(%rip), %rdi     # 0x36654
movb $0x0, %al
callq 0x4040
movq -0x58(%rbp), %rdi
addq $0x28, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x29440
movq %rax, %rdi
callq 0x17630
movq %rax, %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movq (%rdi), %rax
callq *(%rax)
movl -0x24(%rbp), %esi
leaq 0x11ff7(%rip), %rdi     # 0x36874
movb $0x0, %al
callq 0x4040
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
addq $0x10, %rdi
callq 0x29b70
movq -0x68(%rbp), %rdi
movq %rax, %rsi
callq 0x29b00
movq -0x58(%rbp), %rdi
addq $0x28, %rdi
movl $0x1, %esi
callq 0x29440
movq %rax, %rdi
callq 0x17630
movq %rax, %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x24(%rbp), %ecx
movl -0x20(%rbp), %r8d
movq (%rdi), %rax
callq *(%rax)
movq -0x10(%rbp), %rdi
callq 0x29bb0
movl -0x20(%rbp), %esi
leaq 0x11f80(%rip), %rdi     # 0x36868
movb $0x0, %al
callq 0x4040
movl -0x24(%rbp), %esi
leaq 0x11d5b(%rip), %rdi     # 0x36654
movb $0x0, %al
callq 0x4040
jmp 0x24bd9
movq -0x58(%rbp), %rdi
addq $0x28, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x29440
movq %rax, %rdi
callq 0x17630
movq %rax, %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movq (%rdi), %rax
callq *(%rax)
movq -0x58(%rbp), %rdi
addq $0x28, %rdi
callq 0x294c0
cmpq $0x2, %rax
jbe 0x24a73
movl 0x2cbbf(%rip), %esi     # 0x51510
movl %esi, %eax
addl $0x1, %eax
movl %eax, 0x2cbb4(%rip)     # 0x51510
movl %esi, -0x20(%rbp)
leaq 0x11f0e(%rip), %rdi     # 0x36874
movb $0x0, %al
callq 0x4040
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
addq $0x10, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x29be0
movq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x29b00
movq -0x58(%rbp), %rdi
addq $0x28, %rdi
movl $0x1, %esi
callq 0x29440
movq %rax, %rdi
callq 0x17630
movq %rax, %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movq (%rdi), %rax
callq *(%rax)
movq -0x10(%rbp), %rdi
callq 0x29bb0
movl 0x2cb3f(%rip), %esi     # 0x51510
movl %esi, %eax
addl $0x1, %eax
movl %eax, 0x2cb34(%rip)     # 0x51510
movl %esi, -0x24(%rbp)
leaq 0x11e82(%rip), %rdi     # 0x36868
movb $0x0, %al
callq 0x4040
movl -0x20(%rbp), %esi
leaq 0x11c5d(%rip), %rdi     # 0x36654
movb $0x0, %al
callq 0x4040
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
addq $0x10, %rdi
movl $0x1, %esi
callq 0x29be0
movq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x29b00
movq -0x58(%rbp), %rdi
addq $0x28, %rdi
movl $0x2, %esi
callq 0x29440
movq %rax, %rdi
callq 0x17630
movq %rax, %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movq (%rdi), %rax
callq *(%rax)
movq -0x10(%rbp), %rdi
callq 0x29bb0
movl -0x24(%rbp), %esi
leaq 0x11bed(%rip), %rdi     # 0x36654
movb $0x0, %al
callq 0x4040
jmp 0x24b00
movl 0x2ca97(%rip), %esi     # 0x51510
movl %esi, %eax
addl $0x1, %eax
movl %eax, 0x2ca8c(%rip)     # 0x51510
movl %esi, -0x20(%rbp)
leaq 0x11de6(%rip), %rdi     # 0x36874
movb $0x0, %al
callq 0x4040
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
addq $0x10, %rdi
callq 0x29b70
movq -0x80(%rbp), %rdi
movq %rax, %rsi
callq 0x29b00
movq -0x58(%rbp), %rdi
addq $0x28, %rdi
movl $0x1, %esi
callq 0x29440
movq %rax, %rdi
callq 0x17630
movq %rax, %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movq (%rdi), %rax
callq *(%rax)
movq -0x10(%rbp), %rdi
callq 0x29bb0
movl -0x20(%rbp), %esi
leaq 0x11b5b(%rip), %rdi     # 0x36654
movb $0x0, %al
callq 0x4040
jmp 0x24bd9
movq -0x58(%rbp), %rdi
addq $0x28, %rdi
callq 0x294c0
cmpq $0x0, %rax
jne 0x24b28
leaq 0x11b60(%rip), %rdi     # 0x3667f
movb $0x0, %al
callq 0x4040
jmp 0x24b57
movq -0x58(%rbp), %rdi
addq $0x28, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x29440
movq %rax, %rdi
callq 0x17630
movq %rax, %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movq (%rdi), %rax
callq *(%rax)
leaq 0x11b2a(%rip), %rdi     # 0x36688
movb $0x0, %al
callq 0x4040
jmp 0x24bd9
movq -0x58(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x29c00
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x29c30
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x29c60
testb $0x1, %al
jne 0x24ba0
jmp 0x24bd7
leaq -0x38(%rbp), %rdi
callq 0x29ca0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x17630
movq %rax, %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movq (%rdi), %rax
callq *(%rax)
leaq -0x38(%rbp), %rdi
callq 0x29cc0
jmp 0x24b8d
jmp 0x24bd9
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)