#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 cdflib_rexp(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 rexp, w;
  if (fabs(*x) > 0.15e0) {
    goto S10;
  }
  rexp = *x * (((p2 * *x + p1) * *x + 1.0e0) /
               ((((q4 * *x + q3) * *x + q2) * *x + q1) * *x + 1.0e0));
  return rexp;
S10:
  w = exp(*x);
  if (*x > 0.0e0) {
    goto S20;
  }
  rexp = w - 0.5e0 - 0.5e0;
  return rexp;
S20:
  rexp = w * (0.5e0 + (0.5e0 - 1.0e0 / w));
  return rexp;
}


x86 assembly (clang, -O0):
<cdflib_rexp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xf25(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xec9(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1146 <cdflib_rexp+0x36>
jmp    120a <cdflib_rexp+0xfa>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
movsd  0xed2(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xece(%rip),%xmm2
addsd  %xmm2,%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe86(%rip),%xmm2
addsd  %xmm2,%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
movsd  0xe8a(%rip),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe86(%rip),%xmm3
addsd  %xmm3,%xmm2
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe5e(%rip),%xmm3
addsd  %xmm3,%xmm2
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe3e(%rip),%xmm3
addsd  %xmm3,%xmm2
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe1e(%rip),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a4 <cdflib_rexp+0x194>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1236 <cdflib_rexp+0x126>
jmp    1267 <cdflib_rexp+0x157>
movsd  -0x20(%rbp),%xmm0
movsd  0xdfd(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xdf1(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a4 <cdflib_rexp+0x194>
movsd  -0x20(%rbp),%xmm0
movsd  0xd94(%rip),%xmm1
divsd  -0x20(%rbp),%xmm1
movsd  0xdbf(%rip),%xmm2
subsd  %xmm1,%xmm2
movsd  0xdb3(%rip),%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdflib_rexp>:
push   %rbx
movsd  (%rdi),%xmm1
movapd 0xee3(%rip),%xmm0
andpd  %xmm1,%xmm0
ucomisd 0xf17(%rip),%xmm0
jbe    1167 <cdflib_rexp+0x57>
mov    %rdi,%rbx
movapd %xmm1,%xmm0
call   1030 <exp@plt>
movsd  (%rbx),%xmm1
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jbe    11cd <cdflib_rexp+0xbd>
movsd  0xf17(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xf13(%rip),%xmm2
addsd  %xmm2,%xmm1
addsd  %xmm2,%xmm1
jmp    11c7 <cdflib_rexp+0xb7>
movsd  0xed9(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xed5(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xed1(%rip),%xmm0
movapd %xmm1,%xmm2
unpcklpd %xmm0,%xmm2
movapd 0xe79(%rip),%xmm3
unpcklpd %xmm1,%xmm3
mulpd  %xmm2,%xmm3
addpd  0xe79(%rip),%xmm3
movapd %xmm1,%xmm0
unpcklpd %xmm1,%xmm0
mulpd  %xmm3,%xmm0
addpd  0xe75(%rip),%xmm0
movapd %xmm0,%xmm2
unpckhpd %xmm0,%xmm2
divsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
pop    %rbx
ret
movsd  0xe8b(%rip),%xmm1
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
pop    %rbx
ret

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

LLVM IR (-O2):
define double @cdflib_rexp(double* nocapture %0) {
%2 = load double, double* %0
%3 = tail call double @llvm.fabs.f64(double %2)
%4 = fcmp ogt 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 %30
18: ; preds = %1
%19 = tail call double @exp(double %2)
%20 = load double, double* %0
%21 = fcmp ogt double %20, 0.000000e+00
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = fadd double %19, -5.000000e-01
%24 = fadd double %23, -5.000000e-01
br label %30
25: ; preds = %18
%26 = fdiv double 1.000000e+00, %19
%27 = fsub double 5.000000e-01, %26
%28 = fadd double %27, 5.000000e-01
%29 = fmul double %19, %28
br label %30
30: ; preds = %25, %22, %5
%31 = phi double [ %29, %25 ], [ %24, %22 ], [ %17, %5 ]
ret double %31
}