#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, double);
float Rec2020_OETF(float value, int bitdepth) {
  float prime_out;
  if (value > 0) {
    float alpha, beta;
    if (bitdepth == 10) {
      alpha = 1.099;
      beta = 0.018;
    } else {
      alpha = 1.0993;
      beta = 0.0181;
    }
    if (value < beta) {
      prime_out = value * 4.5;
    } else {
      prime_out = alpha * pow(value, 0.45) - (alpha - 1);
    }
  } else {
    prime_out = 0;
  }
  return prime_out;
}


x86 assembly (clang, -O0):
<Rec2020_OETF>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11fe <Rec2020_OETF+0xee>
cmpl   $0xa,-0x8(%rbp)
jne    115a <Rec2020_OETF+0x4a>
movss  0xec9(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xeb8(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1174 <Rec2020_OETF+0x64>
movss  0xea2(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xe91(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x4(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11aa <Rec2020_OETF+0x9a>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe88(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11f9 <Rec2020_OETF+0xe9>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movsd  0xe57(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm2
movss  -0x18(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
movss  0xe35(%rip),%xmm3
subss  %xmm3,%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1206 <Rec2020_OETF+0xf6>
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Rec2020_OETF>:
push   %rax
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    113d <Rec2020_OETF+0x2d>
xor    %eax,%eax
cmp    $0xa,%edi
sete   %al
lea    0xee0(%rip),%rcx
movss  (%rcx,%rax,4),%xmm1
ucomiss %xmm0,%xmm1
jbe    1142 <Rec2020_OETF+0x32>
mulss  0xee2(%rip),%xmm0
movaps %xmm0,%xmm1
movaps %xmm1,%xmm0
pop    %rax
ret
lea    0xeb7(%rip),%rcx
movss  (%rcx,%rax,4),%xmm1
movss  %xmm1,0x4(%rsp)
movsd  0xeb4(%rip),%xmm1
call   1030 <pow@plt>
movss  0xeaf(%rip),%xmm1
movss  0x4(%rsp),%xmm2
addss  %xmm2,%xmm1
mulss  %xmm2,%xmm0
subss  %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @Rec2020_OETF(float %0, i32 %1) {
%3 = alloca float
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %3
store i32 %1, i32* %4
%8 = load float, float* %3
%9 = fcmp ogt float %8, 0.000000e+00
br i1 %9, label %10, label %33
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 10
br i1 %12, label %13, label %14
13: ; preds = %10
store float 0x3FF1958100000000, float* %6
store float 0x3F926E9780000000, float* %7
br label %15
14: ; preds = %10
store float 0x3FF196BBA0000000, float* %6
store float 0x3F9288CE80000000, float* %7
br label %15
15: ; preds = %14, %13
%16 = load float, float* %3
%17 = load float, float* %7
%18 = fcmp olt float %16, %17
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = load float, float* %3
%21 = fpext float %20 to double
%22 = fmul double %21, 4.500000e+00
%23 = fptrunc double %22 to float
store float %23, float* %5
br label %32
24: ; preds = %15
%25 = load float, float* %6
%26 = load float, float* %3
%27 = call float @pow(float %26, double 4.500000e-01)
%28 = load float, float* %6
%29 = fsub float %28, 1.000000e+00
%30 = fneg float %29
%31 = call float @llvm.fmuladd.f32(float %25, float %27, float %30)
store float %31, float* %5
br label %32
32: ; preds = %24, %19
br label %34
33: ; preds = %2
store float 0.000000e+00, float* %5
br label %34
34: ; preds = %33, %32
%35 = load float, float* %5
ret float %35
}

LLVM IR (-O2):
define float @Rec2020_OETF(float %0, i32 %1) {
%3 = fcmp ogt float %0, 0.000000e+00
br i1 %3, label %4, label %16
4: ; preds = %2
%5 = icmp eq i32 %1, 10
%6 = select i1 %5, float 0x3FF1958100000000, float 0x3FF196BBA0000000
%7 = select i1 %5, float 0x3F926E9780000000, float 0x3F9288CE80000000
%8 = fcmp ogt float %7, %0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = fmul float %0, 4.500000e+00
br label %16
11: ; preds = %4
%12 = tail call float @pow(float %0, double 4.500000e-01)
%13 = fadd float %6, -1.000000e+00
%14 = fneg float %13
%15 = tail call float @llvm.fmuladd.f32(float %6, float %12, float %14)
br label %16
16: ; preds = %2, %9, %11
%17 = phi float [ %10, %9 ], [ %15, %11 ], [ 0.000000e+00, %2 ]
ret float %17
}