#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 floorf(float);
void HSVtoRGB(float *r, float *g, float *b, float h, float s, float v) {
  if (h == 360)
    h = 0;
  int i;
  float f, p, q, t;
  if (s == 0) {
    *r = *g = *b = v;
    return;
  }
  h /= 60;
  i = floorf(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;
  default:
    *r = v;
    *g = p;
    *b = q;
    break;
  }
}


x86 assembly (clang, -O0):
<HSVtoRGB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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  -0x1c(%rbp),%xmm0
movss  0xec0(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    1157 <HSVtoRGB+0x47>
jp     1157 <HSVtoRGB+0x47>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1190 <HSVtoRGB+0x80>
jp     1190 <HSVtoRGB+0x80>
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    135a <HSVtoRGB+0x24a>
movss  -0x1c(%rbp),%xmm0
movss  0xe67(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1030 <floorf@plt>
mov    %eax,-0x28(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtsi2ssl -0x28(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x24(%rbp),%xmm0
movss  -0x20(%rbp),%xmm3
movss  0xe30(%rip),%xmm1
movaps %xmm1,%xmm2
subss  %xmm3,%xmm2
mulss  %xmm2,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x24(%rbp),%xmm0
movss  -0x20(%rbp),%xmm3
movss  -0x2c(%rbp),%xmm2
mulss  %xmm2,%xmm3
movaps %xmm1,%xmm2
subss  %xmm3,%xmm2
mulss  %xmm2,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x24(%rbp),%xmm0
movss  -0x20(%rbp),%xmm2
movss  -0x2c(%rbp),%xmm4
movaps %xmm1,%xmm3
subss  %xmm4,%xmm3
mulss  %xmm3,%xmm2
subss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%eax
mov    %rax,-0x40(%rbp)
sub    $0x4,%rax
ja     1333 <HSVtoRGB+0x223>
mov    -0x40(%rbp),%rax
lea    0xdbe(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x24(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    135a <HSVtoRGB+0x24a>
movss  -0x34(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x24(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    135a <HSVtoRGB+0x24a>
movss  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x24(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    135a <HSVtoRGB+0x24a>
movss  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x34(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x24(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    135a <HSVtoRGB+0x24a>
movss  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x24(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    135a <HSVtoRGB+0x24a>
movss  -0x24(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x34(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HSVtoRGB>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xorps  %xmm3,%xmm3
ucomiss %xmm3,%xmm1
jne    1144 <HSVtoRGB+0x34>
jp     1144 <HSVtoRGB+0x34>
movss  %xmm2,(%r14)
movss  %xmm2,(%r15)
movss  %xmm2,(%rbx)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
movss  %xmm1,0x8(%rsp)
movss  %xmm2,0xc(%rsp)
ucomiss 0xea9(%rip),%xmm0
jne    115b <HSVtoRGB+0x4b>
jnp    1166 <HSVtoRGB+0x56>
divss  0xea1(%rip),%xmm0
movaps %xmm0,%xmm3
movss  %xmm3,0x4(%rsp)
movaps %xmm3,%xmm0
call   1030 <floorf@plt>
movss  0x4(%rsp),%xmm6
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
subss  %xmm0,%xmm6
movss  0xe7b(%rip),%xmm1
movaps %xmm1,%xmm0
movss  0x8(%rsp),%xmm5
subss  %xmm5,%xmm0
movss  0xc(%rsp),%xmm4
mulss  %xmm4,%xmm0
movaps %xmm5,%xmm3
mulss  %xmm6,%xmm3
movaps %xmm1,%xmm2
subss  %xmm3,%xmm2
mulss  %xmm4,%xmm2
cmp    $0x4,%eax
ja     11f3 <HSVtoRGB+0xe3>
movaps %xmm1,%xmm3
subss  %xmm6,%xmm3
mulss  %xmm3,%xmm5
subss  %xmm5,%xmm1
mulss  %xmm4,%xmm1
mov    %eax,%eax
lea    0xe35(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  %xmm4,(%rbx)
movss  %xmm1,(%r15)
movss  %xmm0,(%r14)
jmp    113a <HSVtoRGB+0x2a>
movss  %xmm4,(%rbx)
movss  %xmm0,(%r15)
movss  %xmm2,(%r14)
jmp    113a <HSVtoRGB+0x2a>
movss  %xmm2,(%rbx)
movss  %xmm4,(%r15)
movss  %xmm0,(%r14)
jmp    113a <HSVtoRGB+0x2a>
movss  %xmm0,(%rbx)
movss  %xmm4,(%r15)
movss  %xmm1,(%r14)
jmp    113a <HSVtoRGB+0x2a>
movss  %xmm0,(%rbx)
movss  %xmm2,(%r15)
movss  %xmm4,(%r14)
jmp    113a <HSVtoRGB+0x2a>
movss  %xmm1,(%rbx)
movss  %xmm0,(%r15)
movss  %xmm4,(%r14)
jmp    113a <HSVtoRGB+0x2a>

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

LLVM IR (-O2):
define void @HSVtoRGB(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 %30
9: ; preds = %6
%10 = fcmp oeq float %3, 3.600000e+02
%11 = fdiv float %3, 6.000000e+01
%12 = select i1 %10, float 0.000000e+00, float %11
%13 = tail call i32 @floorf(float %12)
%14 = sitofp i32 %13 to float
%15 = fsub float %12, %14
%16 = fsub float 1.000000e+00, %4
%17 = fmul float %16, %5
%18 = fneg float %4
%19 = tail call float @llvm.fmuladd.f32(float %18, float %15, float 1.000000e+00)
%20 = fmul float %19, %5
%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 %22, %5
switch i32 %13, label %29 [
i32 0, label %24
i32 1, label %25
i32 2, label %26
i32 3, label %27
i32 4, label %28
]
24: ; preds = %9
store float %5, float* %0
store float %23, float* %1
store float %17, float* %2
br label %30
25: ; preds = %9
store float %20, float* %0
store float %5, float* %1
store float %17, float* %2
br label %30
26: ; preds = %9
store float %17, float* %0
store float %5, float* %1
store float %23, float* %2
br label %30
27: ; preds = %9
store float %17, float* %0
store float %20, float* %1
store float %5, float* %2
br label %30
28: ; preds = %9
store float %23, float* %0
store float %17, float* %1
store float %5, float* %2
br label %30
29: ; preds = %9
store float %5, float* %0
store float %17, float* %1
store float %20, float* %2
br label %30
30: ; preds = %24, %25, %26, %27, %28, %29, %8
ret void
}