#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 powf(float, float);
float srgb(float v) {
  float K0 = 0.04045f;
  float a = 0.055f;
  float phi = 12.92f;
  float gamma = 2.4f;
  return v <= K0 / phi ? v * phi : (1.0f + a) * powf(v, 1.0f / gamma) - a;
}


x86 assembly (clang, -O0):
<srgb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  0xee7(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xed6(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xec5(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xeb4(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x4(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     117d <srgb+0x6d>
movss  -0x4(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    11cd <srgb+0xbd>
movss  0xe8b(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xe74(%rip),%xmm1
divss  -0x14(%rbp),%xmm1
call   1030 <powf@plt>
movaps %xmm0,%xmm2
movss  -0x1c(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<srgb>:
push   %rax
movss  0xee7(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    113d <srgb+0x2d>
movss  0xee2(%rip),%xmm1
call   1030 <powf@plt>
mulss  0xed9(%rip),%xmm0
addss  0xed5(%rip),%xmm0
pop    %rax
ret
mulss  0xebf(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @srgb(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store float %0, float* %2
store float 0x3FA4B5DCC0000000, float* %3
store float 0x3FAC28F5C0000000, float* %4
store float 0x4029D70A40000000, float* %5
store float 0x4003333340000000, float* %6
%7 = load float, float* %2
%8 = load float, float* %3
%9 = load float, float* %5
%10 = fdiv float %8, %9
%11 = fcmp ole float %7, %10
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = load float, float* %2
%14 = load float, float* %5
%15 = fmul float %13, %14
br label %26
16: ; preds = %1
%17 = load float, float* %4
%18 = fadd float 1.000000e+00, %17
%19 = load float, float* %2
%20 = load float, float* %6
%21 = fdiv float 1.000000e+00, %20
%22 = call float @powf(float %19, float %21)
%23 = load float, float* %4
%24 = fneg float %23
%25 = call float @llvm.fmuladd.f32(float %18, float %22, float %24)
br label %26
26: ; preds = %16, %12
%27 = phi float [ %15, %12 ], [ %25, %16 ]
ret float %27
}

LLVM IR (-O2):
define float @srgb(float %0) {
%2 = fcmp ugt float %0, 0x3F69A5C620000000
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = fmul float %0, 0x4029D70A40000000
br label %8
5: ; preds = %1
%6 = tail call float @powf(float %0, float 0x3FDAAAAAA0000000)
%7 = tail call float @llvm.fmuladd.f32(float %6, float 0x3FF0E147A0000000, float 0xBFAC28F5C0000000)
br label %8
8: ; preds = %5, %3
%9 = phi float [ %4, %3 ], [ %7, %5 ]
ret float %9
}