#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 */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double);
int main(void) {
  double accuracy = -1;
  long e;
  long fact = 1;
  long nextFact = 0;
  double counter = 1;
  int numbTerms = 0;
  while (accuracy < 0) {
    printf("Please enter a positive decimal number (to represent how precise "
           "you want e to be approximated)");
    scanf("%f", accuracy);
  }
  while (counter >= accuracy) {
    nextFact = nextFact + 1;
    fact = fact * nextFact;
    e = e + 1 / fact;
    counter = counter / 10;
  }
  printf("%.15f \n", e);
  printf("Number of terms required to read this value: \n", numbTerms);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xed1(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movq   $0x1,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movsd  0xeac(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1192 <main+0x72>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
lea    0xef0(%rip),%rdi
call   1040 <scanf@plt>
jmp    1160 <main+0x40>
jmp    1197 <main+0x77>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11fc <main+0xdc>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
imul   -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x1,%eax
cqto
idivq  -0x20(%rbp)
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe22(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1197 <main+0x77>
mov    -0x18(%rbp),%rsi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%esi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xedd(%rip),%r14
lea    0xf36(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
movsd  0xeab(%rip),%xmm0
call   1040 <scanf@plt>
jmp    1140 <main+0x20>

LLVM IR (-O0):
@.str = [96 x i8] c"Please enter a positive decimal number (to represent how precise you want e to be approximated)\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [8 x i8] c"%.15f \0A\00"
@.str.3 = [47 x i8] c"Number of terms required to read this value: \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca double
%7 = alloca i32
store i32 0, i32* %1
store double -1.000000e+00, double* %2
store i64 1, i64* %4
store i64 0, i64* %5
store double 1.000000e+00, double* %6
store i32 0, i32* %7
br label %8
8: ; preds = %11, %0
%9 = load double, double* %2
%10 = fcmp olt double %9, 0.000000e+00
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str, i64 0, i64 0))
%13 = load double, double* %2
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double %13)
br label %8
15: ; preds = %8
br label %16
16: ; preds = %20, %15
%17 = load double, double* %6
%18 = load double, double* %2
%19 = fcmp oge double %17, %18
br i1 %19, label %20, label %32
20: ; preds = %16
%21 = load i64, i64* %5
%22 = add nsw i64 %21, 1
store i64 %22, i64* %5
%23 = load i64, i64* %4
%24 = load i64, i64* %5
%25 = mul nsw i64 %23, %24
store i64 %25, i64* %4
%26 = load i64, i64* %3
%27 = load i64, i64* %4
%28 = sdiv i64 1, %27
%29 = add nsw i64 %26, %28
store i64 %29, i64* %3
%30 = load double, double* %6
%31 = fdiv double %30, 1.000000e+01
store double %31, double* %6
br label %16
32: ; preds = %16
%33 = load i64, i64* %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 %33)
%35 = load i32, i32* %7
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i32 %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [96 x i8] c"Please enter a positive decimal number (to represent how precise you want e to be approximated)\00"
@.str.1 = [3 x i8] c"%f\00"
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([96 x i8], [96 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double -1.000000e+00)
br label %1
}