// File: /workspace/github_c_makefile_star2_O0/masyagin1998[P]GCI/src/bytecode-generator/bytecode-generator.c
// Function: stmt_ast_bytecode_generate
static enum BYTECODE_GENERATOR_CODES stmt_ast_bytecode_generate(bytecode_generator_type_t bc_gen, const struct 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;
    
    switch (ast->type) {
    case AST_STMT_TYPE_DECL:
        r = decl_stmt_ast_bytecode_generate(bc_gen, ast->decl_stmt);
        break;
    case AST_STMT_TYPE_ASSIGN:
        r = assign_stmt_ast_bytecode_generate(bc_gen, ast->assign_stmt);
        break;
    case AST_STMT_TYPE_FUNCTION_CALL:
        r = function_call_stmt_ast_bytecode_generate(bc_gen, ast->function_call_stmt);
        break;
    case AST_STMT_TYPE_IF:
        r = if_stmt_ast_bytecode_generate(bc_gen, ast->if_stmt, loop_start_idx,
                                          loop_exit_idxs, loop_exit_idxs_len, loop_exit_idxs_cap);
        break;
    case AST_STMT_TYPE_WHILE:
        r = while_stmt_ast_bytecode_generate(bc_gen, ast->while_stmt);
        break;
    case AST_STMT_TYPE_BREAK:
        r = break_stmt_ast_bytecode_generate(bc_gen, ast->break_stmt, loop_exit_idxs, loop_exit_idxs_len, loop_exit_idxs_cap);
        break;
    case AST_STMT_TYPE_CONTINUE:
        r = continue_stmt_ast_bytecode_generate(bc_gen, ast->continue_stmt, loop_start_idx);
        break;
    case AST_STMT_TYPE_APPEND:
        r = append_stmt_ast_bytecode_generate(bc_gen, ast->append_stmt);
        break;
    case AST_STMT_TYPE_DELETE:
        r = delete_stmt_ast_bytecode_generate(bc_gen, ast->delete_stmt);
        break;        
    case AST_STMT_TYPE_RETURN:
        r = return_stmt_ast_bytecode_generate(bc_gen, ast->return_stmt);
        break;
    default:
        fprintf(stderr, "Invalid STMT_AST type: %d\n", ast->type);
        exit(EXIT_FAILURE);
        break;
    }

    return r;    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, -0x40(%rbp)
subq $0x9, %rax
ja 0xe7cd
movq -0x40(%rbp), %rax
leaq 0xacd0(%rip), %rcx      # 0x19390
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0xe800
movl %eax, -0x34(%rbp)
jmp 0xe7f6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0xece0
movl %eax, -0x34(%rbp)
jmp 0xe7f6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0xdab0
movl %eax, -0x34(%rbp)
jmp 0xe7f6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
callq 0xed40
movl %eax, -0x34(%rbp)
jmp 0xe7f6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0xf110
movl %eax, -0x34(%rbp)
jmp 0xe7f6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0xf5d0
movl %eax, -0x34(%rbp)
jmp 0xe7f6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rdx
callq 0xf760
movl %eax, -0x34(%rbp)
jmp 0xe7f6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0xf7d0
movl %eax, -0x34(%rbp)
jmp 0xe7f6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0xf7e0
movl %eax, -0x34(%rbp)
jmp 0xe7f6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0xf7f0
movl %eax, -0x34(%rbp)
jmp 0xe7f6
movq 0x1081c(%rip), %rax     # 0x1eff0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0xa2ac(%rip), %rsi      # 0x18a91
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1170
movl -0x34(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop