#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(float, float);
float blend_screen(float A, float B) {
  return (A >= 0.0 && A <= 1.0 && B >= 0.0 && B <= 1.0) ? A + B - A * B
                                                        : max(A, B);
}


x86 assembly (clang, -O0):
<blend_screen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11b7 <blend_screen+0xa7>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xeb7(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     11b7 <blend_screen+0xa7>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11b7 <blend_screen+0xa7>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe86(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     11b7 <blend_screen+0xa7>
movss  -0x4(%rbp),%xmm1
addss  -0x8(%rbp),%xmm1
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11cb <blend_screen+0xbb>
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1030 <max@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blend_screen>:
movss  0xee8(%rip),%xmm2
ucomiss %xmm1,%xmm2
jb     1145 <blend_screen+0x35>
xorps  %xmm3,%xmm3
ucomiss %xmm3,%xmm0
jb     1145 <blend_screen+0x35>
ucomiss %xmm0,%xmm2
jb     1145 <blend_screen+0x35>
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm1
jb     1145 <blend_screen+0x35>
movaps %xmm0,%xmm2
addss  %xmm1,%xmm2
mulss  %xmm1,%xmm0
subss  %xmm0,%xmm2
movaps %xmm2,%xmm0
ret
jmp    1030 <max@plt>

LLVM IR (-O0):
define float @blend_screen(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 oge double %6, 0.000000e+00
br i1 %7, label %8, label %28
8: ; preds = %2
%9 = load float, float* %3
%10 = fpext float %9 to double
%11 = fcmp ole double %10, 1.000000e+00
br i1 %11, label %12, label %28
12: ; preds = %8
%13 = load float, float* %4
%14 = fpext float %13 to double
%15 = fcmp oge double %14, 0.000000e+00
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = load float, float* %4
%18 = fpext float %17 to double
%19 = fcmp ole double %18, 1.000000e+00
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = load float, float* %3
%22 = load float, float* %4
%23 = fadd float %21, %22
%24 = load float, float* %3
%25 = load float, float* %4
%26 = fneg float %24
%27 = call float @llvm.fmuladd.f32(float %26, float %25, float %23)
br label %32
28: ; preds = %16, %12, %8, %2
%29 = load float, float* %3
%30 = load float, float* %4
%31 = call float @max(float %29, float %30)
br label %32
32: ; preds = %28, %20
%33 = phi float [ %27, %20 ], [ %31, %28 ]
ret float %33
}

LLVM IR (-O2):
define float @blend_screen(float %0, float %1) {
%3 = fcmp ult float %0, 0.000000e+00
%4 = fcmp ugt float %0, 1.000000e+00
%5 = or i1 %3, %4
%6 = fcmp ult float %1, 0.000000e+00
%7 = or i1 %5, %6
%8 = fcmp ugt float %1, 1.000000e+00
%9 = or i1 %8, %7
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = fadd float %0, %1
%12 = fneg float %0
%13 = tail call float @llvm.fmuladd.f32(float %12, float %1, float %11)
br label %16
14: ; preds = %2
%15 = tail call float @max(float %0, float %1)
br label %16
16: ; preds = %14, %10
%17 = phi float [ %13, %10 ], [ %15, %14 ]
ret float %17
}