#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();
void chrono(int kind, float *time) {
  static clock_t counts;
  if (kind == 1) {
    *time = 0.0;
    counts = clock();
    return;
  }
  if (kind == 0) {
    *time = ((float)(clock() - counts)) / ((float)CLOCKS_PER_SEC);
  }
}


x86 assembly (clang, -O0):
<chrono>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1147 <chrono+0x37>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,0x2eee(%rip)
jmp    117c <chrono+0x6c>
cmpl   $0x0,-0x4(%rbp)
jne    117c <chrono+0x6c>
mov    $0x0,%al
call   1030 <clock@plt>
sub    0x2ed1(%rip),%rax
cvtsi2ss %rax,%xmm0
mov    0x2e7d(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chrono>:
push   %rbx
mov    %rsi,%rbx
test   %edi,%edi
je     1133 <chrono+0x23>
cmp    $0x1,%edi
jne    115a <chrono+0x4a>
movl   $0x0,(%rbx)
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,0x2eff(%rip)
pop    %rbx
ret
xor    %eax,%eax
call   1030 <clock@plt>
sub    0x2eef(%rip),%rax
cvtsi2ss %rax,%xmm0
mov    0x2e9b(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
@chrono.counts = internal global i64 0
@CLOCKS_PER_SEC = global i64 0
define void @chrono(i32 %0, float* %1) {
%3 = alloca i32
%4 = alloca float*
store i32 %0, i32* %3
store float* %1, float** %4
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load float*, float** %4
store float 0.000000e+00, float* %8
%9 = call i64 (...) @clock()
store i64 %9, i64* @chrono.counts
br label %22
10: ; preds = %2
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = call i64 (...) @clock()
%15 = load i64, i64* @chrono.counts
%16 = sub nsw i64 %14, %15
%17 = sitofp i64 %16 to float
%18 = load i64, i64* @CLOCKS_PER_SEC
%19 = sitofp i64 %18 to float
%20 = fdiv float %17, %19
%21 = load float*, float** %4
store float %20, float* %21
br label %22
22: ; preds = %7, %13, %10
ret void
}

LLVM IR (-O2):
@chrono.counts = internal unnamed_addr global i64 0
@CLOCKS_PER_SEC = global i64 0
define void @chrono(i32 %0, float* nocapture writeonly %1) {
switch i32 %0, label %13 [
i32 1, label %3
i32 0, label %5
]
3: ; preds = %2
store float 0.000000e+00, float* %1
%4 = tail call i64 (...) @clock()
store i64 %4, i64* @chrono.counts
br label %13
5: ; preds = %2
%6 = tail call i64 (...) @clock()
%7 = load i64, i64* @chrono.counts
%8 = sub nsw i64 %6, %7
%9 = sitofp i64 %8 to float
%10 = load i64, i64* @CLOCKS_PER_SEC
%11 = sitofp i64 %10 to float
%12 = fdiv float %9, %11
store float %12, float* %1
br label %13
13: ; preds = %2, %3, %5
ret void
}