#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 */
float n_fact(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, a;
  scanf("%d", &n);
  if (!(n >= 0 && n <= 20)) {
    printf("error");
    return 0;
  }
  float s = 0, z;
  for (a = 1; a <= n; a++) {
    z = (float)1 / n_fact(a);
    s = z + s;
  }
  printf("%f", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xebe(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     1163 <main+0x33>
cmpl   $0x14,-0x8(%rbp)
jle    117d <main+0x4d>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ef <main+0xbf>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11d1 <main+0xa1>
mov    -0xc(%rbp),%edi
call   1030 <n_fact@plt>
movaps %xmm0,%xmm1
movss  0xe55(%rip),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118c <main+0x5c>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe2c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec8(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%eax
cmp    $0x14,%eax
ja     1192 <main+0x62>
test   %eax,%eax
je     11a2 <main+0x72>
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movss  %xmm0,0xc(%rsp)
add    $0x1,%ebx
mov    %ebx,%edi
call   1030 <n_fact@plt>
movss  0xe88(%rip),%xmm1
divss  %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
addss  %xmm1,%xmm0
cmp    0x8(%rsp),%ebx
jl     1160 <main+0x30>
cvtss2sd %xmm0,%xmm0
jmp    11a5 <main+0x75>
lea    0xe6e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11b3 <main+0x83>
xorps  %xmm0,%xmm0
lea    0xe61(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"error\00"
@.str.2 = [3 x i8] c"%f\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp ult i32 %4, 21
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = icmp eq i32 %4, 0
br i1 %7, label %21, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %24
10: ; preds = %6, %10
%11 = phi float [ %15, %10 ], [ 0.000000e+00, %6 ]
%12 = phi i32 [ %16, %10 ], [ 1, %6 ]
%13 = call float @n_fact(i32 %12)
%14 = fdiv float 1.000000e+00, %13
%15 = fadd float %11, %14
%16 = add nuw nsw i32 %12, 1
%17 = load i32, i32* %1
%18 = icmp slt i32 %12, %17
br i1 %18, label %10, label %19
19: ; preds = %10
%20 = fpext float %15 to double
br label %21
21: ; preds = %19, %6
%22 = phi double [ 0.000000e+00, %6 ], [ %20, %19 ]
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), double %22)
br label %24
24: ; preds = %21, %8
ret i32 0
}