// File: spatialfruitsalad[P]volume2position/./colors.hpp
// Function: hsv2rgb(hsv)
static inline rgb   hsv2rgb(hsv in){
    double      hh, p, q, t, ff;
    long        i;
    rgb         out;

    if(in.s <= 0.0)         // < is bogus, just shuts up warnings
    {
        out.r = in.v;
        out.g = in.v;
        out.b = in.v;
        return out;
    }
    hh = in.h;
    if(hh >= 360.0) hh = 0.0;
    hh /= 60.0;
    i = (long)hh;
    ff = hh - i;
    p = in.v * (1.0 - in.s);
    q = in.v * (1.0 - (in.s * ff));
    t = in.v * (1.0 - (in.s * (1.0 - ff)));

    switch(i)
    {
    case 0:
        out.r = in.v;
        out.g = t;
        out.b = p;
        break;
    case 1:
        out.r = q;
        out.g = in.v;
        out.b = p;
        break;
    case 2:
        out.r = p;
        out.g = in.v;
        out.b = t;
        break;

    case 3:
        out.r = p;
        out.g = q;
        out.b = in.v;
        break;
    case 4:
        out.r = t;
        out.g = p;
        out.b = in.v;
        break;
    case 5:
    default:
        out.r = in.v;
        out.g = p;
        out.b = q;
        break;
    }
    return out;
}

// Assembly:
movq %rdi, -0x48(%rsp)
movq %rdi, -0x40(%rsp)
leaq 0x8(%rsp), %rax
movq %rax, -0x38(%rsp)
xorps %xmm0, %xmm0
ucomisd 0x8(%rax), %xmm0
jb 0x5eaa
movq -0x48(%rsp), %rax
movq -0x38(%rsp), %rcx
movsd 0x10(%rcx), %xmm0
movsd %xmm0, (%rax)
movsd 0x10(%rcx), %xmm0
movsd %xmm0, 0x8(%rax)
movsd 0x10(%rcx), %xmm0
movsd %xmm0, 0x10(%rax)
jmp 0x60bd
movq -0x38(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x8(%rsp)
movsd -0x8(%rsp), %xmm0
movsd 0x221b9(%rip), %xmm1    # 0x28080
ucomisd %xmm1, %xmm0
jb 0x5ed6
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rsp)
movq -0x38(%rsp), %rax
movsd -0x8(%rsp), %xmm0
movsd 0x221b7(%rip), %xmm1    # 0x280a0
divsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rsp)
cvttsd2si -0x8(%rsp), %rcx
movq %rcx, -0x30(%rsp)
movsd -0x8(%rsp), %xmm0
cvtsi2sdq -0x30(%rsp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rsp)
movsd 0x8(%rax), %xmm3
movsd 0x10(%rax), %xmm0
movsd 0x22118(%rip), %xmm1    # 0x28040
movaps %xmm1, %xmm2
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
movsd %xmm0, -0x10(%rsp)
movsd 0x8(%rax), %xmm3
movsd 0x10(%rax), %xmm0
movsd -0x28(%rsp), %xmm2
mulsd %xmm2, %xmm3
movaps %xmm1, %xmm2
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
movsd %xmm0, -0x18(%rsp)
movsd 0x8(%rax), %xmm2
movsd 0x10(%rax), %xmm0
movsd -0x28(%rsp), %xmm4
movaps %xmm1, %xmm3
subsd %xmm4, %xmm3
mulsd %xmm3, %xmm2
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rsp)
movq -0x30(%rsp), %rax
movq %rax, -0x50(%rsp)
subq $0x5, %rax
ja 0x6092
movq -0x50(%rsp), %rax
leaq 0x22179(%rip), %rcx     # 0x28120
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x48(%rsp), %rax
movq -0x38(%rsp), %rcx
movsd 0x10(%rcx), %xmm0
movsd %xmm0, (%rax)
movsd -0x20(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movsd -0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rax)
jmp 0x60bb
movq -0x48(%rsp), %rax
movq -0x38(%rsp), %rcx
movsd -0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x10(%rcx), %xmm0
movsd %xmm0, 0x8(%rax)
movsd -0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rax)
jmp 0x60bb
movq -0x48(%rsp), %rax
movq -0x38(%rsp), %rcx
movsd -0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x10(%rcx), %xmm0
movsd %xmm0, 0x8(%rax)
movsd -0x20(%rsp), %xmm0
movsd %xmm0, 0x10(%rax)
jmp 0x60bb
movq -0x48(%rsp), %rax
movq -0x38(%rsp), %rcx
movsd -0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd -0x18(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movsd 0x10(%rcx), %xmm0
movsd %xmm0, 0x10(%rax)
jmp 0x60bb
movq -0x48(%rsp), %rax
movq -0x38(%rsp), %rcx
movsd -0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd -0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movsd 0x10(%rcx), %xmm0
movsd %xmm0, 0x10(%rax)
jmp 0x60bb
jmp 0x6092
movq -0x48(%rsp), %rax
movq -0x38(%rsp), %rcx
movsd 0x10(%rcx), %xmm0
movsd %xmm0, (%rax)
movsd -0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movsd -0x18(%rsp), %xmm0
movsd %xmm0, 0x10(%rax)
jmp 0x60bd
movq -0x40(%rsp), %rax
retq
nopw %cs:(%rax,%rax)
nopl (%rax)