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


x86 assembly (clang, -O0):
<linear_to_sRGB>:
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 <linear_to_sRGB+0x3b>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11e5 <linear_to_sRGB+0xc5>
movss  -0x8(%rbp),%xmm0
movss  0xe9c(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1183 <linear_to_sRGB+0x63>
movss  0xe8b(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11e0 <linear_to_sRGB+0xc0>
movss  0xe7d(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     11ac <linear_to_sRGB+0x8c>
movss  0xe7b(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11db <linear_to_sRGB+0xbb>
movss  -0x8(%rbp),%xmm0
movss  0xe5b(%rip),%xmm1
call   1030 <powf@plt>
movss  0xe46(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe3e(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11e0 <linear_to_sRGB+0xc0>
jmp    11e5 <linear_to_sRGB+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):
<linear_to_sRGB>:
push   %rax
cvtsi2ss %edi,%xmm0
divss  0xed3(%rip),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     117c <linear_to_sRGB+0x5c>
movss  0xec7(%rip),%xmm1
ucomiss %xmm1,%xmm0
ja     117c <linear_to_sRGB+0x5c>
movss  0xebe(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    1171 <linear_to_sRGB+0x51>
movss  0xeb9(%rip),%xmm1
call   1030 <powf@plt>
movaps %xmm0,%xmm1
mulss  0xead(%rip),%xmm1
addss  0xea9(%rip),%xmm1
jmp    117c <linear_to_sRGB+0x5c>
mulss  0xe93(%rip),%xmm0
movaps %xmm0,%xmm1
mulss  0xe7c(%rip),%xmm1
addss  0xe90(%rip),%xmm1
movaps %xmm1,%xmm0
pop    %rax
jmp    1040 <floorf@plt>

LLVM IR (-O0):
define i32 @linear_to_sRGB(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 %26
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 %25
14: ; preds = %10
%15 = load float, float* %3
%16 = fcmp ole float %15, 0x3F69A5C380000000
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load float, float* %3
%19 = fmul float 0x4029D70A40000000, %18
store float %19, float* %3
br label %24
20: ; preds = %14
%21 = load float, float* %3
%22 = call float @powf(float %21, float 0x3FDAAA8EC0000000)
%23 = call float @llvm.fmuladd.f32(float 0x3FF0E147A0000000, float %22, float 0xBFAC28F5C0000000)
store float %23, float* %3
br label %24
24: ; preds = %20, %17
br label %25
25: ; preds = %24, %13
br label %26
26: ; preds = %25, %9
%27 = load float, float* %3
%28 = call float @llvm.fmuladd.f32(float 2.550000e+02, float %27, float 5.000000e-01)
%29 = call i64 @floorf(float %28)
%30 = trunc i64 %29 to i32
ret i32 %30
}

LLVM IR (-O2):
define i32 @linear_to_sRGB(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 %14, label %5
5: ; preds = %1
%6 = fcmp ogt float %3, 1.000000e+00
br i1 %6, label %14, label %7
7: ; preds = %5
%8 = fcmp ugt float %3, 0x3F69A5C380000000
br i1 %8, label %11, label %9
9: ; preds = %7
%10 = fmul float %3, 0x4029D70A40000000
br label %14
11: ; preds = %7
%12 = tail call float @powf(float %3, float 0x3FDAAA8EC0000000)
%13 = tail call float @llvm.fmuladd.f32(float %12, float 0x3FF0E147A0000000, float 0xBFAC28F5C0000000)
br label %14
14: ; preds = %5, %1, %11, %9
%15 = phi float [ %10, %9 ], [ %13, %11 ], [ 0.000000e+00, %1 ], [ 1.000000e+00, %5 ]
%16 = tail call float @llvm.fmuladd.f32(float %15, float 2.550000e+02, float 5.000000e-01)
%17 = tail call i64 @floorf(float %16)
%18 = trunc i64 %17 to i32
ret i32 %18
}