// File: /workspace/github_c_makefile_star2_O0/masyagin1998[P]GCI/src/bytecode-generator/bytecode-generator.c
// Function: while_stmt_ast_bytecode_generate
static enum BYTECODE_GENERATOR_CODES while_stmt_ast_bytecode_generate(bytecode_generator_type_t bc_gen, const struct WHILE_STMT_AST*ast)
{
    enum BYTECODE_GENERATOR_CODES r;
    
    size_t i;
    
    int loop_start_idx;
    
    int*loop_exit_idxs = NULL;
    size_t loop_exit_idxs_len = 0;
    size_t loop_exit_idxs_cap = 0;        

    loop_start_idx = bc_gen->bc->op_codes_len;
    
    r = logical_or_expr_ast_bytecode_generate(bc_gen, ast->condition);
    if (r != BYTECODE_GENERATOR_OK) {
        return r;
    }

    PUSH_BACK(loop_exit_idxs, emit_jump(bc_gen, BC_OP_JUMP_IF_FALSE));
    PUSH_BACK(bc_gen->bc->op_codes, BC_OP_POP);

    r = body_ast_bytecode_generate(bc_gen, ast->body, &loop_start_idx,
                                   &loop_exit_idxs, &loop_exit_idxs_len, &loop_exit_idxs_cap);
    if (r != BYTECODE_GENERATOR_OK) {
        return r;
    }    

    emit_loop(bc_gen, loop_start_idx);

    patch_jump(bc_gen, loop_exit_idxs[0]);
    PUSH_BACK(bc_gen->bc->op_codes, BC_OP_POP);
    
    for (i = 1; i < loop_exit_idxs_len; i++) {
        patch_jump(bc_gen, loop_exit_idxs[i]);
    }

    free(loop_exit_idxs);
    
    return BYTECODE_GENERATOR_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x10360
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0xf16b
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xf5c3
jmp 0xf16d
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0xf23d
cmpq $0x0, -0x48(%rbp)
jne 0xf1db
movq $0x1, -0x48(%rbp)
movq -0x48(%rbp), %rdi
shlq $0x2, %rdi
callq 0x1130
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0xf1d7
movq 0xfe48(%rip), %rax      # 0x1eff0
movq (%rax), %rdi
movq -0x48(%rbp), %r8
shlq $0x2, %r8
leaq 0x9454(%rip), %rsi      # 0x1860e
leaq 0xa21f(%rip), %rdx      # 0x193e0
movl $0x284, %ecx            # imm = 0x284
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1170
jmp 0xf1d9
jmp 0xf23b
movq -0x48(%rbp), %rax
shlq %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
shlq $0x2, %rsi
callq 0x1150
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0xf237
movq 0xfde8(%rip), %rax      # 0x1eff0
movq (%rax), %rdi
movq -0x48(%rbp), %r8
shlq $0x2, %r8
leaq 0x977b(%rip), %rsi      # 0x18995
leaq 0xa1bf(%rip), %rdx      # 0x193e0
movl $0x284, %ecx            # imm = 0x284
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1170
jmp 0xf239
jmp 0xf23b
jmp 0xf23d
movq -0x10(%rbp), %rdi
movl $0x1c, %esi
callq 0x139a0
movl %eax, %edx
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0xf266
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpq 0x10(%rcx), %rax
jne 0xf396
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0xf30e
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq $0x1, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rdi
shlq $0x3, %rdi
callq 0x1130
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0xf307
movq 0xfd20(%rip), %rax      # 0x1eff0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %r8
shlq $0x3, %r8
leaq 0x9324(%rip), %rsi      # 0x1860e
leaq 0xa0ef(%rip), %rdx      # 0x193e0
movl $0x285, %ecx            # imm = 0x285
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1170
jmp 0xf309
jmp 0xf394
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rcx
shlq %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rsi
shlq $0x3, %rsi
callq 0x1150
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0xf390
movq 0xfc97(%rip), %rax      # 0x1eff0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %r8
shlq $0x3, %r8
leaq 0x9622(%rip), %rsi      # 0x18995
leaq 0xa066(%rip), %rdx      # 0x193e0
movl $0x285, %ecx            # imm = 0x285
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1170
jmp 0xf392
jmp 0xf394
jmp 0xf396
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq 0x8(%rcx), %rcx
movq $0x0, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x2c(%rbp), %rdx
leaq -0x38(%rbp), %rcx
leaq -0x40(%rbp), %r8
leaq -0x48(%rbp), %r9
callq 0xdb40
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0xf3fe
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xf5c3
movq -0x10(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
callq 0x13cd0
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rax
movslq (%rax), %rsi
callq 0x13c90
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpq 0x10(%rcx), %rax
jne 0xf54b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0xf4c3
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq $0x1, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rdi
shlq $0x3, %rdi
callq 0x1130
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0xf4bc
movq 0xfb6b(%rip), %rax      # 0x1eff0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %r8
shlq $0x3, %r8
leaq 0x916f(%rip), %rsi      # 0x1860e
leaq 0x9f3a(%rip), %rdx      # 0x193e0
movl $0x290, %ecx            # imm = 0x290
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1170
jmp 0xf4be
jmp 0xf549
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rcx
shlq %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rsi
shlq $0x3, %rsi
callq 0x1150
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0xf545
movq 0xfae2(%rip), %rax      # 0x1eff0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %r8
shlq $0x3, %r8
leaq 0x946d(%rip), %rsi      # 0x18995
leaq 0x9eb1(%rip), %rdx      # 0x193e0
movl $0x290, %ecx            # imm = 0x290
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1170
jmp 0xf547
jmp 0xf549
jmp 0xf54b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq 0x8(%rcx), %rcx
movq $0x0, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movq $0x1, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0xf5b3
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rax
movq -0x28(%rbp), %rcx
movslq (%rax,%rcx,4), %rsi
callq 0x13c90
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xf586
movq -0x38(%rbp), %rdi
callq 0x1030
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)