#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 */
float floor(float);
unsigned int getColorFromRGBA(float, float, float, float);
float saturate(float);
unsigned int getColorFromHSVA(float hue, float saturation, float value,
                              float alpha) {
  float r, g, b;
  float h = hue - floor(hue);
  float s = saturate(saturation);
  float v = saturate(value);
  if (s == 0.0)
    r = g = b = v;
  else {
    float i, f, p, q, t;
    if (h == 1.0)
      h = 0.0;
    h *= 6.0;
    i = floor(h);
    f = h - i;
    p = v * (1.0f - s);
    q = v * (1.0f - s * f);
    t = v * (1.0f - s * (1.0f - f));
    switch ((int)h) {
    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;
    }
  }
  return getColorFromRGBA(r, g, b, alpha);
}


x86 assembly (clang, -O0):
<getColorFromHSVA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x4(%rbp),%xmm0
call   1050 <floor@plt>
movaps %xmm0,%xmm1
movss  -0x40(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <saturate@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <saturate@plt>
movss  %xmm0,-0x28(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11c4 <getColorFromHSVA+0x94>
jp     11c4 <getColorFromHSVA+0x94>
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  %xmm0,-0x18(%rbp)
movss  %xmm0,-0x14(%rbp)
jmp    1393 <getColorFromHSVA+0x263>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe2b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11ed <getColorFromHSVA+0xbd>
jp     11ed <getColorFromHSVA+0xbd>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe0a(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
call   1050 <floor@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x20(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x28(%rbp),%xmm0
movss  -0x24(%rbp),%xmm3
movss  0xdd1(%rip),%xmm1
movaps %xmm1,%xmm2
subss  %xmm3,%xmm2
mulss  %xmm2,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x28(%rbp),%xmm0
movss  -0x24(%rbp),%xmm3
movss  -0x30(%rbp),%xmm2
mulss  %xmm2,%xmm3
movaps %xmm1,%xmm2
subss  %xmm3,%xmm2
mulss  %xmm2,%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x28(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
movss  -0x30(%rbp),%xmm4
movaps %xmm1,%xmm3
subss  %xmm4,%xmm3
mulss  %xmm3,%xmm2
subss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
cvttss2si -0x20(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x48(%rbp)
sub    $0x4,%eax
ja     1370 <getColorFromHSVA+0x240>
mov    -0x48(%rbp),%rax
lea    0xd5c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    138e <getColorFromHSVA+0x25e>
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    138e <getColorFromHSVA+0x25e>
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    138e <getColorFromHSVA+0x25e>
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    138e <getColorFromHSVA+0x25e>
movss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    138e <getColorFromHSVA+0x25e>
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    1393 <getColorFromHSVA+0x263>
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm2
movss  -0x10(%rbp),%xmm3
call   1040 <getColorFromRGBA@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getColorFromHSVA>:
sub    $0x28,%rsp
movss  %xmm3,0xc(%rsp)
movss  %xmm2,(%rsp)
movss  %xmm1,0x4(%rsp)
movaps %xmm0,0x10(%rsp)
call   1030 <floorf@plt>
movss  %xmm0,0x8(%rsp)
movss  0x4(%rsp),%xmm0
call   1040 <saturate@plt>
movss  %xmm0,0x4(%rsp)
movss  (%rsp),%xmm0
call   1040 <saturate@plt>
xorps  %xmm1,%xmm1
movss  0x4(%rsp),%xmm3
movaps %xmm0,%xmm2
ucomiss %xmm1,%xmm3
jne    1195 <getColorFromHSVA+0x65>
jp     1195 <getColorFromHSVA+0x65>
movaps %xmm0,%xmm1
movss  0xc(%rsp),%xmm3
add    $0x28,%rsp
jmp    1050 <getColorFromRGBA@plt>
movss  %xmm0,(%rsp)
movaps 0x10(%rsp),%xmm0
subss  0x8(%rsp),%xmm0
movss  0xe53(%rip),%xmm1
mulss  %xmm0,%xmm1
cmpeqss 0xe4a(%rip),%xmm0
andnps %xmm1,%xmm0
movaps %xmm0,0x10(%rsp)
movss  %xmm2,0x8(%rsp)
call   1030 <floorf@plt>
movss  0xe2f(%rip),%xmm6
movss  0x8(%rsp),%xmm5
movaps 0x10(%rsp),%xmm1
cvttss2si %xmm1,%eax
subss  %xmm0,%xmm1
movaps %xmm1,%xmm0
movaps %xmm6,%xmm4
movss  0x4(%rsp),%xmm2
subss  %xmm2,%xmm4
mulss  %xmm5,%xmm4
movaps %xmm2,%xmm1
mulss  %xmm0,%xmm1
movaps %xmm6,%xmm3
subss  %xmm1,%xmm3
mulss  %xmm5,%xmm3
cmp    $0x4,%eax
ja     124f <getColorFromHSVA+0x11f>
movaps %xmm6,%xmm1
subss  %xmm0,%xmm1
mulss  %xmm1,%xmm2
subss  %xmm2,%xmm6
mulss  %xmm6,%xmm5
lea    0xddb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
movaps %xmm4,%xmm2
movaps %xmm5,%xmm1
movss  (%rsp),%xmm0
jmp    *%rax
movaps %xmm4,%xmm2
movaps %xmm0,%xmm1
movaps %xmm3,%xmm0
jmp    1186 <getColorFromHSVA+0x56>
movaps %xmm3,%xmm2
movaps %xmm4,%xmm1
movss  (%rsp),%xmm0
jmp    1186 <getColorFromHSVA+0x56>
movaps %xmm5,%xmm2
movaps %xmm0,%xmm1
movaps %xmm4,%xmm0
jmp    1186 <getColorFromHSVA+0x56>
movaps %xmm0,%xmm2
movaps %xmm3,%xmm1
movaps %xmm4,%xmm0
jmp    1186 <getColorFromHSVA+0x56>
movaps %xmm0,%xmm2
movaps %xmm4,%xmm1
movaps %xmm5,%xmm0
jmp    1186 <getColorFromHSVA+0x56>

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

LLVM IR (-O2):
define i32 @getColorFromHSVA(float %0, float %1, float %2, float %3) {
%5 = tail call float @llvm.floor.f32(float %0)
%6 = fsub float %0, %5
%7 = tail call float @saturate(float %1)
%8 = tail call float @saturate(float %2)
%9 = fcmp oeq float %7, 0.000000e+00
br i1 %9, label %30, label %10
10: ; preds = %4
%11 = fcmp oeq float %6, 1.000000e+00
%12 = fmul float %6, 6.000000e+00
%13 = select i1 %11, float 0.000000e+00, float %12
%14 = tail call float @llvm.floor.f32(float %13)
%15 = fsub float %13, %14
%16 = fsub float 1.000000e+00, %7
%17 = fmul float %8, %16
%18 = fneg float %7
%19 = tail call float @llvm.fmuladd.f32(float %18, float %15, float 1.000000e+00)
%20 = fmul float %8, %19
%21 = fsub float 1.000000e+00, %15
%22 = tail call float @llvm.fmuladd.f32(float %18, float %21, float 1.000000e+00)
%23 = fmul float %8, %22
%24 = fptosi float %13 to i32
switch i32 %24, label %29 [
i32 0, label %30
i32 1, label %25
i32 2, label %26
i32 3, label %27
i32 4, label %28
]
25: ; preds = %10
br label %30
26: ; preds = %10
br label %30
27: ; preds = %10
br label %30
28: ; preds = %10
br label %30
29: ; preds = %10
br label %30
30: ; preds = %25, %26, %27, %28, %29, %10, %4
%31 = phi float [ %8, %4 ], [ %20, %29 ], [ %8, %28 ], [ %8, %27 ], [ %23, %26 ], [ %17, %25 ], [ %17, %10 ]
%32 = phi float [ %8, %4 ], [ %17, %29 ], [ %17, %28 ], [ %20, %27 ], [ %8, %26 ], [ %8, %25 ], [ %23, %10 ]
%33 = phi float [ %8, %4 ], [ %8, %29 ], [ %23, %28 ], [ %17, %27 ], [ %17, %26 ], [ %20, %25 ], [ %8, %10 ]
%34 = tail call i32 @getColorFromRGBA(float %33, float %32, float %31, float %3)
ret i32 %34
}