#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 */
double CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, ...);
void PrintTimeStamp(char *Message) {
  static clock_t LastTime = 0;
  clock_t ThisTime;
  if ((ThisTime = clock()) == (clock_t)-1) {
    printf("ERROR: Cannot PrintTimeStamp %s\n", Message == NULL ? "" : Message);
  } else {
    if (Message != NULL) {
      printf("%s: ", Message);
    }
    printf("Time delta: %f\n",
           ((double)(ThisTime - LastTime)) / CLOCKS_PER_SEC);
    LastTime = ThisTime;
  }
}


x86 assembly (clang, -O0):
<PrintTimeStamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
cmp    $0xffffffffffffffff,%rax
jne    117b <PrintTimeStamp+0x5b>
cmpq   $0x0,-0x8(%rbp)
jne    115c <PrintTimeStamp+0x3c>
lea    0xee2(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1164 <PrintTimeStamp+0x44>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11cc <PrintTimeStamp+0xac>
cmpq   $0x0,-0x8(%rbp)
je     1198 <PrintTimeStamp+0x78>
mov    -0x8(%rbp),%rsi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
sub    0x2e95(%rip),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e39(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe6c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,0x2e6c(%rip)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintTimeStamp>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <clock@plt>
cmp    $0xffffffffffffffff,%rax
je     1184 <PrintTimeStamp+0x64>
mov    %rax,%rbx
test   %r14,%r14
je     114d <PrintTimeStamp+0x2d>
lea    0xede(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rax
sub    0x2ee1(%rip),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e85(%rip),%rax
divsd  (%rax),%xmm0
lea    0xeb8(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbx,0x2ebc(%rip)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
test   %r14,%r14
lea    0xea7(%rip),%rsi
cmovne %r14,%rsi
lea    0xe67(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@PrintTimeStamp.LastTime = internal global i64 0
@.str = [33 x i8] c"ERROR: Cannot PrintTimeStamp %s\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"%s: \00"
@.str.3 = [16 x i8] c"Time delta: %f\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define void @PrintTimeStamp(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
%4 = call i64 (...) @clock()
store i64 %4, i64* %3
%5 = icmp eq i64 %4, -1
br i1 %5, label %6, label %15
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %6
br label %12
10: ; preds = %6
%11 = load i8*, i8** %2
br label %12
12: ; preds = %10, %9
%13 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %9 ], [ %11, %10 ]
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %30
15: ; preds = %1
%16 = load i8*, i8** %2
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i8*, i8** %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %15
%22 = load i64, i64* %3
%23 = load i64, i64* @PrintTimeStamp.LastTime
%24 = sub nsw i64 %22, %23
%25 = sitofp i64 %24 to double
%26 = load double, double* @CLOCKS_PER_SEC
%27 = fdiv double %25, %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %27)
%29 = load i64, i64* %3
store i64 %29, i64* @PrintTimeStamp.LastTime
br label %30
30: ; preds = %21, %12
ret void
}

LLVM IR (-O2):
@PrintTimeStamp.LastTime = internal unnamed_addr global i64 0
@.str = [33 x i8] c"ERROR: Cannot PrintTimeStamp %s\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"%s: \00"
@.str.3 = [16 x i8] c"Time delta: %f\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define void @PrintTimeStamp(i8* %0) {
%2 = tail call i64 (...) @clock()
%3 = icmp eq i64 %2, -1
%4 = icmp eq i8* %0, null
br i1 %3, label %5, label %8
5: ; preds = %1
%6 = select i1 %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* %0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %18
8: ; preds = %1
br i1 %4, label %11, label %9
9: ; preds = %8
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %11
11: ; preds = %9, %8
%12 = load i64, i64* @PrintTimeStamp.LastTime
%13 = sub nsw i64 %2, %12
%14 = sitofp i64 %13 to double
%15 = load double, double* @CLOCKS_PER_SEC
%16 = fdiv double %14, %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %16)
store i64 %2, i64* @PrintTimeStamp.LastTime
br label %18
18: ; preds = %11, %5
ret void
}