#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 */
scalar_t__ fact(int);
int /*<<< orphan*/ printf(char *, float);
int main() {
  int n = 0;
  float e = 0;
  while (n <= 10) {
    e += 1.0 / (float)fact(n);
    n++;
  }
  printf("napier is %f", e);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
cmpl   $0xa,-0x8(%rbp)
jg     1189 <main+0x69>
mov    -0x8(%rbp),%edi
call   1040 <fact@plt>
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe9f(%rip),%xmm1
divsd  %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113e <main+0x1e>
movss  -0xc(%rbp),%xmm0
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %edi,%edi
call   1040 <fact@plt>
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xec7(%rip),%xmm1
divsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0x1,%edi
call   1040 <fact@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe93(%rip),%xmm1
divsd  %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0x2,%edi
call   1040 <fact@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe59(%rip),%xmm1
divsd  %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0x3,%edi
call   1040 <fact@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe1f(%rip),%xmm1
divsd  %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0x4,%edi
call   1040 <fact@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xde5(%rip),%xmm1
divsd  %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0x5,%edi
call   1040 <fact@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdab(%rip),%xmm1
divsd  %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0x6,%edi
call   1040 <fact@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd71(%rip),%xmm1
divsd  %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0x7,%edi
call   1040 <fact@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd37(%rip),%xmm1
divsd  %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0x8,%edi
call   1040 <fact@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcfd(%rip),%xmm1
divsd  %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0x9,%edi
call   1040 <fact@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcc3(%rip),%xmm1
divsd  %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0xa,%edi
call   1040 <fact@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xc89(%rip),%xmm1
divsd  %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
lea    0xc74(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"napier is %f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
store i32 0, i32* %1
store i32 0, i32* %2
store float 0.000000e+00, float* %3
br label %4
4: ; preds = %7, %0
%5 = load i32, i32* %2
%6 = icmp sle i32 %5, 10
br i1 %6, label %7, label %19
7: ; preds = %4
%8 = load i32, i32* %2
%9 = call i64 @fact(i32 %8)
%10 = sitofp i64 %9 to float
%11 = fpext float %10 to double
%12 = fdiv double 1.000000e+00, %11
%13 = load float, float* %3
%14 = fpext float %13 to double
%15 = fadd double %14, %12
%16 = fptrunc double %15 to float
store float %16, float* %3
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %4
19: ; preds = %4
%20 = load float, float* %3
%21 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), float %20)
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [13 x i8] c"napier is %f\00"
define i32 @main() {
%1 = tail call i64 @fact(i32 0)
%2 = sitofp i64 %1 to float
%3 = fpext float %2 to double
%4 = fdiv double 1.000000e+00, %3
%5 = fadd double %4, 0.000000e+00
%6 = fptrunc double %5 to float
%7 = tail call i64 @fact(i32 1)
%8 = sitofp i64 %7 to float
%9 = fpext float %8 to double
%10 = fdiv double 1.000000e+00, %9
%11 = fpext float %6 to double
%12 = fadd double %10, %11
%13 = fptrunc double %12 to float
%14 = tail call i64 @fact(i32 2)
%15 = sitofp i64 %14 to float
%16 = fpext float %15 to double
%17 = fdiv double 1.000000e+00, %16
%18 = fpext float %13 to double
%19 = fadd double %17, %18
%20 = fptrunc double %19 to float
%21 = tail call i64 @fact(i32 3)
%22 = sitofp i64 %21 to float
%23 = fpext float %22 to double
%24 = fdiv double 1.000000e+00, %23
%25 = fpext float %20 to double
%26 = fadd double %24, %25
%27 = fptrunc double %26 to float
%28 = tail call i64 @fact(i32 4)
%29 = sitofp i64 %28 to float
%30 = fpext float %29 to double
%31 = fdiv double 1.000000e+00, %30
%32 = fpext float %27 to double
%33 = fadd double %31, %32
%34 = fptrunc double %33 to float
%35 = tail call i64 @fact(i32 5)
%36 = sitofp i64 %35 to float
%37 = fpext float %36 to double
%38 = fdiv double 1.000000e+00, %37
%39 = fpext float %34 to double
%40 = fadd double %38, %39
%41 = fptrunc double %40 to float
%42 = tail call i64 @fact(i32 6)
%43 = sitofp i64 %42 to float
%44 = fpext float %43 to double
%45 = fdiv double 1.000000e+00, %44
%46 = fpext float %41 to double
%47 = fadd double %45, %46
%48 = fptrunc double %47 to float
%49 = tail call i64 @fact(i32 7)
%50 = sitofp i64 %49 to float
%51 = fpext float %50 to double
%52 = fdiv double 1.000000e+00, %51
%53 = fpext float %48 to double
%54 = fadd double %52, %53
%55 = fptrunc double %54 to float
%56 = tail call i64 @fact(i32 8)
%57 = sitofp i64 %56 to float
%58 = fpext float %57 to double
%59 = fdiv double 1.000000e+00, %58
%60 = fpext float %55 to double
%61 = fadd double %59, %60
%62 = fptrunc double %61 to float
%63 = tail call i64 @fact(i32 9)
%64 = sitofp i64 %63 to float
%65 = fpext float %64 to double
%66 = fdiv double 1.000000e+00, %65
%67 = fpext float %62 to double
%68 = fadd double %66, %67
%69 = fptrunc double %68 to float
%70 = tail call i64 @fact(i32 10)
%71 = sitofp i64 %70 to float
%72 = fpext float %71 to double
%73 = fdiv double 1.000000e+00, %72
%74 = fpext float %69 to double
%75 = fadd double %73, %74
%76 = fptrunc double %75 to float
%77 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), float %76)
ret i32 0
}