// File: /workspace/github_c_makefile_star2_O0/Encryptr[P]O-plus-plus/opp/ir/ir.c
// Function: oppir_eval_const
static void oppir_eval_const(struct OppIr* ir, struct OppIr_Const* imm)
{
	enum Regs reg_type;

	if (!imm->nopush) {
		enum OppIr_Const_Type t;

		if (imm->loc_type == 0)
			t = imm->val.type;
		else
			t = imm->loc_type;

		reg_type = oppir_push_reg(ir, t);
	}
	else
		reg_type = REG_RAX;

	if (imm->val.type == IMM_SYM) {
		oppir_eval_sym(ir, reg_type, imm);
	}
	else if (imm->val.type > IMM_LOC && imm->val.type < IMM_F32) {
		oppir_check_realloc(ir, 2);
		imm->val.type = IMM_I64;
		ir->code.bytes[ir->code.idx++] = 0x48;
		ir->code.bytes[ir->code.idx++] = 0xb8 + reg_type;
	}
	else if (imm->val.type > IMM_I64) {
		oppir_eval_float(ir, reg_type, imm);
	}
	else if (imm->val.type == IMM_LOC) {
		oppir_write_reg(ir, reg_type, imm);
	}
	else if (imm->val.type == IMM_STR) {
		oppir_gen_label();
		make_global_sym((char*)a_label, ir->data_seg.idx, 0);
		oppir_write_data(ir, strlen(imm->val.imm_sym), imm->val.imm_sym);
		oppir_check_realloc(ir, 7);
		IR_EMIT(0x48);
		IR_EMIT(0x8d);
		IR_EMIT(0x05 + (reg_type*8));
		make_reloc(ir->code.idx, (char*)a_label, 2);
		imm->val.type = IMM_I32;
		imm->val.imm_i32 = 0;
	}

	oppir_write_const(ir, &imm->val);
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq 0x18(%rsp), %rax
testb $0x1, 0x14(%rax)
jne 0x98d1
movq 0x18(%rsp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x98b1
movq 0x18(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x10(%rsp)
jmp 0x98bd
movq 0x18(%rsp), %rax
movl 0x10(%rax), %eax
movl %eax, 0x10(%rsp)
movq 0x20(%rsp), %rdi
movl 0x10(%rsp), %esi
callq 0xb8b0
movl %eax, 0x14(%rsp)
jmp 0x98d9
movl $0x0, 0x14(%rsp)
movq 0x18(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x98fb
movq 0x20(%rsp), %rdi
movl 0x14(%rsp), %esi
movq 0x18(%rsp), %rdx
callq 0xba00
jmp 0x9acb
movq 0x18(%rsp), %rax
cmpl $0x2, (%rax)
jbe 0x9978
movq 0x18(%rsp), %rax
cmpl $0xb, (%rax)
jae 0x9978
movq 0x20(%rsp), %rdi
movl $0x2, %esi
callq 0x9750
movq 0x18(%rsp), %rax
movl $0xa, (%rax)
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
movb $0x48, (%rax,%rcx)
movl 0x14(%rsp), %eax
addl $0xb8, %eax
movb %al, %dl
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movb %dl, (%rax,%rcx)
jmp 0x9ac9
movq 0x18(%rsp), %rax
cmpl $0xa, (%rax)
jbe 0x999a
movq 0x20(%rsp), %rdi
movl 0x14(%rsp), %esi
movq 0x18(%rsp), %rdx
callq 0xbad0
jmp 0x9ac7
movq 0x18(%rsp), %rax
cmpl $0x2, (%rax)
jne 0x99bc
movq 0x20(%rsp), %rdi
movl 0x14(%rsp), %esi
movq 0x18(%rsp), %rdx
callq 0xbc50
jmp 0x9ac5
movq 0x18(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x9ac3
callq 0xc750
movq 0x20(%rsp), %rax
movq 0x88(%rax), %rsi
leaq 0xf826(%rip), %rdi      # 0x19208
xorl %edx, %edx
callq 0xd510
movq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x1090
movq 0x8(%rsp), %rdi
movl %eax, %esi
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rdx
callq 0xbf60
movq 0x20(%rsp), %rdi
movl $0x7, %esi
callq 0x9750
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
movb $0x48, (%rax,%rcx)
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
movb $-0x73, (%rax,%rcx)
movl 0x14(%rsp), %eax
shll $0x3, %eax
addl $0x5, %eax
movb %al, %dl
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movb %dl, (%rax,%rcx)
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movl %eax, %edi
leaq 0xf766(%rip), %rsi      # 0x19208
movl $0x2, %edx
callq 0xd620
movq 0x18(%rsp), %rax
movl $0x8, (%rax)
movq 0x18(%rsp), %rax
movl $0x0, 0x8(%rax)
jmp 0x9ac5
jmp 0x9ac7
jmp 0x9ac9
jmp 0x9acb
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0xbfe0
addq $0x28, %rsp
retq
nop