#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 esum(int *mu, double *x) {
  static 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):
<esum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    113a <esum+0x2a>
jmp    11a5 <esum+0x95>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jge    114c <esum+0x3c>
jmp    120c <esum+0xfc>
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
mov    -0x18(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,0x2ed4(%rip)
movsd  0x2ecc(%rip),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    117e <esum+0x6e>
jmp    120c <esum+0xfc>
movsd  0x2eb2(%rip),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,0x2e9d(%rip)
movsd  0x2e95(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    125c <esum+0x14c>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jle    11b7 <esum+0xa7>
jmp    120c <esum+0xfc>
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
mov    -0x18(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,0x2e69(%rip)
xorps  %xmm0,%xmm0
ucomisd 0x2e5e(%rip),%xmm0
jbe    11e5 <esum+0xd5>
jmp    120c <esum+0xfc>
movsd  0x2e4b(%rip),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,0x2e36(%rip)
movsd  0x2e2e(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    125c <esum+0x14c>
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
movsd  %xmm0,0x2e1c(%rip)
movsd  0x2e14(%rip),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x2de1(%rip)
movsd  0x2dd9(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<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 <esum+0x33>
test   %eax,%eax
jg     1155 <esum+0x45>
addsd  %xmm1,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
ja     1155 <esum+0x45>
jmp    1179 <esum+0x69>
test   %eax,%eax
js     1155 <esum+0x45>
addsd  %xmm1,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jbe    1179 <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):
@esum.esum = internal global double 0.000000e+00
@esum.w = internal global double 0.000000e+00
define double @esum(i32* %0, double* %1) {
%3 = alloca double
%4 = alloca i32*
%5 = alloca double*
store i32* %0, i32** %4
store double* %1, double** %5
%6 = load double*, double** %5
%7 = load double, double* %6
%8 = fcmp ogt double %7, 0.000000e+00
br i1 %8, label %9, label %10
9: ; preds = %2
br label %29
10: ; preds = %2
%11 = load i32*, i32** %4
%12 = load i32, i32* %11
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
br label %48
15: ; preds = %10
%16 = load i32*, i32** %4
%17 = load i32, i32* %16
%18 = sitofp i32 %17 to double
%19 = load double*, double** %5
%20 = load double, double* %19
%21 = fadd double %18, %20
store double %21, double* @esum.w
%22 = load double, double* @esum.w
%23 = fcmp ogt double %22, 0.000000e+00
br i1 %23, label %24, label %25
24: ; preds = %15
br label %48
25: ; preds = %15
%26 = load double, double* @esum.w
%27 = call double @exp(double %26)
store double %27, double* @esum.esum
%28 = load double, double* @esum.esum
store double %28, double* %3
br label %59
29: ; preds = %9
%30 = load i32*, i32** %4
%31 = load i32, i32* %30
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29
br label %48
34: ; preds = %29
%35 = load i32*, i32** %4
%36 = load i32, i32* %35
%37 = sitofp i32 %36 to double
%38 = load double*, double** %5
%39 = load double, double* %38
%40 = fadd double %37, %39
store double %40, double* @esum.w
%41 = load double, double* @esum.w
%42 = fcmp olt double %41, 0.000000e+00
br i1 %42, label %43, label %44
43: ; preds = %34
br label %48
44: ; preds = %34
%45 = load double, double* @esum.w
%46 = call double @exp(double %45)
store double %46, double* @esum.esum
%47 = load double, double* @esum.esum
store double %47, double* %3
br label %59
48: ; preds = %43, %33, %24, %14
%49 = load i32*, i32** %4
%50 = load i32, i32* %49
%51 = sitofp i32 %50 to double
store double %51, double* @esum.w
%52 = load double, double* @esum.w
%53 = call double @exp(double %52)
%54 = load double*, double** %5
%55 = load double, double* %54
%56 = call double @exp(double %55)
%57 = fmul double %53, %56
store double %57, double* @esum.esum
%58 = load double, double* @esum.esum
store double %58, double* %3
br label %59
59: ; preds = %48, %44, %25
%60 = load double, double* %3
ret double %60
}

LLVM IR (-O2):
define double @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
}