#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);
int main() {
  double d = 0.0, s = 0.0;
  int i;
  for (i = 0; i < 100000000; i++) {
    d = d + 1.0;
    s = s + 1.0 / d;
  }
  printf("%d\n", (int)(1000000.0 * s));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5f5e100,-0x1c(%rbp)
jge    117e <main+0x6e>
movsd  0xebd(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xea6(%rip),%xmm1
divsd  -0x10(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1136 <main+0x26>
movsd  0xe7a(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%esi
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xorpd  %xmm0,%xmm0
mov    $0x5f5e100,%eax
movsd  0xede(%rip),%xmm1
xorpd  %xmm2,%xmm2
cs nopw 0x0(%rax,%rax,1)
addsd  %xmm1,%xmm2
movapd %xmm1,%xmm3
divsd  %xmm2,%xmm3
addsd  %xmm0,%xmm3
addsd  %xmm1,%xmm2
movapd %xmm1,%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm3,%xmm0
add    $0xfffffffe,%eax
jne    1130 <main+0x20>
mulsd  0xeab(%rip),%xmm0
cvttsd2si %xmm0,%esi
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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