// File: /workspace/github_c_makefile_star2_O0/Encryptr[P]O-plus-plus/opp/ir/ir.c
// Function: oppir_eval_ptr_assign
static void oppir_eval_ptr_assign(struct OppIr* ir, struct OppIr_Cast* cast)
{
	struct Register rhs = oppir_pop_reg(ir);
	struct Register lhs = oppir_pop_reg(ir);

	assert(cast->type != IMM_F32 && cast->type != IMM_F64);

	oppir_check_realloc(ir, 3);

	switch (cast->type)
	{
		case IMM_I8:
		case IMM_U8:
			IR_EMIT(0x88);
			break;

		case IMM_I16:
		case IMM_U16:
			IR_EMIT(0x66);
			IR_EMIT(0x89);
			break;

		case IMM_I32:
		case IMM_U32:
			IR_EMIT(0x89);
			break;

		case IMM_I64:
		case IMM_U64:
			IR_EMIT(0x48);
			IR_EMIT(0x89);
			break;

		default: break;
	}

	switch (lhs.reg)
	{
		case REG_RAX:
			IR_EMIT(0x08 * (rhs.reg));
			break;

		case REG_RCX:
			IR_EMIT(rhs.reg == REG_RAX ? 0x1 : 0x11);
			break;

		case REG_RDX:
			IR_EMIT(rhs.reg == REG_RAX ? 0x2 : 0xa);
			break;
	}
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq 0x40(%rsp), %rdi
callq 0xc780
movq %rax, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movq 0x40(%rsp), %rdi
callq 0xc780
movq %rax, 0x18(%rsp)
movq %rdx, 0x20(%rsp)
movq 0x38(%rsp), %rax
cmpl $0xb, (%rax)
je 0xa5ec
movq 0x38(%rsp), %rax
cmpl $0xc, (%rax)
je 0xa5ec
jmp 0xa60b
leaq 0x9f3d(%rip), %rdi      # 0x14530
leaq 0x9e90(%rip), %rsi      # 0x1448a
movl $0x4ae, %edx            # imm = 0x4AE
leaq 0x9f59(%rip), %rcx      # 0x1455f
callq 0x10e0
movq 0x40(%rsp), %rdi
movl $0x3, %esi
callq 0x9750
movq 0x38(%rsp), %rax
movl (%rax), %eax
addl $-0x3, %eax
movl %eax, %ecx
movq %rcx, 0x10(%rsp)
subl $0x7, %eax
ja 0xa714
movq 0x10(%rsp), %rax
leaq 0x9cf8(%rip), %rcx      # 0x14338
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
movb $-0x78, (%rax,%rcx)
jmp 0xa716
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
movb $0x66, (%rax,%rcx)
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
movb $-0x77, (%rax,%rcx)
jmp 0xa716
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
movb $-0x77, (%rax,%rcx)
jmp 0xa716
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
movb $0x48, (%rax,%rcx)
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
movb $-0x77, (%rax,%rcx)
jmp 0xa716
jmp 0xa716
movl 0x18(%rsp), %eax
movl %eax, 0xc(%rsp)
testl %eax, %eax
je 0xa73d
jmp 0xa724
movl 0xc(%rsp), %eax
subl $0x1, %eax
je 0xa767
jmp 0xa72f
movl 0xc(%rsp), %eax
subl $0x2, %eax
je 0xa79e
jmp 0xa7d3
movl 0x28(%rsp), %eax
shll $0x3, %eax
movb %al, %dl
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movb %dl, (%rax,%rcx)
jmp 0xa7d3
movl 0x28(%rsp), %edx
movl $0x11, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
movb %al, %dl
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movb %dl, (%rax,%rcx)
jmp 0xa7d3
movl 0x28(%rsp), %edx
movl $0xa, %eax
movl $0x2, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
movb %al, %dl
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movb %dl, (%rax,%rcx)
addq $0x48, %rsp
retq
nopl (%rax,%rax)