#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 FastBias(float, float);
float FastGain(float g, float x) {
  return (x < 0.5f) ? FastBias(1.0f - g, 2.0f * x) * 0.5f
                    : 1.0f - FastBias(1.0f - g, 2.0f - 2.0f * x) * 0.5f;
}


x86 assembly (clang, -O0):
<FastGain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  0xed6(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1169 <FastGain+0x59>
movss  0xec8(%rip),%xmm0
subss  -0x4(%rbp),%xmm0
movss  0xebf(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
call   1030 <FastBias@plt>
movss  0xea5(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11ba <FastGain+0xaa>
movss  0xe93(%rip),%xmm0
subss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm2
addss  %xmm2,%xmm2
movss  0xe81(%rip),%xmm1
subss  %xmm2,%xmm1
call   1030 <FastBias@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xe5b(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe53(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FastGain>:
push   %rax
movaps %xmm0,%xmm2
movss  0xee4(%rip),%xmm0
ucomiss %xmm1,%xmm0
movss  0xedd(%rip),%xmm0
subss  %xmm2,%xmm0
addss  %xmm1,%xmm1
jbe    1140 <FastGain+0x30>
call   1030 <FastBias@plt>
mulss  0xec2(%rip),%xmm0
pop    %rax
ret
movss  0xec0(%rip),%xmm2
subss  %xmm1,%xmm2
movaps %xmm2,%xmm1
call   1030 <FastBias@plt>
mulss  0xeb0(%rip),%xmm0
addss  0xea0(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @FastGain(float %0, float %1) {
%3 = alloca float
%4 = alloca float
store float %0, float* %3
store float %1, float* %4
%5 = load float, float* %4
%6 = fcmp olt float %5, 5.000000e-01
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = load float, float* %3
%9 = fsub float 1.000000e+00, %8
%10 = load float, float* %4
%11 = fmul float 2.000000e+00, %10
%12 = call float @FastBias(float %9, float %11)
%13 = fmul float %12, 5.000000e-01
br label %22
14: ; preds = %2
%15 = load float, float* %3
%16 = fsub float 1.000000e+00, %15
%17 = load float, float* %4
%18 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %17, float 2.000000e+00)
%19 = call float @FastBias(float %16, float %18)
%20 = fneg float %19
%21 = call float @llvm.fmuladd.f32(float %20, float 5.000000e-01, float 1.000000e+00)
br label %22
22: ; preds = %14, %7
%23 = phi float [ %13, %7 ], [ %21, %14 ]
ret float %23
}

LLVM IR (-O2):
define float @FastGain(float %0, float %1) {
%3 = fcmp olt float %1, 5.000000e-01
%4 = fsub float 1.000000e+00, %0
br i1 %3, label %5, label %9
5: ; preds = %2
%6 = fmul float %1, 2.000000e+00
%7 = tail call float @FastBias(float %4, float %6)
%8 = fmul float %7, 5.000000e-01
br label %14
9: ; preds = %2
%10 = tail call float @llvm.fmuladd.f32(float %1, float -2.000000e+00, float 2.000000e+00)
%11 = tail call float @FastBias(float %4, float %10)
%12 = fneg float %11
%13 = tail call float @llvm.fmuladd.f32(float %12, float 5.000000e-01, float 1.000000e+00)
br label %14
14: ; preds = %9, %5
%15 = phi float [ %8, %5 ], [ %13, %9 ]
ret float %15
}