// File: /workspace/github_cpp_makefile_star2_O1/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 0xdb8f
movl %eax, %ebx
callq 0xdb8f
movl %eax, 0x8(%rsp)
callq 0xdb8f
movl %eax, 0xc(%rsp)
leaq 0x10e51(%rip), %rcx     # 0x2f6b8
movq 0x30(%rcx), %rdx
movq 0x40(%rcx), %rsi
addq $-0x4, %rsi
cmpq %rsi, %rdx
je 0x1e884
movl %eax, (%rdx)
addq $0x4, %rdx
movq %rdx, 0x30(%rcx)
jmp 0x1e895
leaq 0x10e2d(%rip), %rdi     # 0x2f6b8
leaq 0xc(%rsp), %rsi
callq 0x1f60a
leaq 0x10e6c(%rip), %rax     # 0x2f708
movq 0x30(%rax), %rcx
movq 0x40(%rax), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rcx
je 0x1e8bd
movl 0x8(%rsp), %edx
movl %edx, (%rcx)
addq $0x4, %rcx
movq %rcx, 0x30(%rax)
jmp 0x1e8ce
leaq 0x10e44(%rip), %rdi     # 0x2f708
leaq 0x8(%rsp), %rsi
callq 0x1f60a
leaq 0x10(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10dab(%rip), %rdi     # 0x2f688
callq 0x10aac
movq (%rax), %r15
incl 0x11245(%rip)           # 0x2fb30
leaq 0x10f16(%rip), %rbp     # 0x2f808
movq (%rbp), %rcx
leaq 0x2e50(%rip), %rdi      # 0x2174d
movl $0x10, %esi
movl $0x1, %edx
callq 0x64b0
incl 0x1121e(%rip)           # 0x2fb30
movq (%rbp), %rcx
leaq 0x2e41(%rip), %rdi      # 0x2175e
movl $0x7, %esi
movl $0x1, %edx
callq 0x64b0
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x18(%rax)
incl 0x111f1(%rip)           # 0x2fb30
movq (%rbp), %rdi
leaq 0x2da0(%rip), %r12      # 0x216ea
movq %r12, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x6390
incl 0x111d4(%rip)           # 0x2fb30
movq (%rbp), %rcx
leaq 0x2dff(%rip), %rdi      # 0x21766
movl $0x13, %esi
movl $0x1, %edx
callq 0x64b0
movq 0x10(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x18(%rax)
incl 0x111a7(%rip)           # 0x2fb30
movq (%rbp), %rcx
leaq 0x2ced(%rip), %rdi      # 0x21681
movl $0x7, %esi
movl $0x1, %edx
callq 0x64b0
incl 0x11187(%rip)           # 0x2fb30
movq (%rbp), %rdi
movl 0x8(%rsp), %edx
leaq 0x2cd1(%rip), %r13      # 0x21689
movq %r13, %rsi
xorl %eax, %eax
callq 0x6390
incl 0x11168(%rip)           # 0x2fb30
movq (%rbp), %rcx
leaq 0x2da7(%rip), %rdi      # 0x2177a
movl $0xc, %esi
movl $0x1, %edx
callq 0x64b0
movq 0x20(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x18(%rax)
incl 0x1113b(%rip)           # 0x2fb30
movq (%rbp), %rdi
movl 0xc(%rsp), %edx
movq %r12, %rsi
xorl %eax, %eax
callq 0x6390
incl 0x11123(%rip)           # 0x2fb30
movq (%rbp), %rcx
leaq 0x2d6f(%rip), %rdi      # 0x21787
movl $0x12, %esi
movl $0x1, %edx
callq 0x64b0
movq 0x18(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x18(%rax)
incl 0x110f6(%rip)           # 0x2fb30
movq (%rbp), %rcx
leaq 0x2ba6(%rip), %rdi      # 0x215eb
movl $0x4, %esi
movl $0x1, %edx
callq 0x64b0
incl 0x110d6(%rip)           # 0x2fb30
movq (%rbp), %rdi
movq %r13, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x6390
incl 0x110c0(%rip)           # 0x2fb30
movq (%rbp), %rdi
movl 0x8(%rsp), %edx
movq %r12, %rsi
xorl %eax, %eax
callq 0x6390
leaq 0x10c2f(%rip), %rdi     # 0x2f6b8
callq 0x1f81e
leaq 0x10c73(%rip), %rdi     # 0x2f708
callq 0x1f81e
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop