#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 int uint64_t;
struct timespec {
  scalar_t__ tv_nsec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ CLOCK_REALTIME;
int clock_gettime(int /*<<< orphan*/, struct timespec *);
uint64_t _wall_Date(bool b_realtime) {
  struct timespec ts;
  if (b_realtime || clock_gettime(CLOCK_MONOTONIC, &ts) == -1)
    (void)clock_gettime(CLOCK_REALTIME, &ts);
  return ((uint64_t)ts.tv_sec * (uint64_t)27000000) +
         ((uint64_t)ts.tv_nsec * 27 / 1000);
}


x86 assembly (clang, -O0):
<_wall_Date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1140 <_wall_Date+0x30>
mov    0x2ebc(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1030 <clock_gettime@plt>
cmp    $0xffffffff,%eax
jne    1152 <_wall_Date+0x42>
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x10(%rbp),%rax
imul   $0x19bfcc0,%eax,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
imul   $0x1b,%eax,%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_wall_Date>:
sub    $0x18,%rsp
test   %edi,%edi
jne    1130 <_wall_Date+0x20>
mov    0x2ec9(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1030 <clock_gettime@plt>
cmp    $0xffffffff,%eax
jne    1143 <_wall_Date+0x33>
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1030 <clock_gettime@plt>
imul   $0x19bfcc0,0x10(%rsp),%ecx
01
mov    0x8(%rsp),%eax
lea    (%rax,%rax,8),%eax
lea    (%rax,%rax,2),%eax
cltq
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rax
add    %edx,%eax
add    %ecx,%eax
add    $0x18,%rsp
ret

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

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