// File: /workspace/github_c_makefile_star2_O0/Encryptr[P]O-plus-plus/opp/compiler/compile_expr.c
// Function: opp_compile_addr
static Opp_Obj opp_compile_addr(struct Opp_Context* opp, struct Opp_Node* expr)
{
	Opp_Obj val = {0};
	switch (expr->addr_expr.addr->type)
	{
		case EUNARY: {
			bool global = expr->addr_expr.addr->unary_expr.bidx->type == TYPE_GLOBAL ||
				expr->addr_expr.addr->unary_expr.bidx->type == TYPE_EXTERN;

			OPCODE_START();
				if (!global)
					OPCODE_TYPE(OPCODE_ADDR);
				else
					OPCODE_TYPE(OPCODE_CONST);

				if (!global) {
					opp->ir.opcodes[opp->ir.instr_idx].constant.val.type = IMM_LOC;
					opp->ir.opcodes[opp->ir.instr_idx].constant.val.imm_i32 = 
						expr->addr_expr.addr->unary_expr.bidx->offset;
				}
				else {
					opp->ir.opcodes[opp->ir.instr_idx].constant.val.type = IMM_SYM;
					opp->ir.opcodes[opp->ir.instr_idx].constant.val.imm_sym = 
						expr->addr_expr.addr->unary_expr.val.strval;
				}
			OPCODE_END();

			val = expr->addr_expr.addr->unary_expr.bidx->sym_type;
			break;
		}

		case EDOT: {
			NEED_ADDR();
			val = opp_compile_expr(opp, expr->addr_expr.addr);
			REVERT();

			if (!opp->info.dot.inptr) {
				OPCODE_START();
					OPCODE_TYPE(OPCODE_ADDR);
					opp->ir.opcodes[opp->ir.instr_idx].constant.val.type = IMM_LOC;
					opp->ir.opcodes[opp->ir.instr_idx].constant.val.imm_i32 = 
						opp->info.dot.offset;
				OPCODE_END();
			}
			break;
		}

		default: {
			NEED_ADDR();
			val = opp_compile_expr(opp, expr->addr_expr.addr);
			REVERT();
			break;
		}
	}

	val.depth++;
	return val;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movl (%rax), %eax
movl %eax, 0x4(%rsp)
subl $0x5, %eax
je 0x641e
jmp 0x640c
movl 0x4(%rsp), %eax
subl $0xd, %eax
je 0x656c
jmp 0x6631
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rax), %rcx
movb $0x1, %al
cmpl $0x0, 0x8(%rcx)
movb %al, 0x3(%rsp)
je 0x644f
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rax), %rax
cmpl $0x4, 0x8(%rax)
sete %al
movb %al, 0x3(%rsp)
movb 0x3(%rsp), %al
andb $0x1, %al
movb %al, 0x2f(%rsp)
movq 0x38(%rsp), %rdi
callq 0x5600
testb $0x1, 0x2f(%rsp)
jne 0x6488
movq 0x38(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x38(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0xe, (%rax)
jmp 0x64a4
movq 0x38(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x38(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0x0, (%rax)
testb $0x1, 0x2f(%rsp)
jne 0x64f3
movq 0x38(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x38(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0x2, 0x8(%rax)
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rax), %rax
movl 0x28(%rax), %ecx
movq 0x38(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x38(%rsp), %rdx
imulq $0x28, 0x48(%rdx), %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
jmp 0x6537
movq 0x38(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x38(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0x0, 0x8(%rax)
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rcx
movq 0x38(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x38(%rsp), %rdx
imulq $0x28, 0x48(%rdx), %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movq 0x38(%rsp), %rax
movq 0x48(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x48(%rax)
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %rcx
movq %rcx, 0x40(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x48(%rsp)
jmp 0x6674
movq 0x38(%rsp), %rax
movb $0x1, 0x40(%rax)
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0x5d60
movq %rax, 0x18(%rsp)
movq %rdx, 0x20(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x38(%rsp), %rax
movb $0x0, 0x40(%rax)
movq 0x38(%rsp), %rax
testb $0x1, 0x3c(%rax)
jne 0x662f
movq 0x38(%rsp), %rdi
callq 0x5600
movq 0x38(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x38(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0xe, (%rax)
movq 0x38(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x38(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0x2, 0x8(%rax)
movq 0x38(%rsp), %rax
movl 0x38(%rax), %ecx
movq 0x38(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x38(%rsp), %rdx
imulq $0x28, 0x48(%rdx), %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
movq 0x38(%rsp), %rax
movq 0x48(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x48(%rax)
jmp 0x6674
movq 0x38(%rsp), %rax
movb $0x1, 0x40(%rax)
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0x5d60
movq %rax, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x38(%rsp), %rax
movb $0x0, 0x40(%rax)
movw 0x48(%rsp), %ax
incw %ax
movw %ax, 0x48(%rsp)
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rdx
addq $0x58, %rsp
retq