// File: /workspace/github_c_makefile_star2_O0/Liutos[P]Eloquent/compiler.c
// Function: compiler_do_set
static int compiler_do_set(compiler_t *comp, ast_t *body, ins_t *ins)
{
    ast_t *var = AST_CONS_CAR(body);
    ast_t *expr = AST_CONS_CAR( AST_CONS_CDR(body) );
    if (is_valof_form(var)) {
        if (compiler_do(comp, expr, ins) == ERR)
            return ERR;
        if (compiler_do(comp, AST_CONS_CADR(var), ins) == ERR)
            return ERR;
        ins_push(ins, bc_aset_new());
        return OK;
    }

    bytecode_t *bc = NULL;
    int i = 0, j = 0;
    char *name = AST_IDENT_NAME(var);
    if (env_locate(comp->env, name, &i, &j) == OK) {
        /* In the current lexical environment */
        bc = bc_set_new(i, j, name);
    } else if (env_locate(comp->global_env, name, &i, &j) == OK) {
        /* In the global environment */
        bc = bc_gset_new(i, j, name);
    } else {
        /* Define in current lexical environment */
        env_push(comp->env, name, NULL, NULL, NULL);
        bc = bc_set_new(-1, -1, name);
    }
    if (compiler_do(comp, expr, ins) == ERR)
        return ERR;
    ins_push(ins, bc);
    return OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x8640
cmpl $0x0, %eax
je 0x6c5f
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x7310
cmpl $0x0, %eax
jne 0x6c10
movl $0x0, -0x4(%rbp)
jmp 0x6d4f
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x10(%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x7310
cmpl $0x0, %eax
jne 0x6c3a
movl $0x0, -0x4(%rbp)
jmp 0x6d4f
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
callq 0x6160
movq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x9580
movl $0x1, -0x4(%rbp)
jmp 0x6d4f
movq $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x48(%rbp), %rsi
leaq -0x3c(%rbp), %rdx
leaq -0x40(%rbp), %rcx
callq 0x7f60
cmpl $0x1, %eax
jne 0x6cb7
movl -0x3c(%rbp), %edi
movl -0x40(%rbp), %esi
movq -0x48(%rbp), %rdx
callq 0x6440
movq %rax, -0x38(%rbp)
jmp 0x6d1c
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x48(%rbp), %rsi
leaq -0x3c(%rbp), %rdx
leaq -0x40(%rbp), %rcx
callq 0x7f60
cmpl $0x1, %eax
jne 0x6cea
movl -0x3c(%rbp), %edi
movl -0x40(%rbp), %esi
movq -0x48(%rbp), %rdx
callq 0x62b0
movq %rax, -0x38(%rbp)
jmp 0x6d1a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x48(%rbp), %rsi
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rdx
movq %r8, %rcx
callq 0x7df0
movq -0x48(%rbp), %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %esi, %edi
callq 0x6440
movq %rax, -0x38(%rbp)
jmp 0x6d1c
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x7310
cmpl $0x0, %eax
jne 0x6d3b
movl $0x0, -0x4(%rbp)
jmp 0x6d4f
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x9580
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)