#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 */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ floor(float);
int fmod(int /*<<< orphan*/, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
void hsv_to_rgb_floats(float *out, float *in) {
  float r, g, b, h, s, v;
  r = g = b = h = s = v = 0;
  h = in[0];
  s = in[1];
  v = in[2];
  if (s == 0)
    r = g = b = v;
  else {
    int H = fmod(floor(h / 60), 6);
    float p, q, t, f = h / 60 - H;
    p = v * (1 - s);
    q = v * (1 - f * s);
    t = v * (1 - (1 - f) * s);
    switch (H) {
    case 6:
    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 -1:
    case 5:
      r = v;
      g = p;
      b = q;
      break;
    default:
      fprintf(stderr, "H=%d\n", H);
      assert(false);
    }
  }
  out[0] = r;
  out[1] = g;
  out[2] = b;
}


x86 assembly (clang, -O0):
<hsv_to_rgb_floats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x24(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11d9 <hsv_to_rgb_floats+0x99>
jp     11d9 <hsv_to_rgb_floats+0x99>
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  %xmm0,-0x18(%rbp)
movss  %xmm0,-0x14(%rbp)
jmp    13aa <hsv_to_rgb_floats+0x26a>
movss  -0x20(%rbp),%xmm0
movss  0xe1a(%rip),%xmm1
movss  %xmm1,-0x4c(%rbp)
divss  %xmm1,%xmm0
call   1060 <floor@plt>
mov    %eax,%edi
mov    $0x6,%esi
call   1030 <fmod@plt>
movss  -0x4c(%rbp),%xmm1
mov    %eax,-0x2c(%rbp)
movss  -0x20(%rbp),%xmm0
divss  %xmm1,%xmm0
cvtsi2ssl -0x2c(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x28(%rbp),%xmm0
movss  -0x24(%rbp),%xmm3
movss  0xdd3(%rip),%xmm1
movaps %xmm1,%xmm2
subss  %xmm3,%xmm2
mulss  %xmm2,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x28(%rbp),%xmm0
movss  -0x3c(%rbp),%xmm3
movss  -0x24(%rbp),%xmm2
mulss  %xmm2,%xmm3
movaps %xmm1,%xmm2
subss  %xmm3,%xmm2
mulss  %xmm2,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x28(%rbp),%xmm0
movss  -0x3c(%rbp),%xmm3
movaps %xmm1,%xmm2
subss  %xmm3,%xmm2
movss  -0x24(%rbp),%xmm3
mulss  %xmm3,%xmm2
subss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,%ecx
mov    %rcx,-0x48(%rbp)
sub    $0x7,%eax
ja     1386 <hsv_to_rgb_floats+0x246>
mov    -0x48(%rbp),%rax
lea    0xd5d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    13a5 <hsv_to_rgb_floats+0x265>
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    13a5 <hsv_to_rgb_floats+0x265>
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    13a5 <hsv_to_rgb_floats+0x265>
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    13a5 <hsv_to_rgb_floats+0x265>
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    13a5 <hsv_to_rgb_floats+0x265>
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    13a5 <hsv_to_rgb_floats+0x265>
mov    0x2c53(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xc8f(%rip),%rsi
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1040 <assert@plt>
jmp    13aa <hsv_to_rgb_floats+0x26a>
movss  -0x14(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x1c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hsv_to_rgb_floats>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movss  0x4(%rsi),%xmm1
movss  0x8(%rsi),%xmm5
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jne    1176 <hsv_to_rgb_floats+0x36>
jp     1176 <hsv_to_rgb_floats+0x36>
movaps %xmm5,%xmm1
movaps %xmm5,%xmm3
movss  %xmm5,(%rbx)
movss  %xmm3,0x4(%rbx)
movss  %xmm1,0x8(%rbx)
add    $0x10,%rsp
pop    %rbx
ret
movss  %xmm1,0x8(%rsp)
movss  %xmm5,0xc(%rsp)
movss  (%rsi),%xmm0
divss  0xe72(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
call   1060 <floor@plt>
mov    %eax,%edi
mov    $0x6,%esi
call   1030 <fmod@plt>
lea    0x1(%rax),%ecx
cmp    $0x7,%ecx
ja     1220 <hsv_to_rgb_floats+0xe0>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x4(%rsp),%xmm6
subss  %xmm0,%xmm6
movss  0xe3e(%rip),%xmm2
movaps %xmm2,%xmm0
movss  0x8(%rsp),%xmm3
subss  %xmm3,%xmm0
movss  0xc(%rsp),%xmm5
mulss  %xmm5,%xmm0
movaps %xmm2,%xmm1
subss  %xmm6,%xmm1
mulss  %xmm3,%xmm6
movaps %xmm2,%xmm4
subss  %xmm6,%xmm4
mulss  %xmm5,%xmm4
mulss  %xmm3,%xmm1
subss  %xmm1,%xmm2
mulss  %xmm5,%xmm2
lea    0xe02(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
movaps %xmm0,%xmm1
movaps %xmm2,%xmm3
jmp    *%rcx
movaps %xmm4,%xmm1
movaps %xmm0,%xmm3
jmp    1162 <hsv_to_rgb_floats+0x22>
mov    0x2db9(%rip),%rcx
mov    (%rcx),%edi
lea    0xdf8(%rip),%rsi
mov    %eax,%edx
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1040 <assert@plt>
xorps  %xmm1,%xmm1
xorps  %xmm3,%xmm3
xorps  %xmm5,%xmm5
jmp    1162 <hsv_to_rgb_floats+0x22>
movaps %xmm0,%xmm1
movaps %xmm5,%xmm3
movaps %xmm4,%xmm5
jmp    1162 <hsv_to_rgb_floats+0x22>
movaps %xmm2,%xmm1
movaps %xmm5,%xmm3
movaps %xmm0,%xmm5
jmp    1162 <hsv_to_rgb_floats+0x22>
movaps %xmm5,%xmm1
movaps %xmm4,%xmm3
movaps %xmm0,%xmm5
jmp    1162 <hsv_to_rgb_floats+0x22>
movaps %xmm5,%xmm1
movaps %xmm0,%xmm3
movaps %xmm2,%xmm5
jmp    1162 <hsv_to_rgb_floats+0x22>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [6 x i8] c"H=%d\0A\00"
define void @hsv_to_rgb_floats(float* nocapture writeonly %0, float* nocapture %1) {
%3 = getelementptr inbounds float, float* %1, i64 1
%4 = load float, float* %3
%5 = getelementptr inbounds float, float* %1, i64 2
%6 = load float, float* %5
%7 = fcmp oeq float %4, 0.000000e+00
br i1 %7, label %33, label %8
8: ; preds = %2
%9 = load float, float* %1
%10 = fdiv float %9, 6.000000e+01
%11 = tail call i32 @floor(float %10)
%12 = tail call i32 @fmod(i32 %11, i32 6)
%13 = sitofp i32 %12 to float
%14 = fsub float %10, %13
%15 = fsub float 1.000000e+00, %4
%16 = fmul float %6, %15
%17 = fneg float %14
%18 = tail call float @llvm.fmuladd.f32(float %17, float %4, float 1.000000e+00)
%19 = fmul float %6, %18
%20 = fsub float 1.000000e+00, %14
%21 = fneg float %20
%22 = tail call float @llvm.fmuladd.f32(float %21, float %4, float 1.000000e+00)
%23 = fmul float %6, %22
switch i32 %12, label %29 [
i32 6, label %33
i32 0, label %33
i32 1, label %24
i32 2, label %25
i32 3, label %26
i32 4, label %27
i32 -1, label %28
i32 5, label %28
]
24: ; preds = %8
br label %33
25: ; preds = %8
br label %33
26: ; preds = %8
br label %33
27: ; preds = %8
br label %33
28: ; preds = %8, %8
br label %33
29: ; preds = %8
%30 = load i32, i32* @stderr
%31 = tail call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %12)
%32 = tail call i32 @assert(i32 0)
br label %33
33: ; preds = %24, %25, %26, %27, %28, %29, %8, %8, %2
%34 = phi float [ %6, %2 ], [ 0.000000e+00, %29 ], [ %19, %28 ], [ %6, %27 ], [ %6, %26 ], [ %23, %25 ], [ %16, %24 ], [ %16, %8 ], [ %16, %8 ]
%35 = phi float [ %6, %2 ], [ 0.000000e+00, %29 ], [ %16, %28 ], [ %16, %27 ], [ %19, %26 ], [ %6, %25 ], [ %6, %24 ], [ %23, %8 ], [ %23, %8 ]
%36 = phi float [ %6, %2 ], [ 0.000000e+00, %29 ], [ %6, %28 ], [ %23, %27 ], [ %16, %26 ], [ %16, %25 ], [ %19, %24 ], [ %6, %8 ], [ %6, %8 ]
store float %36, float* %0
%37 = getelementptr inbounds float, float* %0, i64 1
store float %35, float* %37
%38 = getelementptr inbounds float, float* %0, i64 2
store float %34, float* %38
ret void
}