#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 max(int /*<<< orphan*/, float);
float pow(float, float);
float Rec1886_EOTF(float value, float black_luminance, float white_luminance) {
  float linear_out;
  if (value > 0) {
    float gamma = 2.4;
    float gamma_denom = 1 / gamma;
    float tmp =
        pow(white_luminance, gamma_denom) - pow(black_luminance, gamma_denom);
    float gain = pow(tmp, gamma);
    float lift = pow(black_luminance, gamma_denom) / tmp;
    linear_out = gain * pow(max(0, value + lift), gamma);
  } else {
    linear_out = 0;
  }
  return linear_out;
}


x86 assembly (clang, -O0):
<Rec1886_EOTF>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1203 <Rec1886_EOTF+0xe3>
movss  0xeb4(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xea3(%rip),%xmm0
divss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
call   1040 <pow@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
call   1040 <pow@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
call   1040 <pow@plt>
divss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x4(%rbp),%xmm0
addss  -0x24(%rbp),%xmm0
xor    %edi,%edi
call   1030 <max@plt>
movss  -0x14(%rbp),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movss  -0x28(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    120b <Rec1886_EOTF+0xeb>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Rec1886_EOTF>:
movaps %xmm0,%xmm4
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm4
jbe    11ce <Rec1886_EOTF+0xae>
sub    $0x18,%rsp
movaps %xmm1,%xmm3
movss  0xec2(%rip),%xmm1
movaps %xmm2,%xmm0
movss  %xmm4,0x14(%rsp)
movss  %xmm3,0xc(%rsp)
call   1040 <pow@plt>
movss  %xmm0,0x8(%rsp)
movss  0xc(%rsp),%xmm0
movss  0xe9a(%rip),%xmm1
call   1040 <pow@plt>
movss  0x8(%rsp),%xmm2
subss  %xmm0,%xmm2
movss  %xmm2,0x8(%rsp)
movss  0xe81(%rip),%xmm1
movaps %xmm2,%xmm0
call   1040 <pow@plt>
movss  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
movss  0xe61(%rip),%xmm1
call   1040 <pow@plt>
divss  0x8(%rsp),%xmm0
addss  0x14(%rsp),%xmm0
xor    %edi,%edi
call   1030 <max@plt>
movss  0xe45(%rip),%xmm1
call   1040 <pow@plt>
mulss  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @Rec1886_EOTF(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%13 = load float, float* %4
%14 = fcmp ogt float %13, 0.000000e+00
br i1 %14, label %15, label %41
15: ; preds = %3
store float 0x4003333340000000, float* %8
%16 = load float, float* %8
%17 = fdiv float 1.000000e+00, %16
store float %17, float* %9
%18 = load float, float* %6
%19 = load float, float* %9
%20 = call float @pow(float %18, float %19)
%21 = load float, float* %5
%22 = load float, float* %9
%23 = call float @pow(float %21, float %22)
%24 = fsub float %20, %23
store float %24, float* %10
%25 = load float, float* %10
%26 = load float, float* %8
%27 = call float @pow(float %25, float %26)
store float %27, float* %11
%28 = load float, float* %5
%29 = load float, float* %9
%30 = call float @pow(float %28, float %29)
%31 = load float, float* %10
%32 = fdiv float %30, %31
store float %32, float* %12
%33 = load float, float* %11
%34 = load float, float* %4
%35 = load float, float* %12
%36 = fadd float %34, %35
%37 = call float @max(i32 0, float %36)
%38 = load float, float* %8
%39 = call float @pow(float %37, float %38)
%40 = fmul float %33, %39
store float %40, float* %7
br label %42
41: ; preds = %3
store float 0.000000e+00, float* %7
br label %42
42: ; preds = %41, %15
%43 = load float, float* %7
ret float %43
}

LLVM IR (-O2):
define float @Rec1886_EOTF(float %0, float %1, float %2) {
%4 = fcmp ogt float %0, 0.000000e+00
br i1 %4, label %5, label %16
5: ; preds = %3
%6 = tail call float @pow(float %2, float 0x3FDAAAAAA0000000)
%7 = tail call float @pow(float %1, float 0x3FDAAAAAA0000000)
%8 = fsub float %6, %7
%9 = tail call float @pow(float %8, float 0x4003333340000000)
%10 = tail call float @pow(float %1, float 0x3FDAAAAAA0000000)
%11 = fdiv float %10, %8
%12 = fadd float %11, %0
%13 = tail call float @max(i32 0, float %12)
%14 = tail call float @pow(float %13, float 0x4003333340000000)
%15 = fmul float %9, %14
br label %16
16: ; preds = %3, %5
%17 = phi float [ %15, %5 ], [ 0.000000e+00, %3 ]
ret float %17
}