#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 get_seconds();
int /*<<< orphan*/ printf(char *, int, double);
double run_compute_e() {
  double begin, end;
  double secs;
  begin = get_seconds();
  int N = 9009, n = N, a[9009], x;
  while (--n) {
    a[n] = 1 + 1 / n;
  }
  for (; N > 9;) {
    for (n = N--; --n; a[n] = x % n, x = 10 * a[n - 1] + x / n) {
    }
  }
  end = get_seconds();
  secs = (end - begin);
  printf("Time to run computation of e (%d digits): %.2f[secs]\n", 9009, secs);
  return secs;
}


x86 assembly (clang, -O0):
<run_compute_e>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8d00,%rsp
mov    $0x0,%al
call   1030 <get_seconds@plt>
movsd  %xmm0,-0x8(%rbp)
movl   $0x2331,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
je     1174 <run_compute_e+0x54>
mov    $0x1,%eax
cltd
idivl  -0x20(%rbp)
mov    %eax,%ecx
add    $0x1,%ecx
movslq -0x20(%rbp),%rax
mov    %ecx,-0x8cf0(%rbp,%rax,4)
jmp    1144 <run_compute_e+0x24>
jmp    1179 <run_compute_e+0x59>
cmpl   $0x9,-0x1c(%rbp)
jle    11f7 <run_compute_e+0xd7>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
je     11f2 <run_compute_e+0xd2>
jmp    11a8 <run_compute_e+0x88>
mov    -0x8cf4(%rbp),%eax
cltd
idivl  -0x20(%rbp)
movslq -0x20(%rbp),%rax
mov    %edx,-0x8cf0(%rbp,%rax,4)
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
cltq
imul   $0xa,-0x8cf0(%rbp,%rax,4),%eax
0a
mov    %eax,-0x8cf8(%rbp)
mov    -0x8cf4(%rbp),%eax
cltd
idivl  -0x20(%rbp)
mov    %eax,%ecx
mov    -0x8cf8(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x8cf4(%rbp)
jmp    1191 <run_compute_e+0x71>
jmp    1179 <run_compute_e+0x59>
mov    $0x0,%al
call   1030 <get_seconds@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xde2(%rip),%rdi
mov    $0x2331,%esi
call   1040 <printf@plt>
movsd  -0x18(%rbp),%xmm0
add    $0x8d00,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_compute_e>:
sub    $0x8cd8,%rsp
xor    %eax,%eax
call   1030 <get_seconds@plt>
movq   %xmm0,0x8(%rsp)
movdqa 0xec4(%rip),%xmm5
mov    $0x2330,%eax
movdqa 0xec6(%rip),%xmm8
movdqa 0xecd(%rip),%xmm12
movdqa 0xed5(%rip),%xmm2
pcmpeqd %xmm4,%xmm4
movdqa 0xed8(%rip),%xmm9
movdqa 0xedf(%rip),%xmm10
movdqa 0xee6(%rip),%xmm11
nopw   0x0(%rax,%rax,1)
movdqa %xmm5,%xmm0
paddd  %xmm8,%xmm0
movdqa %xmm5,%xmm1
pxor   %xmm12,%xmm1
movdqa %xmm2,%xmm3
pcmpgtd %xmm1,%xmm3
movdqa %xmm0,%xmm1
pxor   %xmm12,%xmm1
movdqa %xmm2,%xmm6
pcmpgtd %xmm1,%xmm6
movdqa %xmm5,%xmm1
pand   %xmm3,%xmm1
paddd  %xmm3,%xmm1
psubd  %xmm4,%xmm1
pand   %xmm6,%xmm0
paddd  %xmm6,%xmm0
psubd  %xmm4,%xmm0
pshufd $0x1b,%xmm1,%xmm1
movdqu %xmm1,0x4(%rsp,%rax,4)
pshufd $0x1b,%xmm0,%xmm0
movdqu %xmm0,-0xc(%rsp,%rax,4)
movdqa %xmm5,%xmm0
paddd  %xmm9,%xmm0
movdqa %xmm5,%xmm1
paddd  %xmm10,%xmm1
movdqa %xmm0,%xmm3
pxor   %xmm12,%xmm3
movdqa %xmm2,%xmm6
pcmpgtd %xmm3,%xmm6
movdqa %xmm1,%xmm3
pxor   %xmm12,%xmm3
movdqa %xmm2,%xmm7
pcmpgtd %xmm3,%xmm7
pand   %xmm6,%xmm0
paddd  %xmm6,%xmm0
psubd  %xmm4,%xmm0
pand   %xmm7,%xmm1
paddd  %xmm7,%xmm1
psubd  %xmm4,%xmm1
pshufd $0x1b,%xmm0,%xmm0
movdqu %xmm0,-0x1c(%rsp,%rax,4)
pshufd $0x1b,%xmm1,%xmm0
movdqu %xmm0,-0x2c(%rsp,%rax,4)
paddd  %xmm11,%xmm5
add    $0xfffffffffffffff0,%rax
jne    1180 <run_compute_e+0x60>
mov    $0x2330,%edi
mov    $0x2331,%esi
nopl   0x0(%rax,%rax,1)
mov    %esi,%r8d
add    $0xffffffffffffffff,%rsi
mov    %rdi,%rcx
nopw   0x0(%rax,%rax,1)
cltd
idiv   %ecx
mov    %edx,0x10(%rsp,%rcx,4)
mov    0xc(%rsp,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
lea    (%rax,%rdx,2),%eax
add    $0xffffffffffffffff,%rcx
jne    1270 <run_compute_e+0x150>
add    $0xffffffffffffffff,%rdi
cmp    $0xb,%r8d
jae    1260 <run_compute_e+0x140>
xor    %eax,%eax
call   1030 <get_seconds@plt>
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xdc5(%rip),%rdi
mov    $0x2331,%esi
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
add    $0x8cd8,%rsp
ret

LLVM IR (-O0):
@.str = [54 x i8] c"Time to run computation of e (%d digits): %.2f[secs]\0A\00"
define double @run_compute_e() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca [9009 x i32]
%7 = alloca i32
%8 = call double (...) @get_seconds()
store double %8, double* %1
store i32 9009, i32* %4
%9 = load i32, i32* %4
store i32 %9, i32* %5
br label %10
10: ; preds = %14, %0
%11 = load i32, i32* %5
%12 = add nsw i32 %11, -1
store i32 %12, i32* %5
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = load i32, i32* %5
%16 = sdiv i32 1, %15
%17 = add nsw i32 1, %16
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [9009 x i32], [9009 x i32]* %6, i64 0, i64 %19
store i32 %17, i32* %20
br label %10
21: ; preds = %10
br label %22
22: ; preds = %50, %21
%23 = load i32, i32* %4
%24 = icmp sgt i32 %23, 9
br i1 %24, label %25, label %51
25: ; preds = %22
%26 = load i32, i32* %4
%27 = add nsw i32 %26, -1
store i32 %27, i32* %4
store i32 %26, i32* %5
br label %28
28: ; preds = %33, %25
%29 = load i32, i32* %5
%30 = add nsw i32 %29, -1
store i32 %30, i32* %5
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %50
32: ; preds = %28
br label %33
33: ; preds = %32
%34 = load i32, i32* %7
%35 = load i32, i32* %5
%36 = srem i32 %34, %35
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [9009 x i32], [9009 x i32]* %6, i64 0, i64 %38
store i32 %36, i32* %39
%40 = load i32, i32* %5
%41 = sub nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [9009 x i32], [9009 x i32]* %6, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = mul nsw i32 10, %44
%46 = load i32, i32* %7
%47 = load i32, i32* %5
%48 = sdiv i32 %46, %47
%49 = add nsw i32 %45, %48
store i32 %49, i32* %7
br label %28
50: ; preds = %28
br label %22
51: ; preds = %22
%52 = call double (...) @get_seconds()
store double %52, double* %2
%53 = load double, double* %2
%54 = load double, double* %1
%55 = fsub double %53, %54
store double %55, double* %3
%56 = load double, double* %3
%57 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 9009, double %56)
%58 = load double, double* %3
ret double %58
}

LLVM IR (-O2):
@.str = [54 x i8] c"Time to run computation of e (%d digits): %.2f[secs]\0A\00"
define double @run_compute_e() {
%1 = alloca [9009 x i32]
%2 = tail call double (...) @get_seconds()
%3 = bitcast [9009 x i32]* %1 to i8*
br label %4
4: ; preds = %4, %0
%5 = phi i64 [ 0, %0 ], [ %34, %4 ]
%6 = phi <4 x i32> [ <i32 9009, i32 9008, i32 9007, i32 9006>, %0 ], [ %35, %4 ]
%7 = sub nuw nsw i64 9008, %5
%8 = add <4 x i32> %6, <i32 -4, i32 -4, i32 -4, i32 -4>
%9 = icmp ult <4 x i32> %6, <i32 3, i32 3, i32 3, i32 3>
%10 = icmp ult <4 x i32> %8, <i32 3, i32 3, i32 3, i32 3>
%11 = select <4 x i1> %9, <4 x i32> %6, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
%12 = select <4 x i1> %10, <4 x i32> %8, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
%13 = getelementptr inbounds [9009 x i32], [9009 x i32]* %1, i64 0, i64 %7
%14 = shufflevector <4 x i32> %11, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
%15 = getelementptr inbounds i32, i32* %13, i64 -3
%16 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> %14, <4 x i32>* %16
%17 = shufflevector <4 x i32> %12, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
%18 = getelementptr inbounds i32, i32* %13, i64 -7
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> %17, <4 x i32>* %19
%20 = add <4 x i32> %6, <i32 -8, i32 -8, i32 -8, i32 -8>
%21 = sub nsw i64 9000, %5
%22 = add <4 x i32> %6, <i32 -12, i32 -12, i32 -12, i32 -12>
%23 = icmp ult <4 x i32> %20, <i32 3, i32 3, i32 3, i32 3>
%24 = icmp ult <4 x i32> %22, <i32 3, i32 3, i32 3, i32 3>
%25 = select <4 x i1> %23, <4 x i32> %20, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
%26 = select <4 x i1> %24, <4 x i32> %22, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
%27 = getelementptr inbounds [9009 x i32], [9009 x i32]* %1, i64 0, i64 %21
%28 = shufflevector <4 x i32> %25, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
%29 = getelementptr inbounds i32, i32* %27, i64 -3
%30 = bitcast i32* %29 to <4 x i32>*
store <4 x i32> %28, <4 x i32>* %30
%31 = shufflevector <4 x i32> %26, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
%32 = getelementptr inbounds i32, i32* %27, i64 -7
%33 = bitcast i32* %32 to <4 x i32>*
store <4 x i32> %31, <4 x i32>* %33
%34 = add nuw nsw i64 %5, 16
%35 = add <4 x i32> %6, <i32 -16, i32 -16, i32 -16, i32 -16>
%36 = icmp eq i64 %34, 9008
br i1 %36, label %40, label %4
37: ; preds = %46
%38 = icmp ugt i32 %44, 10
%39 = add nsw i64 %42, -1
br i1 %38, label %40, label %62
40: ; preds = %4, %37
%41 = phi i64 [ %45, %37 ], [ 9009, %4 ]
%42 = phi i64 [ %39, %37 ], [ 9008, %4 ]
%43 = phi i32 [ %59, %37 ], [ undef, %4 ]
%44 = trunc i64 %41 to i32
%45 = add nsw i64 %41, -1
br label %46
46: ; preds = %40, %46
%47 = phi i64 [ %41, %40 ], [ %50, %46 ]
%48 = phi i64 [ %42, %40 ], [ %60, %46 ]
%49 = phi i32 [ %43, %40 ], [ %59, %46 ]
%50 = add nsw i64 %47, -1
%51 = trunc i64 %48 to i32
%52 = srem i32 %49, %51
%53 = getelementptr inbounds [9009 x i32], [9009 x i32]* %1, i64 0, i64 %48
store i32 %52, i32* %53
%54 = add nsw i64 %47, -2
%55 = getelementptr inbounds [9009 x i32], [9009 x i32]* %1, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = mul nsw i32 %56, 10
%58 = sdiv i32 %49, %51
%59 = add nsw i32 %57, %58
%60 = add nsw i64 %48, -1
%61 = icmp eq i64 %60, 0
br i1 %61, label %37, label %46
62: ; preds = %37
%63 = tail call double (...) @get_seconds()
%64 = fsub double %63, %2
%65 = tail call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 9009, double %64)
ret double %64
}