#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 */
scalar_t__ isnan(float const);
double ls2_gradation(float const);
void __attribute__((__nonnull__, __gnu___, __always___, __const__))
ls2_pick_color_locbased(const float sample, double *r, double *g, double *b,
                        double __attribute__((__unused__)) * a) {
  const float good_color = 50.0F;
  const float bad_color = 250.0F;
  if (isnan(sample)) {
    *r = 1.0;
    *g = 0.0;
    *b = 1.0;
  } else if (sample < good_color) {
    const double t = ls2_gradation(sample / 50.0);
    *r = t;
    *g = 1.0;
    *b = t;
  } else if (sample < bad_color) {
    const double t =
        ls2_gradation(1.0 - (sample - good_color) / (bad_color - good_color));
    *r = t;
    *g = t;
    *b = t;
  } else {
    *r = 0.0;
    *g = 0.0;
    *b = 1.0;
  }
}


x86 assembly (clang, -O0):
<ls2_pick_color_locbased>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movss  0xebf(%rip),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  0xeae(%rip),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x4(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     119b <ls2_pick_color_locbased+0x7b>
mov    -0x10(%rbp),%rax
movsd  0xe99(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  0xe7e(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    12a8 <ls2_pick_color_locbased+0x188>
movss  0xe61(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    11ff <ls2_pick_color_locbased+0xdf>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe5a(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <ls2_gradation@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  0xe27(%rip),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    12a3 <ls2_pick_color_locbased+0x183>
movss  0xdf9(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    1278 <ls2_pick_color_locbased+0x158>
movss  -0x4(%rbp),%xmm0
movss  0xde6(%rip),%xmm1
subss  %xmm1,%xmm0
movss  0xdde(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdd6(%rip),%xmm0
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <ls2_gradation@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    129e <ls2_pick_color_locbased+0x17e>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  0xd76(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    12a3 <ls2_pick_color_locbased+0x183>
jmp    12a8 <ls2_pick_color_locbased+0x188>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ls2_pick_color_locbased>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movss  %xmm0,0xc(%rsp)
call   1040 <isnan@plt>
xorps  %xmm2,%xmm2
movsd  0xeb8(%rip),%xmm1
test   %rax,%rax
je     1152 <ls2_pick_color_locbased+0x32>
movaps %xmm1,%xmm0
jmp    11b8 <ls2_pick_color_locbased+0x98>
movss  0xeae(%rip),%xmm0
movss  0xc(%rsp),%xmm3
ucomiss %xmm3,%xmm0
jbe    117f <ls2_pick_color_locbased+0x5f>
divss  0xe9b(%rip),%xmm3
movaps %xmm3,%xmm0
call   1030 <ls2_gradation@plt>
movsd  0xe83(%rip),%xmm2
jmp    11b5 <ls2_pick_color_locbased+0x95>
xorps  %xmm0,%xmm0
movss  0xe82(%rip),%xmm2
ucomiss %xmm3,%xmm2
xorps  %xmm2,%xmm2
jbe    11b8 <ls2_pick_color_locbased+0x98>
addss  0xe76(%rip),%xmm3
divss  0xe72(%rip),%xmm3
addss  0xe6e(%rip),%xmm3
movaps %xmm3,%xmm0
call   1030 <ls2_gradation@plt>
movaps %xmm0,%xmm2
movaps %xmm0,%xmm1
movsd  %xmm0,(%rbx)
movsd  %xmm2,(%r15)
movsd  %xmm1,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @ls2_pick_color_locbased(float %0, double* %1, double* %2, double* %3, double* %4) {
%6 = alloca float
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca float
%12 = alloca float
%13 = alloca double
%14 = alloca double
store float %0, float* %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
store float 5.000000e+01, float* %11
store float 2.500000e+02, float* %12
%15 = load float, float* %6
%16 = call i64 @isnan(float %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %5
%19 = load double*, double** %7
store double 1.000000e+00, double* %19
%20 = load double*, double** %8
store double 0.000000e+00, double* %20
%21 = load double*, double** %9
store double 1.000000e+00, double* %21
br label %59
22: ; preds = %5
%23 = load float, float* %6
%24 = fcmp olt float %23, 5.000000e+01
br i1 %24, label %25, label %36
25: ; preds = %22
%26 = load float, float* %6
%27 = fpext float %26 to double
%28 = fdiv double %27, 5.000000e+01
%29 = fptrunc double %28 to float
%30 = call double @ls2_gradation(float %29)
store double %30, double* %13
%31 = load double, double* %13
%32 = load double*, double** %7
store double %31, double* %32
%33 = load double*, double** %8
store double 1.000000e+00, double* %33
%34 = load double, double* %13
%35 = load double*, double** %9
store double %34, double* %35
br label %58
36: ; preds = %22
%37 = load float, float* %6
%38 = fcmp olt float %37, 2.500000e+02
br i1 %38, label %39, label %53
39: ; preds = %36
%40 = load float, float* %6
%41 = fsub float %40, 5.000000e+01
%42 = fdiv float %41, 2.000000e+02
%43 = fpext float %42 to double
%44 = fsub double 1.000000e+00, %43
%45 = fptrunc double %44 to float
%46 = call double @ls2_gradation(float %45)
store double %46, double* %14
%47 = load double, double* %14
%48 = load double*, double** %7
store double %47, double* %48
%49 = load double, double* %14
%50 = load double*, double** %8
store double %49, double* %50
%51 = load double, double* %14
%52 = load double*, double** %9
store double %51, double* %52
br label %57
53: ; preds = %36
%54 = load double*, double** %7
store double 0.000000e+00, double* %54
%55 = load double*, double** %8
store double 0.000000e+00, double* %55
%56 = load double*, double** %9
store double 1.000000e+00, double* %56
br label %57
57: ; preds = %53, %39
br label %58
58: ; preds = %57, %25
br label %59
59: ; preds = %58, %18
ret void
}

LLVM IR (-O2):
define void @ls2_pick_color_locbased(float %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double* nocapture %4) {
%6 = tail call i64 @isnan(float %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = fcmp olt float %0, 5.000000e+01
br i1 %9, label %10, label %13
10: ; preds = %8
%11 = fdiv float %0, 5.000000e+01
%12 = tail call double @ls2_gradation(float %11)
br label %20
13: ; preds = %8
%14 = fcmp olt float %0, 2.500000e+02
br i1 %14, label %15, label %20
15: ; preds = %13
%16 = fadd float %0, -5.000000e+01
%17 = fdiv float %16, 2.000000e+02
%18 = fsub float 1.000000e+00, %17
%19 = tail call double @ls2_gradation(float %18)
br label %20
20: ; preds = %13, %5, %10, %15
%21 = phi double [ %12, %10 ], [ %19, %15 ], [ 1.000000e+00, %5 ], [ 0.000000e+00, %13 ]
%22 = phi double [ 1.000000e+00, %10 ], [ %19, %15 ], [ 0.000000e+00, %5 ], [ 0.000000e+00, %13 ]
%23 = phi double [ %12, %10 ], [ %19, %15 ], [ 1.000000e+00, %5 ], [ 1.000000e+00, %13 ]
store double %21, double* %1
store double %22, double* %2
store double %23, double* %3
ret void
}