// File: /workspace/github_c_makefile_star2_O3/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 0x6850
movl 0x10(%rbx), %esi
testl %esi, %esi
jne 0x6846
movl (%rbx), %esi
movq %r14, %rdi
callq 0x6e35
movl %eax, %ebp
movl (%rbx), %eax
testl %eax, %eax
je 0x68a4
leal -0x3(%rax), %ecx
cmpl $0x7, %ecx
ja 0x6909
movq %r14, %rdi
movl $0x2, %esi
callq 0x6790
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 0x6ac4
movq %r14, %rdi
movl $0x3, %esi
callq 0x6790
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
movl $0x9, %edx
callq 0x7753
jmp 0x6ab7
cmpl $0xb, %eax
jb 0x694d
movq %r14, %rdi
movl $0x8, %esi
callq 0x6790
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
cmpl $0xc, (%rbx)
movq %rdx, 0x8(%r14)
jne 0x6a0f
movb $-0xe, (%rax,%rcx)
movsd 0x8(%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
movl $0x7, %r15d
jmp 0x6a24
cmpl $0x1, %eax
je 0x6adb
cmpl $0x2, %eax
jne 0x6ac4
movl 0x8(%rbx), %r15d
xorl %eax, %eax
cmpl $-0x7f, %r15d
setl %al
leal 0x4(,%rax,4), %eax
movl %eax, (%rbx)
movq %r14, %rdi
movl $0x8, %esi
callq 0x6790
movl 0x10(%rbx), %eax
addl $-0x3, %eax
cmpl $0x9, %eax
ja 0x6c1b
leaq 0x594c(%rip), %rcx      # 0xc2e4
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)
movl $0x63, %edx
movl $0xf, %esi
cmovel %edx, %esi
movb %sil, (%rax,%rcx)
movl 0x10(%rbx), %eax
addl $-0x3, %eax
cmpl $0x3, %eax
ja 0x6c1b
leaq 0x591e(%rip), %rcx      # 0xc30c
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 0x6c1b
movb $-0xd, (%rax,%rcx)
cvtsd2ss 0x8(%rbx), %xmm0
movss %xmm0, 0x8(%rsp)
movl $0x3, %r15d
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)
movl 0x9779(%rip), %edx      # 0x101e0
leaq 0x976a(%rip), %r12      # 0x101d8
leaq 0x595e(%rip), %rsi      # 0xc3d3
movq %r12, %rdi
xorl %eax, %eax
callq 0x1200
incl 0x975b(%rip)            # 0x101e0
movq 0x88(%r14), %rsi
movq %r12, %rdi
xorl %edx, %edx
callq 0x76be
movl 0x8(%r14), %edi
movq %r12, %rsi
movl $0x2, %edx
callq 0x7753
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
movl %r15d, %esi
callq 0x6f6f
movl $0x8, (%rbx)
movl $0x0, 0x8(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6fc5
movl 0x96ff(%rip), %edx      # 0x101e0
leaq 0x96f0(%rip), %r15      # 0x101d8
leaq 0x58e4(%rip), %rsi      # 0xc3d3
movq %r15, %rdi
xorl %eax, %eax
callq 0x1200
incl 0x96e1(%rip)            # 0x101e0
movq 0x88(%r14), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x76be
movq 0x8(%rbx), %r12
movq %r12, %rdi
callq 0x10b0
movq %r14, %rdi
movl %eax, %esi
movq %r12, %rdx
callq 0x6f6f
movq %r14, %rdi
movl $0x7, %esi
callq 0x6790
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
movq %r15, %rsi
movl $0x2, %edx
jmp 0x68ff
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 0x6c1b
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $-0x42, (%rax,%rcx)
jmp 0x6c1b
movb $-0xe, %al
jmp 0x6be0
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $-0x41, (%rax,%rcx)
jmp 0x6c1b
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)
movl $0x45, %edx
movl $0x85, %esi
cmovgel %edx, %esi
addb %bpl, %sil
movb %sil, (%rax,%rcx)
jmp 0x6ac4