#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);
double what_time_is_it();
double chrono() {
  static double start_time;
  static double last_time;
  static int first = 1;
  double current_time = what_time_is_it();
  ;
  if (first) {
    start_time = last_time = current_time;
    first = 0;
  } else
    printf("\r\033[2K   TIME Elapsed %.3lfs Total %.3lfs\n\n",
           current_time - last_time, current_time - start_time);
  last_time = current_time;
  return current_time - start_time;
}


x86 assembly (clang, -O0):
<chrono>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <what_time_is_it@plt>
movsd  %xmm0,-0x8(%rbp)
cmpl   $0x0,0x2ef5(%rip)
je     1165 <chrono+0x45>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,0x2efa(%rip)
movsd  %xmm0,0x2eea(%rip)
movl   $0x0,0x2ed0(%rip)
jmp    118b <chrono+0x6b>
movsd  -0x8(%rbp),%xmm0
subsd  0x2ed6(%rip),%xmm0
movsd  -0x8(%rbp),%xmm1
subsd  0x2ec1(%rip),%xmm1
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,0x2eb0(%rip)
movsd  -0x8(%rbp),%xmm0
subsd  0x2e9b(%rip),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chrono>:
push   %rax
xor    %eax,%eax
call   1030 <what_time_is_it@plt>
movapd %xmm0,%xmm1
cmpb   $0x0,0x2f15(%rip)
je     116e <chrono+0x4e>
movapd %xmm1,%xmm0
subsd  0x2eff(%rip),%xmm0
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm1
subsd  0x2ee5(%rip),%xmm1
lea    0xea6(%rip),%rdi
call   1040 <printf@plt>
movsd  (%rsp),%xmm1
movsd  0x2ecc(%rip),%xmm0
jmp    1181 <chrono+0x61>
movsd  %xmm1,0x2ec2(%rip)
movb   $0x1,0x2ecb(%rip)
movapd %xmm1,%xmm0
movsd  %xmm1,0x2eb7(%rip)
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@chrono.start_time = internal global double 0.000000e+00
@chrono.last_time = internal global double 0.000000e+00
@chrono.first = internal global i32 1
@.str = [43 x i8] c"\0D\1B[2K TIME Elapsed %.3lfs Total %.3lfs\0A\0A\00"
define double @chrono() {
%1 = alloca double
%2 = call double (...) @what_time_is_it()
store double %2, double* %1
%3 = load i32, i32* @chrono.first
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = load double, double* %1
store double %6, double* @chrono.last_time
store double %6, double* @chrono.start_time
store i32 0, i32* @chrono.first
br label %15
7: ; preds = %0
%8 = load double, double* %1
%9 = load double, double* @chrono.last_time
%10 = fsub double %8, %9
%11 = load double, double* %1
%12 = load double, double* @chrono.start_time
%13 = fsub double %11, %12
%14 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), double %10, double %13)
br label %15
15: ; preds = %7, %5
%16 = load double, double* %1
store double %16, double* @chrono.last_time
%17 = load double, double* %1
%18 = load double, double* @chrono.start_time
%19 = fsub double %17, %18
ret double %19
}

LLVM IR (-O2):
@chrono.start_time = internal unnamed_addr global double 0.000000e+00
@chrono.last_time = internal unnamed_addr global double 0.000000e+00
@chrono.first = internal unnamed_addr global i1 false
@.str = [43 x i8] c"\0D\1B[2K TIME Elapsed %.3lfs Total %.3lfs\0A\0A\00"
define double @chrono() {
%1 = tail call double (...) @what_time_is_it()
%2 = load i1, i1* @chrono.first
br i1 %2, label %4, label %3
3: ; preds = %0
store double %1, double* @chrono.start_time
store i1 true, i1* @chrono.first
br label %11
4: ; preds = %0
%5 = load double, double* @chrono.last_time
%6 = fsub double %1, %5
%7 = load double, double* @chrono.start_time
%8 = fsub double %1, %7
%9 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), double %6, double %8)
%10 = load double, double* @chrono.start_time
br label %11
11: ; preds = %4, %3
%12 = phi double [ %10, %4 ], [ %1, %3 ]
store double %1, double* @chrono.last_time
%13 = fsub double %1, %12
ret double %13
}