#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 = 100000, n = N, a[100000], 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", 100000,
         secs);
  return secs;
}


x86 assembly (clang, -O0):
<run_compute_e>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61ab0,%rsp
mov    $0x0,%al
call   1030 <get_seconds@plt>
movsd  %xmm0,-0x8(%rbp)
movl   $0x186a0,-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,-0x61aa0(%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    -0x61aa4(%rbp),%eax
cltd
idivl  -0x20(%rbp)
movslq -0x20(%rbp),%rax
mov    %edx,-0x61aa0(%rbp,%rax,4)
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
cltq
imul   $0xa,-0x61aa0(%rbp,%rax,4),%eax
0a
mov    %eax,-0x61aa8(%rbp)
mov    -0x61aa4(%rbp),%eax
cltd
idivl  -0x20(%rbp)
mov    %eax,%ecx
mov    -0x61aa8(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x61aa4(%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    $0x186a0,%esi
call   1040 <printf@plt>
movsd  -0x18(%rbp),%xmm0
add    $0x61ab0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_compute_e>:
sub    $0x61a98,%rsp
xor    %eax,%eax
call   1030 <get_seconds@plt>
movq   %xmm0,0x8(%rsp)
movdqa 0xec4(%rip),%xmm5
mov    $0x18690,%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
movdqa %xmm1,0x40(%rsp,%rax,4)
pshufd $0x1b,%xmm0,%xmm0
movdqa %xmm0,0x30(%rsp,%rax,4)
test   %rax,%rax
je     1252 <run_compute_e+0x132>
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
movdqa %xmm0,0x20(%rsp,%rax,4)
pshufd $0x1b,%xmm1,%xmm0
movdqa %xmm0,0x10(%rsp,%rax,4)
paddd  %xmm11,%xmm5
add    $0xfffffffffffffff0,%rax
jmp    1180 <run_compute_e+0x60>
movl   $0x1,0x2c(%rsp)
movabs $0x100000001,%rax
mov    %rax,0x24(%rsp)
mov    %rax,0x1c(%rsp)
movabs $0x100000002,%rax
mov    %rax,0x14(%rsp)
mov    $0x1869f,%edi
mov    $0x186a0,%esi
nopw   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    12a0 <run_compute_e+0x180>
add    $0xffffffffffffffff,%rdi
cmp    $0xb,%r8d
jae    1290 <run_compute_e+0x170>
xor    %eax,%eax
call   1030 <get_seconds@plt>
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xd95(%rip),%rdi
mov    $0x186a0,%esi
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
add    $0x61a98,%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 [100000 x i32]
%7 = alloca i32
%8 = call double (...) @get_seconds()
store double %8, double* %1
store i32 100000, 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 [100000 x i32], [100000 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 [100000 x i32], [100000 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 [100000 x i32], [100000 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 100000, 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 [100000 x i32]
%2 = tail call double (...) @get_seconds()
%3 = bitcast [100000 x i32]* %1 to i8*
br label %4
4: ; preds = %22, %0
%5 = phi i64 [ 0, %0 ], [ %36, %22 ]
%6 = phi <4 x i32> [ <i32 100000, i32 99999, i32 99998, i32 99997>, %0 ], [ %37, %22 ]
%7 = sub nuw nsw i64 99999, %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 [100000 x i32], [100000 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 = icmp eq i64 %5, 99984
br i1 %21, label %38, label %22
22: ; preds = %4
%23 = sub nsw i64 99991, %5
%24 = add <4 x i32> %6, <i32 -12, i32 -12, i32 -12, i32 -12>
%25 = icmp ult <4 x i32> %20, <i32 3, i32 3, i32 3, i32 3>
%26 = icmp ult <4 x i32> %24, <i32 3, i32 3, i32 3, i32 3>
%27 = select <4 x i1> %25, <4 x i32> %20, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
%28 = select <4 x i1> %26, <4 x i32> %24, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
%29 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %23
%30 = shufflevector <4 x i32> %27, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
%31 = getelementptr inbounds i32, i32* %29, i64 -3
%32 = bitcast i32* %31 to <4 x i32>*
store <4 x i32> %30, <4 x i32>* %32
%33 = shufflevector <4 x i32> %28, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
%34 = getelementptr inbounds i32, i32* %29, i64 -7
%35 = bitcast i32* %34 to <4 x i32>*
store <4 x i32> %33, <4 x i32>* %35
%36 = add nuw nsw i64 %5, 16
%37 = add <4 x i32> %6, <i32 -16, i32 -16, i32 -16, i32 -16>
br label %4
38: ; preds = %4
%39 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 7
store i32 1, i32* %39
%40 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 6
store i32 1, i32* %40
%41 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 5
store i32 1, i32* %41
%42 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 4
store i32 1, i32* %42
%43 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 3
store i32 1, i32* %43
%44 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 2
store i32 1, i32* %44
%45 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 1
store i32 2, i32* %45
br label %49
46: ; preds = %55
%47 = icmp ugt i32 %53, 10
%48 = add nsw i64 %51, -1
br i1 %47, label %49, label %71
49: ; preds = %38, %46
%50 = phi i64 [ %54, %46 ], [ 100000, %38 ]
%51 = phi i64 [ %48, %46 ], [ 99999, %38 ]
%52 = phi i32 [ %68, %46 ], [ undef, %38 ]
%53 = trunc i64 %50 to i32
%54 = add nsw i64 %50, -1
br label %55
55: ; preds = %49, %55
%56 = phi i64 [ %50, %49 ], [ %59, %55 ]
%57 = phi i64 [ %51, %49 ], [ %69, %55 ]
%58 = phi i32 [ %52, %49 ], [ %68, %55 ]
%59 = add nsw i64 %56, -1
%60 = trunc i64 %57 to i32
%61 = srem i32 %58, %60
%62 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %57
store i32 %61, i32* %62
%63 = add nsw i64 %56, -2
%64 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %63
%65 = load i32, i32* %64
%66 = mul nsw i32 %65, 10
%67 = sdiv i32 %58, %60
%68 = add nsw i32 %66, %67
%69 = add nsw i64 %57, -1
%70 = icmp eq i64 %69, 0
br i1 %70, label %46, label %55
71: ; preds = %46
%72 = tail call double (...) @get_seconds()
%73 = fsub double %72, %2
%74 = tail call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 100000, double %73)
ret double %73
}