#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);
int main() {
  double S = 1.0, i = 2;
  while (i <= 100.0) {
    S = S + (1 / i);
    i = i + 1.0;
  }
  printf("%0.2lf\n", S);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xee1(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xecc(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xecf(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     117e <main+0x6e>
movsd  -0x10(%rbp),%xmm0
movsd  0xeaf(%rip),%xmm1
divsd  -0x18(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe99(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1139 <main+0x29>
movsd  -0x10(%rbp),%xmm0
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movsd  0xee7(%rip),%xmm1
movsd  0xee7(%rip),%xmm2
mov    $0x4,%eax
movsd  0xee2(%rip),%xmm3
movapd %xmm1,%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movapd %xmm1,%xmm4
divsd  %xmm2,%xmm4
addsd  %xmm0,%xmm4
lea    -0x1(%rax),%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movapd %xmm1,%xmm5
divsd  %xmm0,%xmm5
addsd  %xmm4,%xmm5
xorps  %xmm4,%xmm4
cvtsi2sd %eax,%xmm4
movapd %xmm1,%xmm0
divsd  %xmm4,%xmm0
addsd  %xmm5,%xmm0
addsd  %xmm3,%xmm2
add    $0x3,%eax
cmp    $0x67,%eax
jne    1140 <main+0x30>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%0.2lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
store double 1.000000e+00, double* %2
store double 2.000000e+00, double* %3
br label %4
4: ; preds = %7, %0
%5 = load double, double* %3
%6 = fcmp ole double %5, 1.000000e+02
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = load double, double* %2
%9 = load double, double* %3
%10 = fdiv double 1.000000e+00, %9
%11 = fadd double %8, %10
store double %11, double* %2
%12 = load double, double* %3
%13 = fadd double %12, 1.000000e+00
store double %13, double* %3
br label %4
14: ; preds = %4
%15 = load double, double* %2
%16 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%0.2lf\0A\00"
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 2, %0 ], [ %15, %1 ]
%3 = phi double [ 1.000000e+00, %0 ], [ %14, %1 ]
%4 = sitofp i32 %2 to double
%5 = fdiv double 1.000000e+00, %4
%6 = fadd double %3, %5
%7 = add nuw nsw i32 %2, 1
%8 = sitofp i32 %7 to double
%9 = fdiv double 1.000000e+00, %8
%10 = fadd double %6, %9
%11 = add nuw nsw i32 %2, 2
%12 = sitofp i32 %11 to double
%13 = fdiv double 1.000000e+00, %12
%14 = fadd double %10, %13
%15 = add nuw nsw i32 %2, 3
%16 = icmp eq i32 %15, 101
br i1 %16, label %17, label %1
17: ; preds = %1
%18 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %14)
ret i32 0
}