// File: rishabh-battulwar[P]imageprocessing/./include/colorspace.h
// Function: Hsv2Rgb(double*, double*, double*, double, double, double)
void Hsv2Rgb(num *R, num *G, num *B, num H, num S, num V)
{
	num C = S * V;
	num Min = V - C;
	num X;
	
	
	H -= 360*floor(H/360);
	H /= 60;
	X = C*(1 - fabs(H - 2*floor(H/2) - 1));
	
	switch((int)H)
	{
	case 0:
		*R = Min + C;
		*G = Min + X;
		*B = Min;
		break;
	case 1:
		*R = Min + X;
		*G = Min + C;
		*B = Min;
		break;
	case 2:
		*R = Min;
		*G = Min + C;
		*B = Min + X;
		break;
	case 3:
		*R = Min;
		*G = Min + X;
		*B = Min + C;
		break;
	case 4:
		*R = Min + X;
		*G = Min;
		*B = Min + C;
		break;
	case 5:
		*R = Min + C;
		*G = Min;
		*B = Min + X;
		break;
	default:
		*R = *G = *B = 0;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movsd %xmm1, -0x28(%rbp)
movsd %xmm2, -0x30(%rbp)
movsd -0x28(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x30(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd 0x12f8d(%rip), %xmm1    # 0x1c258
divsd %xmm1, %xmm0
callq 0x2330
movsd -0x68(%rbp), %xmm1
movsd 0x12f7f(%rip), %xmm2    # 0x1c260
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
movsd 0x12f55(%rip), %xmm1    # 0x1c250
divsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd 0x12de8(%rip), %xmm1    # 0x1c108
mulsd %xmm1, %xmm0
callq 0x2330
movsd -0x60(%rbp), %xmm2
movaps %xmm0, %xmm1
movsd -0x58(%rbp), %xmm0
addsd %xmm1, %xmm1
subsd %xmm1, %xmm2
movsd 0x12f22(%rip), %xmm1    # 0x1c268
subsd %xmm1, %xmm2
movaps 0x131bf(%rip), %xmm3    # 0x1c510
pand %xmm3, %xmm2
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
cvttsd2si -0x20(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0x50(%rbp)
subl $0x5, %eax
ja 0x94c8
movq -0x50(%rbp), %rax
leaq 0x131bf(%rip), %rcx     # 0x1c540
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd -0x40(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x40(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x40(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x94e9
movsd -0x40(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x40(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x40(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x94e9
movsd -0x40(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x40(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x40(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x94e9
movsd -0x40(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x40(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x40(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x94e9
movsd -0x40(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x40(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x40(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x94e9
movsd -0x40(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x40(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x40(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x94e9
movq -0x18(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x8(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
addq $0x70, %rsp
popq %rbp
retq
nop