#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 */
double cbrt(double);
void __attribute__((__nonnull__, __gnu___, __always___, __const__))
ls2_pick_color_inverted(const double sample, double *restrict h,
                        double *restrict s, double *restrict l) {
  *h = 0.0;
  if (sample > 0.0) {
    static const double alpha = (0.04 * 0.04 * 0.04);
    double t = sample;
    t = (1.0 - alpha) * t + alpha;
    *l = 1.0 - cbrt(t);
  } else {
    *l = 1.0;
  }
  if (sample < 0.97) {
    *s = 0.0;
  } else {
    *s = 0.8;
  }
}


x86 assembly (clang, -O0):
<ls2_pick_color_inverted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1198 <ls2_pick_color_inverted+0x88>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xeab(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea7(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <cbrt@plt>
movaps %xmm0,%xmm1
movsd  0xe79(%rip),%xmm0
subsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11a8 <ls2_pick_color_inverted+0x98>
mov    -0x20(%rbp),%rax
movsd  0xe5c(%rip),%xmm0
movsd  %xmm0,(%rax)
movsd  0xe68(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11cb <ls2_pick_color_inverted+0xbb>
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    11db <ls2_pick_color_inverted+0xcb>
mov    -0x18(%rbp),%rax
movsd  0xe49(%rip),%xmm0
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ls2_pick_color_inverted>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
movapd %xmm0,%xmm2
movq   $0x0,(%rdi)
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jbe    1163 <ls2_pick_color_inverted+0x53>
movsd  0xece(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xeca(%rip),%xmm0
movapd %xmm2,(%rsp)
call   1030 <cbrt@plt>
movapd (%rsp),%xmm2
movsd  0xea3(%rip),%xmm1
subsd  %xmm0,%xmm1
jmp    116b <ls2_pick_color_inverted+0x5b>
movsd  0xe95(%rip),%xmm1
cmpltsd 0xea4(%rip),%xmm2
movsd  %xmm1,(%rbx)
movsd  0xea0(%rip),%xmm0
andnpd %xmm0,%xmm2
movlpd %xmm2,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@ls2_pick_color_inverted.alpha = internal constant double 0x3F10C6F7A0B5ED8E
define void @ls2_pick_color_inverted(double %0, double* noalias %1, double* noalias %2, double* noalias %3) {
%5 = alloca double
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
store double %0, double* %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%10 = load double*, double** %6
store double 0.000000e+00, double* %10
%11 = load double, double* %5
%12 = fcmp ogt double %11, 0.000000e+00
br i1 %12, label %13, label %21
13: ; preds = %4
%14 = load double, double* %5
store double %14, double* %9
%15 = load double, double* %9
%16 = call double @llvm.fmuladd.f64(double 9.999360e-01, double %15, double 0x3F10C6F7A0B5ED8E)
store double %16, double* %9
%17 = load double, double* %9
%18 = call double @cbrt(double %17)
%19 = fsub double 1.000000e+00, %18
%20 = load double*, double** %8
store double %19, double* %20
br label %23
21: ; preds = %4
%22 = load double*, double** %8
store double 1.000000e+00, double* %22
br label %23
23: ; preds = %21, %13
%24 = load double, double* %5
%25 = fcmp olt double %24, 0x3FEF0A3D70A3D70A
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = load double*, double** %7
store double 0.000000e+00, double* %27
br label %30
28: ; preds = %23
%29 = load double*, double** %7
store double 8.000000e-01, double* %29
br label %30
30: ; preds = %28, %26
ret void
}

LLVM IR (-O2):
define void @ls2_pick_color_inverted(double %0, double* noalias nocapture %1, double* noalias nocapture %2, double* noalias nocapture %3) {
store double 0.000000e+00, double* %1
%5 = fcmp ogt double %0, 0.000000e+00
br i1 %5, label %6, label %10
6: ; preds = %4
%7 = tail call double @llvm.fmuladd.f64(double %0, double 9.999360e-01, double 0x3F10C6F7A0B5ED8E)
%8 = tail call double @cbrt(double %7)
%9 = fsub double 1.000000e+00, %8
br label %10
10: ; preds = %4, %6
%11 = phi double [ %9, %6 ], [ 1.000000e+00, %4 ]
store double %11, double* %3
%12 = fcmp olt double %0, 0x3FEF0A3D70A3D70A
%13 = select i1 %12, double 0.000000e+00, double 8.000000e-01
store double %13, double* %2
ret void
}