#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 cdflib_esum(const int *mu, const double *x) {
  double esum, w;
  if (*x > 0.0e0) {
    goto S10;
  }
  if (*mu < 0) {
    goto S20;
  }
  w = (double)*mu + *x;
  if (w > 0.0e0) {
    goto S20;
  }
  esum = exp(w);
  return esum;
S10:
  if (*mu > 0) {
    goto S20;
  }
  w = (double)*mu + *x;
  if (w < 0.0e0) {
    goto S20;
  }
  esum = exp(w);
  return esum;
S20:
  w = *mu;
  esum = exp(w) * exp(*x);
  return esum;
}


x86 assembly (clang, -O0):
<cdflib_esum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    113a <cdflib_esum+0x2a>
jmp    1196 <cdflib_esum+0x86>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jge    114c <cdflib_esum+0x3c>
jmp    11ee <cdflib_esum+0xde>
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
mov    -0x18(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1178 <cdflib_esum+0x68>
jmp    11ee <cdflib_esum+0xde>
movsd  -0x28(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1232 <cdflib_esum+0x122>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jle    11a8 <cdflib_esum+0x98>
jmp    11ee <cdflib_esum+0xde>
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
mov    -0x18(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11d0 <cdflib_esum+0xc0>
jmp    11ee <cdflib_esum+0xde>
movsd  -0x28(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1232 <cdflib_esum+0x122>
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdflib_esum>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
movsd  (%rsi),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    (%rdi),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
jbe    1143 <cdflib_esum+0x33>
test   %eax,%eax
jg     1155 <cdflib_esum+0x45>
addsd  %xmm1,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
ja     1155 <cdflib_esum+0x45>
jmp    1179 <cdflib_esum+0x69>
test   %eax,%eax
js     1155 <cdflib_esum+0x45>
addsd  %xmm1,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jbe    1179 <cdflib_esum+0x69>
movapd %xmm1,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx),%xmm0
call   1030 <exp@plt>
mulsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret
add    $0x10,%rsp
pop    %rbx
jmp    1030 <exp@plt>

LLVM IR (-O0):
define double @cdflib_esum(i32* %0, double* %1) {
%3 = alloca double
%4 = alloca i32*
%5 = alloca double*
%6 = alloca double
%7 = alloca double
store i32* %0, i32** %4
store double* %1, double** %5
%8 = load double*, double** %5
%9 = load double, double* %8
%10 = fcmp ogt double %9, 0.000000e+00
br i1 %10, label %11, label %12
11: ; preds = %2
br label %31
12: ; preds = %2
%13 = load i32*, i32** %4
%14 = load i32, i32* %13
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
br label %50
17: ; preds = %12
%18 = load i32*, i32** %4
%19 = load i32, i32* %18
%20 = sitofp i32 %19 to double
%21 = load double*, double** %5
%22 = load double, double* %21
%23 = fadd double %20, %22
store double %23, double* %7
%24 = load double, double* %7
%25 = fcmp ogt double %24, 0.000000e+00
br i1 %25, label %26, label %27
26: ; preds = %17
br label %50
27: ; preds = %17
%28 = load double, double* %7
%29 = call double @exp(double %28)
store double %29, double* %6
%30 = load double, double* %6
store double %30, double* %3
br label %61
31: ; preds = %11
%32 = load i32*, i32** %4
%33 = load i32, i32* %32
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31
br label %50
36: ; preds = %31
%37 = load i32*, i32** %4
%38 = load i32, i32* %37
%39 = sitofp i32 %38 to double
%40 = load double*, double** %5
%41 = load double, double* %40
%42 = fadd double %39, %41
store double %42, double* %7
%43 = load double, double* %7
%44 = fcmp olt double %43, 0.000000e+00
br i1 %44, label %45, label %46
45: ; preds = %36
br label %50
46: ; preds = %36
%47 = load double, double* %7
%48 = call double @exp(double %47)
store double %48, double* %6
%49 = load double, double* %6
store double %49, double* %3
br label %61
50: ; preds = %45, %35, %26, %16
%51 = load i32*, i32** %4
%52 = load i32, i32* %51
%53 = sitofp i32 %52 to double
store double %53, double* %7
%54 = load double, double* %7
%55 = call double @exp(double %54)
%56 = load double*, double** %5
%57 = load double, double* %56
%58 = call double @exp(double %57)
%59 = fmul double %55, %58
store double %59, double* %6
%60 = load double, double* %6
store double %60, double* %3
br label %61
61: ; preds = %50, %46, %27
%62 = load double, double* %3
ret double %62
}

LLVM IR (-O2):
define double @cdflib_esum(i32* nocapture %0, double* nocapture %1) {
%3 = load double, double* %1
%4 = fcmp ogt double %3, 0.000000e+00
%5 = load i32, i32* %0
br i1 %4, label %14, label %6
6: ; preds = %2
%7 = icmp slt i32 %5, 0
br i1 %7, label %22, label %8
8: ; preds = %6
%9 = sitofp i32 %5 to double
%10 = fadd double %3, %9
%11 = fcmp ogt double %10, 0.000000e+00
br i1 %11, label %22, label %12
12: ; preds = %8
%13 = tail call double @exp(double %10)
br label %28
14: ; preds = %2
%15 = icmp sgt i32 %5, 0
br i1 %15, label %22, label %16
16: ; preds = %14
%17 = sitofp i32 %5 to double
%18 = fadd double %3, %17
%19 = fcmp olt double %18, 0.000000e+00
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = tail call double @exp(double %18)
br label %28
22: ; preds = %16, %14, %8, %6
%23 = sitofp i32 %5 to double
%24 = tail call double @exp(double %23)
%25 = load double, double* %1
%26 = tail call double @exp(double %25)
%27 = fmul double %24, %26
br label %28
28: ; preds = %22, %20, %12
%29 = phi double [ %27, %22 ], [ %21, %20 ], [ %13, %12 ]
ret double %29
}