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

	Opp_Obj val = {0};

	OPCODE_START();
	OPCODE_TYPE(OPCODE_CONST);

	switch (unary->unary_expr.type)
	{
		case TINTEGER: {
			opp->ir.opcodes[opp->ir.instr_idx].constant.val.type = IMM_I64;
			opp->ir.opcodes[opp->ir.instr_idx].constant.val.imm_i64 = unary->unary_expr.val.i64val;
			opp->ir.opcodes[opp->ir.instr_idx].constant.loc_type = 0;
			val.decl = int_type;
			break;
		}

		case TFLOAT: {
			opp->ir.opcodes[opp->ir.instr_idx].constant.val.type = IMM_F64;
			opp->ir.opcodes[opp->ir.instr_idx].constant.val.imm_f64 = unary->unary_expr.val.f64val;
			opp->ir.opcodes[opp->ir.instr_idx].constant.loc_type = 0;
			val.decl = float_type;
			break;
		}

		case TSTR: {
			opp->ir.opcodes[opp->ir.instr_idx].constant.val.type = IMM_STR;
			opp->ir.opcodes[opp->ir.instr_idx].constant.val.imm_sym = unary->unary_expr.val.strval;
			opp->ir.opcodes[opp->ir.instr_idx].constant.loc_type = IMM_U64;
			val.decl = char_type;
			val.depth = 1;
			break;
		}

		default: break;
	}

	OPCODE_END();

	return val;
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq 0x10(%rsp), %rax
cmpl $0x1, 0x10(%rax)
jne 0x5ed7
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x6f40
movq %rax, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
jmp 0x609e
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x18(%rsp), %rdi
callq 0x5600
movq 0x18(%rsp), %rax
movq 0x48(%rax), %rcx
movq 0x58(%rax), %rax
leaq (%rcx,%rcx,4), %rcx
movl $0x0, (%rax,%rcx,8)
movq 0x10(%rsp), %rax
movl 0x10(%rax), %eax
movl %eax, 0xc(%rsp)
subl $0x2, %eax
je 0x5f35
jmp 0x5f14
movl 0xc(%rsp), %eax
subl $0x3, %eax
je 0x5fa6
jmp 0x5f23
movl 0xc(%rsp), %eax
subl $0x5, %eax
je 0x6016
jmp 0x608b
movq 0x18(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x18(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0xa, 0x8(%rax)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x18(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x18(%rsp), %rdx
imulq $0x28, 0x48(%rdx), %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movq 0x18(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x18(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0x0, 0x18(%rax)
leaq 0x13327(%rip), %rax     # 0x192c0
movq (%rax), %rax
movq %rax, 0x20(%rsp)
jmp 0x608d
movq 0x18(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x18(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0xc, 0x8(%rax)
movq 0x10(%rsp), %rax
movsd 0x18(%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x18(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movsd %xmm0, 0x10(%rax)
movq 0x18(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x18(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0x0, 0x18(%rax)
leaq 0x132c4(%rip), %rax     # 0x192d0
movq (%rax), %rax
movq %rax, 0x20(%rsp)
jmp 0x608d
movq 0x18(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x18(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0x1, 0x8(%rax)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x18(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x18(%rsp), %rdx
imulq $0x28, 0x48(%rdx), %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movq 0x18(%rsp), %rax
movq 0x58(%rax), %rax
movq 0x18(%rsp), %rcx
imulq $0x28, 0x48(%rcx), %rcx
addq %rcx, %rax
movl $0x9, 0x18(%rax)
leaq 0x1323e(%rip), %rax     # 0x192b8
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movw $0x1, 0x28(%rsp)
jmp 0x608d
jmp 0x608d
movq 0x18(%rsp), %rax
movq 0x48(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x48(%rax)
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rdx
addq $0x38, %rsp
retq
nopl (%rax)