#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 */
long double powl(long double, int);
long double linear_sample_to_srgb_reference(long double in_f) {
  long double tmp;
  if (in_f <= 0.0L) {
    return 0.0L;
  }
  if (in_f >= 1.0L) {
    return 1.0L;
  }
  if (in_f <= 0.00313066844250063L) {
    return in_f * 12.92L;
  } else {
    tmp = powl(in_f, 1 / 2.4L);
    return 1.055L * tmp - 0.055L;
  }
}


x86 assembly (clang, -O0):
<linear_sample_to_srgb_reference>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jb     113c <linear_sample_to_srgb_reference+0x2c>
jmp    1132 <linear_sample_to_srgb_reference+0x22>
fldz
fstpt  -0x10(%rbp)
jmp    11af <linear_sample_to_srgb_reference+0x9f>
fldt   -0x20(%rbp)
fld1
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jb     115c <linear_sample_to_srgb_reference+0x4c>
jmp    1152 <linear_sample_to_srgb_reference+0x42>
fld1
fstpt  -0x10(%rbp)
jmp    11af <linear_sample_to_srgb_reference+0x9f>
fldt   -0x20(%rbp)
fldt   0xe9b(%rip)
fucomip %st(1),%st
fstp   %st(0)
jb     1187 <linear_sample_to_srgb_reference+0x77>
jmp    1174 <linear_sample_to_srgb_reference+0x64>
fldt   -0x20(%rbp)
fldt   0xeb3(%rip)
fmulp  %st,%st(1)
fstpt  -0x10(%rbp)
jmp    11af <linear_sample_to_srgb_reference+0x9f>
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
xor    %edi,%edi
call   1030 <powl@plt>
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
fldt   0xe6e(%rip)
fmulp  %st,%st(1)
fldt   0xe76(%rip)
faddp  %st,%st(1)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linear_sample_to_srgb_reference>:
sub    $0x18,%rsp
fldt   0x20(%rsp)
fldz
fucomi %st(1),%st
jae    1161 <linear_sample_to_srgb_reference+0x51>
fstp   %st(0)
fld1
fxch   %st(1)
fucomi %st(1),%st
fxch   %st(1)
jae    1161 <linear_sample_to_srgb_reference+0x51>
fstp   %st(0)
fldt   0xece(%rip)
fucomip %st(1),%st
jae    1155 <linear_sample_to_srgb_reference+0x45>
fstpt  (%rsp)
xor    %edi,%edi
call   1030 <powl@plt>
fldt   0xeda(%rip)
fmulp  %st,%st(1)
fldt   0xee2(%rip)
faddp  %st,%st(1)
add    $0x18,%rsp
ret
fldt   0xeb5(%rip)
fmulp  %st,%st(1)
fldz
fxch   %st(1)
fstp   %st(1)
add    $0x18,%rsp
ret

LLVM IR (-O0):
define x86_fp80 @linear_sample_to_srgb_reference(x86_fp80 %0) {
%2 = alloca x86_fp80
%3 = alloca x86_fp80
%4 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %3
%5 = load x86_fp80, x86_fp80* %3
%6 = fcmp ole x86_fp80 %5, 0xK00000000000000000000
br i1 %6, label %7, label %8
7: ; preds = %1
store x86_fp80 0xK00000000000000000000, x86_fp80* %2
br label %23
8: ; preds = %1
%9 = load x86_fp80, x86_fp80* %3
%10 = fcmp oge x86_fp80 %9, 0xK3FFF8000000000000000
br i1 %10, label %11, label %12
11: ; preds = %8
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %2
br label %23
12: ; preds = %8
%13 = load x86_fp80, x86_fp80* %3
%14 = fcmp ole x86_fp80 %13, 0xK3FF6CD2BE6933DA6889B
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load x86_fp80, x86_fp80* %3
%17 = fmul x86_fp80 %16, 0xK4002CEB851EB851EB852
store x86_fp80 %17, x86_fp80* %2
br label %23
18: ; preds = %12
%19 = load x86_fp80, x86_fp80* %3
%20 = call x86_fp80 @powl(x86_fp80 %19, i32 0)
store x86_fp80 %20, x86_fp80* %4
%21 = load x86_fp80, x86_fp80* %4
%22 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK3FFF870A3D70A3D70A3D, x86_fp80 %21, x86_fp80 0xKBFFAE147AE147AE147AE)
store x86_fp80 %22, x86_fp80* %2
br label %23
23: ; preds = %18, %15, %11, %7
%24 = load x86_fp80, x86_fp80* %2
ret x86_fp80 %24
}

LLVM IR (-O2):
define x86_fp80 @linear_sample_to_srgb_reference(x86_fp80 %0) {
%2 = fcmp ugt x86_fp80 %0, 0xK00000000000000000000
br i1 %2, label %3, label %12
3: ; preds = %1
%4 = fcmp ult x86_fp80 %0, 0xK3FFF8000000000000000
br i1 %4, label %5, label %12
5: ; preds = %3
%6 = fcmp ugt x86_fp80 %0, 0xK3FF6CD2BE6933DA6889B
br i1 %6, label %9, label %7
7: ; preds = %5
%8 = fmul x86_fp80 %0, 0xK4002CEB851EB851EB852
br label %12
9: ; preds = %5
%10 = tail call x86_fp80 @powl(x86_fp80 %0, i32 0)
%11 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %10, x86_fp80 0xK3FFF870A3D70A3D70A3D, x86_fp80 0xKBFFAE147AE147AE147AE)
br label %12
12: ; preds = %3, %1, %9, %7
%13 = phi x86_fp80 [ %8, %7 ], [ %11, %9 ], [ 0xK00000000000000000000, %1 ], [ 0xK3FFF8000000000000000, %3 ]
ret x86_fp80 %13
}