#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 Interpolate(double, double, double, double, double);
double JetPaletteBase(double val) {
  if (val <= -0.75)
    return 0;
  else if (val <= -0.25)
    return Interpolate(val, 0.0, -0.75, 1.0, -0.25);
  else if (val <= 0.25)
    return 1.0;
  else if (val <= 0.75)
    return Interpolate(val, 1.0, 0.25, 0.0, 0.75);
  else
    return 0.0;
}


x86 assembly (clang, -O0):
<JetPaletteBase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xedb(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     113d <JetPaletteBase+0x2d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ee <JetPaletteBase+0xde>
movsd  0xec3(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     117f <JetPaletteBase+0x6f>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
movsd  0xea0(%rip),%xmm2
movsd  0xeb8(%rip),%xmm3
movsd  0xe98(%rip),%xmm4
call   1030 <Interpolate@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11ee <JetPaletteBase+0xde>
movsd  0xe89(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11a4 <JetPaletteBase+0x94>
movsd  0xe86(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ee <JetPaletteBase+0xde>
movsd  0xe6c(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11e6 <JetPaletteBase+0xd6>
movsd  -0x10(%rbp),%xmm0
movsd  0xe5c(%rip),%xmm1
movsd  0xe44(%rip),%xmm2
xorps  %xmm3,%xmm3
movsd  0xe41(%rip),%xmm4
call   1030 <Interpolate@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11ee <JetPaletteBase+0xde>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<JetPaletteBase>:
xorps  %xmm1,%xmm1
movsd  0xee5(%rip),%xmm2
ucomisd %xmm0,%xmm2
jae    114b <JetPaletteBase+0x3b>
movsd  0xedf(%rip),%xmm2
ucomisd %xmm0,%xmm2
jae    114f <JetPaletteBase+0x3f>
movsd  0xee1(%rip),%xmm2
ucomisd %xmm0,%xmm2
jae    116f <JetPaletteBase+0x5f>
movsd  0xedb(%rip),%xmm2
ucomisd %xmm0,%xmm2
jae    1178 <JetPaletteBase+0x68>
movaps %xmm1,%xmm0
ret
movsd  0xea9(%rip),%xmm2
movsd  0xeb1(%rip),%xmm3
movsd  0xea1(%rip),%xmm4
xorps  %xmm1,%xmm1
jmp    1030 <Interpolate@plt>
movsd  0xe99(%rip),%xmm0
ret
movsd  0xe90(%rip),%xmm1
movsd  0xe90(%rip),%xmm2
movsd  0xe90(%rip),%xmm4
xorps  %xmm3,%xmm3
jmp    1030 <Interpolate@plt>

LLVM IR (-O0):
define double @JetPaletteBase(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp ole double %4, -7.500000e-01
br i1 %5, label %6, label %7
6: ; preds = %1
store double 0.000000e+00, double* %2
br label %24
7: ; preds = %1
%8 = load double, double* %3
%9 = fcmp ole double %8, -2.500000e-01
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load double, double* %3
%12 = call double @Interpolate(double %11, double 0.000000e+00, double -7.500000e-01, double 1.000000e+00, double -2.500000e-01)
store double %12, double* %2
br label %24
13: ; preds = %7
%14 = load double, double* %3
%15 = fcmp ole double %14, 2.500000e-01
br i1 %15, label %16, label %17
16: ; preds = %13
store double 1.000000e+00, double* %2
br label %24
17: ; preds = %13
%18 = load double, double* %3
%19 = fcmp ole double %18, 7.500000e-01
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load double, double* %3
%22 = call double @Interpolate(double %21, double 1.000000e+00, double 2.500000e-01, double 0.000000e+00, double 7.500000e-01)
store double %22, double* %2
br label %24
23: ; preds = %17
store double 0.000000e+00, double* %2
br label %24
24: ; preds = %23, %20, %16, %10, %6
%25 = load double, double* %2
ret double %25
}

LLVM IR (-O2):
define double @JetPaletteBase(double %0) {
%2 = fcmp ugt double %0, -7.500000e-01
br i1 %2, label %3, label %13
3: ; preds = %1
%4 = fcmp ugt double %0, -2.500000e-01
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call double @Interpolate(double %0, double 0.000000e+00, double -7.500000e-01, double 1.000000e+00, double -2.500000e-01)
br label %13
7: ; preds = %3
%8 = fcmp ugt double %0, 2.500000e-01
br i1 %8, label %9, label %13
9: ; preds = %7
%10 = fcmp ugt double %0, 7.500000e-01
br i1 %10, label %13, label %11
11: ; preds = %9
%12 = tail call double @Interpolate(double %0, double 1.000000e+00, double 2.500000e-01, double 0.000000e+00, double 7.500000e-01)
br label %13
13: ; preds = %9, %7, %1, %11, %5
%14 = phi double [ %6, %5 ], [ %12, %11 ], [ 0.000000e+00, %1 ], [ 1.000000e+00, %7 ], [ 0.000000e+00, %9 ]
ret double %14
}