#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 scalar_t__ clock_t;

/* Variables and functions */
scalar_t__ CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, char const *, double, scalar_t__);
void wall_clock_status(const char *title) {
  static clock_t t1;
  clock_t t2;
  double seconds;
  t2 = clock();
  seconds = (double)(t2 - t1) / (double)CLOCKS_PER_SEC;
  printf("%s:  %f s (%lu cycles)\n", title, seconds, t2 - t1);
  t1 = t2;
  return;
}


x86 assembly (clang, -O0):
<wall_clock_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
sub    0x2ef6(%rip),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e9a(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
movsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rdx
sub    0x2ec8(%rip),%rdx
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,0x2eb1(%rip)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wall_clock_status>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
mov    %rax,%rdx
sub    0x2efd(%rip),%rdx
cvtsi2sd %rdx,%xmm0
mov    0x2ea1(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
lea    0xea9(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %rbx,0x2ed2(%rip)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@wall_clock_status.t1 = internal global i64 0
@CLOCKS_PER_SEC = global i64 0
@.str = [24 x i8] c"%s: %f s (%lu cycles)\0A\00"
define void @wall_clock_status(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca double
store i8* %0, i8** %2
%5 = call i64 (...) @clock()
store i64 %5, i64* %3
%6 = load i64, i64* %3
%7 = load i64, i64* @wall_clock_status.t1
%8 = sub nsw i64 %6, %7
%9 = sitofp i64 %8 to double
%10 = load i64, i64* @CLOCKS_PER_SEC
%11 = sitofp i64 %10 to double
%12 = fdiv double %9, %11
store double %12, double* %4
%13 = load i8*, i8** %2
%14 = load double, double* %4
%15 = load i64, i64* %3
%16 = load i64, i64* @wall_clock_status.t1
%17 = sub nsw i64 %15, %16
%18 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %13, double %14, i64 %17)
%19 = load i64, i64* %3
store i64 %19, i64* @wall_clock_status.t1
ret void
}

LLVM IR (-O2):
@wall_clock_status.t1 = internal unnamed_addr global i64 0
@CLOCKS_PER_SEC = global i64 0
@.str = [24 x i8] c"%s: %f s (%lu cycles)\0A\00"
define void @wall_clock_status(i8* %0) {
%2 = tail call i64 (...) @clock()
%3 = load i64, i64* @wall_clock_status.t1
%4 = sub nsw i64 %2, %3
%5 = sitofp i64 %4 to double
%6 = load i64, i64* @CLOCKS_PER_SEC
%7 = sitofp i64 %6 to double
%8 = fdiv double %5, %7
%9 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0, double %8, i64 %4)
store i64 %2, i64* @wall_clock_status.t1
ret void
}