#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;
  scalar_t__ tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ LOG_WARNING;
int /*<<< orphan*/ _(char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ teredo_gettime(struct timespec *);
bool checkTimeDrift(struct timespec *ts) {
  struct timespec now;
  teredo_gettime(&now);
  if ((now.tv_sec > ts->tv_sec) ||
      ((now.tv_sec == ts->tv_sec) && (now.tv_nsec > ts->tv_nsec))) {
    syslog(LOG_WARNING, _("Too much time drift. Resynchronizing."));
    *ts = now;
    return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<checkTimeDrift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
call   1050 <teredo_gettime@plt>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jg     1179 <checkTimeDrift+0x49>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jne    11ba <checkTimeDrift+0x8a>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    0x8(%rcx),%rax
jle    11ba <checkTimeDrift+0x8a>
mov    0x2e68(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
lea    0xe74(%rip),%rdi
call   1040 <_@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%esi
call   1030 <syslog@plt>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rcx
mov    %rcx,0x8(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11c1 <checkTimeDrift+0x91>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkTimeDrift>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
call   1050 <teredo_gettime@plt>
mov    (%rbx),%rax
cmp    %rax,0x8(%rsp)
jg     115f <checkTimeDrift+0x2f>
mov    $0x1,%eax
jne    1187 <checkTimeDrift+0x57>
mov    0x10(%rsp),%rcx
cmp    0x8(%rbx),%rcx
jle    1187 <checkTimeDrift+0x57>
mov    0x2e82(%rip),%rax
mov    (%rax),%ebp
lea    0xe91(%rip),%rdi
call   1040 <_@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1030 <syslog@plt>
movups 0x8(%rsp),%xmm0
movups %xmm0,(%rbx)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
@LOG_WARNING = global i32 0
@.str = [38 x i8] c"Too much time drift. Resynchronizing.\00"
define i32 @checkTimeDrift(%struct.timespec* %0) {
%2 = alloca i32
%3 = alloca %struct.timespec*
%4 = alloca %struct.timespec
store %struct.timespec* %0, %struct.timespec** %3
%5 = call i32 @teredo_gettime(%struct.timespec* %4)
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%7 = load i64, i64* %6
%8 = load %struct.timespec*, %struct.timespec** %3
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i32 0, i32 0
%10 = load i64, i64* %9
%11 = icmp sgt i64 %7, %10
br i1 %11, label %26, label %12
12: ; preds = %1
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%14 = load i64, i64* %13
%15 = load %struct.timespec*, %struct.timespec** %3
%16 = getelementptr inbounds %struct.timespec, %struct.timespec* %15, i32 0, i32 0
%17 = load i64, i64* %16
%18 = icmp eq i64 %14, %17
br i1 %18, label %19, label %33
19: ; preds = %12
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 1
%21 = load i64, i64* %20
%22 = load %struct.timespec*, %struct.timespec** %3
%23 = getelementptr inbounds %struct.timespec, %struct.timespec* %22, i32 0, i32 1
%24 = load i64, i64* %23
%25 = icmp sgt i64 %21, %24
br i1 %25, label %26, label %33
26: ; preds = %19, %1
%27 = load i32, i32* @LOG_WARNING
%28 = call i32 @_(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%29 = call i32 @syslog(i32 %27, i32 %28)
%30 = load %struct.timespec*, %struct.timespec** %3
%31 = bitcast %struct.timespec* %30 to i8*
%32 = bitcast %struct.timespec* %4 to i8*
store i32 0, i32* %2
br label %34
33: ; preds = %19, %12
store i32 1, i32* %2
br label %34
34: ; preds = %33, %26
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
@LOG_WARNING = global i32 0
@.str = [38 x i8] c"Too much time drift. Resynchronizing.\00"
define i32 @checkTimeDrift(%struct.timespec* nocapture %0) {
%2 = alloca %struct.timespec
%3 = bitcast %struct.timespec* %2 to i8*
%4 = call i32 @teredo_gettime(%struct.timespec* %2)
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%6 = load i64, i64* %5
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 0
%8 = load i64, i64* %7
%9 = icmp sgt i64 %6, %8
br i1 %9, label %18, label %10
10: ; preds = %1
%11 = icmp eq i64 %6, %8
br i1 %11, label %12, label %23
12: ; preds = %10
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%14 = load i64, i64* %13
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 1
%16 = load i64, i64* %15
%17 = icmp sgt i64 %14, %16
br i1 %17, label %18, label %23
18: ; preds = %12, %1
%19 = load i32, i32* @LOG_WARNING
%20 = call i32 @_(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @syslog(i32 %19, i32 %20)
%22 = bitcast %struct.timespec* %0 to i8*
br label %23
23: ; preds = %10, %12, %18
%24 = phi i32 [ 0, %18 ], [ 1, %12 ], [ 1, %10 ]
ret i32 %24
}