#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 n, e = 1.0f;
  printf("Enter a small floating point number: ");
  scanf("%f", &n);
  int term = 1, factorial = 1;
  for (;;) {
    factorial *= term;
    if (1.0f / factorial < n) {
      break;
    }
    e += (1.0f / factorial);
    term++;
  }
  printf("Result is: %f\n", e);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xec9(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm0
movss  0xe81(%rip),%xmm1
divss  %xmm0,%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1196 <main+0x76>
jmp    11bf <main+0x9f>
cvtsi2ssl -0x14(%rbp),%xmm1
movss  0xe5d(%rip),%xmm0
divss  %xmm1,%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1168 <main+0x48>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe5e(%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
lea    0xee4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xefc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
movss  0x4(%rsp),%xmm0
ucomiss 0xebb(%rip),%xmm0
jbe    1159 <main+0x39>
movsd  0xea9(%rip),%xmm0
jmp    11a4 <main+0x84>
mov    $0x1,%eax
movss  0xea2(%rip),%xmm1
mov    $0x2,%ecx
movaps %xmm1,%xmm3
movaps %xmm1,%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
addss  %xmm3,%xmm2
imul   %ecx,%eax
xorps  %xmm4,%xmm4
cvtsi2ss %eax,%xmm4
movaps %xmm1,%xmm3
divss  %xmm4,%xmm3
add    $0x1,%ecx
ucomiss %xmm3,%xmm0
jbe    1180 <main+0x60>
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
lea    0xe8a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Enter a small floating point number: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [15 x i8] c"Result is: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store float 1.000000e+00, float* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 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* %2)
store i32 1, i32* %4
store i32 1, i32* %5
br label %8
8: ; preds = %18, %0
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = mul nsw i32 %10, %9
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = sitofp i32 %12 to float
%14 = fdiv float 1.000000e+00, %13
%15 = load float, float* %2
%16 = fcmp olt float %14, %15
br i1 %16, label %17, label %18
17: ; preds = %8
br label %26
18: ; preds = %8
%19 = load i32, i32* %5
%20 = sitofp i32 %19 to float
%21 = fdiv float 1.000000e+00, %20
%22 = load float, float* %3
%23 = fadd float %22, %21
store float %23, float* %3
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %8
26: ; preds = %17
%27 = load float, float* %3
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"Enter a small floating point number: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [15 x i8] c"Result is: %f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 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
%6 = fcmp ogt float %5, 1.000000e+00
br i1 %6, label %20, label %7
7: ; preds = %0, %7
%8 = phi float [ %16, %7 ], [ 1.000000e+00, %0 ]
%9 = phi i32 [ %14, %7 ], [ 1, %0 ]
%10 = phi i32 [ %13, %7 ], [ 1, %0 ]
%11 = phi float [ %12, %7 ], [ 1.000000e+00, %0 ]
%12 = fadd float %11, %8
%13 = add nuw nsw i32 %10, 1
%14 = mul nsw i32 %9, %13
%15 = sitofp i32 %14 to float
%16 = fdiv float 1.000000e+00, %15
%17 = fcmp olt float %16, %5
br i1 %17, label %18, label %7
18: ; preds = %7
%19 = fpext float %12 to double
br label %20
20: ; preds = %18, %0
%21 = phi double [ 1.000000e+00, %0 ], [ %19, %18 ]
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %21)
ret i32 0
}