#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() {
  double a = 1;
  double b = 0;
  while (1) {
    long i;
    for (i = 0; i < 10000000; i++) {
      b += 1.0 / a;
      a++;
    }
    printf("%f\n", b);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xed9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x989680,-0x20(%rbp)
jge    1184 <main+0x74>
movsd  0xeae(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe97(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113c <main+0x2c>
movsd  -0x18(%rbp),%xmm0
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
jmp    1134 <main+0x24>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movsd  0xee3(%rip),%xmm1
xorpd  %xmm0,%xmm0
xor    %eax,%eax
lea    0xede(%rip),%rbx
movapd %xmm1,%xmm3
xchg   %ax,%ax
movapd %xmm1,%xmm2
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm0
addsd  %xmm1,%xmm3
add    $0x1,%rax
cmp    $0x989680,%rax
jne    1130 <main+0x20>
mov    %rbx,%rdi
movsd  %xmm0,0x8(%rsp)
movsd  %xmm3,(%rsp)
call   1030 <printf@plt>
movsd  (%rsp),%xmm3
movsd  0x8(%rsp),%xmm0
movsd  0xe8e(%rip),%xmm1
xor    %eax,%eax
jmp    1130 <main+0x20>

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

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