void HSVtoRGBPat(double *r, double *g, double *b, double h, double s,
                 double v) {
  int i;
  double f, p, q, t;
  if (s == 0) {
    *r = *g = *b = v;
    return;
  }
  h /= 60;
  i = (int)(h);
  f = h - i;
  p = v * (1 - s);
  q = v * (1 - s * f);
  t = v * (1 - s * (1 - f));
  switch (i) {
  case 0:
    *r = v;
    *g = t;
    *b = p;
    break;
  case 1:
    *r = q;
    *g = v;
    *b = p;
    break;
  case 2:
    *r = p;
    *g = v;
    *b = t;
    break;
  case 3:
    *r = p;
    *g = q;
    *b = v;
    break;
  case 4:
    *r = t;
    *g = p;
    *b = v;
    break;
  default:
    *r = v;
    *g = p;
    *b = q;
    break;
  }
}


x86 assembly (clang, -O0):
<HSVtoRGBPat>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movsd  %xmm2,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1159 <HSVtoRGBPat+0x59>
jp     1159 <HSVtoRGBPat+0x59>
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    131e <HSVtoRGBPat+0x21e>
movsd  -0x20(%rbp),%xmm0
movsd  0xe9a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvttsd2si -0x20(%rbp),%eax
mov    %eax,-0x34(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x34(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm3
movsd  0xe6c(%rip),%xmm1
movaps %xmm1,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm3
movaps %xmm1,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm4
movaps %xmm1,%xmm3
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x34(%rbp),%eax
mov    %rax,-0x60(%rbp)
sub    $0x4,%rax
ja     12f7 <HSVtoRGBPat+0x1f7>
mov    -0x60(%rbp),%rax
lea    0xdfe(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    131e <HSVtoRGBPat+0x21e>
movsd  -0x50(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    131e <HSVtoRGBPat+0x21e>
movsd  -0x48(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    131e <HSVtoRGBPat+0x21e>
movsd  -0x48(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    131e <HSVtoRGBPat+0x21e>
movsd  -0x58(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    131e <HSVtoRGBPat+0x21e>
movsd  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<HSVtoRGBPat>:
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm1
jne    1119 <HSVtoRGBPat+0x19>
jp     1119 <HSVtoRGBPat+0x19>
movsd  %xmm2,(%rdx)
movsd  %xmm2,(%rsi)
movsd  %xmm2,(%rdi)
ret
divsd  0xedf(%rip),%xmm0
cvttsd2si %xmm0,%eax
cvttpd2dq %xmm0,%xmm3
cvtdq2pd %xmm3,%xmm3
subsd  %xmm3,%xmm0
movsd  0xecf(%rip),%xmm4
movapd %xmm4,%xmm3
subsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm3
movapd %xmm1,%xmm6
mulsd  %xmm0,%xmm6
movapd %xmm4,%xmm5
subsd  %xmm6,%xmm5
mulsd  %xmm2,%xmm5
cmp    $0x4,%eax
ja     118f <HSVtoRGBPat+0x8f>
movapd %xmm4,%xmm6
subsd  %xmm0,%xmm6
mulsd  %xmm6,%xmm1
subsd  %xmm1,%xmm4
mulsd  %xmm2,%xmm4
lea    0xe97(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  %xmm2,(%rdi)
movsd  %xmm4,(%rsi)
movsd  %xmm3,(%rdx)
ret
movsd  %xmm2,(%rdi)
movsd  %xmm3,(%rsi)
movsd  %xmm5,(%rdx)
ret
movsd  %xmm5,(%rdi)
movsd  %xmm2,(%rsi)
movsd  %xmm3,(%rdx)
ret
movsd  %xmm3,(%rdi)
movsd  %xmm2,(%rsi)
movsd  %xmm4,(%rdx)
ret
movsd  %xmm3,(%rdi)
movsd  %xmm5,(%rsi)
movsd  %xmm2,(%rdx)
ret
movsd  %xmm4,(%rdi)
movsd  %xmm3,(%rsi)
movsd  %xmm2,(%rdx)
ret

LLVM IR (-O0):
define void @HSVtoRGBPat(double* %0, double* %1, double* %2, double %3, double %4, double %5) {
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
store double* %0, double** %7
store double* %1, double** %8
store double* %2, double** %9
store double %3, double* %10
store double %4, double* %11
store double %5, double* %12
%18 = load double, double* %11
%19 = fcmp oeq double %18, 0.000000e+00
br i1 %19, label %20, label %25
20: ; preds = %6
%21 = load double, double* %12
%22 = load double*, double** %9
store double %21, double* %22
%23 = load double*, double** %8
store double %21, double* %23
%24 = load double*, double** %7
store double %21, double* %24
br label %94
25: ; preds = %6
%26 = load double, double* %10
%27 = fdiv double %26, 6.000000e+01
store double %27, double* %10
%28 = load double, double* %10
%29 = fptosi double %28 to i32
store i32 %29, i32* %13
%30 = load double, double* %10
%31 = load i32, i32* %13
%32 = sitofp i32 %31 to double
%33 = fsub double %30, %32
store double %33, double* %14
%34 = load double, double* %12
%35 = load double, double* %11
%36 = fsub double 1.000000e+00, %35
%37 = fmul double %34, %36
store double %37, double* %15
%38 = load double, double* %12
%39 = load double, double* %11
%40 = load double, double* %14
%41 = fneg double %39
%42 = call double @llvm.fmuladd.f64(double %41, double %40, double 1.000000e+00)
%43 = fmul double %38, %42
store double %43, double* %16
%44 = load double, double* %12
%45 = load double, double* %11
%46 = load double, double* %14
%47 = fsub double 1.000000e+00, %46
%48 = fneg double %45
%49 = call double @llvm.fmuladd.f64(double %48, double %47, double 1.000000e+00)
%50 = fmul double %44, %49
store double %50, double* %17
%51 = load i32, i32* %13
switch i32 %51, label %87 [
i32 0, label %52
i32 1, label %59
i32 2, label %66
i32 3, label %73
i32 4, label %80
]
52: ; preds = %25
%53 = load double, double* %12
%54 = load double*, double** %7
store double %53, double* %54
%55 = load double, double* %17
%56 = load double*, double** %8
store double %55, double* %56
%57 = load double, double* %15
%58 = load double*, double** %9
store double %57, double* %58
br label %94
59: ; preds = %25
%60 = load double, double* %16
%61 = load double*, double** %7
store double %60, double* %61
%62 = load double, double* %12
%63 = load double*, double** %8
store double %62, double* %63
%64 = load double, double* %15
%65 = load double*, double** %9
store double %64, double* %65
br label %94
66: ; preds = %25
%67 = load double, double* %15
%68 = load double*, double** %7
store double %67, double* %68
%69 = load double, double* %12
%70 = load double*, double** %8
store double %69, double* %70
%71 = load double, double* %17
%72 = load double*, double** %9
store double %71, double* %72
br label %94
73: ; preds = %25
%74 = load double, double* %15
%75 = load double*, double** %7
store double %74, double* %75
%76 = load double, double* %16
%77 = load double*, double** %8
store double %76, double* %77
%78 = load double, double* %12
%79 = load double*, double** %9
store double %78, double* %79
br label %94
80: ; preds = %25
%81 = load double, double* %17
%82 = load double*, double** %7
store double %81, double* %82
%83 = load double, double* %15
%84 = load double*, double** %8
store double %83, double* %84
%85 = load double, double* %12
%86 = load double*, double** %9
store double %85, double* %86
br label %94
87: ; preds = %25
%88 = load double, double* %12
%89 = load double*, double** %7
store double %88, double* %89
%90 = load double, double* %15
%91 = load double*, double** %8
store double %90, double* %91
%92 = load double, double* %16
%93 = load double*, double** %9
store double %92, double* %93
br label %94
94: ; preds = %20, %87, %80, %73, %66, %59, %52
ret void
}

LLVM IR (-O2):
define void @HSVtoRGBPat(double* nocapture writeonly %0, double* nocapture writeonly %1, double* nocapture writeonly %2, double %3, double %4, double %5) {
%7 = fcmp oeq double %4, 0.000000e+00
br i1 %7, label %8, label %9
8: ; preds = %6
store double %5, double* %2
store double %5, double* %1
store double %5, double* %0
br label %28
9: ; preds = %6
%10 = fdiv double %3, 6.000000e+01
%11 = fptosi double %10 to i32
%12 = sitofp i32 %11 to double
%13 = fsub double %10, %12
%14 = fsub double 1.000000e+00, %4
%15 = fmul double %14, %5
%16 = fneg double %4
%17 = tail call double @llvm.fmuladd.f64(double %16, double %13, double 1.000000e+00)
%18 = fmul double %17, %5
%19 = fsub double 1.000000e+00, %13
%20 = tail call double @llvm.fmuladd.f64(double %16, double %19, double 1.000000e+00)
%21 = fmul double %20, %5
switch i32 %11, label %27 [
i32 0, label %22
i32 1, label %23
i32 2, label %24
i32 3, label %25
i32 4, label %26
]
22: ; preds = %9
store double %5, double* %0
store double %21, double* %1
store double %15, double* %2
br label %28
23: ; preds = %9
store double %18, double* %0
store double %5, double* %1
store double %15, double* %2
br label %28
24: ; preds = %9
store double %15, double* %0
store double %5, double* %1
store double %21, double* %2
br label %28
25: ; preds = %9
store double %15, double* %0
store double %18, double* %1
store double %5, double* %2
br label %28
26: ; preds = %9
store double %21, double* %0
store double %15, double* %1
store double %5, double* %2
br label %28
27: ; preds = %9
store double %5, double* %0
store double %15, double* %1
store double %18, double* %2
br label %28
28: ; preds = %22, %23, %24, %25, %26, %27, %8
ret void
}