#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 hsv2rgb(float *r, float *g, float *b, float h, float s, float v) {
  float F, M, N, K;
  int i;
  if (s == 0.0) {
    *r = *g = *b = v;
  } else {
    if (h == 1.0)
      h = 0.0;
    h *= 6.0;
    i = floorf(h);
    F = h - i;
    M = v * (1 - s);
    N = v * (1 - s * F);
    K = v * (1 - s * (1 - F));
    switch (i) {
    case 0:
      *r = v;
      *g = K;
      *b = M;
      break;
    case 1:
      *r = N;
      *g = v;
      *b = M;
      break;
    case 2:
      *r = M;
      *g = v;
      *b = K;
      break;
    case 3:
      *r = M;
      *g = N;
      *b = v;
      break;
    case 4:
      *r = K;
      *g = M;
      *b = v;
      break;
    case 5:
      *r = v;
      *g = M;
      *b = N;
      break;
    }
  }
}


x86 assembly (clang, -O0):
<hsv2rgb>:
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  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1171 <hsv2rgb+0x61>
jp     1171 <hsv2rgb+0x61>
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    1371 <hsv2rgb+0x261>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe7e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    119a <hsv2rgb+0x8a>
jp     119a <hsv2rgb+0x8a>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe5d(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1030 <floorf@plt>
mov    %eax,-0x38(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtsi2ssl -0x38(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x24(%rbp),%xmm0
movss  -0x20(%rbp),%xmm3
movss  0xe26(%rip),%xmm1
movaps %xmm1,%xmm2
subss  %xmm3,%xmm2
mulss  %xmm2,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x24(%rbp),%xmm0
movss  -0x20(%rbp),%xmm3
movss  -0x28(%rbp),%xmm2
mulss  %xmm2,%xmm3
movaps %xmm1,%xmm2
subss  %xmm3,%xmm2
mulss  %xmm2,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x24(%rbp),%xmm0
movss  -0x20(%rbp),%xmm2
movss  -0x28(%rbp),%xmm4
movaps %xmm1,%xmm3
subss  %xmm4,%xmm3
mulss  %xmm3,%xmm2
subss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x38(%rbp),%eax
mov    %rax,-0x40(%rbp)
sub    $0x5,%rax
ja     136c <hsv2rgb+0x25c>
mov    -0x40(%rbp),%rax
lea    0xdb4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x24(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x34(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x2c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    136c <hsv2rgb+0x25c>
movss  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x24(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x2c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    136c <hsv2rgb+0x25c>
movss  -0x2c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x24(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x34(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    136c <hsv2rgb+0x25c>
movss  -0x2c(%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    136c <hsv2rgb+0x25c>
movss  -0x34(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x2c(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x24(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    136c <hsv2rgb+0x25c>
movss  -0x24(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x2c(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    1371 <hsv2rgb+0x261>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hsv2rgb>:
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    1144 <hsv2rgb+0x34>
jp     1144 <hsv2rgb+0x34>
movss  %xmm2,(%r14)
movss  %xmm2,(%r15)
movss  %xmm2,(%rbx)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
movss  %xmm1,0x8(%rsp)
movss  %xmm2,0xc(%rsp)
movss  0xea8(%rip),%xmm1
mulss  %xmm0,%xmm1
cmpeqss 0xe9f(%rip),%xmm0
andnps %xmm1,%xmm0
movaps %xmm0,0x10(%rsp)
call   1030 <floorf@plt>
cmp    $0x5,%eax
ja     113a <hsv2rgb+0x2a>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movaps 0x10(%rsp),%xmm6
subss  %xmm0,%xmm6
movss  0xe75(%rip),%xmm4
movaps %xmm4,%xmm0
movss  0x8(%rsp),%xmm5
subss  %xmm5,%xmm0
movss  0xc(%rsp),%xmm3
mulss  %xmm3,%xmm0
movaps %xmm5,%xmm2
mulss  %xmm6,%xmm2
movaps %xmm4,%xmm1
subss  %xmm2,%xmm1
mulss  %xmm3,%xmm1
movaps %xmm4,%xmm2
subss  %xmm6,%xmm2
mulss  %xmm5,%xmm2
subss  %xmm2,%xmm4
mulss  %xmm3,%xmm4
mov    %eax,%eax
lea    0xe34(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  %xmm3,(%rbx)
movss  %xmm4,(%r15)
movss  %xmm0,(%r14)
jmp    113a <hsv2rgb+0x2a>
movss  %xmm1,(%rbx)
movss  %xmm3,(%r15)
movss  %xmm0,(%r14)
jmp    113a <hsv2rgb+0x2a>
movss  %xmm0,(%rbx)
movss  %xmm3,(%r15)
movss  %xmm4,(%r14)
jmp    113a <hsv2rgb+0x2a>
movss  %xmm0,(%rbx)
movss  %xmm1,(%r15)
movss  %xmm3,(%r14)
jmp    113a <hsv2rgb+0x2a>
movss  %xmm4,(%rbx)
movss  %xmm0,(%r15)
movss  %xmm3,(%r14)
jmp    113a <hsv2rgb+0x2a>
movss  %xmm3,(%rbx)
movss  %xmm0,(%r15)
movss  %xmm1,(%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 float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = 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
%18 = load float, float* %11
%19 = fpext float %18 to double
%20 = fcmp oeq double %19, 0.000000e+00
br i1 %20, label %21, label %26
21: ; preds = %6
%22 = load float, float* %12
%23 = load float*, float** %9
store float %22, float* %23
%24 = load float*, float** %8
store float %22, float* %24
%25 = load float*, float** %7
store float %22, float* %25
br label %103
26: ; preds = %6
%27 = load float, float* %10
%28 = fpext float %27 to double
%29 = fcmp oeq double %28, 1.000000e+00
br i1 %29, label %30, label %31
30: ; preds = %26
store float 0.000000e+00, float* %10
br label %31
31: ; preds = %30, %26
%32 = load float, float* %10
%33 = fpext float %32 to double
%34 = fmul double %33, 6.000000e+00
%35 = fptrunc double %34 to float
store float %35, float* %10
%36 = load float, float* %10
%37 = call i32 @floorf(float %36)
store i32 %37, i32* %17
%38 = load float, float* %10
%39 = load i32, i32* %17
%40 = sitofp i32 %39 to float
%41 = fsub float %38, %40
store float %41, float* %13
%42 = load float, float* %12
%43 = load float, float* %11
%44 = fsub float 1.000000e+00, %43
%45 = fmul float %42, %44
store float %45, float* %14
%46 = load float, float* %12
%47 = load float, float* %11
%48 = load float, float* %13
%49 = fneg float %47
%50 = call float @llvm.fmuladd.f32(float %49, float %48, float 1.000000e+00)
%51 = fmul float %46, %50
store float %51, float* %15
%52 = load float, float* %12
%53 = load float, float* %11
%54 = load float, float* %13
%55 = fsub float 1.000000e+00, %54
%56 = fneg float %53
%57 = call float @llvm.fmuladd.f32(float %56, float %55, float 1.000000e+00)
%58 = fmul float %52, %57
store float %58, float* %16
%59 = load i32, i32* %17
switch i32 %59, label %102 [
i32 0, label %60
i32 1, label %67
i32 2, label %74
i32 3, label %81
i32 4, label %88
i32 5, label %95
]
60: ; preds = %31
%61 = load float, float* %12
%62 = load float*, float** %7
store float %61, float* %62
%63 = load float, float* %16
%64 = load float*, float** %8
store float %63, float* %64
%65 = load float, float* %14
%66 = load float*, float** %9
store float %65, float* %66
br label %102
67: ; preds = %31
%68 = load float, float* %15
%69 = load float*, float** %7
store float %68, float* %69
%70 = load float, float* %12
%71 = load float*, float** %8
store float %70, float* %71
%72 = load float, float* %14
%73 = load float*, float** %9
store float %72, float* %73
br label %102
74: ; preds = %31
%75 = load float, float* %14
%76 = load float*, float** %7
store float %75, float* %76
%77 = load float, float* %12
%78 = load float*, float** %8
store float %77, float* %78
%79 = load float, float* %16
%80 = load float*, float** %9
store float %79, float* %80
br label %102
81: ; preds = %31
%82 = load float, float* %14
%83 = load float*, float** %7
store float %82, float* %83
%84 = load float, float* %15
%85 = load float*, float** %8
store float %84, float* %85
%86 = load float, float* %12
%87 = load float*, float** %9
store float %86, float* %87
br label %102
88: ; preds = %31
%89 = load float, float* %16
%90 = load float*, float** %7
store float %89, float* %90
%91 = load float, float* %14
%92 = load float*, float** %8
store float %91, float* %92
%93 = load float, float* %12
%94 = load float*, float** %9
store float %93, float* %94
br label %102
95: ; preds = %31
%96 = load float, float* %12
%97 = load float*, float** %7
store float %96, float* %97
%98 = load float, float* %14
%99 = load float*, float** %8
store float %98, float* %99
%100 = load float, float* %15
%101 = load float*, float** %9
store float %100, float* %101
br label %102
102: ; preds = %31, %95, %88, %81, %74, %67, %60
br label %103
103: ; preds = %102, %21
ret void
}

LLVM IR (-O2):
define void @hsv2rgb(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, 1.000000e+00
%11 = fmul float %3, 6.000000e+00
%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 %30 [
i32 0, label %24
i32 1, label %25
i32 2, label %26
i32 3, label %27
i32 4, label %28
i32 5, label %29
]
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, %9, %8
ret void
}