#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 pow(float, float);
float Rec1886_OETF(float value, float black_luminance, float white_luminance) {
  float prime_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;
    prime_out = pow(value / gain, gamma_denom - lift);
  } else {
    prime_out = 0;
  }
  return prime_out;
}


x86 assembly (clang, -O0):
<Rec1886_OETF>:
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    11db <Rec1886_OETF+0xcb>
movss  0xec4(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xeb3(%rip),%xmm0
divss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
call   1030 <pow@plt>
movss  %xmm0,-0x28(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movss  -0x28(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
call   1030 <pow@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
call   1030 <pow@plt>
divss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x4(%rbp),%xmm0
divss  -0x20(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
subss  -0x24(%rbp),%xmm1
call   1030 <pow@plt>
movss  %xmm0,-0x10(%rbp)
jmp    11e3 <Rec1886_OETF+0xd3>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Rec1886_OETF>:
movaps %xmm0,%xmm3
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm3
jbe    11bb <Rec1886_OETF+0xab>
sub    $0x18,%rsp
movss  %xmm1,0xc(%rsp)
movss  0xecf(%rip),%xmm1
movaps %xmm2,%xmm0
movss  %xmm3,0x14(%rsp)
call   1030 <pow@plt>
movss  %xmm0,0x8(%rsp)
movss  0xc(%rsp),%xmm0
movss  0xead(%rip),%xmm1
call   1030 <pow@plt>
movss  0x8(%rsp),%xmm2
subss  %xmm0,%xmm2
movss  %xmm2,0x8(%rsp)
movss  0xe94(%rip),%xmm1
movaps %xmm2,%xmm0
call   1030 <pow@plt>
movss  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
movss  0xe74(%rip),%xmm1
call   1030 <pow@plt>
divss  0x8(%rsp),%xmm0
movss  0x14(%rsp),%xmm2
divss  0x10(%rsp),%xmm2
movss  0xe55(%rip),%xmm1
subss  %xmm0,%xmm1
movaps %xmm2,%xmm0
add    $0x18,%rsp
jmp    1030 <pow@plt>
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
define float @Rec1886_OETF(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 %40
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* %4
%34 = load float, float* %11
%35 = fdiv float %33, %34
%36 = load float, float* %9
%37 = load float, float* %12
%38 = fsub float %36, %37
%39 = call float @pow(float %35, float %38)
store float %39, float* %7
br label %41
40: ; preds = %3
store float 0.000000e+00, float* %7
br label %41
41: ; preds = %40, %15
%42 = load float, float* %7
ret float %42
}

LLVM IR (-O2):
define float @Rec1886_OETF(float %0, float %1, float %2) {
%4 = fcmp ogt float %0, 0.000000e+00
br i1 %4, label %5, label %15
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 = fdiv float %0, %9
%13 = fsub float 0x3FDAAAAAA0000000, %11
%14 = tail call float @pow(float %12, float %13)
br label %15
15: ; preds = %3, %5
%16 = phi float [ %14, %5 ], [ 0.000000e+00, %3 ]
ret float %16
}