#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 */
struct timespec {
  scalar_t__ tv_sec;
  int tv_nsec;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
unsigned Clock() {
  static struct timespec Init = {0};
  if (Init.tv_sec == 0)
    clock_gettime(CLOCK_MONOTONIC, &Init);
  struct timespec Now = {0};
  clock_gettime(CLOCK_MONOTONIC, &Now);
  return ((Now.tv_sec - Init.tv_sec) * 1000000) +
         ((Now.tv_nsec - Init.tv_nsec) / 1000);
}


x86 assembly (clang, -O0):
<Clock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
cmpq   $0x0,0x2f08(%rip)
jne    114b <Clock+0x2b>
mov    0x2eab(%rip),%rax
mov    (%rax),%edi
lea    0x2ef2(%rip),%rsi
call   1030 <clock_gettime@plt>
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x10(%rbp),%rax
sub    0x2ec0(%rip),%rax
imul   $0xf4240,%rax,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
sub    0x2eb4(%rip),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Clock>:
sub    $0x18,%rsp
cmpq   $0x0,0x2f14(%rip)
jne    1133 <Clock+0x23>
mov    0x2ec3(%rip),%rax
mov    (%rax),%edi
lea    0x2f02(%rip),%rsi
call   1030 <clock_gettime@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    0x2ea7(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1030 <clock_gettime@plt>
mov    (%rsp),%eax
mov    0x8(%rsp),%ecx
sub    0x2ed8(%rip),%eax
sub    0x2eda(%rip),%ecx
movslq %ecx,%rcx
imul   $0x10624dd3,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0xf4240,%eax,%eax
add    %ecx,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i32, i32 }
@Clock.Init = internal global %struct.timespec zeroinitializer
@CLOCK_MONOTONIC = global i32 0
define i32 @Clock() {
%1 = alloca %struct.timespec
%2 = load i64, i64* getelementptr inbounds (%struct.timespec, %struct.timespec* @Clock.Init, i32 0, i32 0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = load i32, i32* @CLOCK_MONOTONIC
%6 = call i32 @clock_gettime(i32 %5, %struct.timespec* @Clock.Init)
br label %7
7: ; preds = %4, %0
%8 = bitcast %struct.timespec* %1 to i8*
%9 = load i32, i32* @CLOCK_MONOTONIC
%10 = call i32 @clock_gettime(i32 %9, %struct.timespec* %1)
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%12 = load i64, i64* %11
%13 = load i64, i64* getelementptr inbounds (%struct.timespec, %struct.timespec* @Clock.Init, i32 0, i32 0)
%14 = sub nsw i64 %12, %13
%15 = mul nsw i64 %14, 1000000
%16 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
%17 = load i32, i32* %16
%18 = load i32, i32* getelementptr inbounds (%struct.timespec, %struct.timespec* @Clock.Init, i32 0, i32 1)
%19 = sub nsw i32 %17, %18
%20 = sdiv i32 %19, 1000
%21 = sext i32 %20 to i64
%22 = add nsw i64 %15, %21
%23 = trunc i64 %22 to i32
ret i32 %23
}

LLVM IR (-O2):
%struct.timespec = type { i64, i32, i32 }
@Clock.Init = internal global %struct.timespec zeroinitializer
@CLOCK_MONOTONIC = global i32 0
define i32 @Clock() {
%1 = alloca %struct.timespec
%2 = load i64, i64* getelementptr inbounds (%struct.timespec, %struct.timespec* @Clock.Init, i64 0, i32 0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = load i32, i32* @CLOCK_MONOTONIC
%6 = tail call i32 @clock_gettime(i32 %5, %struct.timespec* @Clock.Init)
br label %7
7: ; preds = %4, %0
%8 = bitcast %struct.timespec* %1 to i8*
%9 = load i32, i32* @CLOCK_MONOTONIC
%10 = call i32 @clock_gettime(i32 %9, %struct.timespec* %1)
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%12 = load i64, i64* %11
%13 = load i64, i64* getelementptr inbounds (%struct.timespec, %struct.timespec* @Clock.Init, i64 0, i32 0)
%14 = sub nsw i64 %12, %13
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%16 = load i32, i32* %15
%17 = load i32, i32* getelementptr inbounds (%struct.timespec, %struct.timespec* @Clock.Init, i64 0, i32 1)
%18 = sub nsw i32 %16, %17
%19 = sdiv i32 %18, 1000
%20 = trunc i64 %14 to i32
%21 = mul i32 %20, 1000000
%22 = add i32 %19, %21
ret i32 %22
}