#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 *, long double *);
int main(void) {
  long double min_term;
  unsigned long factorial;
  long double term = 1;
  long double result = 0;
  int i = 1;
  printf("Enter the smallest desired term: ");
  scanf("%Lf", &min_term);
  while (term > min_term) {
    factorial = 1;
    for (int j = 1; j < i; j++) {
      factorial *= j;
    }
    term = (long double)1.0 / (long double)factorial;
    printf("%Lf\n", term);
    result += term;
    i++;
  }
  printf("Is is approx. %.60Lf\n", result);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
fld1
fstpt  -0x40(%rbp)
fldz
fstpt  -0x50(%rbp)
movl   $0x1,-0x54(%rbp)
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
fldt   -0x40(%rbp)
fldt   -0x20(%rbp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    1203 <main+0xe3>
jmp    1175 <main+0x55>
movq   $0x1,-0x28(%rbp)
movl   $0x1,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    11ab <main+0x8b>
movslq -0x58(%rbp),%rax
imul   -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1184 <main+0x64>
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
test   %rax,%rax
sets   %al
movzbl %al,%eax
mov    %eax,%ecx
fildll -0x60(%rbp)
lea    0xe38(%rip),%rax
flds   (%rax,%rcx,4)
faddp  %st,%st(1)
fld1
fdivp  %st,%st(1)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
fldt   -0x40(%rbp)
fldt   -0x50(%rbp)
faddp  %st,%st(1)
fstpt  -0x50(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    115e <main+0x3e>
fldt   -0x50(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xe21(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xed6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
lea    0x40(%rsp),%rsi
call   1040 <scanf@plt>
fldt   0x40(%rsp)
fldz
fld1
fld    %st(0)
fstpt  0x1c(%rsp)
fucomip %st(2),%st
fstp   %st(1)
jbe    1283 <main+0x163>
fstp   %st(0)
fldz
mov    $0x1,%r12d
lea    0xe8d(%rip),%r15
lea    0xeb4(%rip),%r14
xor    %ebx,%ebx
jmp    11d0 <main+0xb0>
xchg   %ax,%ax
mov    %rcx,0x10(%rsp)
xor    %eax,%eax
test   %rcx,%rcx
sets   %al
fildll 0x10(%rsp)
fadds  (%r15,%rax,4)
fldt   0x1c(%rsp)
fdivp  %st,%st(1)
fld    %st(0)
fstpt  0x28(%rsp)
fstpt  (%rsp)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
fldt   0x34(%rsp)
fldt   0x28(%rsp)
fadd   %st,%st(1)
add    $0x1,%r12
fldt   0x40(%rsp)
add    $0x1,%rbx
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    1283 <main+0x163>
fstpt  0x34(%rsp)
mov    $0x1,%ecx
cmp    $0x2,%r12
jb     1180 <main+0x60>
lea    -0x1(%rbx),%rdx
mov    $0x1,%eax
mov    $0x1,%ecx
cmp    $0x7,%rdx
jb     1262 <main+0x142>
mov    %rbx,%rdx
and    $0xfffffffffffffff8,%rdx
neg    %rdx
mov    $0x1,%ecx
mov    $0x8,%eax
nopw   0x0(%rax,%rax,1)
lea    -0x7(%rax),%rsi
imul   %rcx,%rsi
lea    -0x6(%rax),%rcx
lea    -0x5(%rax),%rdi
imul   %rdi,%rcx
imul   %rsi,%rcx
lea    -0x4(%rax),%rsi
lea    -0x3(%rax),%rdi
imul   %rdi,%rsi
lea    -0x2(%rax),%rdi
imul   %rsi,%rdi
imul   %rcx,%rdi
lea    -0x1(%rax),%rcx
imul   %rax,%rcx
imul   %rdi,%rcx
lea    (%rdx,%rax,1),%rsi
add    $0x8,%rsi
add    $0x8,%rax
cmp    $0x8,%rsi
jne    1210 <main+0xf0>
add    $0xfffffffffffffff9,%rax
test   $0x7,%bl
je     1180 <main+0x60>
mov    %ebx,%edx
and    $0x7,%edx
imul   %rax,%rcx
add    $0x1,%rax
add    $0xffffffffffffffff,%rdx
jne    1270 <main+0x150>
jmp    1180 <main+0x60>
fstpt  (%rsp)
lea    0xda6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Enter the smallest desired term: \00"
@.str.1 = [4 x i8] c"%Lf\00"
@.str.2 = [5 x i8] c"%Lf\0A\00"
@.str.3 = [22 x i8] c"Is is approx. %.60Lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca x86_fp80
%3 = alloca i64
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %4
store x86_fp80 0xK00000000000000000000, x86_fp80* %5
store i32 1, i32* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), x86_fp80* %2)
br label %10
10: ; preds = %27, %0
%11 = load x86_fp80, x86_fp80* %4
%12 = load x86_fp80, x86_fp80* %2
%13 = fcmp ogt x86_fp80 %11, %12
br i1 %13, label %14, label %38
14: ; preds = %10
store i64 1, i64* %3
store i32 1, i32* %7
br label %15
15: ; preds = %24, %14
%16 = load i32, i32* %7
%17 = load i32, i32* %6
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = load i64, i64* %3
%23 = mul i64 %22, %21
store i64 %23, i64* %3
br label %24
24: ; preds = %19
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %15
27: ; preds = %15
%28 = load i64, i64* %3
%29 = uitofp i64 %28 to x86_fp80
%30 = fdiv x86_fp80 0xK3FFF8000000000000000, %29
store x86_fp80 %30, x86_fp80* %4
%31 = load x86_fp80, x86_fp80* %4
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), x86_fp80 %31)
%33 = load x86_fp80, x86_fp80* %4
%34 = load x86_fp80, x86_fp80* %5
%35 = fadd x86_fp80 %34, %33
store x86_fp80 %35, x86_fp80* %5
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %10
38: ; preds = %10
%39 = load x86_fp80, x86_fp80* %5
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), x86_fp80 %39)
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@.str = [34 x i8] c"Enter the smallest desired term: \00"
@.str.1 = [4 x i8] c"%Lf\00"
@.str.2 = [5 x i8] c"%Lf\0A\00"
@.str.3 = [22 x i8] c"Is is approx. %.60Lf\0A\00"
define i32 @main() {
%1 = alloca x86_fp80
%2 = bitcast x86_fp80* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), x86_fp80* %1)
%5 = load x86_fp80, x86_fp80* %1
%6 = fcmp olt x86_fp80 %5, 0xK3FFF8000000000000000
br i1 %6, label %7, label %63
7: ; preds = %0, %31
%8 = phi i64 [ %40, %31 ], [ 0, %0 ]
%9 = phi i64 [ %37, %31 ], [ 1, %0 ]
%10 = phi x86_fp80 [ %36, %31 ], [ 0xK00000000000000000000, %0 ]
%11 = icmp ugt i64 %9, 1
br i1 %11, label %12, label %31
12: ; preds = %7
%13 = add i64 %8, -1
%14 = and i64 %8, 7
%15 = icmp ult i64 %13, 7
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = and i64 %8, -8
br label %41
18: ; preds = %41, %12
%19 = phi i64 [ undef, %12 ], [ %59, %41 ]
%20 = phi i64 [ 1, %12 ], [ %60, %41 ]
%21 = phi i64 [ 1, %12 ], [ %59, %41 ]
%22 = icmp eq i64 %14, 0
br i1 %22, label %31, label %23
23: ; preds = %18, %23
%24 = phi i64 [ %28, %23 ], [ %20, %18 ]
%25 = phi i64 [ %27, %23 ], [ %21, %18 ]
%26 = phi i64 [ %29, %23 ], [ 0, %18 ]
%27 = mul i64 %25, %24
%28 = add nuw nsw i64 %24, 1
%29 = add i64 %26, 1
%30 = icmp eq i64 %29, %14
br i1 %30, label %31, label %23
31: ; preds = %18, %23, %7
%32 = phi i64 [ 1, %7 ], [ %19, %18 ], [ %27, %23 ]
%33 = uitofp i64 %32 to x86_fp80
%34 = fdiv x86_fp80 0xK3FFF8000000000000000, %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), x86_fp80 %34)
%36 = fadd x86_fp80 %10, %34
%37 = add nuw i64 %9, 1
%38 = load x86_fp80, x86_fp80* %1
%39 = fcmp ogt x86_fp80 %34, %38
%40 = add i64 %8, 1
br i1 %39, label %7, label %63
41: ; preds = %41, %16
%42 = phi i64 [ 1, %16 ], [ %60, %41 ]
%43 = phi i64 [ 1, %16 ], [ %59, %41 ]
%44 = phi i64 [ 0, %16 ], [ %61, %41 ]
%45 = mul i64 %43, %42
%46 = add nuw nsw i64 %42, 1
%47 = mul i64 %45, %46
%48 = add nuw nsw i64 %42, 2
%49 = mul i64 %47, %48
%50 = add nuw nsw i64 %42, 3
%51 = mul i64 %49, %50
%52 = add nuw nsw i64 %42, 4
%53 = mul i64 %51, %52
%54 = add nuw nsw i64 %42, 5
%55 = mul i64 %53, %54
%56 = add nuw nsw i64 %42, 6
%57 = mul i64 %55, %56
%58 = add nuw nsw i64 %42, 7
%59 = mul i64 %57, %58
%60 = add nuw nsw i64 %42, 8
%61 = add i64 %44, 8
%62 = icmp eq i64 %61, %17
br i1 %62, label %18, label %41
63: ; preds = %31, %0
%64 = phi x86_fp80 [ 0xK00000000000000000000, %0 ], [ %36, %31 ]
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), x86_fp80 %64)
ret i32 0
}