// File: /workspace/github_cpp_makefile_star2_O1/mlugo2[P]SunshineGPU/src/gpu.cpp
// Function: gpu::mov_instr(unsigned long long)
void gpu::mov_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);

	// Negate it
	if (get_srcN_neg(instr, 0))
	{
		temp.x = -temp.x;
		temp.y = -temp.y;
		temp.z = -temp.z;
		temp.w = -temp.w;
	}

	// Bop it..
	if ( dest == TEMP_REG )
	{
		if (destW) main_mem[dest][destIndex].w = temp.w;
		if (destZ) main_mem[dest][destIndex].z = temp.z;
		if (destY) main_mem[dest][destIndex].y = temp.y;
		if (destX) main_mem[dest][destIndex].x = temp.x;
	}
	else
	{
		if (destW) VOB[destIndex].w = temp.w;
		if (destZ) VOB[destIndex].z = temp.z;
		if (destY) VOB[destIndex].y = temp.y;
		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 0x5339
movaps 0x3f2d(%rip), %xmm2     # 0x9260
xorps %xmm2, %xmm1
xorps %xmm2, %xmm0
movq %r14, %rax
shrq $0x34, %rax
btq $0x38, %r14
jb 0x53a6
addq $0x7d6c0, %rbx          # imm = 0x7D6C0
btq $0x33, %r14
jae 0x5362
movl %eax, %ecx
andl $0xf, %ecx
shll $0x4, %ecx
movss %xmm0, (%rbx,%rcx)
testb $0x1, %r13b
je 0x537a
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movl %eax, %ecx
andl $0xf, %ecx
shll $0x4, %ecx
movss %xmm0, 0x4(%rbx,%rcx)
testb $0x1, %r12b
je 0x538e
movl %eax, %ecx
andl $0xf, %ecx
shll $0x4, %ecx
movss %xmm1, 0x8(%rbx,%rcx)
testb $0x1, %r15b
je 0x5409
andl $0xf, %eax
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
shll $0x4, %eax
movss %xmm1, 0xc(%rbx,%rax)
jmp 0x5409
btq $0x33, %r14
jae 0x53be
movl %eax, %ecx
andl $0xf, %ecx
shll $0x4, %ecx
movss %xmm0, 0x7dec0(%rbx,%rcx)
testb $0x1, %r13b
je 0x53d9
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movl %eax, %ecx
andl $0xf, %ecx
shll $0x4, %ecx
movss %xmm0, 0x7dec4(%rbx,%rcx)
testb $0x1, %r12b
je 0x53f0
movl %eax, %ecx
andl $0xf, %ecx
shll $0x4, %ecx
movss %xmm1, 0x7dec8(%rbx,%rcx)
testb $0x1, %r15b
je 0x5409
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
andl $0xf, %eax
shll $0x4, %eax
movss %xmm1, 0x7decc(%rbx,%rax)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop