#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, double);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ timer_init();
double timer_seconds_since_init();
int main() {
  int i;
  timer_init();
  for (i = 0; i < 20; i++) {
    double t0 = timer_seconds_since_init();
    sleep(1);
    double t1 = timer_seconds_since_init();
    printf("%12.9f, %12.9f\n", t0, t1 - t0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <timer_init@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jge    11b2 <main+0x72>
mov    $0x0,%al
call   1060 <timer_seconds_since_init@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x0,%al
call   1060 <timer_seconds_since_init@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <timer_init@plt>
mov    $0x14,%ebp
lea    0xeaa(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <timer_seconds_since_init@plt>
movsd  %xmm0,(%rsp)
mov    $0x1,%edi
call   1050 <sleep@plt>
xor    %eax,%eax
call   1060 <timer_seconds_since_init@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm0,%xmm1
mov    %rbx,%rdi
call   1030 <printf@plt>
add    $0xffffffff,%ebp
jne    1160 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [16 x i8] c"%12.9f, %12.9f\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @timer_init()
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %9, %2 ]
%4 = tail call double (...) @timer_seconds_since_init()
%5 = tail call i32 @sleep(i32 1)
%6 = tail call double (...) @timer_seconds_since_init()
%7 = fsub double %6, %4
%8 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %4, double %7)
%9 = add nuw nsw i32 %3, 1
%10 = icmp eq i32 %9, 20
br i1 %10, label %11, label %2
11: ; preds = %2
ret i32 0
}