#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 log(double);
double Ei2(double x) {
  double epsilon = 1.e-10;
  double xn = -x;
  double Sn = -x;
  double Sm1 = 0.;
  double hsum = 1.;
  double g = 0.5772156649015328606065121;
  double y = 1.;
  double factorial = 1.;
  while (fabs(Sn - Sm1) > epsilon * fabs(Sm1)) {
    Sm1 = Sn;
    y += 1.;
    xn *= (-x);
    factorial *= y;
    hsum += 1. / y;
    Sn += hsum * xn / factorial;
  }
  return (g + log(fabs(x)) - exp(x) * Sn);
}


x86 assembly (clang, -O0):
<Ei2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xedb(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe74(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe6f(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe5a(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe4d(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movaps 0xe57(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movaps 0xe42(%rip),%xmm3
pand   %xmm3,%xmm2
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1276 <Ei2+0x156>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdfe(%rip),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xdb7(%rip),%xmm0
divsd  -0x40(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11b8 <Ei2+0x98>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xd94(%rip),%xmm1
pand   %xmm1,%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <exp@plt>
movsd  -0x50(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Ei2>:
sub    $0x28,%rsp
movapd %xmm0,%xmm10
movapd 0xecf(%rip),%xmm2
xorpd  %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm10
je     11cd <Ei2+0xad>
movsd  0xed3(%rip),%xmm11
movapd 0xeba(%rip),%xmm9
movsd  0xec9(%rip),%xmm8
movapd %xmm11,%xmm4
movapd %xmm11,%xmm5
movapd %xmm2,%xmm3
movapd %xmm11,%xmm7
movapd %xmm2,%xmm0
cs nopw 0x0(%rax,%rax,1)
addsd  %xmm11,%xmm5
mulsd  %xmm2,%xmm3
mulsd  %xmm5,%xmm4
movapd %xmm11,%xmm1
divsd  %xmm5,%xmm1
addsd  %xmm1,%xmm7
movapd %xmm3,%xmm6
mulsd  %xmm7,%xmm6
divsd  %xmm4,%xmm6
addsd  %xmm0,%xmm6
movapd %xmm6,%xmm1
subsd  %xmm0,%xmm1
andpd  %xmm9,%xmm1
andpd  %xmm9,%xmm0
mulsd  %xmm8,%xmm0
ucomisd %xmm0,%xmm1
movapd %xmm6,%xmm0
ja     1180 <Ei2+0x60>
jmp    11d1 <Ei2+0xb1>
movapd %xmm2,%xmm6
movsd  %xmm6,0x8(%rsp)
movapd 0xe31(%rip),%xmm0
andpd  %xmm10,%xmm0
movapd %xmm10,0x10(%rsp)
call   1040 <log@plt>
addsd  0xe38(%rip),%xmm0
movsd  %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
call   1030 <exp@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

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

LLVM IR (-O2):
define double @Ei2(double %0) {
%2 = fneg double %0
%3 = fcmp ueq double %0, 0.000000e+00
br i1 %3, label %23, label %4
4: ; preds = %1, %4
%5 = phi double [ %12, %4 ], [ 1.000000e+00, %1 ]
%6 = phi double [ %10, %4 ], [ 1.000000e+00, %1 ]
%7 = phi double [ %11, %4 ], [ %2, %1 ]
%8 = phi double [ %14, %4 ], [ 1.000000e+00, %1 ]
%9 = phi double [ %17, %4 ], [ %2, %1 ]
%10 = fadd double %6, 1.000000e+00
%11 = fmul double %7, %2
%12 = fmul double %5, %10
%13 = fdiv double 1.000000e+00, %10
%14 = fadd double %8, %13
%15 = fmul double %11, %14
%16 = fdiv double %15, %12
%17 = fadd double %9, %16
%18 = fsub double %17, %9
%19 = tail call double @llvm.fabs.f64(double %18)
%20 = tail call double @llvm.fabs.f64(double %9)
%21 = fmul double %20, 1.000000e-10
%22 = fcmp ogt double %19, %21
br i1 %22, label %4, label %23
23: ; preds = %4, %1
%24 = phi double [ %2, %1 ], [ %17, %4 ]
%25 = tail call double @llvm.fabs.f64(double %0)
%26 = tail call double @log(double %25)
%27 = fadd double %26, 0x3FE2788CFC6FB619
%28 = tail call double @exp(double %0)
%29 = fneg double %28
%30 = tail call double @llvm.fmuladd.f64(double %29, double %24, double %27)
ret double %30
}