#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 exp(double);
double fabs(double);
double chi(double B, double E1, double E0) {
  if (fabs(E1 - E0) < 1.0e-12) {
    return B * exp(-B * E0);
  } else {
    return -(exp(-B * E1) - exp(-B * E0)) / (E1 - E0);
  }
}


x86 assembly (clang, -O0):
<chi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movaps 0xed8(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xebc(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1194 <chi+0x84>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121b <chi+0x10b>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chi>:
sub    $0x48,%rsp
movapd %xmm0,%xmm5
movapd %xmm1,%xmm3
subsd  %xmm2,%xmm3
movapd 0xed8(%rip),%xmm0
andpd  %xmm3,%xmm0
movsd  0xeec(%rip),%xmm4
ucomisd %xmm0,%xmm4
movapd 0xed0(%rip),%xmm0
xorpd  %xmm5,%xmm0
jbe    115e <chi+0x4e>
mulsd  %xmm2,%xmm0
movapd %xmm5,(%rsp)
call   1030 <exp@plt>
mulsd  (%rsp),%xmm0
add    $0x48,%rsp
ret
mulsd  %xmm0,%xmm1
movapd %xmm0,0x20(%rsp)
movapd %xmm1,%xmm0
movapd %xmm3,(%rsp)
movsd  %xmm2,0x18(%rsp)
call   1030 <exp@plt>
movapd %xmm0,0x30(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
call   1030 <exp@plt>
movapd 0x30(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
xorpd  0xe67(%rip),%xmm0
divsd  (%rsp),%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
define double @chi(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%8 = load double, double* %6
%9 = load double, double* %7
%10 = fsub double %8, %9
%11 = call double @llvm.fabs.f64(double %10)
%12 = fcmp olt double %11, 0x3D719799812DEA11
br i1 %12, label %13, label %21
13: ; preds = %3
%14 = load double, double* %5
%15 = load double, double* %5
%16 = fneg double %15
%17 = load double, double* %7
%18 = fmul double %16, %17
%19 = call double @exp(double %18)
%20 = fmul double %14, %19
store double %20, double* %4
br label %38
21: ; preds = %3
%22 = load double, double* %5
%23 = fneg double %22
%24 = load double, double* %6
%25 = fmul double %23, %24
%26 = call double @exp(double %25)
%27 = load double, double* %5
%28 = fneg double %27
%29 = load double, double* %7
%30 = fmul double %28, %29
%31 = call double @exp(double %30)
%32 = fsub double %26, %31
%33 = fneg double %32
%34 = load double, double* %6
%35 = load double, double* %7
%36 = fsub double %34, %35
%37 = fdiv double %33, %36
store double %37, double* %4
br label %38
38: ; preds = %21, %13
%39 = load double, double* %4
ret double %39
}

LLVM IR (-O2):
define double @chi(double %0, double %1, double %2) {
%4 = fsub double %1, %2
%5 = tail call double @llvm.fabs.f64(double %4)
%6 = fcmp olt double %5, 0x3D719799812DEA11
%7 = fneg double %0
br i1 %6, label %8, label %12
8: ; preds = %3
%9 = fmul double %7, %2
%10 = tail call double @exp(double %9)
%11 = fmul double %10, %0
br label %20
12: ; preds = %3
%13 = fmul double %7, %1
%14 = tail call double @exp(double %13)
%15 = fmul double %7, %2
%16 = tail call double @exp(double %15)
%17 = fsub double %14, %16
%18 = fneg double %17
%19 = fdiv double %18, %4
br label %20
20: ; preds = %12, %8
%21 = phi double [ %11, %8 ], [ %19, %12 ]
ret double %21
}