#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);
int fabs(double);
double Ei1(double x) {
  double epsilon = 1.e-10;
  double Am1 = 1.;
  double A0 = 0.;
  double Bm1 = 0.;
  double B0 = 1.;
  double a = exp(x);
  double b = -x + 1.;
  double Ap1 = b * A0 + a * Am1;
  double Bp1 = b * B0 + a * Bm1;
  int j = 1;
  a = 1.;
  while (fabs(Ap1 * B0 - A0 * Bp1) > epsilon * fabs(A0 * Bp1)) {
    if (fabs(Bp1) > 1.) {
      Am1 = A0 / Bp1;
      A0 = Ap1 / Bp1;
      Bm1 = B0 / Bp1;
      B0 = 1.;
    } else {
      Am1 = A0;
      A0 = Ap1;
      Bm1 = B0;
      B0 = Bp1;
    }
    a = -j * j;
    b += 2.;
    Ap1 = b * A0 + a * Am1;
    Bp1 = b * B0 + a * Bm1;
    j += 1;
  }
  return (-Ap1 / Bp1);
}


x86 assembly (clang, -O0):
<Ei1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xed3(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xebe(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xea1(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe69(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x1,-0x54(%rbp)
movsd  0xe0f(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
call   1030 <fabs@plt>
movsd  -0x68(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm0
cvtsi2sd %eax,%xmm2
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1367 <Ei1+0x247>
movsd  -0x50(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xd7e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12cb <Ei1+0x1ab>
movsd  -0x20(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x48(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xd3f(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12f3 <Ei1+0x1d3>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
xor    %eax,%eax
sub    -0x54(%rbp),%eax
imul   -0x54(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xd03(%rip),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11f6 <Ei1+0xd6>
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x50(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Ei1>:
push   %rbx
sub    $0x50,%rsp
movsd  %xmm0,(%rsp)
call   1040 <exp@plt>
movsd  0xec9(%rip),%xmm2
subsd  (%rsp),%xmm2
xorpd  %xmm3,%xmm3
movapd %xmm2,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
mulsd  %xmm3,%xmm0
movapd %xmm2,0x40(%rsp)
addsd  %xmm2,%xmm0
movapd %xmm0,(%rsp)
mulsd  %xmm0,%xmm3
movsd  %xmm3,0x30(%rsp)
movapd %xmm1,%xmm0
subsd  %xmm3,%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x30(%rsp),%xmm0
call   1030 <fabs@plt>
movapd (%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe60(%rip),%xmm0
movsd  0x18(%rsp),%xmm2
ucomisd %xmm0,%xmm2
unpcklpd 0x20(%rsp),%xmm1
jbe    12de <Ei1+0x1be>
movsd  0xe3a(%rip),%xmm0
mov    $0x1,%ebx
jmp    12ab <Ei1+0x18b>
movapd (%rsp),%xmm3
movapd %xmm3,%xmm0
unpckhpd %xmm3,%xmm0
divsd  %xmm3,%xmm0
movapd 0xe37(%rip),%xmm1
unpcklpd %xmm0,%xmm1
unpcklpd %xmm3,%xmm3
movapd 0x20(%rsp),%xmm2
divpd  %xmm3,%xmm2
movapd %xmm1,%xmm0
movapd 0x40(%rsp),%xmm1
movapd %xmm0,%xmm3
mov    %ebx,%eax
imul   %ebx,%eax
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0xdf1(%rip),%xmm1
unpcklpd %xmm0,%xmm0
mulpd  %xmm2,%xmm0
movapd %xmm1,0x40(%rsp)
unpcklpd %xmm1,%xmm1
movapd %xmm3,0x20(%rsp)
mulpd  %xmm3,%xmm1
addpd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
add    $0x1,%ebx
movapd %xmm3,%xmm2
unpckhpd %xmm3,%xmm2
mulsd  %xmm1,%xmm2
movapd %xmm2,0x30(%rsp)
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
mulsd  %xmm3,%xmm0
subsd  %xmm2,%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x18(%rsp)
movaps 0x30(%rsp),%xmm0
call   1030 <fabs@plt>
movapd (%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xd6f(%rip),%xmm0
movsd  0x18(%rsp),%xmm2
ucomisd %xmm0,%xmm2
movapd 0x20(%rsp),%xmm0
jbe    12de <Ei1+0x1be>
movapd %xmm1,(%rsp)
movapd %xmm0,0x20(%rsp)
movapd %xmm1,%xmm0
call   1030 <fabs@plt>
cmp    $0x2,%eax
jge    11d0 <Ei1+0xb0>
movapd 0x40(%rsp),%xmm1
movapd (%rsp),%xmm0
movapd 0x20(%rsp),%xmm2
jmp    1205 <Ei1+0xe5>
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
xorpd  0xd42(%rip),%xmm0
divsd  %xmm1,%xmm0
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @Ei1(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
%11 = alloca double
%12 = alloca i32
store double %0, double* %2
store double 1.000000e-10, double* %3
store double 1.000000e+00, double* %4
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %6
store double 1.000000e+00, double* %7
%13 = load double, double* %2
%14 = call double @exp(double %13)
store double %14, double* %8
%15 = load double, double* %2
%16 = fneg double %15
%17 = fadd double %16, 1.000000e+00
store double %17, double* %9
%18 = load double, double* %9
%19 = load double, double* %5
%20 = load double, double* %8
%21 = load double, double* %4
%22 = fmul double %20, %21
%23 = call double @llvm.fmuladd.f64(double %18, double %19, double %22)
store double %23, double* %10
%24 = load double, double* %9
%25 = load double, double* %7
%26 = load double, double* %8
%27 = load double, double* %6
%28 = fmul double %26, %27
%29 = call double @llvm.fmuladd.f64(double %24, double %25, double %28)
store double %29, double* %11
store i32 1, i32* %12
store double 1.000000e+00, double* %8
br label %30
30: ; preds = %68, %1
%31 = load double, double* %10
%32 = load double, double* %7
%33 = load double, double* %5
%34 = load double, double* %11
%35 = fmul double %33, %34
%36 = fneg double %35
%37 = call double @llvm.fmuladd.f64(double %31, double %32, double %36)
%38 = call i32 @fabs(double %37)
%39 = sitofp i32 %38 to double
%40 = load double, double* %3
%41 = load double, double* %5
%42 = load double, double* %11
%43 = fmul double %41, %42
%44 = call i32 @fabs(double %43)
%45 = sitofp i32 %44 to double
%46 = fmul double %40, %45
%47 = fcmp ogt double %39, %46
br i1 %47, label %48, label %90
48: ; preds = %30
%49 = load double, double* %11
%50 = call i32 @fabs(double %49)
%51 = sitofp i32 %50 to double
%52 = fcmp ogt double %51, 1.000000e+00
br i1 %52, label %53, label %63
53: ; preds = %48
%54 = load double, double* %5
%55 = load double, double* %11
%56 = fdiv double %54, %55
store double %56, double* %4
%57 = load double, double* %10
%58 = load double, double* %11
%59 = fdiv double %57, %58
store double %59, double* %5
%60 = load double, double* %7
%61 = load double, double* %11
%62 = fdiv double %60, %61
store double %62, double* %6
store double 1.000000e+00, double* %7
br label %68
63: ; preds = %48
%64 = load double, double* %5
store double %64, double* %4
%65 = load double, double* %10
store double %65, double* %5
%66 = load double, double* %7
store double %66, double* %6
%67 = load double, double* %11
store double %67, double* %7
br label %68
68: ; preds = %63, %53
%69 = load i32, i32* %12
%70 = sub nsw i32 0, %69
%71 = load i32, i32* %12
%72 = mul nsw i32 %70, %71
%73 = sitofp i32 %72 to double
store double %73, double* %8
%74 = load double, double* %9
%75 = fadd double %74, 2.000000e+00
store double %75, double* %9
%76 = load double, double* %9
%77 = load double, double* %5
%78 = load double, double* %8
%79 = load double, double* %4
%80 = fmul double %78, %79
%81 = call double @llvm.fmuladd.f64(double %76, double %77, double %80)
store double %81, double* %10
%82 = load double, double* %9
%83 = load double, double* %7
%84 = load double, double* %8
%85 = load double, double* %6
%86 = fmul double %84, %85
%87 = call double @llvm.fmuladd.f64(double %82, double %83, double %86)
store double %87, double* %11
%88 = load i32, i32* %12
%89 = add nsw i32 %88, 1
store i32 %89, i32* %12
br label %30
90: ; preds = %30
%91 = load double, double* %10
%92 = fneg double %91
%93 = load double, double* %11
%94 = fdiv double %92, %93
ret double %94
}

LLVM IR (-O2):
define double @Ei1(double %0) {
%2 = tail call double @exp(double %0)
%3 = fsub double 1.000000e+00, %0
%4 = tail call double @llvm.fmuladd.f64(double %3, double 0.000000e+00, double %2)
%5 = fmul double %2, 0.000000e+00
%6 = fadd double %3, %5
%7 = fmul double %6, 0.000000e+00
%8 = fsub double %4, %7
%9 = tail call i32 @fabs(double %8)
%10 = sitofp i32 %9 to double
%11 = tail call i32 @fabs(double %7)
%12 = sitofp i32 %11 to double
%13 = fmul double %12, 1.000000e-10
%14 = fcmp olt double %13, %10
%15 = insertelement <2 x double> poison, double %6, i64 0
%16 = insertelement <2 x double> %15, double %4, i64 1
br i1 %14, label %17, label %59
17: ; preds = %1, %31
%18 = phi i32 [ %45, %31 ], [ 1, %1 ]
%19 = phi double [ %37, %31 ], [ %3, %1 ]
%20 = phi <2 x double> [ %43, %31 ], [ %16, %1 ]
%21 = phi <2 x double> [ %32, %31 ], [ <double 1.000000e+00, double 0.000000e+00>, %1 ]
%22 = extractelement <2 x double> %20, i64 0
%23 = tail call i32 @fabs(double %22)
%24 = icmp sgt i32 %23, 1
br i1 %24, label %25, label %31
25: ; preds = %17
%26 = extractelement <2 x double> %20, i64 1
%27 = fdiv double %26, %22
%28 = shufflevector <2 x double> %20, <2 x double> undef, <2 x i32> zeroinitializer
%29 = fdiv <2 x double> %21, %28
%30 = insertelement <2 x double> <double 1.000000e+00, double poison>, double %27, i64 1
br label %31
31: ; preds = %17, %25
%32 = phi <2 x double> [ %30, %25 ], [ %20, %17 ]
%33 = phi <2 x double> [ %29, %25 ], [ %21, %17 ]
%34 = mul i32 %18, %18
%35 = sub i32 0, %34
%36 = sitofp i32 %35 to double
%37 = fadd double %19, 2.000000e+00
%38 = insertelement <2 x double> poison, double %36, i64 0
%39 = shufflevector <2 x double> %38, <2 x double> poison, <2 x i32> zeroinitializer
%40 = fmul <2 x double> %33, %39
%41 = insertelement <2 x double> poison, double %37, i64 0
%42 = shufflevector <2 x double> %41, <2 x double> poison, <2 x i32> zeroinitializer
%43 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %42, <2 x double> %32, <2 x double> %40)
%44 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %42, <2 x double> %32, <2 x double> %40)
%45 = add nuw nsw i32 %18, 1
%46 = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%47 = fmul <2 x double> %46, %44
%48 = extractelement <2 x double> %47, i64 0
%49 = fneg double %48
%50 = extractelement <2 x double> %44, i64 1
%51 = extractelement <2 x double> %32, i64 0
%52 = tail call double @llvm.fmuladd.f64(double %50, double %51, double %49)
%53 = tail call i32 @fabs(double %52)
%54 = sitofp i32 %53 to double
%55 = tail call i32 @fabs(double %48)
%56 = sitofp i32 %55 to double
%57 = fmul double %56, 1.000000e-10
%58 = fcmp olt double %57, %54
br i1 %58, label %17, label %59
59: ; preds = %31, %1
%60 = phi <2 x double> [ %16, %1 ], [ %44, %31 ]
%61 = extractelement <2 x double> %60, i64 1
%62 = fneg double %61
%63 = extractelement <2 x double> %60, i64 0
%64 = fdiv double %62, %63
ret double %64
}