#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 const);
double fabs(double const);
double cdflib_dexpm1(const double *x) {
  static const double p1 = .914041914819518e-09;
  static const double p2 = .238082361044469e-01;
  static const double q1 = -.499999999085958e+00;
  static const double q2 = .107141568980644e+00;
  static const double q3 = -.119041179760821e-01;
  static const double q4 = .595130811860248e-03;
  double dexpm1;
  double w;
  if (fabs(*x) <= 0.15e0) {
    dexpm1 = *x * (((p2 * *x + p1) * *x + 1.0e0) /
                   ((((q4 * *x + q3) * *x + q2) * *x + q1) * *x + 1.0e0));
  } else if (*x <= 0.0e0) {
    w = exp(*x);
    dexpm1 = w - 0.5e0 - 0.5e0;
  } else {
    w = exp(*x);
    dexpm1 = w * (0.5e0 + (0.5e0 - 1.0e0 / w));
  }
  return dexpm1;
}


x86 assembly (clang, -O0):
<cdflib_dexpm1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
movaps 0xf25(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xec9(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     11fb <cdflib_dexpm1+0xeb>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
movsd  0xedf(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xedb(%rip),%xmm2
addsd  %xmm2,%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe93(%rip),%xmm2
addsd  %xmm2,%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
movsd  0xe97(%rip),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe93(%rip),%xmm3
addsd  %xmm3,%xmm2
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe6b(%rip),%xmm3
addsd  %xmm3,%xmm2
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe4b(%rip),%xmm3
addsd  %xmm3,%xmm2
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe2b(%rip),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    128f <cdflib_dexpm1+0x17f>
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jb     1245 <cdflib_dexpm1+0x135>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xddd(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xdd1(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    128a <cdflib_dexpm1+0x17a>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xdac(%rip),%xmm1
divsd  -0x18(%rbp),%xmm1
movsd  0xd97(%rip),%xmm2
subsd  %xmm1,%xmm2
movsd  0xd8b(%rip),%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    128f <cdflib_dexpm1+0x17f>
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdflib_dexpm1>:
sub    $0x18,%rsp
movsd  (%rdi),%xmm3
movapd 0xee0(%rip),%xmm0
andpd  %xmm3,%xmm0
movsd  0xf14(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    1174 <cdflib_dexpm1+0x64>
movapd %xmm3,%xmm0
movapd %xmm3,(%rsp)
call   1030 <exp@plt>
xorpd  %xmm1,%xmm1
ucomisd (%rsp),%xmm1
jae    11dd <cdflib_dexpm1+0xcd>
movsd  0xf11(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xf0d(%rip),%xmm2
addsd  %xmm2,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
add    $0x18,%rsp
ret
movsd  0xecc(%rip),%xmm0
mulsd  %xmm3,%xmm0
addsd  0xec8(%rip),%xmm0
mulsd  %xmm3,%xmm0
addsd  0xec4(%rip),%xmm0
movapd %xmm3,%xmm1
unpcklpd %xmm0,%xmm1
movapd 0xe6c(%rip),%xmm2
unpcklpd %xmm3,%xmm2
mulpd  %xmm1,%xmm2
addpd  0xe6c(%rip),%xmm2
movapd %xmm3,%xmm0
unpcklpd %xmm3,%xmm0
mulpd  %xmm2,%xmm0
addpd  0xe68(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
divsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm0
add    $0x18,%rsp
ret
movsd  0xe7b(%rip),%xmm1
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@cdflib_dexpm1.p1 = internal constant double 0x3E0F67FF69DA8D77
@cdflib_dexpm1.p2 = internal constant double 0x3F98612FADC6B3F6
@cdflib_dexpm1.q1 = internal constant double 0xBFDFFFFFFF04C003
@cdflib_dexpm1.q2 = internal constant double 0x3FBB6DA13ED061EA
@cdflib_dexpm1.q3 = internal constant double 0xBF88612FAB28F4E2
@cdflib_dexpm1.q4 = internal constant double 0x3F438051AFD8141C
define double @cdflib_dexpm1(double* %0) {
%2 = alloca double*
%3 = alloca double
%4 = alloca double
store double* %0, double** %2
%5 = load double*, double** %2
%6 = load double, double* %5
%7 = call double @llvm.fabs.f64(double %6)
%8 = fcmp ole double %7, 1.500000e-01
br i1 %8, label %9, label %32
9: ; preds = %1
%10 = load double*, double** %2
%11 = load double, double* %10
%12 = load double*, double** %2
%13 = load double, double* %12
%14 = call double @llvm.fmuladd.f64(double 0x3F98612FADC6B3F6, double %13, double 0x3E0F67FF69DA8D77)
%15 = load double*, double** %2
%16 = load double, double* %15
%17 = call double @llvm.fmuladd.f64(double %14, double %16, double 1.000000e+00)
%18 = load double*, double** %2
%19 = load double, double* %18
%20 = call double @llvm.fmuladd.f64(double 0x3F438051AFD8141C, double %19, double 0xBF88612FAB28F4E2)
%21 = load double*, double** %2
%22 = load double, double* %21
%23 = call double @llvm.fmuladd.f64(double %20, double %22, double 0x3FBB6DA13ED061EA)
%24 = load double*, double** %2
%25 = load double, double* %24
%26 = call double @llvm.fmuladd.f64(double %23, double %25, double 0xBFDFFFFFFF04C003)
%27 = load double*, double** %2
%28 = load double, double* %27
%29 = call double @llvm.fmuladd.f64(double %26, double %28, double 1.000000e+00)
%30 = fdiv double %17, %29
%31 = fmul double %11, %30
store double %31, double* %3
br label %54
32: ; preds = %1
%33 = load double*, double** %2
%34 = load double, double* %33
%35 = fcmp ole double %34, 0.000000e+00
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load double*, double** %2
%38 = load double, double* %37
%39 = call double @exp(double %38)
store double %39, double* %4
%40 = load double, double* %4
%41 = fsub double %40, 5.000000e-01
%42 = fsub double %41, 5.000000e-01
store double %42, double* %3
br label %53
43: ; preds = %32
%44 = load double*, double** %2
%45 = load double, double* %44
%46 = call double @exp(double %45)
store double %46, double* %4
%47 = load double, double* %4
%48 = load double, double* %4
%49 = fdiv double 1.000000e+00, %48
%50 = fsub double 5.000000e-01, %49
%51 = fadd double 5.000000e-01, %50
%52 = fmul double %47, %51
store double %52, double* %3
br label %53
53: ; preds = %43, %36
br label %54
54: ; preds = %53, %9
%55 = load double, double* %3
ret double %55
}

LLVM IR (-O2):
define double @cdflib_dexpm1(double* nocapture %0) {
%2 = load double, double* %0
%3 = tail call double @llvm.fabs.f64(double %2)
%4 = fcmp ugt double %3, 1.500000e-01
br i1 %4, label %18, label %5
5: ; preds = %1
%6 = tail call double @llvm.fmuladd.f64(double %2, double 0x3F438051AFD8141C, double 0xBF88612FAB28F4E2)
%7 = tail call double @llvm.fmuladd.f64(double %6, double %2, double 0x3FBB6DA13ED061EA)
%8 = insertelement <2 x double> poison, double %2, i64 0
%9 = insertelement <2 x double> %8, double %7, i64 1
%10 = insertelement <2 x double> <double 0x3F98612FADC6B3F6, double poison>, double %2, i64 1
%11 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %9, <2 x double> %10, <2 x double> <double 0x3E0F67FF69DA8D77, double 0xBFDFFFFFFF04C003>)
%12 = shufflevector <2 x double> %8, <2 x double> poison, <2 x i32> zeroinitializer
%13 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %11, <2 x double> %12, <2 x double> <double 1.000000e+00, double 1.000000e+00>)
%14 = extractelement <2 x double> %13, i64 0
%15 = extractelement <2 x double> %13, i64 1
%16 = fdiv double %14, %15
%17 = fmul double %2, %16
br label %29
18: ; preds = %1
%19 = fcmp ugt double %2, 0.000000e+00
%20 = tail call double @exp(double %2)
br i1 %19, label %24, label %21
21: ; preds = %18
%22 = fadd double %20, -5.000000e-01
%23 = fadd double %22, -5.000000e-01
br label %29
24: ; preds = %18
%25 = fdiv double 1.000000e+00, %20
%26 = fsub double 5.000000e-01, %25
%27 = fadd double %26, 5.000000e-01
%28 = fmul double %20, %27
br label %29
29: ; preds = %21, %24, %5
%30 = phi double [ %17, %5 ], [ %23, %21 ], [ %28, %24 ]
ret double %30
}