#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 */
int exp(double);
int fabs(double);
int pow(double, double);
double dB(double x) {
  double ret;
  if (fabs(x) > 1e-10) {
    ret = (exp(x) - 1.0 - x * exp(x)) / (exp(x) - 1) / (exp(x) - 1);
  } else {
    ret = -1.0 / 2.0 + x / 6.0 - pow(x, 3.0) / 180.0 + pow(x, 5.0) / 5040;
  }
  return ret;
}


x86 assembly (clang, -O0):
<dB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xead(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1205 <dB+0xd5>
movsd  -0x8(%rbp),%xmm0
call   1040 <exp@plt>
cvtsi2sd %eax,%xmm0
movsd  0xebd(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <exp@plt>
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
cvtsi2sd %eax,%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <exp@plt>
movsd  -0x20(%rbp),%xmm0
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <exp@plt>
movsd  -0x18(%rbp),%xmm0
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1283 <dB+0x153>
movsd  -0x8(%rbp),%xmm1
movsd  0xe16(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe02(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xde4(%rip),%xmm1
call   1050 <pow@plt>
movsd  -0x40(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
movsd  0xdc6(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xda4(%rip),%xmm1
call   1050 <pow@plt>
movsd  -0x38(%rbp),%xmm0
mov    $0x13b0,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dB>:
sub    $0x28,%rsp
movaps %xmm0,0x10(%rsp)
call   1030 <fabs@plt>
test   %eax,%eax
jle    11d3 <dB+0xa3>
movaps 0x10(%rsp),%xmm0
call   1040 <exp@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0xeb9(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movaps 0x10(%rsp),%xmm0
call   1040 <exp@plt>
cvtsi2sd %eax,%xmm2
movapd 0x10(%rsp),%xmm0
mulsd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm1
subsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
call   1040 <exp@plt>
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movaps 0x10(%rsp),%xmm0
call   1040 <exp@plt>
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret
movsd  0xe25(%rip),%xmm1
movaps 0x10(%rsp),%xmm0
call   1050 <pow@plt>
cvtsi2sd %eax,%xmm2
movapd 0x10(%rsp),%xmm0
movapd %xmm0,%xmm1
unpcklpd %xmm2,%xmm1
divpd  0xe21(%rip),%xmm1
movsd  0xe01(%rip),%xmm2
addsd  %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
subsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0xdef(%rip),%xmm1
call   1050 <pow@plt>
cltq
imul   $0xffffffffd00d00d1,%rax,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xc,%eax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @dB(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
%4 = load double, double* %2
%5 = call i32 @fabs(double %4)
%6 = sitofp i32 %5 to double
%7 = fcmp ogt double %6, 1.000000e-10
br i1 %7, label %8, label %29
8: ; preds = %1
%9 = load double, double* %2
%10 = call i32 @exp(double %9)
%11 = sitofp i32 %10 to double
%12 = fsub double %11, 1.000000e+00
%13 = load double, double* %2
%14 = load double, double* %2
%15 = call i32 @exp(double %14)
%16 = sitofp i32 %15 to double
%17 = fneg double %13
%18 = call double @llvm.fmuladd.f64(double %17, double %16, double %12)
%19 = load double, double* %2
%20 = call i32 @exp(double %19)
%21 = sub nsw i32 %20, 1
%22 = sitofp i32 %21 to double
%23 = fdiv double %18, %22
%24 = load double, double* %2
%25 = call i32 @exp(double %24)
%26 = sub nsw i32 %25, 1
%27 = sitofp i32 %26 to double
%28 = fdiv double %23, %27
store double %28, double* %3
br label %43
29: ; preds = %1
%30 = load double, double* %2
%31 = fdiv double %30, 6.000000e+00
%32 = fadd double -5.000000e-01, %31
%33 = load double, double* %2
%34 = call i32 @pow(double %33, double 3.000000e+00)
%35 = sitofp i32 %34 to double
%36 = fdiv double %35, 1.800000e+02
%37 = fsub double %32, %36
%38 = load double, double* %2
%39 = call i32 @pow(double %38, double 5.000000e+00)
%40 = sdiv i32 %39, 5040
%41 = sitofp i32 %40 to double
%42 = fadd double %37, %41
store double %42, double* %3
br label %43
43: ; preds = %29, %8
%44 = load double, double* %3
ret double %44
}

LLVM IR (-O2):
define double @dB(double %0) {
%2 = tail call i32 @fabs(double %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %20
4: ; preds = %1
%5 = tail call i32 @exp(double %0)
%6 = sitofp i32 %5 to double
%7 = fadd double %6, -1.000000e+00
%8 = tail call i32 @exp(double %0)
%9 = sitofp i32 %8 to double
%10 = fneg double %0
%11 = tail call double @llvm.fmuladd.f64(double %10, double %9, double %7)
%12 = tail call i32 @exp(double %0)
%13 = add nsw i32 %12, -1
%14 = sitofp i32 %13 to double
%15 = fdiv double %11, %14
%16 = tail call i32 @exp(double %0)
%17 = add nsw i32 %16, -1
%18 = sitofp i32 %17 to double
%19 = fdiv double %15, %18
br label %34
20: ; preds = %1
%21 = tail call i32 @pow(double %0, double 3.000000e+00)
%22 = sitofp i32 %21 to double
%23 = insertelement <2 x double> poison, double %0, i64 0
%24 = insertelement <2 x double> %23, double %22, i64 1
%25 = fdiv <2 x double> %24, <double 6.000000e+00, double 1.800000e+02>
%26 = extractelement <2 x double> %25, i64 0
%27 = fadd double %26, -5.000000e-01
%28 = extractelement <2 x double> %25, i64 1
%29 = fsub double %27, %28
%30 = tail call i32 @pow(double %0, double 5.000000e+00)
%31 = sdiv i32 %30, 5040
%32 = sitofp i32 %31 to double
%33 = fadd double %29, %32
br label %34
34: ; preds = %20, %4
%35 = phi double [ %19, %4 ], [ %33, %20 ]
ret double %35
}