// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, %r15d
movl %ecx, %r12d
movl %edx, %r14d
movq %rsi, %rbx
movq %rdi, %r13
movl $0xfffffef9, %eax       # imm = 0xFFFFFEF9
addl 0x8(%rdi), %eax
cmpl $0x8, %eax
ja 0xdf13
leaq 0x68d4(%rip), %rcx      # 0x146fc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0xe6c1(%rip), %ecx      # 0x1c4f8
leal 0x1(%rcx), %eax
movl %eax, -0x30(%rbp)
leal 0x2(%rcx), %eax
movl %eax, -0x40(%rbp)
movq %rcx, -0x38(%rbp)
leal 0x3(%rcx), %eax
movl %eax, 0xe6a8(%rip)      # 0x1c4f8
movq 0x18(%r13), %rdx
addq $-0x4, %rdx
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0xe047
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xe04f
movq 0x28(%r13), %rax
movq (%rax), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %r15d, %r8d
movl %r14d, %r15d
movl %r14d, %edx
movl %r12d, %ecx
movl %r8d, -0x30(%rbp)
callq *(%rax)
movq 0x30(%r13), %r14
subq 0x28(%r13), %r14
movl 0xe654(%rip), %esi      # 0x1c4f8
leal 0x1(%rsi), %eax
movl %eax, 0xe64b(%rip)      # 0x1c4f8
leaq 0x69cf(%rip), %rdi      # 0x14883
movq %rsi, -0x38(%rbp)
xorl %eax, %eax
callq 0x4050
cmpq $0x21, %r14
jb 0xdffa
movq 0x10(%r13), %rdx
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0xe162
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xe16a
movq 0x28(%r13), %rax
cmpq %rax, 0x30(%r13)
je 0xe021
movq (%rax), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %r14d, %edx
movl %r12d, %ecx
movl %r15d, %r8d
callq *(%rax)
jmp 0xe02d
movl %r12d, %ecx
movl %r14d, %r12d
movq 0x28(%r13), %r14
movq 0x30(%r13), %rax
cmpq %rax, %r14
je 0xdf55
movq %rbx, %rdx
movq %rax, -0x30(%rbp)
movq (%r14), %rdi
movq (%rdi), %rax
movq %rdx, %r13
movq %rdx, %rsi
movl %r12d, %edx
movl %ecx, %ebx
movl %r15d, %r8d
callq *(%rax)
movq -0x30(%rbp), %rax
movq %r13, %rdx
movl %ebx, %ecx
addq $0x10, %r14
cmpq %rax, %r14
jne 0xdf2d
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0xe58e(%rip), %esi      # 0x1c4f8
leal 0x1(%rsi), %eax
movl %eax, -0x38(%rbp)
leal 0x2(%rsi), %eax
movl %eax, 0xe57f(%rip)      # 0x1c4f8
leaq 0x669a(%rip), %rdi      # 0x1461a
movq %rsi, -0x30(%rbp)
xorl %eax, %eax
callq 0x4050
movq 0x28(%r13), %rax
movq (%rax), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %r14d, %edx
movl %r12d, %ecx
movl %r15d, %r8d
movl -0x38(%rbp), %r15d
callq *(%rax)
leaq 0x68d5(%rip), %rdi      # 0x14883
movl %r15d, %esi
xorl %eax, %eax
callq 0x4050
movq 0x18(%r13), %rdx
addq $-0x4, %rdx
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0xe118
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xe120
leaq 0x6891(%rip), %rdi      # 0x14877
movl %r12d, %esi
jmp 0xe247
leaq 0x6882(%rip), %rdi      # 0x14877
jmp 0xe15a
movq 0x18(%r13), %rdx
addq $-0x4, %rdx
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0xe1e2
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xe1ea
leaq 0x663a(%rip), %rdi      # 0x14662
callq 0x4330
leaq 0x6636(%rip), %rdi      # 0x1466a
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4330
movq %rbx, %rdi
callq 0x12182
movq 0x28(%r13), %rax
movq (%rax), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %r14d, %edx
movl %r12d, %ecx
movl %r12d, -0x44(%rbp)
movl %r15d, %r8d
callq *(%rax)
leaq 0x65a8(%rip), %rdi      # 0x1461a
movq -0x38(%rbp), %rsi
xorl %eax, %eax
callq 0x4050
movq 0x28(%r13), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %r14d, %edx
movl %r12d, %ecx
movl %r15d, %r8d
callq *(%rax)
leaq 0x67e6(%rip), %rdi      # 0x14883
movl -0x30(%rbp), %r12d
movl %r12d, %esi
xorl %eax, %eax
callq 0x4050
movq 0x28(%r13), %rax
movq 0x30(%rax), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %r14d, %edx
movl %r12d, %ecx
movl -0x40(%rbp), %r12d
movl %r12d, %r8d
callq *(%rax)
leaq 0x654b(%rip), %rdi      # 0x1461a
movl %r12d, %esi
xorl %eax, %eax
callq 0x4050
movq 0x28(%r13), %rax
movq 0x20(%rax), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %r14d, %edx
movl -0x44(%rbp), %ecx
movl %r15d, %r8d
callq *(%rax)
addq $-0x4, 0x8(%rbx)
leaq 0x6779(%rip), %rdi      # 0x14877
movq -0x38(%rbp), %rsi
xorl %eax, %eax
callq 0x4050
leaq 0x650a(%rip), %rdi      # 0x1461a
movl -0x30(%rbp), %esi
jmp 0xe247
movq %rbx, %rdi
callq 0x12182
movq 0x28(%r13), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %r14d, %edx
movl %r15d, %ecx
movq -0x30(%rbp), %r14
movl %r14d, %r8d
callq *(%rax)
addq $-0x4, 0x8(%rbx)
leaq 0x672e(%rip), %rdi      # 0x14877
movl %r14d, %esi
xorl %eax, %eax
callq 0x4050
leaq 0x64c0(%rip), %rdi      # 0x1461a
movl %r15d, %esi
jmp 0xe247
movq %rbx, %rdi
callq 0x12182
movl %r15d, %r14d
movq 0x28(%r13), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %r15d, %edx
movl %r12d, %ecx
movl -0x30(%rbp), %r15d
movl %r15d, %r8d
callq *(%rax)
addq $-0x4, 0x8(%rbx)
movl 0xe363(%rip), %esi      # 0x1c4f8
leal 0x1(%rsi), %eax
movl %eax, 0xe35a(%rip)      # 0x1c4f8
leaq 0x66d2(%rip), %rdi      # 0x14877
movq %rsi, -0x40(%rbp)
xorl %eax, %eax
callq 0x4050
leaq 0x6463(%rip), %rdi      # 0x1461a
movq -0x38(%rbp), %rsi
xorl %eax, %eax
callq 0x4050
movq 0x10(%r13), %rdx
addq $0x4, %rdx
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0xe216
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xe21e
movq %rbx, %rdi
callq 0x12182
movl %r15d, %edx
movq 0x28(%r13), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %r12d, %ecx
movl -0x30(%rbp), %r8d
callq *(%rax)
addq $-0x4, 0x8(%rbx)
leaq 0x640a(%rip), %rdi      # 0x1461a
movq -0x38(%rbp), %rsi
jmp 0xe247
movq %rbx, %rdi
callq 0x12182
movq 0x28(%r13), %rax
movq 0x20(%rax), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %r14d, %edx
movl %r12d, %ecx
movl %r15d, %r8d
callq *(%rax)
addq $-0x4, 0x8(%rbx)
leaq 0x63d7(%rip), %rdi      # 0x1461a
movq -0x40(%rbp), %rsi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4050