#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 *, int *);
int main(void) {
  float factorial, e = 1.0f, number;
  int n, i, j;
  printf("enter the number: ");
  scanf("%d", &n);
  printf("1");
  for (i = 1; i <= n; i++) {
    for (j = 1, factorial = 1.0f; j <= i; j++) {
      factorial *= j;
    }
    number = 1.0f / factorial;
    printf(" + 1/%.f", factorial);
    e += number;
  }
  printf("\n\nexp is %.10f\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    0xec6(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11fe <main+0xde>
movl   $0x1,-0x1c(%rbp)
movss  0xe76(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11b8 <main+0x98>
cvtsi2ssl -0x1c(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118f <main+0x6f>
movss  0xe40(%rip),%xmm0
divss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe42(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x10(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116f <main+0x4f>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe17(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xecd(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed0(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    $0x31,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0x8(%rsp)
jle    12a1 <main+0x171>
movss  0xe92(%rip),%xmm4
mov    $0x1,%ebx
lea    0xea0(%rip),%r14
movaps %xmm4,%xmm5
jmp    11cc <main+0x9c>
nopw   0x0(%rax,%rax,1)
movaps %xmm4,%xmm1
divss  %xmm0,%xmm1
addss  %xmm1,%xmm5
movss  %xmm5,0xc(%rsp)
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm5
movss  0xe4b(%rip),%xmm4
lea    0x1(%rbx),%eax
cmp    0x8(%rsp),%ebx
mov    %eax,%ebx
jge    1298 <main+0x168>
mov    %ebp,%ecx
lea    0x1(%rcx),%ebp
mov    $0x1,%eax
movaps %xmm4,%xmm0
cmp    $0x7,%ecx
jb     1264 <main+0x134>
mov    %ebp,%ecx
and    $0xfffffff8,%ecx
mov    $0x1,%eax
movaps %xmm4,%xmm0
nop
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
mulss  %xmm0,%xmm1
lea    0x1(%rax),%edx
xorps  %xmm0,%xmm0
cvtsi2ss %edx,%xmm0
mulss  %xmm1,%xmm0
lea    0x2(%rax),%edx
xorps  %xmm1,%xmm1
cvtsi2ss %edx,%xmm1
lea    0x3(%rax),%edx
xorps  %xmm2,%xmm2
cvtsi2ss %edx,%xmm2
lea    0x4(%rax),%edx
xorps  %xmm3,%xmm3
cvtsi2ss %edx,%xmm3
mulss  %xmm0,%xmm1
mulss  %xmm1,%xmm2
mulss  %xmm2,%xmm3
lea    0x5(%rax),%edx
xorps  %xmm1,%xmm1
cvtsi2ss %edx,%xmm1
mulss  %xmm3,%xmm1
lea    0x6(%rax),%edx
xorps  %xmm2,%xmm2
cvtsi2ss %edx,%xmm2
lea    0x7(%rax),%edx
xorps  %xmm0,%xmm0
cvtsi2ss %edx,%xmm0
mulss  %xmm1,%xmm2
mulss  %xmm2,%xmm0
add    $0x8,%eax
cmp    %ecx,%edx
jne    11f0 <main+0xc0>
test   $0x7,%bpl
je     1190 <main+0x60>
mov    %ebx,%ecx
and    $0x7,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
add    $0x1,%eax
add    $0xffffffff,%ecx
jne    1280 <main+0x150>
jmp    1190 <main+0x60>
xorps  %xmm0,%xmm0
cvtss2sd %xmm5,%xmm0
jmp    12a9 <main+0x179>
movsd  0xd57(%rip),%xmm0
lea    0xd7b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"enter the number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [9 x i8] c" + 1/%.f\00"
@.str.4 = [16 x i8] c"\0A\0Aexp is %.10f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store float 1.000000e+00, float* %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %6
br label %11
11: ; preds = %37, %0
%12 = load i32, i32* %6
%13 = load i32, i32* %5
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %40
15: ; preds = %11
store i32 1, i32* %7
store float 1.000000e+00, float* %2
br label %16
16: ; preds = %25, %15
%17 = load i32, i32* %7
%18 = load i32, i32* %6
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = load i32, i32* %7
%22 = sitofp i32 %21 to float
%23 = load float, float* %2
%24 = fmul float %23, %22
store float %24, float* %2
br label %25
25: ; preds = %20
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %16
28: ; preds = %16
%29 = load float, float* %2
%30 = fdiv float 1.000000e+00, %29
store float %30, float* %4
%31 = load float, float* %2
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), double %32)
%34 = load float, float* %4
%35 = load float, float* %3
%36 = fadd float %35, %34
store float %36, float* %3
br label %37
37: ; preds = %28
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %11
40: ; preds = %11
%41 = load float, float* %3
%42 = fpext float %41 to double
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %42)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"enter the number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [9 x i8] c" + 1/%.f\00"
@.str.4 = [16 x i8] c"\0A\0Aexp is %.10f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 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), i32* %1)
%5 = call i32 @putchar(i32 49)
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 1
br i1 %7, label %73, label %8
8: ; preds = %0, %61
%9 = phi i32 [ %70, %61 ], [ 0, %0 ]
%10 = phi i32 [ %67, %61 ], [ 1, %0 ]
%11 = phi float [ %66, %61 ], [ 1.000000e+00, %0 ]
%12 = add i32 %9, 1
%13 = and i32 %12, 7
%14 = icmp ult i32 %9, 7
br i1 %14, label %47, label %15
15: ; preds = %8
%16 = and i32 %12, -8
br label %17
17: ; preds = %17, %15
%18 = phi i32 [ 1, %15 ], [ %44, %17 ]
%19 = phi float [ 1.000000e+00, %15 ], [ %43, %17 ]
%20 = phi i32 [ 0, %15 ], [ %45, %17 ]
%21 = sitofp i32 %18 to float
%22 = fmul float %19, %21
%23 = add nuw nsw i32 %18, 1
%24 = sitofp i32 %23 to float
%25 = fmul float %22, %24
%26 = add nuw nsw i32 %18, 2
%27 = sitofp i32 %26 to float
%28 = fmul float %25, %27
%29 = add nuw nsw i32 %18, 3
%30 = sitofp i32 %29 to float
%31 = fmul float %28, %30
%32 = add nuw nsw i32 %18, 4
%33 = sitofp i32 %32 to float
%34 = fmul float %31, %33
%35 = add nuw nsw i32 %18, 5
%36 = sitofp i32 %35 to float
%37 = fmul float %34, %36
%38 = add nuw nsw i32 %18, 6
%39 = sitofp i32 %38 to float
%40 = fmul float %37, %39
%41 = add nuw i32 %18, 7
%42 = sitofp i32 %41 to float
%43 = fmul float %40, %42
%44 = add nuw i32 %18, 8
%45 = add i32 %20, 8
%46 = icmp eq i32 %45, %16
br i1 %46, label %47, label %17
47: ; preds = %17, %8
%48 = phi float [ undef, %8 ], [ %43, %17 ]
%49 = phi i32 [ 1, %8 ], [ %44, %17 ]
%50 = phi float [ 1.000000e+00, %8 ], [ %43, %17 ]
%51 = icmp eq i32 %13, 0
br i1 %51, label %61, label %52
52: ; preds = %47, %52
%53 = phi i32 [ %58, %52 ], [ %49, %47 ]
%54 = phi float [ %57, %52 ], [ %50, %47 ]
%55 = phi i32 [ %59, %52 ], [ 0, %47 ]
%56 = sitofp i32 %53 to float
%57 = fmul float %54, %56
%58 = add nuw i32 %53, 1
%59 = add i32 %55, 1
%60 = icmp eq i32 %59, %13
br i1 %60, label %61, label %52
61: ; preds = %52, %47
%62 = phi float [ %48, %47 ], [ %57, %52 ]
%63 = fdiv float 1.000000e+00, %62
%64 = fpext float %62 to double
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), double %64)
%66 = fadd float %11, %63
%67 = add nuw nsw i32 %10, 1
%68 = load i32, i32* %1
%69 = icmp slt i32 %10, %68
%70 = add i32 %9, 1
br i1 %69, label %8, label %71
71: ; preds = %61
%72 = fpext float %66 to double
br label %73
73: ; preds = %71, %0
%74 = phi double [ 1.000000e+00, %0 ], [ %72, %71 ]
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %74)
ret i32 0
}