// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorl %ebp, %ebp
cmpb $0x0, 0x14(%rsi)
jne 0x64ce
movl 0x10(%rbx), %esi
testl %esi, %esi
jne 0x64c4
movl (%rbx), %esi
movq %r14, %rdi
callq 0x6a97
movl %eax, %ebp
movl (%rbx), %eax
testl %eax, %eax
je 0x6520
leal -0x3(%rax), %ecx
cmpl $0x7, %ecx
ja 0x6581
pushq $0x2
popq %rsi
movq %r14, %rdi
callq 0x640e
movl $0xa, (%rbx)
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $0x48, (%rax,%rcx)
addb $-0x48, %bpl
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb %bpl, (%rax,%rcx)
jmp 0x6711
pushq $0x3
popq %rsi
movq %r14, %rdi
callq 0x640e
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $0x48, (%rax,%rcx)
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $-0x75, (%rax,%rcx)
shlb $0x3, %bpl
orb $0x5, %bpl
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb %bpl, (%rax,%rcx)
movl 0x8(%r14), %edi
movq 0x8(%rbx), %rsi
pushq $0x9
popq %rdx
callq 0x73a2
jmp 0x6707
cmpl $0xb, %eax
jb 0x65bf
pushq $0x8
popq %rsi
movq %r14, %rdi
callq 0x640e
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
cmpl $0xc, (%rbx)
movq %rdx, 0x8(%r14)
jne 0x667b
movb $-0xe, (%rax,%rcx)
movsd 0x8(%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
pushq $0x7
jmp 0x668c
cmpl $0x1, %eax
je 0x6728
cmpl $0x2, %eax
jne 0x6711
movl 0x8(%rbx), %r15d
xorl %eax, %eax
cmpl $-0x7f, %r15d
setl %al
leal 0x4(,%rax,4), %eax
movl %eax, (%rbx)
pushq $0x8
popq %rsi
movq %r14, %rdi
callq 0x640e
movl 0x10(%rbx), %eax
addl $-0x3, %eax
cmpl $0x9, %eax
ja 0x684c
leaq 0x4ce0(%rip), %rcx      # 0xb2e8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $0x48, (%rax,%rcx)
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
cmpl $0x8, 0x10(%rbx)
movq %rdx, 0x8(%r14)
pushq $0x63
popq %rdx
pushq $0xf
popq %rsi
cmovel %edx, %esi
movb %sil, (%rax,%rcx)
movl 0x10(%rbx), %eax
addl $-0x3, %eax
cmpl $0x3, %eax
ja 0x684c
leaq 0x4cb6(%rip), %rcx      # 0xb310
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $-0x49, (%rax,%rcx)
jmp 0x684c
movb $-0xd, (%rax,%rcx)
cvtsd2ss 0x8(%rbx), %xmm0
movss %xmm0, 0x8(%rsp)
pushq $0x3
popq %r15
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $0xf, (%rax,%rcx)
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $0x10, (%rax,%rcx)
addb $0x2, %bpl
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb %bpl, (%rax,%rcx)
callq 0x6ede
movq 0x88(%r14), %rsi
leaq 0x9afa(%rip), %r12      # 0x101d8
movq %r12, %rdi
xorl %edx, %edx
callq 0x7316
movl 0x8(%r14), %edi
pushq $0x2
popq %rdx
movq %r12, %rsi
callq 0x73a2
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
movl %r15d, %esi
callq 0x6bc9
movl $0x8, (%rbx)
andl $0x0, 0x8(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6c13
callq 0x6ede
movq 0x88(%r14), %rsi
leaq 0x9a9d(%rip), %r15      # 0x101d8
movq %r15, %rdi
xorl %edx, %edx
callq 0x7316
movq 0x8(%rbx), %r12
movq %r12, %rdi
callq 0x10b0
movq %r14, %rdi
movl %eax, %esi
movq %r12, %rdx
callq 0x6bc9
pushq $0x7
popq %rsi
movq %r14, %rdi
callq 0x640e
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $0x48, (%rax,%rcx)
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $-0x73, (%rax,%rcx)
shlb $0x3, %bpl
orb $0x5, %bpl
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb %bpl, (%rax,%rcx)
movl 0x8(%r14), %edi
pushq $0x2
popq %rdx
movq %r15, %rsi
jmp 0x6577
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $0x48, (%rax,%rcx)
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $-0x75, (%rax,%rcx)
jmp 0x684c
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $-0x42, (%rax,%rcx)
jmp 0x684c
movb $-0xe, %al
jmp 0x6811
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $-0x41, (%rax,%rcx)
jmp 0x684c
movb $-0xd, %al
movq (%r14), %rcx
movq 0x8(%r14), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%r14)
movb %al, (%rcx,%rdx)
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $0xf, (%rax,%rcx)
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $0x10, (%rax,%rcx)
addl $-0x3, %ebp
shlb $0x3, %bpl
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
cmpl $-0x7f, %r15d
movq %rdx, 0x8(%r14)
pushq $0x45
popq %rdx
movl $0x85, %esi
cmovgel %edx, %esi
addb %bpl, %sil
movb %sil, (%rax,%rcx)
jmp 0x6711