#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 *, unsigned int *);
void main() {
  unsigned int N = 1, Cnt;
  double e = 1, X = 1;
  printf("Input N: ");
  scanf("%d", &N);
  for (Cnt = 1; Cnt <= N; Cnt++) {
    X = X / Cnt;
    e = e + X;
  }
  printf("e = %.20f\n", e);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0x4(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xebc(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb4(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
ja     11ad <main+0x8d>
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%eax
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116e <main+0x4e>
movsd  -0x10(%rbp),%xmm0
lea    0xe5c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x1,0x4(%rsp)
lea    0xee0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     116b <main+0x4b>
cmp    $0x1,%eax
jne    1175 <main+0x55>
movsd  0xea3(%rip),%xmm1
movapd %xmm1,%xmm0
movapd %xmm1,%xmm2
test   $0x1,%al
jne    11dc <main+0xbc>
jmp    11e4 <main+0xc4>
movsd  0xe8d(%rip),%xmm0
jmp    11e4 <main+0xc4>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
neg    %ecx
mov    $0x1,%edx
movsd  0xe77(%rip),%xmm1
movsd  0xe77(%rip),%xmm2
movapd %xmm1,%xmm0
movapd %xmm1,%xmm3
nopl   0x0(%rax)
divsd  %xmm3,%xmm1
addsd  %xmm1,%xmm0
lea    0x1(%rdx),%esi
xorps  %xmm4,%xmm4
cvtsi2sd %rsi,%xmm4
divsd  %xmm4,%xmm1
addsd  %xmm1,%xmm0
addsd  %xmm2,%xmm3
mov    %edx,%esi
add    $0x2,%edx
add    %ecx,%esi
add    $0x2,%esi
cmp    $0x1,%esi
jne    11a0 <main+0x80>
mov    %edx,%ecx
xorps  %xmm2,%xmm2
cvtsi2sd %rcx,%xmm2
test   $0x1,%al
je     11e4 <main+0xc4>
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
lea    0xe32(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Input N: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"e = %.20f\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
store i32 1, i32* %1
store double 1.000000e+00, double* %3
store double 1.000000e+00, double* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
store i32 1, i32* %2
br label %7
7: ; preds = %19, %0
%8 = load i32, i32* %2
%9 = load i32, i32* %1
%10 = icmp ule i32 %8, %9
br i1 %10, label %11, label %22
11: ; preds = %7
%12 = load double, double* %4
%13 = load i32, i32* %2
%14 = uitofp i32 %13 to double
%15 = fdiv double %12, %14
store double %15, double* %4
%16 = load double, double* %3
%17 = load double, double* %4
%18 = fadd double %16, %17
store double %18, double* %3
br label %19
19: ; preds = %11
%20 = load i32, i32* %2
%21 = add i32 %20, 1
store i32 %21, i32* %2
br label %7
22: ; preds = %7
%23 = load double, double* %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %23)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"Input N: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"e = %.20f\0A\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 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 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %38, label %7
7: ; preds = %0
%8 = and i32 %5, 1
%9 = icmp eq i32 %5, 1
br i1 %9, label %29, label %10
10: ; preds = %7
%11 = and i32 %5, -2
br label %12
12: ; preds = %12, %10
%13 = phi double [ 1.000000e+00, %10 ], [ %22, %12 ]
%14 = phi double [ 1.000000e+00, %10 ], [ %23, %12 ]
%15 = phi i32 [ 1, %10 ], [ %24, %12 ]
%16 = phi i32 [ 0, %10 ], [ %25, %12 ]
%17 = uitofp i32 %15 to double
%18 = fdiv double %13, %17
%19 = fadd double %14, %18
%20 = add nuw i32 %15, 1
%21 = uitofp i32 %20 to double
%22 = fdiv double %18, %21
%23 = fadd double %19, %22
%24 = add nuw i32 %15, 2
%25 = add i32 %16, 2
%26 = icmp eq i32 %25, %11
br i1 %26, label %27, label %12
27: ; preds = %12
%28 = uitofp i32 %24 to double
br label %29
29: ; preds = %27, %7
%30 = phi double [ undef, %7 ], [ %23, %27 ]
%31 = phi double [ 1.000000e+00, %7 ], [ %22, %27 ]
%32 = phi double [ 1.000000e+00, %7 ], [ %23, %27 ]
%33 = phi double [ 1.000000e+00, %7 ], [ %28, %27 ]
%34 = icmp eq i32 %8, 0
br i1 %34, label %38, label %35
35: ; preds = %29
%36 = fdiv double %31, %33
%37 = fadd double %32, %36
br label %38
38: ; preds = %35, %29, %0
%39 = phi double [ 1.000000e+00, %0 ], [ %30, %29 ], [ %37, %35 ]
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %39)
ret void
}