#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 max(double, float);
float min(double, float);
float blend_linear_light(float A, float B) {
  return (B < 0.5) ? max(0.0, A + 2.0 * B - 1.0)
                   : min(1.0, A + 2.0 * (B - 0.5));
}


x86 assembly (clang, -O0):
<blend_linear_light>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xebd(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1189 <blend_linear_light+0x69>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe99(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm1
xorps  %xmm0,%xmm0
call   1040 <max@plt>
movss  %xmm0,-0xc(%rbp)
jmp    11c5 <blend_linear_light+0xa5>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe5d(%rip),%xmm2
subsd  %xmm2,%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm1
movsd  0xe4d(%rip),%xmm0
call   1030 <min@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blend_linear_light>:
cvtss2sd %xmm1,%xmm2
movss  0xed4(%rip),%xmm3
ucomiss %xmm1,%xmm3
cvtss2sd %xmm0,%xmm0
jbe    1154 <blend_linear_light+0x34>
addsd  %xmm2,%xmm2
addsd  %xmm0,%xmm2
addsd  0xed3(%rip),%xmm2
xorps  %xmm1,%xmm1
cvtsd2ss %xmm2,%xmm1
xorps  %xmm0,%xmm0
jmp    1040 <max@plt>
addsd  0xeac(%rip),%xmm2
addsd  %xmm2,%xmm2
addsd  %xmm0,%xmm2
xorps  %xmm1,%xmm1
cvtsd2ss %xmm2,%xmm1
movsd  0xe9d(%rip),%xmm0
jmp    1030 <min@plt>

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

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