#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__ floorf(float);
float powf(float, float);
int sRGB_to_linear(int c) {
  float v = (float)c / 255.0f;
  if (v < 0)
    v = 0;
  else if (v > 1)
    v = 1;
  else if (v <= 0.04045f)
    v /= 12.92f;
  else
    v = powf((v + 0.055f) / 1.055f, 2.4f);
  return ((int)floorf(255.0f * v + 0.5f));
}


x86 assembly (clang, -O0):
<sRGB_to_linear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cvtsi2ssl -0x4(%rbp),%xmm0
movss  0xec8(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    115b <sRGB_to_linear+0x3b>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11e5 <sRGB_to_linear+0xc5>
movss  -0x8(%rbp),%xmm0
movss  0xe9c(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1183 <sRGB_to_linear+0x63>
movss  0xe8b(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11e0 <sRGB_to_linear+0xc0>
movss  0xe7d(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     11b0 <sRGB_to_linear+0x90>
movss  -0x8(%rbp),%xmm0
movss  0xe76(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11db <sRGB_to_linear+0xbb>
movss  0xe5c(%rip),%xmm0
addss  -0x8(%rbp),%xmm0
movss  0xe4b(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe3b(%rip),%xmm1
call   1030 <powf@plt>
movss  %xmm0,-0x8(%rbp)
jmp    11e0 <sRGB_to_linear+0xc0>
jmp    11e5 <sRGB_to_linear+0xc5>
movss  -0x8(%rbp),%xmm0
movss  0xe0e(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe1e(%rip),%xmm1
addss  %xmm1,%xmm0
call   1040 <floorf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sRGB_to_linear>:
push   %rax
cvtsi2ss %edi,%xmm0
divss  0xed3(%rip),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     1179 <sRGB_to_linear+0x59>
movss  0xec7(%rip),%xmm1
ucomiss %xmm1,%xmm0
ja     1179 <sRGB_to_linear+0x59>
movss  0xebe(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    116e <sRGB_to_linear+0x4e>
addss  0xeb9(%rip),%xmm0
divss  0xeb5(%rip),%xmm0
movss  0xeb1(%rip),%xmm1
call   1030 <powf@plt>
jmp    1176 <sRGB_to_linear+0x56>
divss  0xe96(%rip),%xmm0
movaps %xmm0,%xmm1
mulss  0xe7f(%rip),%xmm1
addss  0xe93(%rip),%xmm1
movaps %xmm1,%xmm0
pop    %rax
jmp    1040 <floorf@plt>

LLVM IR (-O0):
define i32 @sRGB_to_linear(i32 %0) {
%2 = alloca i32
%3 = alloca float
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = sitofp i32 %4 to float
%6 = fdiv float %5, 2.550000e+02
store float %6, float* %3
%7 = load float, float* %3
%8 = fcmp olt float %7, 0.000000e+00
br i1 %8, label %9, label %10
9: ; preds = %1
store float 0.000000e+00, float* %3
br label %27
10: ; preds = %1
%11 = load float, float* %3
%12 = fcmp ogt float %11, 1.000000e+00
br i1 %12, label %13, label %14
13: ; preds = %10
store float 1.000000e+00, float* %3
br label %26
14: ; preds = %10
%15 = load float, float* %3
%16 = fcmp ole float %15, 0x3FA4B5DCC0000000
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load float, float* %3
%19 = fdiv float %18, 0x4029D70A40000000
store float %19, float* %3
br label %25
20: ; preds = %14
%21 = load float, float* %3
%22 = fadd float %21, 0x3FAC28F5C0000000
%23 = fdiv float %22, 0x3FF0E147A0000000
%24 = call float @powf(float %23, float 0x4003333340000000)
store float %24, float* %3
br label %25
25: ; preds = %20, %17
br label %26
26: ; preds = %25, %13
br label %27
27: ; preds = %26, %9
%28 = load float, float* %3
%29 = call float @llvm.fmuladd.f32(float 2.550000e+02, float %28, float 5.000000e-01)
%30 = call i64 @floorf(float %29)
%31 = trunc i64 %30 to i32
ret i32 %31
}

LLVM IR (-O2):
define i32 @sRGB_to_linear(i32 %0) {
%2 = sitofp i32 %0 to float
%3 = fdiv float %2, 2.550000e+02
%4 = fcmp olt float %3, 0.000000e+00
br i1 %4, label %15, label %5
5: ; preds = %1
%6 = fcmp ogt float %3, 1.000000e+00
br i1 %6, label %15, label %7
7: ; preds = %5
%8 = fcmp ugt float %3, 0x3FA4B5DCC0000000
br i1 %8, label %11, label %9
9: ; preds = %7
%10 = fdiv float %3, 0x4029D70A40000000
br label %15
11: ; preds = %7
%12 = fadd float %3, 0x3FAC28F5C0000000
%13 = fdiv float %12, 0x3FF0E147A0000000
%14 = tail call float @powf(float %13, float 0x4003333340000000)
br label %15
15: ; preds = %5, %1, %11, %9
%16 = phi float [ %10, %9 ], [ %14, %11 ], [ 0.000000e+00, %1 ], [ 1.000000e+00, %5 ]
%17 = tail call float @llvm.fmuladd.f32(float %16, float 2.550000e+02, float 5.000000e-01)
%18 = tail call i64 @floorf(float %17)
%19 = trunc i64 %18 to i32
ret i32 %19
}