#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 bias(int, int);
float gain(float value, float g) {
  return (value < 0.5) ? bias(value * 2, 1 - g) * 0.5
                       : 1 - bias(2 - (value * 2), 1 - g) * 0.5;
}


x86 assembly (clang, -O0):
<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    117a <gain+0x6a>
movss  0xecf(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
cvttss2si %xmm0,%edi
movss  0xeba(%rip),%xmm0
subss  -0x8(%rbp),%xmm0
cvttss2si %xmm0,%esi
call   1030 <bias@plt>
movsd  0xe94(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11ea <gain+0xda>
movss  -0x4(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
addss  %xmm0,%xmm0
movss  0xe7c(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
movss  0xe68(%rip),%xmm0
subss  -0x8(%rbp),%xmm0
cvttss2si %xmm0,%esi
call   1030 <bias@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe2b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe27(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gain>:
push   %rax
movss  0xee7(%rip),%xmm2
ucomiss %xmm0,%xmm2
jbe    1145 <gain+0x35>
addss  %xmm0,%xmm0
cvttss2si %xmm0,%edi
movss  0xeda(%rip),%xmm0
subss  %xmm1,%xmm0
cvttss2si %xmm0,%esi
call   1030 <bias@plt>
mulsd  0xedd(%rip),%xmm0
jmp    117e <gain+0x6e>
addss  %xmm0,%xmm0
movss  0xeb3(%rip),%xmm2
subss  %xmm0,%xmm2
cvttss2si %xmm2,%edi
movss  0xea7(%rip),%xmm0
subss  %xmm1,%xmm0
cvttss2si %xmm0,%esi
call   1030 <bias@plt>
mulsd  0xe9a(%rip),%xmm0
addsd  0xe9a(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @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 %17
8: ; preds = %2
%9 = load float, float* %3
%10 = fmul float %9, 2.000000e+00
%11 = fptosi float %10 to i32
%12 = load float, float* %4
%13 = fsub float 1.000000e+00, %12
%14 = fptosi float %13 to i32
%15 = call double @bias(i32 %11, i32 %14)
%16 = fmul double %15, 5.000000e-01
br label %28
17: ; preds = %2
%18 = load float, float* %3
%19 = fneg float %18
%20 = call float @llvm.fmuladd.f32(float %19, float 2.000000e+00, float 2.000000e+00)
%21 = fptosi float %20 to i32
%22 = load float, float* %4
%23 = fsub float 1.000000e+00, %22
%24 = fptosi float %23 to i32
%25 = call double @bias(i32 %21, i32 %24)
%26 = fneg double %25
%27 = call double @llvm.fmuladd.f64(double %26, double 5.000000e-01, double 1.000000e+00)
br label %28
28: ; preds = %17, %8
%29 = phi double [ %16, %8 ], [ %27, %17 ]
%30 = fptrunc double %29 to float
ret float %30
}

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