#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 */
typedef scalar_t__ int32_t;

/* Variables and functions */
float sqrtf(float);
__attribute__((always_)) float srgb2linear(float v) {
  float v2, vpow, vpwsqrt;
  union {
    int32_t i;
    float f;
  } u;
  if (v <= (0.04045f * 255.0f))
    v = v * ((1.0f / 12.92f) * (1.0f / 255.0f));
  else {
    v = (v + (0.055f * 255.0f)) * ((1.0f / 1.055f) * (1.0f / 255.0f));
    v2 = v * v;
    u.f = v * 5417434112.0f;
    u.i = (int32_t)((int)(((float)u.i * 0.8f) + 0.5f));
    vpow = u.f;
    vpwsqrt = sqrtf(vpow);
    v = ((v2 * vpwsqrt) + (((v2 * v) / vpwsqrt) / sqrtf(vpwsqrt))) *
        0.51011878327f;
  }
  return v;
}


x86 assembly (clang, -O0):
<srgb2linear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  0xedb(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jb     1146 <srgb2linear+0x36>
movss  0xee5(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1227 <srgb2linear+0x117>
movss  0xeca(%rip),%xmm0
addss  -0x4(%rbp),%xmm0
movss  0xeb9(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xe95(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
cvtsi2ssq -0x18(%rbp),%xmm0
movss  0xe75(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe6d(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
cltq
mov    %rax,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <sqrtf@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x10(%rbp),%xmm0
call   1030 <sqrtf@plt>
movss  -0x24(%rbp),%xmm1
movss  -0x20(%rbp),%xmm2
movaps %xmm0,%xmm3
movss  -0x1c(%rbp),%xmm0
divss  %xmm3,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  0xde6(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<srgb2linear>:
sub    $0x18,%rsp
movaps %xmm0,%xmm1
movss  0xee1(%rip),%xmm0
ucomiss %xmm1,%xmm0
jae    117f <srgb2linear+0x6f>
addss  0xedc(%rip),%xmm1
mulss  0xed8(%rip),%xmm1
movss  0xed4(%rip),%xmm0
mulss  %xmm1,%xmm0
movd   %xmm0,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movaps %xmm1,%xmm2
mulss  %xmm1,%xmm2
mulss  0xeb9(%rip),%xmm0
addss  0xeb5(%rip),%xmm0
cvttss2si %xmm0,%eax
movd   %eax,%xmm0
xorps  %xmm4,%xmm4
ucomiss %xmm4,%xmm0
movss  %xmm2,0x10(%rsp)
jb     118c <srgb2linear+0x7c>
sqrtss %xmm0,%xmm3
jmp    11a9 <srgb2linear+0x99>
mulss  0xe7d(%rip),%xmm1
movaps %xmm1,%xmm2
jmp    11f9 <srgb2linear+0xe9>
movss  %xmm1,0xc(%rsp)
call   1030 <sqrtf@plt>
xorps  %xmm4,%xmm4
movss  0x10(%rsp),%xmm2
movss  0xc(%rsp),%xmm1
movaps %xmm0,%xmm3
mulss  %xmm2,%xmm1
divss  %xmm3,%xmm1
ucomiss %xmm4,%xmm3
jb     11bf <srgb2linear+0xaf>
xorps  %xmm0,%xmm0
sqrtss %xmm3,%xmm0
jmp    11e5 <srgb2linear+0xd5>
movaps %xmm3,%xmm0
movss  %xmm1,0xc(%rsp)
movss  %xmm3,0x14(%rsp)
call   1030 <sqrtf@plt>
movss  0x14(%rsp),%xmm3
movss  0x10(%rsp),%xmm2
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
mulss  %xmm3,%xmm2
addss  %xmm1,%xmm2
mulss  0xe23(%rip),%xmm2
movaps %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
%union.anon = type { i64 }
define float @srgb2linear(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca %union.anon
store float %0, float* %2
%7 = load float, float* %2
%8 = fcmp ole float %7, 0x4024A126E0000000
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load float, float* %2
%11 = fmul float %10, 0x3F33E45680000000
store float %11, float* %2
br label %45
12: ; preds = %1
%13 = load float, float* %2
%14 = fadd float %13, 0x402C0CCCC0000000
%15 = fmul float %14, 0x3F6E736160000000
store float %15, float* %2
%16 = load float, float* %2
%17 = load float, float* %2
%18 = fmul float %16, %17
store float %18, float* %3
%19 = load float, float* %2
%20 = fmul float %19, 0x41F42E77C0000000
%21 = bitcast %union.anon* %6 to float*
store float %20, float* %21
%22 = bitcast %union.anon* %6 to i64*
%23 = load i64, i64* %22
%24 = sitofp i64 %23 to float
%25 = call float @llvm.fmuladd.f32(float %24, float 0x3FE99999A0000000, float 5.000000e-01)
%26 = fptosi float %25 to i32
%27 = sext i32 %26 to i64
%28 = bitcast %union.anon* %6 to i64*
store i64 %27, i64* %28
%29 = bitcast %union.anon* %6 to float*
%30 = load float, float* %29
store float %30, float* %4
%31 = load float, float* %4
%32 = call float @sqrtf(float %31)
store float %32, float* %5
%33 = load float, float* %3
%34 = load float, float* %5
%35 = load float, float* %3
%36 = load float, float* %2
%37 = fmul float %35, %36
%38 = load float, float* %5
%39 = fdiv float %37, %38
%40 = load float, float* %5
%41 = call float @sqrtf(float %40)
%42 = fdiv float %39, %41
%43 = call float @llvm.fmuladd.f32(float %33, float %34, float %42)
%44 = fmul float %43, 0x3FE052E4A0000000
store float %44, float* %2
br label %45
45: ; preds = %12, %9
%46 = load float, float* %2
ret float %46
}

LLVM IR (-O2):
define float @srgb2linear(float %0) {
%2 = fcmp ugt float %0, 0x4024A126E0000000
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = fmul float %0, 0x3F33E45680000000
br label %22
5: ; preds = %1
%6 = fadd float %0, 0x402C0CCCC0000000
%7 = fmul float %6, 0x3F6E736160000000
%8 = fmul float %7, %7
%9 = fmul float %7, 0x41F42E77C0000000
%10 = bitcast float %9 to i32
%11 = uitofp i32 %10 to float
%12 = tail call float @llvm.fmuladd.f32(float %11, float 0x3FE99999A0000000, float 5.000000e-01)
%13 = fptosi float %12 to i32
%14 = bitcast i32 %13 to float
%15 = tail call float @sqrtf(float %14)
%16 = fmul float %7, %8
%17 = fdiv float %16, %15
%18 = tail call float @sqrtf(float %15)
%19 = fdiv float %17, %18
%20 = tail call float @llvm.fmuladd.f32(float %8, float %15, float %19)
%21 = fmul float %20, 0x3FE052E4A0000000
br label %22
22: ; preds = %5, %3
%23 = phi float [ %4, %3 ], [ %21, %5 ]
ret float %23
}