#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, long long, double);
int main() {
  double s;
  long long i, m;
  s = 0;
  m = 1;
  for (i = 1;; ++i) {
    s += (double)1.0 / i;
    if (i >= m) {
      printf("%lld: %.3f\n", i, s);
      if (m >= 100000000000LL)
        exit(0);
      m *= 10;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movq   $0x1,-0x20(%rbp)
movq   $0x1,-0x18(%rbp)
cvtsi2sdq -0x18(%rbp),%xmm1
movsd  0xeab(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jl     11aa <main+0x8a>
mov    -0x18(%rbp),%rsi
movsd  -0x10(%rbp),%xmm0
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
movabs $0x174876e800,%rax
cmp    %rax,-0x20(%rbp)
jl     11a1 <main+0x81>
xor    %edi,%edi
call   1040 <exit@plt>
imul   $0xa,-0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11af <main+0x8f>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1147 <main+0x27>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x1,%ebx
xorpd  %xmm0,%xmm0
movsd  0xec7(%rip),%xmm3
lea    0xec8(%rip),%r14
movabs $0x174876e800,%r15
mov    $0x1,%r12d
jmp    1164 <main+0x44>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
xorps  %xmm2,%xmm2
cvtsi2sd %rbx,%xmm2
movapd %xmm0,%xmm1
movapd %xmm3,%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cmp    %r12,%rbx
jl     1160 <main+0x40>
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  %xmm0,(%rsp)
call   1030 <printf@plt>
cmp    %r15,%r12
jge    11ac <main+0x8c>
add    %r12,%r12
lea    (%r12,%r12,4),%r12
movsd  (%rsp),%xmm0
movsd  0xe56(%rip),%xmm3
jmp    1160 <main+0x40>
xor    %edi,%edi
call   1040 <exit@plt>

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

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