#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 *, double);
main() {
  int i = 1;
  int fact = 1;
  double e = 1.0;
  while (i < 10) {
    fact *= i;
    e += 1.0 / fact;
    printf("e = %f\n", e);
    i++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movsd  0xecb(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1188 <main+0x78>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xea5(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113a <main+0x2a>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xf30(%rip),%rbx
movsd  0xee0(%rip),%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
movsd  0xed8(%rip),%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
movsd  0xed0(%rip),%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
movsd  0xec8(%rip),%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
movsd  0xec0(%rip),%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
movsd  0xeb8(%rip),%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
movsd  0xeb0(%rip),%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
movsd  0xea8(%rip),%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
movsd  0xea0(%rip),%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"e = %f\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double 2.000000e+00)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double 2.500000e+00)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double 0x4005555555555555)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double 0x4005AAAAAAAAAAAA)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double 0x4005BBBBBBBBBBBB)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double 0x4005BE93E93E93E9)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double 0x4005BEFBEFBEFBF0)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double 0x4005BF08F08F08F1)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double 0x4005BF0A626D4346)
ret i32 0
}