// File: mlugo2[P]SunshineGPU/src/gpu.cpp
// Function: gpu::swizzle(__u128, unsigned char, unsigned char, unsigned char, unsigned char)
u128 gpu::swizzle(u128 data, u8 w, u8 z, u8 y, u8 x)
{
	// No swizzle 
	if (w == 3 && z == 2 && y == 1 && x == 0)
		return data;

	u32 temp[4];

	// Tear apart all componets, put them in array..
	temp[0] = data.x;
	temp[1] = data.y;
	temp[2] = data.z;
	temp[3] = data.w;

	data.x = temp[x];
	data.y = temp[y];
	data.z = temp[z];
	data.w = temp[w];

	return data;
}

// Assembly:
movb %r8b, %al
movlpd %xmm0, -0x20(%rsp)
movlpd %xmm1, -0x18(%rsp)
movq %rdi, -0x28(%rsp)
movb %sil, -0x29(%rsp)
movb %dl, -0x2a(%rsp)
movb %cl, -0x2b(%rsp)
movb %al, -0x2c(%rsp)
movzbl -0x29(%rsp), %eax
cmpl $0x3, %eax
jne 0x148a6
movzbl -0x2a(%rsp), %eax
cmpl $0x2, %eax
jne 0x148a6
movzbl -0x2b(%rsp), %eax
cmpl $0x1, %eax
jne 0x148a6
movzbl -0x2c(%rsp), %eax
cmpl $0x0, %eax
jne 0x148a6
movq -0x20(%rsp), %rax
movq %rax, -0x10(%rsp)
movq -0x18(%rsp), %rax
movq %rax, -0x8(%rsp)
jmp 0x14aa2
movss -0x14(%rsp), %xmm0
movss 0xa78(%rip), %xmm2      # 0x1532c
movaps %xmm0, %xmm1
subss %xmm2, %xmm1
cvttss2si %xmm1, %rcx
cvttss2si %xmm0, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x58(%rsp)
movss -0x18(%rsp), %xmm0
movaps %xmm0, %xmm1
subss %xmm2, %xmm1
cvttss2si %xmm1, %rcx
cvttss2si %xmm0, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x50(%rsp)
movss -0x1c(%rsp), %xmm0
movaps %xmm0, %xmm1
subss %xmm2, %xmm1
cvttss2si %xmm1, %rcx
cvttss2si %xmm0, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x48(%rsp)
movss -0x20(%rsp), %xmm0
movaps %xmm0, %xmm1
subss %xmm2, %xmm1
cvttss2si %xmm1, %rcx
cvttss2si %xmm0, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x40(%rsp)
movzbl -0x2c(%rsp), %eax
movq -0x58(%rsp,%rax,8), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x60(%rsp)
testq %rax, %rax
movss %xmm0, -0x5c(%rsp)
js 0x14995
movss -0x60(%rsp), %xmm0
movss %xmm0, -0x5c(%rsp)
movss -0x5c(%rsp), %xmm0
movss %xmm0, -0x14(%rsp)
movzbl -0x2b(%rsp), %eax
movq -0x58(%rsp,%rax,8), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x68(%rsp)
testq %rax, %rax
movss %xmm0, -0x64(%rsp)
js 0x149e4
movss -0x68(%rsp), %xmm0
movss %xmm0, -0x64(%rsp)
movss -0x64(%rsp), %xmm0
movss %xmm0, -0x18(%rsp)
movzbl -0x2a(%rsp), %eax
movq -0x58(%rsp,%rax,8), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x70(%rsp)
testq %rax, %rax
movss %xmm0, -0x6c(%rsp)
js 0x14a33
movss -0x70(%rsp), %xmm0
movss %xmm0, -0x6c(%rsp)
movss -0x6c(%rsp), %xmm0
movss %xmm0, -0x1c(%rsp)
movzbl -0x29(%rsp), %eax
movq -0x58(%rsp,%rax,8), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x78(%rsp)
testq %rax, %rax
movss %xmm0, -0x74(%rsp)
js 0x14a82
movss -0x78(%rsp), %xmm0
movss %xmm0, -0x74(%rsp)
movss -0x74(%rsp), %xmm0
movss %xmm0, -0x20(%rsp)
movq -0x20(%rsp), %rax
movq %rax, -0x10(%rsp)
movq -0x18(%rsp), %rax
movq %rax, -0x8(%rsp)
movsd -0x10(%rsp), %xmm0
movsd -0x8(%rsp), %xmm1
retq
nop