// File: /workspace/github_cpp_makefile_star2_O3/Eronana[P]strawberry/src/ast_codegen.cpp
// Function: AST_ForStatement::codeGen(Symbol*)
DEF_AST_METHOD(ForStatement,AST_CODEGEN)
{
    int beginLabel=nextLabel();
    int endLabel=nextLabel();
    int continueLabel=nextLabel();
    continueStack.push(continueLabel);
    breakStack.push(endLabel);
    GET_SCOPE();
    PRINTF("; for statement\n");
    PRINTF("; init\n");
    CODEGEN(init);
    PRINTF("label_%d:\n",beginLabel);
    PRINTF("; check expression\n");
    CODEGEN(expr);
    PRINTF("istrue\n");
    PRINTF("jmp label_%d\n",endLabel);
    PRINTF("; statement\n");
    CODEGEN(statement);
    PRINTF("label_%d:\n",continueLabel);
    PRINTF("; loop expression\n");
    CODEGEN(loopExpr);
    PRINTF("pop\n");
    PRINTF("jmp label_%d\n",beginLabel);
    PRINTF("label_%d:\n",endLabel);
    continueStack.pop();
    breakStack.pop();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
callq 0xdb7b
movl %eax, %ebx
callq 0xdb7b
movl %eax, %ebp
movl %eax, 0x8(%rsp)
callq 0xdb7b
movl %eax, 0xc(%rsp)
leaq 0x1143d(%rip), %rcx     # 0x2f6b8
movq 0x30(%rcx), %rdx
movq 0x40(%rcx), %rsi
addq $-0x4, %rsi
cmpq %rsi, %rdx
je 0x1e298
movl %eax, (%rdx)
addq $0x4, %rdx
movq %rdx, 0x30(%rcx)
jmp 0x1e2a9
leaq 0x11419(%rip), %rdi     # 0x2f6b8
leaq 0xc(%rsp), %rsi
callq 0x1f024
leaq 0x11458(%rip), %rax     # 0x2f708
movq 0x30(%rax), %rcx
movq 0x40(%rax), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rcx
je 0x1e2cd
movl %ebp, (%rcx)
addq $0x4, %rcx
movq %rcx, 0x30(%rax)
jmp 0x1e2de
leaq 0x11434(%rip), %rdi     # 0x2f708
leaq 0x8(%rsp), %rsi
callq 0x1f024
leaq 0x10(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x1139b(%rip), %rdi     # 0x2f688
callq 0x10a90
movq (%rax), %r15
incl 0x11835(%rip)           # 0x2fb30
leaq 0x11506(%rip), %rbp     # 0x2f808
movq (%rbp), %rcx
leaq 0x345c(%rip), %rdi      # 0x21769
movl $0x10, %esi
movl $0x1, %edx
callq 0x64b0
incl 0x1180e(%rip)           # 0x2fb30
movq (%rbp), %rcx
leaq 0x344d(%rip), %rdi      # 0x2177a
movl $0x7, %esi
movl $0x1, %edx
callq 0x64b0
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x18(%rax)
incl 0x117e1(%rip)           # 0x2fb30
movq (%rbp), %rdi
leaq 0x33ac(%rip), %r12      # 0x21706
movq %r12, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x6390
incl 0x117c4(%rip)           # 0x2fb30
movq (%rbp), %rcx
leaq 0x340b(%rip), %rdi      # 0x21782
movl $0x13, %esi
movl $0x1, %edx
callq 0x64b0
movq 0x10(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x18(%rax)
incl 0x11797(%rip)           # 0x2fb30
movq (%rbp), %rcx
leaq 0x32f9(%rip), %rdi      # 0x2169d
movl $0x7, %esi
movl $0x1, %edx
callq 0x64b0
incl 0x11777(%rip)           # 0x2fb30
movq (%rbp), %rdi
movl 0x8(%rsp), %edx
leaq 0x32dd(%rip), %r13      # 0x216a5
movq %r13, %rsi
xorl %eax, %eax
callq 0x6390
incl 0x11758(%rip)           # 0x2fb30
movq (%rbp), %rcx
leaq 0x33b3(%rip), %rdi      # 0x21796
movl $0xc, %esi
movl $0x1, %edx
callq 0x64b0
movq 0x20(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x18(%rax)
incl 0x1172b(%rip)           # 0x2fb30
movq (%rbp), %rdi
movl 0xc(%rsp), %edx
movq %r12, %rsi
xorl %eax, %eax
callq 0x6390
incl 0x11713(%rip)           # 0x2fb30
movq (%rbp), %rcx
leaq 0x337b(%rip), %rdi      # 0x217a3
movl $0x12, %esi
movl $0x1, %edx
callq 0x64b0
movq 0x18(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x18(%rax)
incl 0x116e6(%rip)           # 0x2fb30
movq (%rbp), %rcx
leaq 0x31b2(%rip), %rdi      # 0x21607
movl $0x4, %esi
movl $0x1, %edx
callq 0x64b0
incl 0x116c6(%rip)           # 0x2fb30
movq (%rbp), %rdi
movq %r13, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x6390
incl 0x116b0(%rip)           # 0x2fb30
movq (%rbp), %rdi
movl 0x8(%rsp), %edx
movq %r12, %rsi
xorl %eax, %eax
callq 0x6390
leaq 0x1121f(%rip), %rdi     # 0x2f6b8
callq 0x1f238
leaq 0x11263(%rip), %rdi     # 0x2f708
callq 0x1f238
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop