#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 saturate(float);
float X360LinearToGamma(float flLinearValue) {
  float fl360GammaValue;
  flLinearValue = saturate(flLinearValue);
  if (flLinearValue < (128.0f / 1023.0f)) {
    if (flLinearValue < (64.0f / 1023.0f)) {
      fl360GammaValue = flLinearValue * (1023.0f * (1.0f / 255.0f));
    } else {
      fl360GammaValue = flLinearValue * ((1023.0f / 2.0f) * (1.0f / 255.0f)) +
                        (32.0f / 255.0f);
    }
  } else {
    if (flLinearValue < (512.0f / 1023.0f)) {
      fl360GammaValue = flLinearValue * ((1023.0f / 4.0f) * (1.0f / 255.0f)) +
                        (64.0f / 255.0f);
    } else {
      fl360GammaValue = flLinearValue * ((1023.0f / 8.0f) * (1.0f / 255.0f)) +
                        (128.0f / 255.0f);
      if (fl360GammaValue > 1.0f) {
        fl360GammaValue = 1.0f;
      }
    }
  }
  fl360GammaValue = saturate(fl360GammaValue);
  return fl360GammaValue;
}


x86 assembly (clang, -O0):
<X360LinearToGamma>:
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  0xecc(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    118e <X360LinearToGamma+0x7e>
movss  0xed6(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    1167 <X360LinearToGamma+0x57>
movss  0xed0(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1189 <X360LinearToGamma+0x79>
movss  -0x4(%rbp),%xmm0
movss  0xeac(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xea4(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1216 <X360LinearToGamma+0x106>
movss  0xe6e(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    11c7 <X360LinearToGamma+0xb7>
movss  -0x4(%rbp),%xmm0
movss  0xe67(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe5f(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1211 <X360LinearToGamma+0x101>
movss  -0x4(%rbp),%xmm0
movss  0xe38(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe30(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
movss  0xe12(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    120c <X360LinearToGamma+0xfc>
movss  0xe01(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1211 <X360LinearToGamma+0x101>
jmp    1216 <X360LinearToGamma+0x106>
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):
<X360LinearToGamma>:
push   %rax
call   1030 <saturate@plt>
movss  0xee2(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    113e <X360LinearToGamma+0x2e>
movss  0xef1(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1161 <X360LinearToGamma+0x51>
mulss  0xef0(%rip),%xmm0
pop    %rax
jmp    1030 <saturate@plt>
movss  0xebe(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1177 <X360LinearToGamma+0x67>
mulss  0xec1(%rip),%xmm0
addss  0xebd(%rip),%xmm0
pop    %rax
jmp    1030 <saturate@plt>
mulss  0xeb7(%rip),%xmm0
addss  0xeb3(%rip),%xmm0
pop    %rax
jmp    1030 <saturate@plt>
mulss  0xe89(%rip),%xmm0
addss  0xe85(%rip),%xmm0
ucomiss 0xe82(%rip),%xmm0
jbe    1198 <X360LinearToGamma+0x88>
movss  0xe78(%rip),%xmm0
pop    %rax
jmp    1030 <saturate@plt>

LLVM IR (-O0):
define float @X360LinearToGamma(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, 0x3FC0040100000000
br i1 %7, label %8, label %18
8: ; preds = %1
%9 = load float, float* %2
%10 = fcmp olt float %9, 0x3FB0040100000000
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load float, float* %2
%13 = fmul float %12, 0x40100C0C20000000
store float %13, float* %3
br label %17
14: ; preds = %8
%15 = load float, float* %2
%16 = call float @llvm.fmuladd.f32(float %15, float 0x40000C0C20000000, float 0x3FC0101020000000)
store float %16, float* %3
br label %17
17: ; preds = %14, %11
br label %32
18: ; preds = %1
%19 = load float, float* %2
%20 = fcmp olt float %19, 0x3FE0040100000000
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load float, float* %2
%23 = call float @llvm.fmuladd.f32(float %22, float 0x3FF00C0C20000000, float 0x3FD0101020000000)
store float %23, float* %3
br label %31
24: ; preds = %18
%25 = load float, float* %2
%26 = call float @llvm.fmuladd.f32(float %25, float 0x3FE00C0C20000000, float 0x3FE0101020000000)
store float %26, float* %3
%27 = load float, float* %3
%28 = fcmp ogt float %27, 1.000000e+00
br i1 %28, label %29, label %30
29: ; preds = %24
store float 1.000000e+00, float* %3
br label %30
30: ; preds = %29, %24
br label %31
31: ; preds = %30, %21
br label %32
32: ; preds = %31, %17
%33 = load float, float* %3
%34 = call float @saturate(float %33)
store float %34, float* %3
%35 = load float, float* %3
ret float %35
}

LLVM IR (-O2):
define float @X360LinearToGamma(float %0) {
%2 = tail call float @saturate(float %0)
%3 = fcmp olt float %2, 0x3FC0040100000000
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = fcmp olt float %2, 0x3FB0040100000000
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = fmul float %2, 0x40100C0C20000000
br label %18
8: ; preds = %4
%9 = tail call float @llvm.fmuladd.f32(float %2, float 0x40000C0C20000000, float 0x3FC0101020000000)
br label %18
10: ; preds = %1
%11 = fcmp olt float %2, 0x3FE0040100000000
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = tail call float @llvm.fmuladd.f32(float %2, float 0x3FF00C0C20000000, float 0x3FD0101020000000)
br label %18
14: ; preds = %10
%15 = tail call float @llvm.fmuladd.f32(float %2, float 0x3FE00C0C20000000, float 0x3FE0101020000000)
%16 = fcmp ogt float %15, 1.000000e+00
br i1 %16, label %17, label %18
17: ; preds = %14
br label %18
18: ; preds = %12, %17, %14, %6, %8
%19 = phi float [ %7, %6 ], [ %9, %8 ], [ %13, %12 ], [ 1.000000e+00, %17 ], [ %15, %14 ]
%20 = tail call float @saturate(float %19)
ret float %20
}