#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 contrast(float v, float contrast_value) {
  float _c = (contrast_value <= 0.0) ? contrast_value + 1.0
                                     : (1.0 / (1.0 - contrast_value));
  return (v - 0.5) * max(_c, 0.0f) + 0.5;
}


x86 assembly (clang, -O0):
<contrast>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jb     1157 <contrast+0x47>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeb7(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    117d <contrast+0x6d>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe98(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  0xe8c(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe6c(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
call   1030 <max@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe3e(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<contrast>:
push   %rax
cvtss2sd %xmm1,%xmm2
xorps  %xmm3,%xmm3
ucomiss %xmm1,%xmm3
jae    1137 <contrast+0x27>
movsd  0xedb(%rip),%xmm1
movapd %xmm1,%xmm3
subsd  %xmm2,%xmm3
divsd  %xmm3,%xmm1
movapd %xmm1,%xmm2
jmp    113f <contrast+0x2f>
addsd  0xec1(%rip),%xmm2
cvtsd2ss %xmm2,%xmm2
cvtss2sd %xmm0,%xmm0
addsd  0xeb9(%rip),%xmm0
movsd  %xmm0,(%rsp)
xorps  %xmm1,%xmm1
movaps %xmm2,%xmm0
call   1030 <max@plt>
cvtss2sd %xmm0,%xmm0
mulsd  (%rsp),%xmm0
addsd  0xea0(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
pop    %rax
ret

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

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