#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 *, float *);
int main(void) {
  float e = 1.00f, term = 1.00f, epsilon = 0.001f;
  printf("enter the epsilon\n");
  scanf("%f", &epsilon);
  for (int i = 1;; i++) {
    term = term / i;
    e = e + term;
    if (term < epsilon) {
      break;
    }
  }
  printf("e:%.6f\n", e);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xecd(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xec0(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xeaf(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0xc(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11b5 <main+0x95>
jmp    11c8 <main+0xa8>
jmp    11ba <main+0x9a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117b <main+0x5b>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe46(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x3a83126f,0x4(%rsp)
3a
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    $0x1,%eax
movss  0xe9d(%rip),%xmm0
movss  0x4(%rsp),%xmm1
movaps %xmm0,%xmm2
nopl   0x0(%rax)
xorps  %xmm3,%xmm3
cvtsi2ss %eax,%xmm3
divss  %xmm3,%xmm2
addss  %xmm2,%xmm0
add    $0x1,%eax
ucomiss %xmm2,%xmm1
jbe    1170 <main+0x40>
cvtss2sd %xmm0,%xmm0
lea    0xe75(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"enter the epsilon\0A\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [8 x i8] c"e:%.6f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca i32
store i32 0, i32* %1
store float 1.000000e+00, float* %2
store float 1.000000e+00, float* %3
store float 0x3F50624DE0000000, float* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
store i32 1, i32* %5
br label %8
8: ; preds = %21, %0
%9 = load float, float* %3
%10 = load i32, i32* %5
%11 = sitofp i32 %10 to float
%12 = fdiv float %9, %11
store float %12, float* %3
%13 = load float, float* %2
%14 = load float, float* %3
%15 = fadd float %13, %14
store float %15, float* %2
%16 = load float, float* %3
%17 = load float, float* %4
%18 = fcmp olt float %16, %17
br i1 %18, label %19, label %20
19: ; preds = %8
br label %24
20: ; preds = %8
br label %21
21: ; preds = %20
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %8
24: ; preds = %19
%25 = load float, float* %2
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %26)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [8 x i8] c"e:%.6f\0A\00"
@str = [18 x i8] c"enter the epsilon\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
store float 0x3F50624DE0000000, float* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%5 = load float, float* %1
br label %6
6: ; preds = %6, %0
%7 = phi float [ 1.000000e+00, %0 ], [ %12, %6 ]
%8 = phi float [ 1.000000e+00, %0 ], [ %11, %6 ]
%9 = phi i32 [ 1, %0 ], [ %14, %6 ]
%10 = sitofp i32 %9 to float
%11 = fdiv float %8, %10
%12 = fadd float %7, %11
%13 = fcmp olt float %11, %5
%14 = add nuw nsw i32 %9, 1
br i1 %13, label %15, label %6
15: ; preds = %6
%16 = fpext float %12 to double
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %16)
ret i32 0
}