// File: /workspace/github_c_makefile_star2_O0/Encryptr[P]O-plus-plus/opp/ir/ir.c
// Function: oppir_eval_arg
static void oppir_eval_arg(struct OppIr* ir, struct OppIr_Arg* arg)
{
	// Ignore size type for now all are treated as 64 bit regs
	switch (arg->type)
	{
		case IMM_U8...IMM_I64:
			oppir_check_realloc(ir, 4);
			if (arg->idx < 4)
				IR_EMIT(0x48);
			else
				IR_EMIT(0x4c);

			IR_EMIT(0x89);

			if (arg->idx <= 1)
				IR_EMIT(0x7d - (arg->idx*8));
			else if (arg->idx <= 3)
				IR_EMIT(0x55 - ((arg->idx-2)*8));
			else
				IR_EMIT(0x45 + ((arg->idx-4)*8));
			break;

		case IMM_F32...IMM_F64:
			oppir_check_realloc(ir, 5);
			if (arg->type == IMM_F64)
				IR_EMIT(0xf2);
			else
				IR_EMIT(0xf3);

			IR_EMIT(0x0f);
			IR_EMIT(0x11);
			IR_EMIT(0x45 + (arg->idx*8));
			break;
		default: break;
	}
	ir->local_stack.size += 8;
	ir->local_stack.pos -= 8;
	IR_EMIT((char)ir->local_stack.pos);
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movq 0x8(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x4(%rsp)
addl $-0x3, %eax
subl $0x8, %eax
jb 0x9c88
jmp 0x9c73
movl 0x4(%rsp), %eax
addl $-0xb, %eax
subl $0x2, %eax
jb 0x9dc0
jmp 0x9e8c
movq 0x10(%rsp), %rdi
movl $0x4, %esi
callq 0x9750
movq 0x8(%rsp), %rax
cmpl $0x4, 0x4(%rax)
jae 0x9cc4
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
movb $0x48, (%rax,%rcx)
jmp 0x9ce4
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
movb $0x4c, (%rax,%rcx)
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
movb $-0x77, (%rax,%rcx)
movq 0x8(%rsp), %rax
cmpl $0x1, 0x4(%rax)
ja 0x9d44
movq 0x8(%rsp), %rax
movl 0x4(%rax), %ecx
shll $0x3, %ecx
movl $0x7d, %eax
subl %ecx, %eax
movb %al, %dl
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movb %dl, (%rax,%rcx)
jmp 0x9dbb
movq 0x8(%rsp), %rax
cmpl $0x3, 0x4(%rax)
ja 0x9d87
movq 0x8(%rsp), %rax
movl 0x4(%rax), %ecx
subl $0x2, %ecx
shll $0x3, %ecx
movl $0x55, %eax
subl %ecx, %eax
movb %al, %dl
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movb %dl, (%rax,%rcx)
jmp 0x9db9
movq 0x8(%rsp), %rax
movl 0x4(%rax), %eax
subl $0x4, %eax
shll $0x3, %eax
addl $0x45, %eax
movb %al, %dl
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movb %dl, (%rax,%rcx)
jmp 0x9dbb
jmp 0x9e8e
movq 0x10(%rsp), %rdi
movl $0x5, %esi
callq 0x9750
movq 0x8(%rsp), %rax
cmpl $0xc, (%rax)
jne 0x9dfb
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
movb $-0xe, (%rax,%rcx)
jmp 0x9e1b
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
movb $-0xd, (%rax,%rcx)
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
movb $0xf, (%rax,%rcx)
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
movb $0x11, (%rax,%rcx)
movq 0x8(%rsp), %rax
movl 0x4(%rax), %eax
shll $0x3, %eax
addl $0x45, %eax
movb %al, %dl
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movb %dl, (%rax,%rcx)
jmp 0x9e8e
jmp 0x9e8e
movq 0x10(%rsp), %rax
movl 0x48(%rax), %ecx
addl $0x8, %ecx
movl %ecx, 0x48(%rax)
movq 0x10(%rsp), %rax
movl 0x4c(%rax), %ecx
subl $0x8, %ecx
movl %ecx, 0x4c(%rax)
movq 0x10(%rsp), %rax
movl 0x4c(%rax), %eax
movb %al, %dl
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movb %dl, (%rax,%rcx)
addq $0x18, %rsp
retq
nopl (%rax,%rax)