#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 */
float pow(float, float);
float math_gammaToLinear(float c) {
  if (c > 1.0f)
    return 1.0f;
  else if (c < 0.0f)
    return 0.0f;
  else if (c <= 0.04045)
    return c / 12.92f;
  else
    return pow((c + 0.055f) / 1.055f, 2.4f);
}


x86 assembly (clang, -O0):
<math_gammaToLinear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
movss  0xed6(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1145 <math_gammaToLinear+0x35>
movss  0xec5(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c0 <math_gammaToLinear+0xb0>
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    115f <math_gammaToLinear+0x4f>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c0 <math_gammaToLinear+0xb0>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xea8(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1195 <math_gammaToLinear+0x85>
movss  -0x8(%rbp),%xmm0
movss  0xe89(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c0 <math_gammaToLinear+0xb0>
movss  0xe6f(%rip),%xmm0
addss  -0x8(%rbp),%xmm0
movss  0xe5e(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe4e(%rip),%xmm1
call   1030 <pow@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<math_gammaToLinear>:
movss  0xee8(%rip),%xmm1
ucomiss %xmm1,%xmm0
ja     1162 <math_gammaToLinear+0x52>
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     1162 <math_gammaToLinear+0x52>
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xee4(%rip),%xmm2
ucomisd %xmm1,%xmm2
jae    1157 <math_gammaToLinear+0x47>
addss  0xec6(%rip),%xmm0
divss  0xec2(%rip),%xmm0
movss  0xebe(%rip),%xmm1
jmp    1030 <pow@plt>
divss  0xea5(%rip),%xmm0
movaps %xmm0,%xmm1
movaps %xmm1,%xmm0
ret

LLVM IR (-O0):
define float @math_gammaToLinear(float %0) {
%2 = alloca float
%3 = alloca float
store float %0, float* %3
%4 = load float, float* %3
%5 = fcmp ogt float %4, 1.000000e+00
br i1 %5, label %6, label %7
6: ; preds = %1
store float 1.000000e+00, float* %2
br label %23
7: ; preds = %1
%8 = load float, float* %3
%9 = fcmp olt float %8, 0.000000e+00
br i1 %9, label %10, label %11
10: ; preds = %7
store float 0.000000e+00, float* %2
br label %23
11: ; preds = %7
%12 = load float, float* %3
%13 = fpext float %12 to double
%14 = fcmp ole double %13, 4.045000e-02
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load float, float* %3
%17 = fdiv float %16, 0x4029D70A40000000
store float %17, float* %2
br label %23
18: ; preds = %11
%19 = load float, float* %3
%20 = fadd float %19, 0x3FAC28F5C0000000
%21 = fdiv float %20, 0x3FF0E147A0000000
%22 = call float @pow(float %21, float 0x4003333340000000)
store float %22, float* %2
br label %23
23: ; preds = %18, %15, %10, %6
%24 = load float, float* %2
ret float %24
}

LLVM IR (-O2):
define float @math_gammaToLinear(float %0) {
%2 = fcmp ogt float %0, 1.000000e+00
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = fcmp olt float %0, 0.000000e+00
br i1 %4, label %14, label %5
5: ; preds = %3
%6 = fpext float %0 to double
%7 = fcmp ugt double %6, 4.045000e-02
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = fdiv float %0, 0x4029D70A40000000
br label %14
10: ; preds = %5
%11 = fadd float %0, 0x3FAC28F5C0000000
%12 = fdiv float %11, 0x3FF0E147A0000000
%13 = tail call float @pow(float %12, float 0x4003333340000000)
br label %14
14: ; preds = %3, %1, %10, %8
%15 = phi float [ %9, %8 ], [ %13, %10 ], [ 1.000000e+00, %1 ], [ 0.000000e+00, %3 ]
ret float %15
}