#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(float);
void HSV_To_RGB(float *red, float *green, float *blue, float h, float s,
                float v) {
  if (s == 0) {
    *red = *green = *blue = v;
    return;
  }
  double f, p, q, t, r, g, b;
  int i;
  if (h == 1)
    h = 0;
  h *= 6;
  i = (int)floor(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;
  case 5:
    r = v;
    g = p;
    b = q;
    break;
  }
  *red = r;
  *green = g;
  *blue = b;
}


x86 assembly (clang, -O0):
<HSV_To_RGB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movss  %xmm0,-0x1c(%rbp)
movss  %xmm1,-0x20(%rbp)
movss  %xmm2,-0x24(%rbp)
movss  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    116c <HSV_To_RGB+0x5c>
jp     116c <HSV_To_RGB+0x5c>
movss  -0x24(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
jmp    138c <HSV_To_RGB+0x27c>
movss  -0x1c(%rbp),%xmm0
movss  0xe87(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    1190 <HSV_To_RGB+0x80>
jp     1190 <HSV_To_RGB+0x80>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  0xe67(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1030 <floor@plt>
mov    %eax,-0x64(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtsi2ssl -0x64(%rbp),%xmm1
subss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movss  -0x24(%rbp),%xmm0
movss  -0x20(%rbp),%xmm2
movss  0xe24(%rip),%xmm1
subss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x20(%rbp),%xmm1
cvtss2sd %xmm1,%xmm3
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm3
movsd  0xdf8(%rip),%xmm1
movaps %xmm1,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,-0x40(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x20(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movsd  -0x30(%rbp),%xmm4
movaps %xmm1,%xmm3
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x64(%rbp),%eax
mov    %rax,-0x70(%rbp)
sub    $0x5,%rax
ja     1359 <HSV_To_RGB+0x249>
mov    -0x70(%rbp),%rax
lea    0xda5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1359 <HSV_To_RGB+0x249>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1359 <HSV_To_RGB+0x249>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1359 <HSV_To_RGB+0x249>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1359 <HSV_To_RGB+0x249>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1359 <HSV_To_RGB+0x249>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movsd  -0x60(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HSV_To_RGB>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xorps  %xmm3,%xmm3
ucomiss %xmm3,%xmm1
jne    113f <HSV_To_RGB+0x2f>
jp     113f <HSV_To_RGB+0x2f>
movss  %xmm2,(%r14)
movss  %xmm2,(%r15)
movss  %xmm2,(%rbx)
jmp    1251 <HSV_To_RGB+0x141>
movss  0xeb9(%rip),%xmm3
mulss  %xmm0,%xmm3
cmpeqss 0xeb0(%rip),%xmm0
andnps %xmm3,%xmm0
movaps %xmm0,0x10(%rsp)
movss  %xmm2,0xc(%rsp)
movss  %xmm1,0x8(%rsp)
call   1030 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movaps 0x10(%rsp),%xmm1
subss  %xmm0,%xmm1
cvtss2sd %xmm1,%xmm4
movss  0xe7b(%rip),%xmm0
movss  0x8(%rsp),%xmm2
subss  %xmm2,%xmm0
movss  0xc(%rsp),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
cvtss2sd %xmm2,%xmm5
movsd  0xe57(%rip),%xmm2
movapd %xmm2,%xmm6
subsd  %xmm4,%xmm6
mulsd  %xmm5,%xmm6
movapd %xmm2,%xmm3
subsd  %xmm6,%xmm3
mulsd  %xmm1,%xmm3
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     11f6 <HSV_To_RGB+0xe6>
mulsd  %xmm4,%xmm5
subsd  %xmm5,%xmm2
mulsd  %xmm1,%xmm2
lea    0xe2c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movapd %xmm2,%xmm4
movaps %xmm1,%xmm5
jmp    1231 <HSV_To_RGB+0x121>
movapd %xmm1,%xmm4
movapd %xmm3,%xmm5
jmp    1231 <HSV_To_RGB+0x121>
movaps %xmm0,%xmm4
movaps %xmm1,%xmm5
movapd %xmm3,%xmm0
jmp    1231 <HSV_To_RGB+0x121>
movaps %xmm0,%xmm4
movapd %xmm2,%xmm5
movapd %xmm1,%xmm0
jmp    1231 <HSV_To_RGB+0x121>
movapd %xmm3,%xmm4
movaps %xmm0,%xmm5
movapd %xmm1,%xmm0
jmp    1231 <HSV_To_RGB+0x121>
movapd %xmm1,%xmm4
movaps %xmm0,%xmm5
movapd %xmm2,%xmm0
xorps  %xmm1,%xmm1
cvtsd2ss %xmm4,%xmm1
movss  %xmm1,(%rbx)
xorps  %xmm1,%xmm1
cvtsd2ss %xmm5,%xmm1
movss  %xmm1,(%r15)
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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