void hsv2rgb(double *hsv_in, double *out_rgb) {
  double hh, p, q, t, ff;
  long i;
  if (hsv_in[1] <= 0.0000001) {
    out_rgb[0] = hsv_in[2];
    out_rgb[1] = hsv_in[2];
    out_rgb[2] = hsv_in[2];
    return;
  }
  hh = hsv_in[0];
  if (hh >= 360.0)
    hh = 0.0;
  hh /= 60.0;
  i = (long)hh;
  ff = hh - i;
  p = hsv_in[2] * (1.0 - hsv_in[1]);
  q = hsv_in[2] * (1.0 - (hsv_in[1] * ff));
  t = hsv_in[2] * (1.0 - (hsv_in[1] * (1.0 - ff)));
  switch (i) {
  case 0:
    out_rgb[0] = hsv_in[2];
    out_rgb[1] = t;
    out_rgb[2] = p;
    break;
  case 1:
    out_rgb[0] = q;
    out_rgb[1] = hsv_in[2];
    out_rgb[2] = p;
    break;
  case 2:
    out_rgb[0] = p;
    out_rgb[1] = hsv_in[2];
    out_rgb[2] = t;
    break;
  case 3:
    out_rgb[0] = p;
    out_rgb[1] = q;
    out_rgb[2] = hsv_in[2];
    break;
  case 4:
    out_rgb[0] = t;
    out_rgb[1] = p;
    out_rgb[2] = hsv_in[2];
    break;
  case 5:
  default:
    out_rgb[0] = hsv_in[2];
    out_rgb[1] = p;
    out_rgb[2] = q;
    break;
  }
}


x86 assembly (clang, -O0):
<hsv2rgb>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  0xee8(%rip),%xmm0
ucomisd 0x8(%rax),%xmm0
jb     115d <hsv2rgb+0x5d>
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1387 <hsv2rgb+0x287>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe91(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1189 <hsv2rgb+0x89>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe7a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
cvtsi2sdq -0x40(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm3
movsd  0x10(%rax),%xmm0
movsd  0xe45(%rip),%xmm1
movaps %xmm1,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm3
movsd  0x10(%rax),%xmm0
movsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm3
movaps %xmm1,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm2
movsd  0x10(%rax),%xmm0
movsd  -0x38(%rbp),%xmm4
movaps %xmm1,%xmm3
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
sub    $0x5,%rax
ja     135a <hsv2rgb+0x25a>
mov    -0x48(%rbp),%rax
lea    0xdce(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1387 <hsv2rgb+0x287>
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1387 <hsv2rgb+0x287>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1387 <hsv2rgb+0x287>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1387 <hsv2rgb+0x287>
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1387 <hsv2rgb+0x287>
jmp    135a <hsv2rgb+0x25a>
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<hsv2rgb>:
movsd  0x8(%rdi),%xmm1
movsd  0xef3(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    11ac <hsv2rgb+0xac>
movsd  (%rdi),%xmm0
xorpd  %xmm4,%xmm4
ucomisd 0xee1(%rip),%xmm0
jae    1135 <hsv2rgb+0x35>
divsd  0xedf(%rip),%xmm0
movapd %xmm0,%xmm4
cvttsd2si %xmm4,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
subsd  %xmm0,%xmm4
movsd  0x10(%rdi),%xmm3
movsd  0xec5(%rip),%xmm2
movapd %xmm2,%xmm0
subsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm0
movapd %xmm1,%xmm6
mulsd  %xmm4,%xmm6
movapd %xmm2,%xmm5
subsd  %xmm6,%xmm5
mulsd  %xmm3,%xmm5
cmp    $0x4,%rax
ja     11ca <hsv2rgb+0xca>
movapd %xmm2,%xmm6
subsd  %xmm4,%xmm6
mulsd  %xmm6,%xmm1
subsd  %xmm1,%xmm2
mulsd  %xmm3,%xmm2
lea    0xe8c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  %xmm3,(%rsi)
movsd  %xmm2,0x8(%rsi)
movsd  %xmm0,0x10(%rsi)
ret
movsd  0x10(%rdi),%xmm0
movsd  %xmm0,(%rsi)
movsd  0x10(%rdi),%xmm0
movsd  %xmm0,0x8(%rsi)
movsd  0x10(%rdi),%xmm0
movsd  %xmm0,0x10(%rsi)
ret
movsd  %xmm3,(%rsi)
movsd  %xmm0,0x8(%rsi)
movsd  %xmm5,0x10(%rsi)
ret
movsd  %xmm5,(%rsi)
movsd  0x10(%rdi),%xmm1
movsd  %xmm1,0x8(%rsi)
movsd  %xmm0,0x10(%rsi)
ret
movsd  %xmm0,(%rsi)
movsd  0x10(%rdi),%xmm0
movsd  %xmm0,0x8(%rsi)
movsd  %xmm2,0x10(%rsi)
ret
movsd  %xmm0,(%rsi)
movsd  %xmm5,0x8(%rsi)
jmp    11bf <hsv2rgb+0xbf>
movsd  %xmm2,(%rsi)
jmp    11ba <hsv2rgb+0xba>

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

LLVM IR (-O2):
define void @hsv2rgb(double* nocapture %0, double* writeonly %1) {
%3 = getelementptr inbounds double, double* %0, i64 1
%4 = load double, double* %3
%5 = fcmp ugt double %4, 0x3E7AD7F29ABCAF48
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = getelementptr inbounds double, double* %0, i64 2
%8 = load double, double* %7
store double %8, double* %1
%9 = load double, double* %7
%10 = getelementptr inbounds double, double* %1, i64 1
store double %9, double* %10
%11 = load double, double* %7
br label %46
12: ; preds = %2
%13 = load double, double* %0
%14 = fcmp ult double %13, 3.600000e+02
%15 = fdiv double %13, 6.000000e+01
%16 = select i1 %14, double %15, double 0.000000e+00
%17 = fptosi double %16 to i64
%18 = sitofp i64 %17 to double
%19 = fsub double %16, %18
%20 = getelementptr inbounds double, double* %0, i64 2
%21 = load double, double* %20
%22 = fsub double 1.000000e+00, %4
%23 = fmul double %22, %21
%24 = fneg double %4
%25 = tail call double @llvm.fmuladd.f64(double %24, double %19, double 1.000000e+00)
%26 = fmul double %21, %25
%27 = fsub double 1.000000e+00, %19
%28 = tail call double @llvm.fmuladd.f64(double %24, double %27, double 1.000000e+00)
%29 = fmul double %21, %28
switch i64 %17, label %44 [
i64 0, label %30
i64 1, label %32
i64 2, label %35
i64 3, label %38
i64 4, label %41
]
30: ; preds = %12
store double %21, double* %1
%31 = getelementptr inbounds double, double* %1, i64 1
store double %29, double* %31
br label %46
32: ; preds = %12
store double %26, double* %1
%33 = load double, double* %20
%34 = getelementptr inbounds double, double* %1, i64 1
store double %33, double* %34
br label %46
35: ; preds = %12
store double %23, double* %1
%36 = load double, double* %20
%37 = getelementptr inbounds double, double* %1, i64 1
store double %36, double* %37
br label %46
38: ; preds = %12
store double %23, double* %1
%39 = getelementptr inbounds double, double* %1, i64 1
store double %26, double* %39
%40 = load double, double* %20
br label %46
41: ; preds = %12
store double %29, double* %1
%42 = getelementptr inbounds double, double* %1, i64 1
store double %23, double* %42
%43 = load double, double* %20
br label %46
44: ; preds = %12
store double %21, double* %1
%45 = getelementptr inbounds double, double* %1, i64 1
store double %23, double* %45
br label %46
46: ; preds = %30, %32, %35, %38, %41, %44, %6
%47 = phi double [ %23, %30 ], [ %23, %32 ], [ %29, %35 ], [ %40, %38 ], [ %43, %41 ], [ %26, %44 ], [ %11, %6 ]
%48 = getelementptr inbounds double, double* %1, i64 2
store double %47, double* %48
ret void
}