#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 */
typedef int /*<<< orphan*/ clock_t;

/* Variables and functions */
int /*<<< orphan*/ clock();
double difftime(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ getch();
int /*<<< orphan*/ printf(char *, double);
main() {
  clock_t INIT, FINAL;
  INIT = clock();
  double s = 0;
  unsigned long i;
  for (i = 1; i <= 10000; ++i) {
    double t;
    t = 1.0 / i;
    s = s + t;
  }
  printf("%lf\n", s);
  FINAL = clock();
  double time;
  time = difftime(FINAL, INIT);
  printf("%lf", time);
  getch();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movq   $0x1,-0x20(%rbp)
cmpq   $0x2710,-0x20(%rbp)
ja     11cf <main+0x8f>
movaps 0xe92(%rip),%xmm0
movq   -0x20(%rbp),%xmm1
punpckldq %xmm0,%xmm1
movapd 0xe91(%rip),%xmm0
subpd  %xmm0,%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe5a(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1169 <main+0x29>
movsd  -0x18(%rbp),%xmm0
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <difftime@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xe2f(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getch@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %eax,%ebx
mov    $0x1,%eax
xorpd  %xmm0,%xmm0
movdqa 0xea5(%rip),%xmm1
movapd 0xead(%rip),%xmm2
movsd  0xeb5(%rip),%xmm3
nopl   0x0(%rax,%rax,1)
movq   %rax,%xmm4
punpckldq %xmm1,%xmm4
subpd  %xmm2,%xmm4
movapd %xmm4,%xmm5
unpckhpd %xmm4,%xmm5
addsd  %xmm4,%xmm5
movapd %xmm3,%xmm4
divsd  %xmm5,%xmm4
addsd  %xmm0,%xmm4
lea    0x1(%rax),%rcx
movq   %rcx,%xmm0
punpckldq %xmm1,%xmm0
subpd  %xmm2,%xmm0
movapd %xmm0,%xmm5
unpckhpd %xmm0,%xmm5
addsd  %xmm0,%xmm5
movapd %xmm3,%xmm0
divsd  %xmm5,%xmm0
addsd  %xmm4,%xmm0
add    $0x2,%rax
cmp    $0x2711,%rax
jne    1170 <main+0x30>
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %eax,%edi
mov    %ebx,%esi
call   1050 <difftime@plt>
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lf\0A\00"
@.str.1 = [4 x i8] c"%lf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca i64
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
%8 = call i32 (...) @clock()
store i32 %8, i32* %2
store double 0.000000e+00, double* %4
store i64 1, i64* %5
br label %9
9: ; preds = %19, %0
%10 = load i64, i64* %5
%11 = icmp ule i64 %10, 10000
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = load i64, i64* %5
%14 = uitofp i64 %13 to double
%15 = fdiv double 1.000000e+00, %14
store double %15, double* %6
%16 = load double, double* %4
%17 = load double, double* %6
%18 = fadd double %16, %17
store double %18, double* %4
br label %19
19: ; preds = %12
%20 = load i64, i64* %5
%21 = add i64 %20, 1
store i64 %21, i64* %5
br label %9
22: ; preds = %9
%23 = load double, double* %4
%24 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %23)
%25 = call i32 (...) @clock()
store i32 %25, i32* %3
%26 = load i32, i32* %3
%27 = load i32, i32* %2
%28 = call double @difftime(i32 %26, i32 %27)
store double %28, double* %7
%29 = load double, double* %7
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %29)
%31 = call i32 (...) @getch()
%32 = load i32, i32* %1
ret i32 %32
}

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