#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*/ abort();
scalar_t__ floor(float);
void hue2rgb(float hue, float *r, float *g, float *b) {
  float p, n;
  int k;
  hue -= 360 * (float)floor(hue / 360);
  hue /= 60;
  k = (int)floor(hue);
  if (k == 6) {
    k = 5;
  } else if (k < 0) {
    k = 0;
  }
  p = hue - k;
  n = 1 - p;
  switch (k) {
  case 0:
    *r = 1;
    *g = p;
    *b = 0;
    break;
  case 1:
    *r = n;
    *g = 1;
    *b = 0;
    break;
  case 2:
    *r = 0;
    *g = 1;
    *b = p;
    break;
  case 3:
    *r = 0;
    *g = n;
    *b = 1;
    break;
  case 4:
    *r = p;
    *g = 0;
    *b = 1;
    break;
  case 5:
    *r = 1;
    *g = 0;
    *b = n;
    break;
  default:
    abort();
  }
}


x86 assembly (clang, -O0):
<hue2rgb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xec2(%rip),%xmm1
divss  %xmm1,%xmm0
call   1040 <floor@plt>
cvtsi2ss %rax,%xmm0
movss  -0x4(%rbp),%xmm1
movss  0xea3(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xe85(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x6,-0x2c(%rbp)
jne    11a7 <hue2rgb+0x87>
movl   $0x5,-0x2c(%rbp)
jmp    11bd <hue2rgb+0x9d>
cmpl   $0x0,-0x2c(%rbp)
jge    11b8 <hue2rgb+0x98>
movl   $0x0,-0x2c(%rbp)
jmp    11bd <hue2rgb+0x9d>
movss  -0x4(%rbp),%xmm0
cvtsi2ssl -0x2c(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm1
movss  0xe2f(%rip),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rax,-0x38(%rbp)
sub    $0x5,%rax
ja     1319 <hue2rgb+0x1f9>
mov    -0x38(%rbp),%rax
lea    0xe0e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
movss  0xdf5(%rip),%xmm0
movss  %xmm0,(%rax)
movss  -0x24(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
jmp    1320 <hue2rgb+0x200>
movss  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movss  0xdbb(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
jmp    1320 <hue2rgb+0x200>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movss  0xd90(%rip),%xmm0
movss  %xmm0,(%rax)
movss  -0x24(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
jmp    1320 <hue2rgb+0x200>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
movss  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movss  0xd56(%rip),%xmm0
movss  %xmm0,(%rax)
jmp    1320 <hue2rgb+0x200>
movss  -0x24(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movss  0xd29(%rip),%xmm0
movss  %xmm0,(%rax)
jmp    1320 <hue2rgb+0x200>
mov    -0x10(%rbp),%rax
movss  0xd14(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
movss  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
jmp    1320 <hue2rgb+0x200>
mov    $0x0,%al
call   1030 <abort@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hue2rgb>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movss  %xmm0,0xc(%rsp)
divss  0xec0(%rip),%xmm0
call   1040 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0xeaf(%rip),%xmm0
addss  0xc(%rsp),%xmm0
divss  0xea5(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
call   1040 <floor@plt>
xor    %ecx,%ecx
test   %eax,%eax
cmovns %eax,%ecx
cmp    $0x6,%eax
mov    $0x5,%eax
cmovne %ecx,%eax
cmp    $0x5,%eax
ja     121a <hue2rgb+0xfa>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0xc(%rsp),%xmm4
subss  %xmm0,%xmm4
movss  0xe6a(%rip),%xmm0
movaps %xmm0,%xmm3
subss  %xmm4,%xmm3
xorps  %xmm1,%xmm1
lea    0xe5d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
movaps %xmm4,%xmm2
jmp    *%rax
movss  0xe45(%rip),%xmm2
movaps %xmm3,%xmm0
jmp    1202 <hue2rgb+0xe2>
movss  0xe38(%rip),%xmm2
xorps  %xmm0,%xmm0
movaps %xmm4,%xmm1
jmp    1202 <hue2rgb+0xe2>
movss  0xe28(%rip),%xmm1
xorps  %xmm0,%xmm0
movaps %xmm3,%xmm2
jmp    1202 <hue2rgb+0xe2>
movss  0xe18(%rip),%xmm1
xorps  %xmm2,%xmm2
movaps %xmm4,%xmm0
jmp    1202 <hue2rgb+0xe2>
xorps  %xmm2,%xmm2
movaps %xmm3,%xmm1
movss  %xmm0,(%rbx)
movss  %xmm2,(%r15)
movss  %xmm1,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define void @hue2rgb(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 i32
store float %0, float* %5
store float* %1, float** %6
store float* %2, float** %7
store float* %3, float** %8
%12 = load float, float* %5
%13 = fdiv float %12, 3.600000e+02
%14 = call i64 @floor(float %13)
%15 = sitofp i64 %14 to float
%16 = load float, float* %5
%17 = call float @llvm.fmuladd.f32(float -3.600000e+02, float %15, float %16)
store float %17, float* %5
%18 = load float, float* %5
%19 = fdiv float %18, 6.000000e+01
store float %19, float* %5
%20 = load float, float* %5
%21 = call i64 @floor(float %20)
%22 = trunc i64 %21 to i32
store i32 %22, i32* %11
%23 = load i32, i32* %11
%24 = icmp eq i32 %23, 6
br i1 %24, label %25, label %26
25: ; preds = %4
store i32 5, i32* %11
br label %31
26: ; preds = %4
%27 = load i32, i32* %11
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %26
store i32 0, i32* %11
br label %30
30: ; preds = %29, %26
br label %31
31: ; preds = %30, %25
%32 = load float, float* %5
%33 = load i32, i32* %11
%34 = sitofp i32 %33 to float
%35 = fsub float %32, %34
store float %35, float* %9
%36 = load float, float* %9
%37 = fsub float 1.000000e+00, %36
store float %37, float* %10
%38 = load i32, i32* %11
switch i32 %38, label %69 [
i32 0, label %39
i32 1, label %44
i32 2, label %49
i32 3, label %54
i32 4, label %59
i32 5, label %64
]
39: ; preds = %31
%40 = load float*, float** %6
store float 1.000000e+00, float* %40
%41 = load float, float* %9
%42 = load float*, float** %7
store float %41, float* %42
%43 = load float*, float** %8
store float 0.000000e+00, float* %43
br label %71
44: ; preds = %31
%45 = load float, float* %10
%46 = load float*, float** %6
store float %45, float* %46
%47 = load float*, float** %7
store float 1.000000e+00, float* %47
%48 = load float*, float** %8
store float 0.000000e+00, float* %48
br label %71
49: ; preds = %31
%50 = load float*, float** %6
store float 0.000000e+00, float* %50
%51 = load float*, float** %7
store float 1.000000e+00, float* %51
%52 = load float, float* %9
%53 = load float*, float** %8
store float %52, float* %53
br label %71
54: ; preds = %31
%55 = load float*, float** %6
store float 0.000000e+00, float* %55
%56 = load float, float* %10
%57 = load float*, float** %7
store float %56, float* %57
%58 = load float*, float** %8
store float 1.000000e+00, float* %58
br label %71
59: ; preds = %31
%60 = load float, float* %9
%61 = load float*, float** %6
store float %60, float* %61
%62 = load float*, float** %7
store float 0.000000e+00, float* %62
%63 = load float*, float** %8
store float 1.000000e+00, float* %63
br label %71
64: ; preds = %31
%65 = load float*, float** %6
store float 1.000000e+00, float* %65
%66 = load float*, float** %7
store float 0.000000e+00, float* %66
%67 = load float, float* %10
%68 = load float*, float** %8
store float %67, float* %68
br label %71
69: ; preds = %31
%70 = call i32 (...) @abort()
unreachable
71: ; preds = %64, %59, %54, %49, %44, %39
ret void
}

LLVM IR (-O2):
define void @hue2rgb(float %0, float* nocapture writeonly %1, float* nocapture writeonly %2, float* nocapture writeonly %3) {
%5 = fdiv float %0, 3.600000e+02
%6 = tail call i64 @floor(float %5)
%7 = sitofp i64 %6 to float
%8 = tail call float @llvm.fmuladd.f32(float %7, float -3.600000e+02, float %0)
%9 = fdiv float %8, 6.000000e+01
%10 = tail call i64 @floor(float %9)
%11 = trunc i64 %10 to i32
%12 = icmp eq i32 %11, 6
%13 = icmp sgt i32 %11, 0
%14 = select i1 %13, i32 %11, i32 0
%15 = select i1 %12, i32 5, i32 %14
%16 = sitofp i32 %15 to float
%17 = fsub float %9, %16
%18 = fsub float 1.000000e+00, %17
switch i32 %15, label %24 [
i32 0, label %26
i32 1, label %19
i32 2, label %20
i32 3, label %21
i32 4, label %22
i32 5, label %23
]
19: ; preds = %4
br label %26
20: ; preds = %4
br label %26
21: ; preds = %4
br label %26
22: ; preds = %4
br label %26
23: ; preds = %4
br label %26
24: ; preds = %4
%25 = tail call i32 (...) @abort()
unreachable
26: ; preds = %4, %23, %22, %21, %20, %19
%27 = phi float [ 1.000000e+00, %23 ], [ %17, %22 ], [ 0.000000e+00, %21 ], [ 0.000000e+00, %20 ], [ %18, %19 ], [ 1.000000e+00, %4 ]
%28 = phi float [ 0.000000e+00, %23 ], [ 0.000000e+00, %22 ], [ %18, %21 ], [ 1.000000e+00, %20 ], [ 1.000000e+00, %19 ], [ %17, %4 ]
%29 = phi float [ %18, %23 ], [ 1.000000e+00, %22 ], [ 1.000000e+00, %21 ], [ %17, %20 ], [ 0.000000e+00, %19 ], [ 0.000000e+00, %4 ]
store float %27, float* %1
store float %28, float* %2
store float %29, float* %3
ret void
}