#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ floor(double);
void HSVtoRGB(double h, double s, double v, double *r, double *g, double *b) {
  int i;
  double f, p, q, t;
  if (s < 1.0e-6) {
    *r = *g = *b = v;
    return;
  }
  h /= 60.0;
  i = (int)floor(h);
  f = h - (double)i;
  p = v * (1.0 - s);
  q = v * (1.0 - s * f);
  t = v * (1.0 - s * (1.0 - 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):
<HSVtoRGB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
movsd  0xec5(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1168 <HSVtoRGB+0x58>
movsd  -0x18(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1332 <HSVtoRGB+0x222>
movsd  -0x8(%rbp),%xmm0
movsd  0xe93(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <floor@plt>
mov    %eax,-0x34(%rbp)
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x34(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm3
movsd  0xe60(%rip),%xmm1
movaps %xmm1,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm3
movaps %xmm1,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%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     130b <HSVtoRGB+0x1fb>
mov    -0x60(%rbp),%rax
lea    0xdf2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x18(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1332 <HSVtoRGB+0x222>
movsd  -0x50(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1332 <HSVtoRGB+0x222>
movsd  -0x48(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1332 <HSVtoRGB+0x222>
movsd  -0x48(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1332 <HSVtoRGB+0x222>
movsd  -0x58(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1332 <HSVtoRGB+0x222>
movsd  -0x18(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HSVtoRGB>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movsd  0xed6(%rip),%xmm3
ucomisd %xmm1,%xmm3
jbe    1148 <HSVtoRGB+0x38>
movsd  %xmm2,(%r14)
movsd  %xmm2,(%r15)
movsd  %xmm2,(%rbx)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
divsd  0xeb8(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
call   1030 <floor@plt>
movsd  0x8(%rsp),%xmm6
movsd  0x10(%rsp),%xmm5
movsd  0x18(%rsp),%xmm4
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
subsd  %xmm0,%xmm6
movsd  0xe84(%rip),%xmm1
movapd %xmm1,%xmm0
subsd  %xmm5,%xmm0
mulsd  %xmm4,%xmm0
movapd %xmm5,%xmm3
mulsd  %xmm6,%xmm3
movapd %xmm1,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm4,%xmm2
cmp    $0x4,%eax
ja     11ea <HSVtoRGB+0xda>
movapd %xmm1,%xmm3
subsd  %xmm6,%xmm3
mulsd  %xmm3,%xmm5
subsd  %xmm5,%xmm1
mulsd  %xmm4,%xmm1
mov    %eax,%eax
lea    0xe4a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  %xmm4,(%rbx)
movsd  %xmm1,(%r15)
movsd  %xmm0,(%r14)
jmp    113e <HSVtoRGB+0x2e>
movsd  %xmm4,(%rbx)
movsd  %xmm0,(%r15)
movsd  %xmm2,(%r14)
jmp    113e <HSVtoRGB+0x2e>
movsd  %xmm2,(%rbx)
movsd  %xmm4,(%r15)
movsd  %xmm0,(%r14)
jmp    113e <HSVtoRGB+0x2e>
movsd  %xmm0,(%rbx)
movsd  %xmm4,(%r15)
movsd  %xmm1,(%r14)
jmp    113e <HSVtoRGB+0x2e>
movsd  %xmm0,(%rbx)
movsd  %xmm2,(%r15)
movsd  %xmm4,(%r14)
jmp    113e <HSVtoRGB+0x2e>
movsd  %xmm1,(%rbx)
movsd  %xmm0,(%r15)
movsd  %xmm4,(%r14)
jmp    113e <HSVtoRGB+0x2e>

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

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