// File: /workspace/github_c_makefile_star2_O0/masyagin1998[P]GCI/src/bytecode-generator/bytecode-generator.c
// Function: if_stmt_ast_bytecode_generate
static enum BYTECODE_GENERATOR_CODES if_stmt_ast_bytecode_generate(bytecode_generator_type_t bc_gen, const struct IF_STMT_AST*ast, int*loop_start_idx,
                                                                   int**loop_exit_idxs, size_t*loop_exit_idxs_len, size_t*loop_exit_idxs_cap)
{
    enum BYTECODE_GENERATOR_CODES r;
    
    int if_idx;
    int else_idx;
    
    r = logical_or_expr_ast_bytecode_generate(bc_gen, ast->condition);
    if (r != BYTECODE_GENERATOR_OK) {
        return r;
    }    

    if_idx = 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->if_body, loop_start_idx,
                                   loop_exit_idxs, loop_exit_idxs_len, loop_exit_idxs_cap);
    if (r != BYTECODE_GENERATOR_OK) {
        return r;
    }    

    else_idx = emit_jump(bc_gen, BC_OP_JUMP);

    patch_jump(bc_gen, if_idx);
    PUSH_BACK(bc_gen->bc->op_codes, BC_OP_POP);

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

    patch_jump(bc_gen, else_idx);
    
    return BYTECODE_GENERATOR_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x10360
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0xed84
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xf101
movq -0x10(%rbp), %rdi
movl $0x1c, %esi
callq 0x139a0
movl %eax, -0x40(%rbp)
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 0xeec5
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0xee3d
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 0xee36
movq 0x101f1(%rip), %rax     # 0x1eff0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %r8
shlq $0x3, %r8
leaq 0x97f5(%rip), %rsi      # 0x1860e
leaq 0xa5c0(%rip), %rdx      # 0x193e0
movl $0x24c, %ecx            # imm = 0x24C
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1170
jmp 0xee38
jmp 0xeec3
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 0xeebf
movq 0x10168(%rip), %rax     # 0x1eff0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %r8
shlq $0x3, %r8
leaq 0x9af3(%rip), %rsi      # 0x18995
leaq 0xa537(%rip), %rdx      # 0x193e0
movl $0x24c, %ecx            # imm = 0x24C
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1170
jmp 0xeec1
jmp 0xeec3
jmp 0xeec5
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
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %r9
callq 0xdb40
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0xef2d
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xf101
movq -0x10(%rbp), %rdi
movl $0x1d, %esi
callq 0x139a0
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x40(%rbp), %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 0xf07b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0xeff3
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 0xefec
movq 0x1003b(%rip), %rax     # 0x1eff0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %r8
shlq $0x3, %r8
leaq 0x963f(%rip), %rsi      # 0x1860e
leaq 0xa40a(%rip), %rdx      # 0x193e0
movl $0x257, %ecx            # imm = 0x257
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1170
jmp 0xefee
jmp 0xf079
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 0xf075
movq 0xffb2(%rip), %rax      # 0x1eff0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %r8
shlq $0x3, %r8
leaq 0x993d(%rip), %rsi      # 0x18995
leaq 0xa381(%rip), %rdx      # 0x193e0
movl $0x257, %ecx            # imm = 0x257
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1170
jmp 0xf077
jmp 0xf079
jmp 0xf07b
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 -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xf0ed
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %r9
callq 0xdb40
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0xf0eb
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xf101
jmp 0xf0ed
movq -0x10(%rbp), %rdi
movslq -0x44(%rbp), %rsi
callq 0x13c90
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)