#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 linear2srgb(float v) {
  float vpow;
  union {
    int32_t i;
    float f;
  } u;
  if (v <= 0.0031308f)
    v = v * (12.92f * 255.0f);
  else {
    u.f = (v * 6521909350804488192.0f);
    u.i = (int32_t)((int)(((float)u.i * 0.666666666666f) + 0.5f));
    vpow = u.f;
    v = (v * vpow) + ((v * v) / sqrtf(vpow));
    v = ((1.055f * 255.0f) * sqrtf(sqrtf(v * 0.5290553722f)) -
         (0.055f * 255.0f));
  }
  return v;
}


x86 assembly (clang, -O0):
<linear2srgb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  0xedb(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jb     1146 <linear2srgb+0x36>
movss  0xee5(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    120e <linear2srgb+0xfe>
movss  0xeca(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
cvtsi2ssq -0x10(%rbp),%xmm0
movss  0xeaa(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xea2(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
cltq
mov    %rax,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <sqrtf@plt>
movss  -0x1c(%rbp),%xmm1
movss  -0x18(%rbp),%xmm2
movaps %xmm0,%xmm3
movss  -0x14(%rbp),%xmm0
divss  %xmm3,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  0xe2a(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
call   1030 <sqrtf@plt>
call   1030 <sqrtf@plt>
movss  0xe0b(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe03(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linear2srgb>:
sub    $0x18,%rsp
movaps %xmm0,%xmm1
movss  0xee1(%rip),%xmm0
ucomiss %xmm1,%xmm0
jae    116c <linear2srgb+0x5c>
movss  0xedc(%rip),%xmm0
mulss  %xmm1,%xmm0
movd   %xmm0,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0xec8(%rip),%xmm0
addss  0xec4(%rip),%xmm0
cvttss2si %xmm0,%eax
movd   %eax,%xmm4
movaps %xmm1,%xmm3
mulss  %xmm1,%xmm3
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm4
jb     117c <linear2srgb+0x6c>
xorps  %xmm0,%xmm0
sqrtss %xmm4,%xmm0
jmp    11ab <linear2srgb+0x9b>
mulss  0xe90(%rip),%xmm1
movaps %xmm1,%xmm0
add    $0x18,%rsp
ret
movaps %xmm4,%xmm0
movss  %xmm1,0x14(%rsp)
movss  %xmm3,0x10(%rsp)
movss  %xmm4,0xc(%rsp)
call   1030 <sqrtf@plt>
movss  0xc(%rsp),%xmm4
movss  0x10(%rsp),%xmm3
xorps  %xmm2,%xmm2
movss  0x14(%rsp),%xmm1
divss  %xmm0,%xmm3
mulss  %xmm4,%xmm1
addss  %xmm3,%xmm1
mulss  0xe55(%rip),%xmm1
ucomiss %xmm2,%xmm1
jb     11cd <linear2srgb+0xbd>
xorps  %xmm0,%xmm0
sqrtss %xmm1,%xmm0
jmp    11d5 <linear2srgb+0xc5>
movaps %xmm1,%xmm0
call   1030 <sqrtf@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     11e3 <linear2srgb+0xd3>
sqrtss %xmm0,%xmm0
jmp    11e8 <linear2srgb+0xd8>
call   1030 <sqrtf@plt>
mulss  0xe28(%rip),%xmm0
addss  0xe24(%rip),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
%union.anon = type { i64 }
define float @linear2srgb(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca %union.anon
store float %0, float* %2
%5 = load float, float* %2
%6 = fcmp ole float %5, 0x3F69A5C380000000
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load float, float* %2
%9 = fmul float %8, 0x40A9BD3340000000
store float %9, float* %2
br label %37
10: ; preds = %1
%11 = load float, float* %2
%12 = fmul float %11, 0x43D6A09E80000000
%13 = bitcast %union.anon* %4 to float*
store float %12, float* %13
%14 = bitcast %union.anon* %4 to i64*
%15 = load i64, i64* %14
%16 = sitofp i64 %15 to float
%17 = call float @llvm.fmuladd.f32(float %16, float 0x3FE5555560000000, float 5.000000e-01)
%18 = fptosi float %17 to i32
%19 = sext i32 %18 to i64
%20 = bitcast %union.anon* %4 to i64*
store i64 %19, i64* %20
%21 = bitcast %union.anon* %4 to float*
%22 = load float, float* %21
store float %22, float* %3
%23 = load float, float* %2
%24 = load float, float* %3
%25 = load float, float* %2
%26 = load float, float* %2
%27 = fmul float %25, %26
%28 = load float, float* %3
%29 = call float @sqrtf(float %28)
%30 = fdiv float %27, %29
%31 = call float @llvm.fmuladd.f32(float %23, float %24, float %30)
store float %31, float* %2
%32 = load float, float* %2
%33 = fmul float %32, 0x3FE0EE0580000000
%34 = call float @sqrtf(float %33)
%35 = call float @sqrtf(float %34)
%36 = call float @llvm.fmuladd.f32(float 0x4070D06660000000, float %35, float 0xC02C0CCCC0000000)
store float %36, float* %2
br label %37
37: ; preds = %10, %7
%38 = load float, float* %2
ret float %38
}

LLVM IR (-O2):
define float @linear2srgb(float %0) {
%2 = fcmp ugt float %0, 0x3F69A5C380000000
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = fmul float %0, 0x40A9BD3340000000
br label %20
5: ; preds = %1
%6 = fmul float %0, 0x43D6A09E80000000
%7 = bitcast float %6 to i32
%8 = uitofp i32 %7 to float
%9 = tail call float @llvm.fmuladd.f32(float %8, float 0x3FE5555560000000, float 5.000000e-01)
%10 = fptosi float %9 to i32
%11 = bitcast i32 %10 to float
%12 = fmul float %0, %0
%13 = tail call float @sqrtf(float %11)
%14 = fdiv float %12, %13
%15 = tail call float @llvm.fmuladd.f32(float %0, float %11, float %14)
%16 = fmul float %15, 0x3FE0EE0580000000
%17 = tail call float @sqrtf(float %16)
%18 = tail call float @sqrtf(float %17)
%19 = tail call float @llvm.fmuladd.f32(float %18, float 0x4070D06660000000, float 0xC02C0CCCC0000000)
br label %20
20: ; preds = %5, %3
%21 = phi float [ %4, %3 ], [ %19, %5 ]
ret float %21
}