#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 */
double fast_bias(float, int);
float fast_gain(float value, float g) {
  return (value < 0.5) ? fast_bias(value * 2, g) * 0.5
                       : fast_bias(value * 2 - 1, 1 - g) * 0.5 + 0.5;
}


x86 assembly (clang, -O0):
<fast_gain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xecd(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    116a <fast_gain+0x5a>
movss  0xecb(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
cvttss2si -0x8(%rbp),%edi
call   1030 <fast_bias@plt>
movsd  0xea4(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11aa <fast_gain+0x9a>
movss  -0x4(%rbp),%xmm0
addss  %xmm0,%xmm0
movss  0xe91(%rip),%xmm1
addss  %xmm1,%xmm0
movss  0xe81(%rip),%xmm1
subss  -0x8(%rbp),%xmm1
cvttss2si %xmm1,%edi
call   1030 <fast_bias@plt>
movsd  0xe63(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fast_gain>:
push   %rax
movss  0xee7(%rip),%xmm2
ucomiss %xmm0,%xmm2
jbe    1135 <fast_gain+0x25>
addss  %xmm0,%xmm0
cvttss2si %xmm1,%edi
call   1030 <fast_bias@plt>
mulsd  0xedd(%rip),%xmm0
jmp    1166 <fast_gain+0x56>
addss  %xmm0,%xmm0
addss  0xec3(%rip),%xmm0
movss  0xebf(%rip),%xmm2
subss  %xmm1,%xmm2
cvttss2si %xmm2,%edi
call   1030 <fast_bias@plt>
movsd  0xeb2(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
pop    %rax
ret

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

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