#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);
void HSV2RGB(float h, float s, float v, float *r, float *g, float *b) {
  int i;
  float f, p, q, t;
  if (s == 0) {
    *r = *b = *g = v;
    return;
  }
  h /= 60;
  i = ((int)floor(h)) % 6;
  f = h - floor(h);
  p = v * (1 - s);
  q = v * (1 - s * f);
  t = v * (1 - s * (1 - f));
  switch (i) {
  case 0:
    *r = (float)v;
    *g = (float)t;
    *b = (float)p;
    break;
  case 1:
    *r = (float)q;
    *g = (float)v;
    *b = (float)p;
    break;
  case 2:
    *r = (float)p;
    *g = (float)v;
    *b = (float)t;
    break;
  case 3:
    *r = (float)p;
    *g = (float)q;
    *b = (float)v;
    break;
  case 4:
    *r = (float)t;
    *g = (float)p;
    *b = (float)v;
    break;
  default:
    *r = (float)v;
    *g = (float)p;
    *b = (float)q;
    break;
  }
  return;
}


x86 assembly (clang, -O0):
<HSV2RGB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    116c <HSV2RGB+0x5c>
jp     116c <HSV2RGB+0x5c>
movss  -0xc(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    136c <HSV2RGB+0x25c>
movss  -0x4(%rbp),%xmm0
movss  0xe87(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <floor@plt>
cvttss2si %xmm0,%eax
movslq %eax,%rcx
imul   $0x2aaaaaab,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rdx
add    %ecx,%edx
add    %edx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movss  -0x4c(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x8(%rbp),%xmm3
movss  0xe1f(%rip),%xmm1
movaps %xmm1,%xmm2
subss  %xmm3,%xmm2
mulss  %xmm2,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x8(%rbp),%xmm3
movss  -0x30(%rbp),%xmm2
mulss  %xmm2,%xmm3
movaps %xmm1,%xmm2
subss  %xmm3,%xmm2
mulss  %xmm2,%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x8(%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)
mov    -0x2c(%rbp),%eax
mov    %rax,-0x48(%rbp)
sub    $0x4,%rax
ja     1340 <HSV2RGB+0x230>
mov    -0x48(%rbp),%rax
lea    0xdad(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0xc(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x3c(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x34(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
jmp    1367 <HSV2RGB+0x257>
movss  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0xc(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x34(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
jmp    1367 <HSV2RGB+0x257>
movss  -0x34(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0xc(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x3c(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
jmp    1367 <HSV2RGB+0x257>
movss  -0x34(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0xc(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
jmp    1367 <HSV2RGB+0x257>
movss  -0x3c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x34(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0xc(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
jmp    1367 <HSV2RGB+0x257>
movss  -0xc(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x34(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
jmp    136c <HSV2RGB+0x25c>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HSV2RGB>:
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 <HSV2RGB+0x34>
jp     1144 <HSV2RGB+0x34>
movss  %xmm2,(%r15)
movss  %xmm2,(%r14)
movss  %xmm2,(%rbx)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
divss  0xeb4(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
movss  %xmm2,0xc(%rsp)
movss  %xmm1,0x8(%rsp)
call   1030 <floorf@plt>
movss  0x4(%rsp),%xmm6
movss  0x8(%rsp),%xmm5
movss  0xc(%rsp),%xmm4
cvttss2si %xmm0,%eax
cltq
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
subss  %xmm0,%xmm6
movss  0xe62(%rip),%xmm1
movaps %xmm1,%xmm0
subss  %xmm5,%xmm0
mulss  %xmm4,%xmm0
movaps %xmm5,%xmm3
mulss  %xmm6,%xmm3
movaps %xmm1,%xmm2
subss  %xmm3,%xmm2
mulss  %xmm4,%xmm2
cmp    $0x4,%eax
ja     11fa <HSV2RGB+0xea>
movaps %xmm1,%xmm3
subss  %xmm6,%xmm3
mulss  %xmm3,%xmm5
subss  %xmm5,%xmm1
mulss  %xmm4,%xmm1
lea    0xe2a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  %xmm4,(%rbx)
movss  %xmm1,(%r15)
movss  %xmm0,(%r14)
jmp    113a <HSV2RGB+0x2a>
movss  %xmm4,(%rbx)
movss  %xmm0,(%r15)
movss  %xmm2,(%r14)
jmp    113a <HSV2RGB+0x2a>
movss  %xmm2,(%rbx)
movss  %xmm4,(%r15)
movss  %xmm0,(%r14)
jmp    113a <HSV2RGB+0x2a>
movss  %xmm0,(%rbx)
movss  %xmm4,(%r15)
movss  %xmm1,(%r14)
jmp    113a <HSV2RGB+0x2a>
movss  %xmm0,(%rbx)
movss  %xmm2,(%r15)
movss  %xmm4,(%r14)
jmp    113a <HSV2RGB+0x2a>
movss  %xmm1,(%rbx)
movss  %xmm0,(%r15)
movss  %xmm4,(%r14)
jmp    113a <HSV2RGB+0x2a>

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

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