#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*/ assert(int);
double cbrt(double);
scalar_t__ isnan(float const);
void __attribute__((__nonnull__, __gnu___, __always___, __const__))
ls2_pick_color_density(const float sample, double *restrict hue,
                       double *restrict saturation,
                       double *restrict lightness) {
  if (isnan(sample)) {
    *hue = 300.0;
    *saturation = 1.0;
    *lightness = 0.5;
  } else {
    assert(0.0 <= sample && sample <= 1.0);
    const double t = cbrt(1.0 - sample);
    if (sample <= 0.25) {
      *hue = 150.0;
    } else if (0.25 < sample && sample <= 0.5) {
      *hue = 120.0;
    } else if (0.5 < sample && sample <= 0.75) {
      *hue = 90.0;
    } else if (0.75 < sample && sample <= 0.95) {
      *hue = 60.0;
    } else if (0.95 < sample && sample <= 0.98) {
      *hue = 30.0;
    } else if (0.98 < sample && sample <= 0.99) {
      *hue = 0.0;
    } else {
      *hue = 300.0;
    }
    *saturation = 1.0;
    *lightness = t;
  }
}


x86 assembly (clang, -O0):
<ls2_pick_color_density>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movss  -0x4(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     1192 <ls2_pick_color_density+0x62>
mov    -0x10(%rbp),%rax
movsd  0xecf(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  0xe87(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  0xe87(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    13dc <ls2_pick_color_density+0x2ac>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x29(%rbp)
jb     11c8 <ls2_pick_color_density+0x98>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe42(%rip),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe1a(%rip),%xmm0
subsd  %xmm1,%xmm0
call   1050 <cbrt@plt>
movsd  %xmm0,-0x28(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe03(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1224 <ls2_pick_color_density+0xf4>
mov    -0x10(%rbp),%rax
movsd  0xe45(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    13bf <ls2_pick_color_density+0x28f>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdd3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    126f <ls2_pick_color_density+0x13f>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdc0(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     126f <ls2_pick_color_density+0x13f>
mov    -0x10(%rbp),%rax
movsd  0xdf2(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    13ba <ls2_pick_color_density+0x28a>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd90(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12ba <ls2_pick_color_density+0x18a>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd7d(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     12ba <ls2_pick_color_density+0x18a>
mov    -0x10(%rbp),%rax
movsd  0xd9f(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    13b5 <ls2_pick_color_density+0x285>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd4d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1305 <ls2_pick_color_density+0x1d5>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd3a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1305 <ls2_pick_color_density+0x1d5>
mov    -0x10(%rbp),%rax
movsd  0xd4c(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    13b0 <ls2_pick_color_density+0x280>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd0a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1350 <ls2_pick_color_density+0x220>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xcf7(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1350 <ls2_pick_color_density+0x220>
mov    -0x10(%rbp),%rax
movsd  0xcf9(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    13ab <ls2_pick_color_density+0x27b>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcc7(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1396 <ls2_pick_color_density+0x266>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xcb4(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1396 <ls2_pick_color_density+0x266>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    13a6 <ls2_pick_color_density+0x276>
mov    -0x10(%rbp),%rax
movsd  0xc96(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    13ab <ls2_pick_color_density+0x27b>
jmp    13b0 <ls2_pick_color_density+0x280>
jmp    13b5 <ls2_pick_color_density+0x285>
jmp    13ba <ls2_pick_color_density+0x28a>
jmp    13bf <ls2_pick_color_density+0x28f>
mov    -0x18(%rbp),%rax
movsd  0xc35(%rip),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ls2_pick_color_density>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movss  %xmm0,0xc(%rsp)
call   1040 <isnan@plt>
test   %rax,%rax
je     1167 <ls2_pick_color_density+0x37>
movsd  0xea6(%rip),%xmm0
movsd  0xea6(%rip),%xmm1
jmp    11f2 <ls2_pick_color_density+0xc2>
xorps  %xmm0,%xmm0
movss  0xc(%rsp),%xmm1
ucomiss %xmm0,%xmm1
setae  %al
movss  0xeda(%rip),%xmm0
ucomiss %xmm1,%xmm0
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movaps %xmm0,0x10(%rsp)
setae  %cl
and    %al,%cl
movzbl %cl,%edi
call   1030 <assert@plt>
movsd  0xe6e(%rip),%xmm0
subsd  0x10(%rsp),%xmm0
call   1050 <cbrt@plt>
movss  0xea7(%rip),%xmm1
ucomiss 0xc(%rsp),%xmm1
jae    11ea <ls2_pick_color_density+0xba>
movapd 0x10(%rsp),%xmm4
movss  0xc(%rsp),%xmm1
ucomiss 0xe8d(%rip),%xmm1
jbe    1212 <ls2_pick_color_density+0xe2>
movss  0xe87(%rip),%xmm1
ucomiss 0xc(%rsp),%xmm1
jb     1212 <ls2_pick_color_density+0xe2>
movsd  0xe38(%rip),%xmm1
jmp    11f2 <ls2_pick_color_density+0xc2>
movsd  0xe26(%rip),%xmm1
movsd  %xmm1,(%rbx)
movabs $0x3ff0000000000000,%rax
mov    %rax,(%r15)
movsd  %xmm0,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
movss  0xc(%rsp),%xmm1
ucomiss 0xe41(%rip),%xmm1
jbe    123a <ls2_pick_color_density+0x10a>
movss  0xe3b(%rip),%xmm1
ucomiss 0xc(%rsp),%xmm1
jb     123a <ls2_pick_color_density+0x10a>
movsd  0xdf0(%rip),%xmm1
jmp    11f2 <ls2_pick_color_density+0xc2>
movss  0xc(%rsp),%xmm1
ucomiss 0xe1d(%rip),%xmm1
jbe    1261 <ls2_pick_color_density+0x131>
movsd  0xde7(%rip),%xmm1
ucomisd %xmm4,%xmm1
jb     1261 <ls2_pick_color_density+0x131>
movsd  0xdd1(%rip),%xmm1
jmp    11f2 <ls2_pick_color_density+0xc2>
ucomisd 0xdcf(%rip),%xmm4
jbe    1286 <ls2_pick_color_density+0x156>
movsd  0xdd5(%rip),%xmm1
ucomisd %xmm4,%xmm1
jb     1286 <ls2_pick_color_density+0x156>
movsd  0xdbf(%rip),%xmm1
jmp    11f2 <ls2_pick_color_density+0xc2>
movsd  0xdba(%rip),%xmm1
cmpnltsd %xmm4,%xmm1
cmpnlesd 0xdb4(%rip),%xmm4
movsd  0xd64(%rip),%xmm2
andpd  %xmm2,%xmm4
movapd %xmm1,%xmm3
andnpd %xmm4,%xmm3
andpd  %xmm2,%xmm1
orpd   %xmm3,%xmm1
jmp    11f2 <ls2_pick_color_density+0xc2>

LLVM IR (-O0):
define void @ls2_pick_color_density(float %0, double* noalias %1, double* noalias %2, double* noalias %3) {
%5 = alloca float
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
store float %0, float* %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%10 = load float, float* %5
%11 = call i64 @isnan(float %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %4
%14 = load double*, double** %6
store double 3.000000e+02, double* %14
%15 = load double*, double** %7
store double 1.000000e+00, double* %15
%16 = load double*, double** %8
store double 5.000000e-01, double* %16
br label %99
17: ; preds = %4
%18 = load float, float* %5
%19 = fpext float %18 to double
%20 = fcmp ole double 0.000000e+00, %19
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load float, float* %5
%23 = fpext float %22 to double
%24 = fcmp ole double %23, 1.000000e+00
br label %25
25: ; preds = %21, %17
%26 = phi i1 [ false, %17 ], [ %24, %21 ]
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load float, float* %5
%30 = fpext float %29 to double
%31 = fsub double 1.000000e+00, %30
%32 = call double @cbrt(double %31)
store double %32, double* %9
%33 = load float, float* %5
%34 = fpext float %33 to double
%35 = fcmp ole double %34, 2.500000e-01
br i1 %35, label %36, label %38
36: ; preds = %25
%37 = load double*, double** %6
store double 1.500000e+02, double* %37
br label %95
38: ; preds = %25
%39 = load float, float* %5
%40 = fpext float %39 to double
%41 = fcmp olt double 2.500000e-01, %40
br i1 %41, label %42, label %48
42: ; preds = %38
%43 = load float, float* %5
%44 = fpext float %43 to double
%45 = fcmp ole double %44, 5.000000e-01
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = load double*, double** %6
store double 1.200000e+02, double* %47
br label %94
48: ; preds = %42, %38
%49 = load float, float* %5
%50 = fpext float %49 to double
%51 = fcmp olt double 5.000000e-01, %50
br i1 %51, label %52, label %58
52: ; preds = %48
%53 = load float, float* %5
%54 = fpext float %53 to double
%55 = fcmp ole double %54, 7.500000e-01
br i1 %55, label %56, label %58
56: ; preds = %52
%57 = load double*, double** %6
store double 9.000000e+01, double* %57
br label %93
58: ; preds = %52, %48
%59 = load float, float* %5
%60 = fpext float %59 to double
%61 = fcmp olt double 7.500000e-01, %60
br i1 %61, label %62, label %68
62: ; preds = %58
%63 = load float, float* %5
%64 = fpext float %63 to double
%65 = fcmp ole double %64, 0x3FEE666666666666
br i1 %65, label %66, label %68
66: ; preds = %62
%67 = load double*, double** %6
store double 6.000000e+01, double* %67
br label %92
68: ; preds = %62, %58
%69 = load float, float* %5
%70 = fpext float %69 to double
%71 = fcmp olt double 0x3FEE666666666666, %70
br i1 %71, label %72, label %78
72: ; preds = %68
%73 = load float, float* %5
%74 = fpext float %73 to double
%75 = fcmp ole double %74, 0x3FEF5C28F5C28F5C
br i1 %75, label %76, label %78
76: ; preds = %72
%77 = load double*, double** %6
store double 3.000000e+01, double* %77
br label %91
78: ; preds = %72, %68
%79 = load float, float* %5
%80 = fpext float %79 to double
%81 = fcmp olt double 0x3FEF5C28F5C28F5C, %80
br i1 %81, label %82, label %88
82: ; preds = %78
%83 = load float, float* %5
%84 = fpext float %83 to double
%85 = fcmp ole double %84, 0x3FEFAE147AE147AE
br i1 %85, label %86, label %88
86: ; preds = %82
%87 = load double*, double** %6
store double 0.000000e+00, double* %87
br label %90
88: ; preds = %82, %78
%89 = load double*, double** %6
store double 3.000000e+02, double* %89
br label %90
90: ; preds = %88, %86
br label %91
91: ; preds = %90, %76
br label %92
92: ; preds = %91, %66
br label %93
93: ; preds = %92, %56
br label %94
94: ; preds = %93, %46
br label %95
95: ; preds = %94, %36
%96 = load double*, double** %7
store double 1.000000e+00, double* %96
%97 = load double, double* %9
%98 = load double*, double** %8
store double %97, double* %98
br label %99
99: ; preds = %95, %13
ret void
}

LLVM IR (-O2):
define void @ls2_pick_color_density(float %0, double* noalias nocapture %1, double* noalias nocapture %2, double* noalias nocapture %3) {
%5 = tail call i64 @isnan(float %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %38
7: ; preds = %4
%8 = fpext float %0 to double
%9 = fcmp oge float %0, 0.000000e+00
%10 = fcmp ole float %0, 1.000000e+00
%11 = and i1 %9, %10
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = fsub double 1.000000e+00, %8
%15 = tail call double @cbrt(double %14)
%16 = fcmp ugt float %0, 2.500000e-01
br i1 %16, label %17, label %38
17: ; preds = %7
%18 = fcmp ule float %0, 2.500000e-01
%19 = fcmp ugt float %0, 5.000000e-01
%20 = or i1 %18, %19
br i1 %20, label %21, label %38
21: ; preds = %17
%22 = fcmp ule float %0, 5.000000e-01
%23 = fcmp ugt float %0, 7.500000e-01
%24 = or i1 %22, %23
br i1 %24, label %25, label %38
25: ; preds = %21
%26 = fcmp ule float %0, 7.500000e-01
%27 = fcmp ugt double %8, 0x3FEE666666666666
%28 = or i1 %26, %27
br i1 %28, label %29, label %38
29: ; preds = %25
%30 = fcmp ule double %8, 0x3FEE666666666666
%31 = fcmp ugt double %8, 0x3FEF5C28F5C28F5C
%32 = or i1 %30, %31
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = fcmp ule double %8, 0x3FEF5C28F5C28F5C
%35 = fcmp ugt double %8, 0x3FEFAE147AE147AE
%36 = or i1 %34, %35
%37 = select i1 %36, double 3.000000e+02, double 0.000000e+00
br label %38
38: ; preds = %33, %29, %25, %21, %17, %7, %4
%39 = phi double [ 3.000000e+02, %4 ], [ 1.500000e+02, %7 ], [ 1.200000e+02, %17 ], [ 9.000000e+01, %21 ], [ 6.000000e+01, %25 ], [ 3.000000e+01, %29 ], [ %37, %33 ]
%40 = phi double [ 5.000000e-01, %4 ], [ %15, %7 ], [ %15, %17 ], [ %15, %21 ], [ %15, %25 ], [ %15, %29 ], [ %15, %33 ]
store double %39, double* %1
store double 1.000000e+00, double* %2
store double %40, double* %3
ret void
}