#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__ time_t;
struct timespec {
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
scalar_t__ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int libred_check_timetravel(void) {
  struct timespec now;
  if (clock_gettime(CLOCK_REALTIME, &now))
    return -1;
  if (now.tv_sec < (time_t)946728000L) {
    fprintf(stderr, "We have detected that you are a time-traveller"
                    "(or your clock is not configured correctly.)"
                    "Please recompile libred with -DTIMETRAVELLER"
                    "(or correct your clock.)");
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<libred_check_timetravel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1030 <clock_gettime@plt>
cmp    $0x0,%rax
je     1160 <libred_check_timetravel+0x30>
movl   $0xffffffff,-0x4(%rbp)
jmp    1194 <libred_check_timetravel+0x64>
cmpq   $0x386dec40,-0x10(%rbp)
38
jge    118d <libred_check_timetravel+0x5d>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libred_check_timetravel>:
push   %rax
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1030 <clock_gettime@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    115b <libred_check_timetravel+0x2b>
xor    %eax,%eax
cmpq   $0x386dec3f,(%rsp)
38
jle    115d <libred_check_timetravel+0x2d>
pop    %rcx
ret
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.timespec = type { i64 }
@CLOCK_REALTIME = global i32 0
@stderr = global i32 0
@.str = [159 x i8] c"We have detected that you are a time-traveller(or your clock is not configured correctly.)Please recompile libred with -DTIMETRAVELLER(or correct your clock.)\00"
define i32 @libred_check_timetravel() {
%1 = alloca i32
%2 = alloca %struct.timespec
%3 = load i32, i32* @CLOCK_REALTIME
%4 = call i64 @clock_gettime(i32 %3, %struct.timespec* %2)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 -1, i32* %1
br label %16
7: ; preds = %0
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%9 = load i64, i64* %8
%10 = icmp slt i64 %9, 946728000
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([159 x i8], [159 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %7
store i32 0, i32* %1
br label %16
16: ; preds = %15, %6
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
%struct.timespec = type { i64 }
@CLOCK_REALTIME = global i32 0
@stderr = global i32 0
@.str = [159 x i8] c"We have detected that you are a time-traveller(or your clock is not configured correctly.)Please recompile libred with -DTIMETRAVELLER(or correct your clock.)\00"
define i32 @libred_check_timetravel() {
%1 = alloca %struct.timespec
%2 = bitcast %struct.timespec* %1 to i8*
%3 = load i32, i32* @CLOCK_REALTIME
%4 = call i64 @clock_gettime(i32 %3, %struct.timespec* %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %0
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%8 = load i64, i64* %7
%9 = icmp slt i64 %8, 946728000
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([159 x i8], [159 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %6, %0
%15 = phi i32 [ -1, %0 ], [ 0, %6 ]
ret i32 %15
}