// File: /workspace/github_cpp_makefile_star2_O1/mlugo2[P]SunshineGPU/src/gpu.cpp
// Function: gpu::rcp_instr(unsigned long long)
void gpu::rcp_instr(u64 instr)
{
	u128 temp;

	// Determine destination and source paths
	u8 dest = get_dest_type(instr);
	u8 destIndex = get_dest_index(instr);
	u8 destW = get_dest_w(instr);
	u8 destZ = get_dest_z(instr);
	u8 destY = get_dest_y(instr);
	u8 destX = get_dest_x(instr);

	u8 src = get_srcN_type(instr, 0);
	u8 srcIndex = get_srcN_index(instr, 0);
	u8 srcW = get_srcN_w(instr, 0);
	u8 srcZ = get_srcN_z(instr, 0);
	u8 srcY = get_srcN_y(instr, 0);
	u8 srcX = get_srcN_x(instr, 0);

	// Swizzle it
	temp = swizzle(main_mem[src][srcIndex], srcW, srcZ, srcY, srcX);

	if (get_srcN_neg(instr, 0))
	{
		temp.x = -temp.x;
	}

	if ( temp.x == 1.0 )
		temp.x = 1;
	else {
		temp.x = 1.0 / temp.x;
	}

	// Bop it..
	if ( dest == TEMP_REG )
	{
		if (destW) main_mem[dest][destIndex].w = temp.x;
		if (destZ) main_mem[dest][destIndex].z = temp.x;
		if (destY) main_mem[dest][destIndex].y = temp.x;
		if (destX) main_mem[dest][destIndex].x = temp.x;
	}
	else
	{
		if (destW) VOB[destIndex].w = temp.x;
		if (destZ) VOB[destIndex].z = temp.x;
		if (destY) VOB[destIndex].y = temp.x;
		if (destX) VOB[destIndex].x = temp.x;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %r13
shrq $0x32, %r13
movq %rsi, %r12
shrq $0x31, %r12
movq %rsi, %r15
shrq $0x30, %r15
movq %rsi, %rax
shrq $0x2d, %rax
andl $0x3, %eax
movq %rsi, %rdi
shrq $0x29, %rdi
andl $0xf, %edi
shrq $0x27, %rsi
movq %r14, %rdx
shrq $0x25, %rdx
movq %r14, %rcx
shrq $0x23, %rcx
movq %r14, %r8
shrq $0x21, %r8
shll $0x8, %eax
addq %rbx, %rax
addq $0x7d6c0, %rax          # imm = 0x7D6C0
shll $0x4, %edi
movsd (%rdi,%rax), %xmm0
movsd 0x8(%rdi,%rax), %xmm1
andl $0x3, %esi
andl $0x3, %edx
andl $0x3, %ecx
andl $0x3, %r8d
callq 0x83f6
btq $0x2f, %r14
jae 0x6883
xorps 0x29dd(%rip), %xmm1     # 0x9260
movq %r14, %rax
shrq $0x34, %rax
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
movss 0x2a5a(%rip), %xmm0     # 0x92f0
movaps %xmm0, %xmm2
divss %xmm1, %xmm2
cmpeqss %xmm0, %xmm1
movaps %xmm1, %xmm3
andnps %xmm2, %xmm3
andps %xmm0, %xmm1
orps %xmm3, %xmm1
btq $0x38, %r14
jb 0x690d
addq $0x7d6c0, %rbx          # imm = 0x7D6C0
btq $0x33, %r14
jae 0x68d0
movl %eax, %ecx
andl $0xf, %ecx
shll $0x4, %ecx
movss %xmm1, (%rbx,%rcx)
testb $0x1, %r13b
je 0x68e4
movl %eax, %ecx
andl $0xf, %ecx
shll $0x4, %ecx
movss %xmm1, 0x4(%rbx,%rcx)
testb $0x1, %r12b
je 0x68f8
movl %eax, %ecx
andl $0xf, %ecx
shll $0x4, %ecx
movss %xmm1, 0x8(%rbx,%rcx)
testb $0x1, %r15b
je 0x696c
andl $0xf, %eax
shll $0x4, %eax
addq %rbx, %rax
addq $0xc, %rax
jmp 0x6968
btq $0x33, %r14
jae 0x6925
movl %eax, %ecx
andl $0xf, %ecx
shll $0x4, %ecx
movss %xmm1, 0x7dec0(%rbx,%rcx)
testb $0x1, %r13b
je 0x693c
movl %eax, %ecx
andl $0xf, %ecx
shll $0x4, %ecx
movss %xmm1, 0x7dec4(%rbx,%rcx)
testb $0x1, %r12b
je 0x6953
movl %eax, %ecx
andl $0xf, %ecx
shll $0x4, %ecx
movss %xmm1, 0x7dec8(%rbx,%rcx)
testb $0x1, %r15b
je 0x696c
andl $0xf, %eax
shll $0x4, %eax
addq %rbx, %rax
addq $0x7decc, %rax          # imm = 0x7DECC
movss %xmm1, (%rax)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq