#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);
scalar_t__ isinf(double);
double fermi_dirac_derivative(double E, double EF, double kBTemp) {
  if (kBTemp == 0) {
    if (E == EF) {
      return -1E20;
    } else {
      return 0;
    }
  } else {
    double tmp = exp((E - EF) / kBTemp);
    if (tmp == 0 || isinf(tmp)) {
      return 0;
    } else {
      return -tmp / (kBTemp * (1 + tmp) * (1 + tmp));
    }
  }
}


x86 assembly (clang, -O0):
<fermi_dirac_derivative>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1184 <fermi_dirac_derivative+0x64>
jp     1184 <fermi_dirac_derivative+0x64>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1177 <fermi_dirac_derivative+0x57>
jp     1177 <fermi_dirac_derivative+0x57>
movsd  0xe9b(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1227 <fermi_dirac_derivative+0x107>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1227 <fermi_dirac_derivative+0x107>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ba <fermi_dirac_derivative+0x9a>
jp     11ba <fermi_dirac_derivative+0x9a>
jmp    11ce <fermi_dirac_derivative+0xae>
movsd  -0x28(%rbp),%xmm0
call   1040 <isinf@plt>
cmp    $0x0,%rax
je     11db <fermi_dirac_derivative+0xbb>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1227 <fermi_dirac_derivative+0x107>
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xdfc(%rip),%xmm2
addsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdeb(%rip),%xmm2
addsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fermi_dirac_derivative>:
sub    $0x28,%rsp
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm2
jne    1143 <fermi_dirac_derivative+0x23>
jp     1143 <fermi_dirac_derivative+0x23>
cmpeqsd %xmm1,%xmm0
movsd  0xedb(%rip),%xmm1
andpd  %xmm0,%xmm1
jmp    11a2 <fermi_dirac_derivative+0x82>
subsd  %xmm1,%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm2,0x8(%rsp)
call   1030 <exp@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1162 <fermi_dirac_derivative+0x42>
jnp    11a2 <fermi_dirac_derivative+0x82>
movapd %xmm0,0x10(%rsp)
call   1040 <isinf@plt>
xorpd  %xmm1,%xmm1
test   %rax,%rax
jne    11a2 <fermi_dirac_derivative+0x82>
movapd 0xe82(%rip),%xmm1
movapd 0x10(%rsp),%xmm2
xorpd  %xmm2,%xmm1
addsd  0xe80(%rip),%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @fermi_dirac_derivative(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%9 = load double, double* %7
%10 = fcmp oeq double %9, 0.000000e+00
br i1 %10, label %11, label %17
11: ; preds = %3
%12 = load double, double* %5
%13 = load double, double* %6
%14 = fcmp oeq double %12, %13
br i1 %14, label %15, label %16
15: ; preds = %11
store double -1.000000e+20, double* %4
br label %42
16: ; preds = %11
store double 0.000000e+00, double* %4
br label %42
17: ; preds = %3
%18 = load double, double* %5
%19 = load double, double* %6
%20 = fsub double %18, %19
%21 = load double, double* %7
%22 = fdiv double %20, %21
%23 = call double @exp(double %22)
store double %23, double* %8
%24 = load double, double* %8
%25 = fcmp oeq double %24, 0.000000e+00
br i1 %25, label %30, label %26
26: ; preds = %17
%27 = load double, double* %8
%28 = call i64 @isinf(double %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26, %17
store double 0.000000e+00, double* %4
br label %42
31: ; preds = %26
%32 = load double, double* %8
%33 = fneg double %32
%34 = load double, double* %7
%35 = load double, double* %8
%36 = fadd double 1.000000e+00, %35
%37 = fmul double %34, %36
%38 = load double, double* %8
%39 = fadd double 1.000000e+00, %38
%40 = fmul double %37, %39
%41 = fdiv double %33, %40
store double %41, double* %4
br label %42
42: ; preds = %31, %30, %16, %15
%43 = load double, double* %4
ret double %43
}

LLVM IR (-O2):
define double @fermi_dirac_derivative(double %0, double %1, double %2) {
%4 = fcmp oeq double %2, 0.000000e+00
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = fcmp oeq double %0, %1
%7 = select i1 %6, double -1.000000e+20, double 0.000000e+00
br label %22
8: ; preds = %3
%9 = fsub double %0, %1
%10 = fdiv double %9, %2
%11 = tail call double @exp(double %10)
%12 = fcmp oeq double %11, 0.000000e+00
br i1 %12, label %22, label %13
13: ; preds = %8
%14 = tail call i64 @isinf(double %11)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = fneg double %11
%18 = fadd double %11, 1.000000e+00
%19 = fmul double %18, %2
%20 = fmul double %18, %19
%21 = fdiv double %17, %20
br label %22
22: ; preds = %16, %13, %8, %5
%23 = phi double [ %7, %5 ], [ %21, %16 ], [ 0.000000e+00, %13 ], [ 0.000000e+00, %8 ]
ret double %23
}