#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__ floor(float);
float saturate(float);
float X360GammaToLinear(float fl360GammaValue) {
  float flLinearValue;
  fl360GammaValue = saturate(fl360GammaValue);
  if (fl360GammaValue < (96.0f / 255.0f)) {
    if (fl360GammaValue < (64.0f / 255.0f)) {
      flLinearValue = fl360GammaValue * 255.0f;
    } else {
      flLinearValue = fl360GammaValue * (255.0f * 2.0f) - 64.0f;
      flLinearValue += floor(flLinearValue * (1.0f / 512.0f));
    }
  } else {
    if (fl360GammaValue < (192.0f / 255.0f)) {
      flLinearValue = fl360GammaValue * (255.0f * 4.0f) - 256.0f;
      flLinearValue += floor(flLinearValue * (1.0f / 256.0f));
    } else {
      flLinearValue = fl360GammaValue * (255.0f * 8.0f) - 1024.0f;
      flLinearValue += floor(flLinearValue * (1.0f / 128.0f));
    }
  }
  flLinearValue *= 1.0f / 1023.0f;
  flLinearValue = saturate(flLinearValue);
  return flLinearValue;
}


x86 assembly (clang, -O0):
<X360GammaToLinear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <saturate@plt>
movss  %xmm0,-0x4(%rbp)
movss  0xebc(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    11bf <X360GammaToLinear+0x9f>
movss  0xeca(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    1177 <X360GammaToLinear+0x57>
movss  0xec8(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11ba <X360GammaToLinear+0x9a>
movss  -0x4(%rbp),%xmm0
movss  0xea4(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe9c(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xe83(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
cvtsi2ss %rax,%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1261 <X360GammaToLinear+0x141>
movss  0xe3d(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    1219 <X360GammaToLinear+0xf9>
movss  -0x4(%rbp),%xmm0
movss  0xe3a(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe32(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xe19(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
cvtsi2ss %rax,%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    125c <X360GammaToLinear+0x13c>
movss  -0x4(%rbp),%xmm0
movss  0xde6(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xdde(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xdc5(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
cvtsi2ss %rax,%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1261 <X360GammaToLinear+0x141>
movss  0xdcb(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <saturate@plt>
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<X360GammaToLinear>:
push   %rax
call   1030 <saturate@plt>
movaps %xmm0,%xmm1
movss  0xecf(%rip),%xmm0
ucomiss %xmm1,%xmm0
jbe    1150 <X360GammaToLinear+0x30>
movss  0xee2(%rip),%xmm0
ucomiss %xmm1,%xmm0
jbe    117d <X360GammaToLinear+0x5d>
mulss  0xee5(%rip),%xmm1
jmp    11d6 <X360GammaToLinear+0xb6>
movss  0xeac(%rip),%xmm0
ucomiss %xmm1,%xmm0
jbe    119d <X360GammaToLinear+0x7d>
mulss  0xeaf(%rip),%xmm1
addss  0xeab(%rip),%xmm1
movss  %xmm1,0x4(%rsp)
movss  0xea1(%rip),%xmm0
jmp    11bb <X360GammaToLinear+0x9b>
mulss  0xe9f(%rip),%xmm1
addss  0xe9b(%rip),%xmm1
movss  %xmm1,0x4(%rsp)
movss  0xe91(%rip),%xmm0
jmp    11bb <X360GammaToLinear+0x9b>
mulss  0xe63(%rip),%xmm1
addss  0xe5f(%rip),%xmm1
movss  %xmm1,0x4(%rsp)
movss  0xe55(%rip),%xmm0
mulss  %xmm1,%xmm0
call   1040 <floor@plt>
movss  0x4(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  %xmm0,%xmm1
mulss  0xe56(%rip),%xmm1
movaps %xmm1,%xmm0
pop    %rax
jmp    1030 <saturate@plt>

LLVM IR (-O0):
define float @X360GammaToLinear(float %0) {
%2 = alloca float
%3 = alloca float
store float %0, float* %2
%4 = load float, float* %2
%5 = call float @saturate(float %4)
store float %5, float* %2
%6 = load float, float* %2
%7 = fcmp olt float %6, 0x3FD8181820000000
br i1 %7, label %8, label %24
8: ; preds = %1
%9 = load float, float* %2
%10 = fcmp olt float %9, 0x3FD0101020000000
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load float, float* %2
%13 = fmul float %12, 2.550000e+02
store float %13, float* %3
br label %23
14: ; preds = %8
%15 = load float, float* %2
%16 = call float @llvm.fmuladd.f32(float %15, float 5.100000e+02, float -6.400000e+01)
store float %16, float* %3
%17 = load float, float* %3
%18 = fmul float %17, 0x3F60000000000000
%19 = call i64 @floor(float %18)
%20 = sitofp i64 %19 to float
%21 = load float, float* %3
%22 = fadd float %21, %20
store float %22, float* %3
br label %23
23: ; preds = %14, %11
br label %46
24: ; preds = %1
%25 = load float, float* %2
%26 = fcmp olt float %25, 0x3FE8181820000000
br i1 %26, label %27, label %36
27: ; preds = %24
%28 = load float, float* %2
%29 = call float @llvm.fmuladd.f32(float %28, float 1.020000e+03, float -2.560000e+02)
store float %29, float* %3
%30 = load float, float* %3
%31 = fmul float %30, 3.906250e-03
%32 = call i64 @floor(float %31)
%33 = sitofp i64 %32 to float
%34 = load float, float* %3
%35 = fadd float %34, %33
store float %35, float* %3
br label %45
36: ; preds = %24
%37 = load float, float* %2
%38 = call float @llvm.fmuladd.f32(float %37, float 2.040000e+03, float -1.024000e+03)
store float %38, float* %3
%39 = load float, float* %3
%40 = fmul float %39, 7.812500e-03
%41 = call i64 @floor(float %40)
%42 = sitofp i64 %41 to float
%43 = load float, float* %3
%44 = fadd float %43, %42
store float %44, float* %3
br label %45
45: ; preds = %36, %27
br label %46
46: ; preds = %45, %23
%47 = load float, float* %3
%48 = fmul float %47, 0x3F50040100000000
store float %48, float* %3
%49 = load float, float* %3
%50 = call float @saturate(float %49)
store float %50, float* %3
%51 = load float, float* %3
ret float %51
}

LLVM IR (-O2):
define float @X360GammaToLinear(float %0) {
%2 = tail call float @saturate(float %0)
%3 = fcmp olt float %2, 0x3FD8181820000000
br i1 %3, label %4, label %14
4: ; preds = %1
%5 = fcmp olt float %2, 0x3FD0101020000000
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = fmul float %2, 2.550000e+02
br label %28
8: ; preds = %4
%9 = tail call float @llvm.fmuladd.f32(float %2, float 5.100000e+02, float -6.400000e+01)
%10 = fmul float %9, 0x3F60000000000000
%11 = tail call i64 @floor(float %10)
%12 = sitofp i64 %11 to float
%13 = fadd float %9, %12
br label %28
14: ; preds = %1
%15 = fcmp olt float %2, 0x3FE8181820000000
br i1 %15, label %16, label %22
16: ; preds = %14
%17 = tail call float @llvm.fmuladd.f32(float %2, float 1.020000e+03, float -2.560000e+02)
%18 = fmul float %17, 3.906250e-03
%19 = tail call i64 @floor(float %18)
%20 = sitofp i64 %19 to float
%21 = fadd float %17, %20
br label %28
22: ; preds = %14
%23 = tail call float @llvm.fmuladd.f32(float %2, float 2.040000e+03, float -1.024000e+03)
%24 = fmul float %23, 7.812500e-03
%25 = tail call i64 @floor(float %24)
%26 = sitofp i64 %25 to float
%27 = fadd float %23, %26
br label %28
28: ; preds = %16, %22, %6, %8
%29 = phi float [ %7, %6 ], [ %13, %8 ], [ %21, %16 ], [ %27, %22 ]
%30 = fmul float %29, 0x3F50040100000000
%31 = tail call float @saturate(float %30)
ret float %31
}