// File: /workspace/github_c_makefile_star2_O0/Encryptr[P]O-plus-plus/opp/compiler/compile_expr.c
// Function: opp_compile_literal
static Opp_Obj opp_compile_literal(struct Opp_Context* opp, struct Opp_Node* unary)
{
	if (unary->unary_expr.bidx->sym_type.decl->t_type == TYPE_STRUCT)
		return opp_compile_struct(opp, unary);

	bool global = unary->unary_expr.bidx->type == TYPE_GLOBAL || 
		unary->unary_expr.bidx->type == TYPE_EXTERN || 
		unary->unary_expr.bidx->type == TYPE_FUNC;

	bool need_addr = unary->unary_expr.bidx->sym_type.size > 0;

	OPCODE_START();
	opp->ir.opcodes[opp->ir.instr_idx].constant.loc_type =
		opp_type_to_ir(&unary->unary_expr.bidx->sym_type);

	if (unary->unary_expr.bidx->type == TYPE_EXTERN || 
		unary->unary_expr.bidx->type == TYPE_FUNC)
		opp->ir.opcodes[opp->ir.instr_idx].constant.loc_type = IMM_U64;

	opp->ir.opcodes[opp->ir.instr_idx].constant.val.type = 
		global ? IMM_SYM : IMM_LOC;

	if (need_addr)
		OPCODE_TYPE(OPCODE_ADDR);
	else
		OPCODE_TYPE(OPCODE_CONST);
	if (global) {
		opp->ir.opcodes[opp->ir.instr_idx].constant.val.type = IMM_SYM;
		opp->ir.opcodes[opp->ir.instr_idx].constant.val.imm_sym = 
			unary->unary_expr.bidx->key;
		opp->ir.opcodes[opp->ir.instr_idx].constant.loc_type = IMM_U64;

		if (unary->unary_expr.bidx->type == TYPE_GLOBAL && !opp->info.need_addr) { // make sure need_addr is valud
			OPCODE_END();
			OPCODE_START();
				OPCODE_TYPE(OPCODE_DEREF);
				opp->ir.opcodes[opp->ir.instr_idx].cast.type = 
					opp_type_to_ir(&unary->unary_expr.bidx->sym_type);
		}
	}
	else {
		opp->ir.opcodes[opp->ir.instr_idx].constant.val.type = IMM_LOC;
		opp->ir.opcodes[opp->ir.instr_idx].constant.val.imm_i32 = 
			unary->unary_expr.bidx->offset;
	}

	OPCODE_END();

	return unary->unary_expr.bidx->sym_type;
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %rax
cmpl $0x8, 0x8(%rax)
jne 0x6f7f
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x7230
movq %rax, 0x18(%rsp)
movq %rdx, 0x20(%rsp)
jmp 0x7216
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rcx
movb $0x1, %al
cmpl $0x0, 0x8(%rcx)
movb %al, 0x5(%rsp)
je 0x6fbd
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rcx
movb $0x1, %al
cmpl $0x4, 0x8(%rcx)
movb %al, 0x5(%rsp)
je 0x6fbd
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $0x2, 0x8(%rax)
sete %al
movb %al, 0x5(%rsp)
movb 0x5(%rsp), %al
andb $0x1, %al
movb %al, 0x7(%rsp)
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movzwl 0x1a(%rax), %eax
cmpl $0x0, %eax
setg %al
andb $0x1, %al
movb %al, 0x6(%rsp)
movq 0x10(%rsp), %rdi
callq 0x5600
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rdi
addq $0x10, %rdi
callq 0x5670
movl %eax, %ecx
movq 0x10(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x10(%rsp), %rdx
imulq $0x28, 0x48(%rdx), %rdx
addq %rdx, %rax
movl %ecx, 0x18(%rax)
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $0x4, 0x8(%rax)
je 0x7035
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $0x2, 0x8(%rax)
jne 0x7052
movq 0x10(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x10(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0x9, 0x18(%rax)
movb 0x7(%rsp), %dl
movl $0x2, %ecx
xorl %eax, %eax
testb $0x1, %dl
cmovnel %eax, %ecx
movq 0x10(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x10(%rsp), %rdx
imulq $0x28, 0x48(%rdx), %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
testb $0x1, 0x6(%rsp)
je 0x70a1
movq 0x10(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x10(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0xe, (%rax)
jmp 0x70bd
movq 0x10(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x10(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0x0, (%rax)
testb $0x1, 0x7(%rsp)
je 0x71a8
movq 0x10(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x10(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0x0, 0x8(%rax)
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rcx
movq 0x10(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x10(%rsp), %rdx
imulq $0x28, 0x48(%rdx), %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movq 0x10(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x10(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0x9, 0x18(%rax)
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $0x0, 0x8(%rax)
jne 0x71a6
movq 0x10(%rsp), %rax
testb $0x1, 0x40(%rax)
jne 0x71a6
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x48(%rax)
movq 0x10(%rsp), %rdi
callq 0x5600
movq 0x10(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x10(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0xc, (%rax)
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rdi
addq $0x10, %rdi
callq 0x5670
movl %eax, %ecx
movq 0x10(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x10(%rsp), %rdx
imulq $0x28, 0x48(%rdx), %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
jmp 0x71ea
movq 0x10(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x10(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0x2, 0x8(%rax)
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movl 0x28(%rax), %ecx
movq 0x10(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x10(%rsp), %rdx
imulq $0x28, 0x48(%rdx), %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x48(%rax)
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rdx
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)