extern int hsvD_to_rgbD(const double hsvD[3], double rgbD[3]) {
  double f, p, q, t, h, s, v;
  h = hsvD[0];
  s = hsvD[1];
  v = hsvD[2];
  if (s == 0.0) {
    rgbD[0] = v;
    rgbD[1] = v;
    rgbD[2] = v;
    return 0;
  }
  h = h * 6.0;
  if (h == 6.0)
    h = 0.0;
  f = h - (int)h;
  p = v * (1.0 - s);
  q = v * (1.0 - s * f);
  t = v * (1.0 - s * (1.0 - f));
  switch ((int)h) {
  case 0:
    rgbD[0] = v;
    rgbD[1] = t;
    rgbD[2] = p;
    break;
  case 1:
    rgbD[0] = q;
    rgbD[1] = v;
    rgbD[2] = p;
    break;
  case 2:
    rgbD[0] = p;
    rgbD[1] = v;
    rgbD[2] = t;
    break;
  case 3:
    rgbD[0] = p;
    rgbD[1] = q;
    rgbD[2] = v;
    break;
  case 4:
    rgbD[0] = t;
    rgbD[1] = p;
    rgbD[2] = v;
    break;
  case 5:
    rgbD[0] = v;
    rgbD[1] = p;
    rgbD[2] = q;
    break;
  default:
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<hsvD_to_rgbD>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1182 <hsvD_to_rgbD+0x82>
jp     1182 <hsvD_to_rgbD+0x82>
movsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movl   $0x0,-0x4(%rbp)
jmp    138d <hsvD_to_rgbD+0x28d>
movsd  0xe76(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xe5f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11b9 <hsvD_to_rgbD+0xb9>
jp     11b9 <hsvD_to_rgbD+0xb9>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movaps %xmm0,%xmm1
cvttpd2dq %xmm1,%xmm1
cvtdq2pd %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm3
movsd  0xe24(%rip),%xmm1
movaps %xmm1,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm3
movaps %xmm1,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm4
movaps %xmm1,%xmm3
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvttsd2si -0x40(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x58(%rbp)
sub    $0x5,%eax
ja     137a <hsvD_to_rgbD+0x27a>
mov    -0x58(%rbp),%rax
lea    0xdb3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1386 <hsvD_to_rgbD+0x286>
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1386 <hsvD_to_rgbD+0x286>
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1386 <hsvD_to_rgbD+0x286>
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1386 <hsvD_to_rgbD+0x286>
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1386 <hsvD_to_rgbD+0x286>
movsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1386 <hsvD_to_rgbD+0x286>
movl   $0x1,-0x4(%rbp)
jmp    138d <hsvD_to_rgbD+0x28d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<hsvD_to_rgbD>:
movsd  0x8(%rdi),%xmm2
movsd  0x10(%rdi),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm2
jne    1133 <hsvD_to_rgbD+0x33>
jp     1133 <hsvD_to_rgbD+0x33>
movapd %xmm0,%xmm2
movapd %xmm0,%xmm4
movapd %xmm0,%xmm1
movsd  %xmm2,(%rsi)
movsd  %xmm4,0x8(%rsi)
movsd  %xmm1,0x10(%rsi)
xor    %eax,%eax
ret
movsd  0xec5(%rip),%xmm4
movsd  (%rdi),%xmm1
mulsd  %xmm4,%xmm1
cmpeqsd %xmm1,%xmm4
andnpd %xmm1,%xmm4
cvttsd2si %xmm4,%eax
cmp    $0x5,%eax
ja     11c2 <hsvD_to_rgbD+0xc2>
cvttpd2dq %xmm4,%xmm1
cvtdq2pd %xmm1,%xmm1
subsd  %xmm1,%xmm4
movsd  0xe9f(%rip),%xmm3
movapd %xmm3,%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm2,%xmm6
mulsd  %xmm4,%xmm6
movapd %xmm3,%xmm5
subsd  %xmm6,%xmm5
mulsd  %xmm0,%xmm5
movapd %xmm3,%xmm6
subsd  %xmm4,%xmm6
mulsd  %xmm2,%xmm6
subsd  %xmm6,%xmm3
mulsd  %xmm0,%xmm3
lea    0xe6c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
movapd %xmm0,%xmm2
movapd %xmm3,%xmm4
jmp    *%rax
movapd %xmm5,%xmm2
movapd %xmm0,%xmm4
jmp    1122 <hsvD_to_rgbD+0x22>
mov    $0x1,%eax
ret
movapd %xmm1,%xmm2
movapd %xmm0,%xmm4
movapd %xmm3,%xmm1
jmp    1122 <hsvD_to_rgbD+0x22>
movapd %xmm1,%xmm2
movapd %xmm5,%xmm4
jmp    111e <hsvD_to_rgbD+0x1e>
movapd %xmm3,%xmm2
movapd %xmm1,%xmm4
jmp    111e <hsvD_to_rgbD+0x1e>
movapd %xmm0,%xmm2
movapd %xmm1,%xmm4
movapd %xmm5,%xmm1
jmp    1122 <hsvD_to_rgbD+0x22>

LLVM IR (-O0):
define i32 @hsvD_to_rgbD(double* %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca double*
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double* %0, double** %4
store double* %1, double** %5
%13 = load double*, double** %4
%14 = getelementptr inbounds double, double* %13, i64 0
%15 = load double, double* %14
store double %15, double* %10
%16 = load double*, double** %4
%17 = getelementptr inbounds double, double* %16, i64 1
%18 = load double, double* %17
store double %18, double* %11
%19 = load double*, double** %4
%20 = getelementptr inbounds double, double* %19, i64 2
%21 = load double, double* %20
store double %21, double* %12
%22 = load double, double* %11
%23 = fcmp oeq double %22, 0.000000e+00
br i1 %23, label %24, label %34
24: ; preds = %2
%25 = load double, double* %12
%26 = load double*, double** %5
%27 = getelementptr inbounds double, double* %26, i64 0
store double %25, double* %27
%28 = load double, double* %12
%29 = load double*, double** %5
%30 = getelementptr inbounds double, double* %29, i64 1
store double %28, double* %30
%31 = load double, double* %12
%32 = load double*, double** %5
%33 = getelementptr inbounds double, double* %32, i64 2
store double %31, double* %33
store i32 0, i32* %3
br label %127
34: ; preds = %2
%35 = load double, double* %10
%36 = fmul double %35, 6.000000e+00
store double %36, double* %10
%37 = load double, double* %10
%38 = fcmp oeq double %37, 6.000000e+00
br i1 %38, label %39, label %40
39: ; preds = %34
store double 0.000000e+00, double* %10
br label %40
40: ; preds = %39, %34
%41 = load double, double* %10
%42 = load double, double* %10
%43 = fptosi double %42 to i32
%44 = sitofp i32 %43 to double
%45 = fsub double %41, %44
store double %45, double* %6
%46 = load double, double* %12
%47 = load double, double* %11
%48 = fsub double 1.000000e+00, %47
%49 = fmul double %46, %48
store double %49, double* %7
%50 = load double, double* %12
%51 = load double, double* %11
%52 = load double, double* %6
%53 = fneg double %51
%54 = call double @llvm.fmuladd.f64(double %53, double %52, double 1.000000e+00)
%55 = fmul double %50, %54
store double %55, double* %8
%56 = load double, double* %12
%57 = load double, double* %11
%58 = load double, double* %6
%59 = fsub double 1.000000e+00, %58
%60 = fneg double %57
%61 = call double @llvm.fmuladd.f64(double %60, double %59, double 1.000000e+00)
%62 = fmul double %56, %61
store double %62, double* %9
%63 = load double, double* %10
%64 = fptosi double %63 to i32
switch i32 %64, label %125 [
i32 0, label %65
i32 1, label %75
i32 2, label %85
i32 3, label %95
i32 4, label %105
i32 5, label %115
]
65: ; preds = %40
%66 = load double, double* %12
%67 = load double*, double** %5
%68 = getelementptr inbounds double, double* %67, i64 0
store double %66, double* %68
%69 = load double, double* %9
%70 = load double*, double** %5
%71 = getelementptr inbounds double, double* %70, i64 1
store double %69, double* %71
%72 = load double, double* %7
%73 = load double*, double** %5
%74 = getelementptr inbounds double, double* %73, i64 2
store double %72, double* %74
br label %126
75: ; preds = %40
%76 = load double, double* %8
%77 = load double*, double** %5
%78 = getelementptr inbounds double, double* %77, i64 0
store double %76, double* %78
%79 = load double, double* %12
%80 = load double*, double** %5
%81 = getelementptr inbounds double, double* %80, i64 1
store double %79, double* %81
%82 = load double, double* %7
%83 = load double*, double** %5
%84 = getelementptr inbounds double, double* %83, i64 2
store double %82, double* %84
br label %126
85: ; preds = %40
%86 = load double, double* %7
%87 = load double*, double** %5
%88 = getelementptr inbounds double, double* %87, i64 0
store double %86, double* %88
%89 = load double, double* %12
%90 = load double*, double** %5
%91 = getelementptr inbounds double, double* %90, i64 1
store double %89, double* %91
%92 = load double, double* %9
%93 = load double*, double** %5
%94 = getelementptr inbounds double, double* %93, i64 2
store double %92, double* %94
br label %126
95: ; preds = %40
%96 = load double, double* %7
%97 = load double*, double** %5
%98 = getelementptr inbounds double, double* %97, i64 0
store double %96, double* %98
%99 = load double, double* %8
%100 = load double*, double** %5
%101 = getelementptr inbounds double, double* %100, i64 1
store double %99, double* %101
%102 = load double, double* %12
%103 = load double*, double** %5
%104 = getelementptr inbounds double, double* %103, i64 2
store double %102, double* %104
br label %126
105: ; preds = %40
%106 = load double, double* %9
%107 = load double*, double** %5
%108 = getelementptr inbounds double, double* %107, i64 0
store double %106, double* %108
%109 = load double, double* %7
%110 = load double*, double** %5
%111 = getelementptr inbounds double, double* %110, i64 1
store double %109, double* %111
%112 = load double, double* %12
%113 = load double*, double** %5
%114 = getelementptr inbounds double, double* %113, i64 2
store double %112, double* %114
br label %126
115: ; preds = %40
%116 = load double, double* %12
%117 = load double*, double** %5
%118 = getelementptr inbounds double, double* %117, i64 0
store double %116, double* %118
%119 = load double, double* %7
%120 = load double*, double** %5
%121 = getelementptr inbounds double, double* %120, i64 1
store double %119, double* %121
%122 = load double, double* %8
%123 = load double*, double** %5
%124 = getelementptr inbounds double, double* %123, i64 2
store double %122, double* %124
br label %126
125: ; preds = %40
store i32 1, i32* %3
br label %127
126: ; preds = %115, %105, %95, %85, %75, %65
store i32 0, i32* %3
br label %127
127: ; preds = %126, %125, %24
%128 = load i32, i32* %3
ret i32 %128
}

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