#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*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ assertTrue(char *, int);
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
void test_monotonic() {
  struct timespec start;
  struct timespec end;
  clock_gettime(CLOCK_MONOTONIC, &start);
  clock_gettime(CLOCK_MONOTONIC, &end);
  assertTrue("(end.tv_sec > start.tv_sec) || ((end.tv_sec == start.tv_sec) && "
             "(end.tv_nsec >= start.tv_nsec))",
             (end.tv_sec > start.tv_sec) || ((end.tv_sec == start.tv_sec) &&
                                             (end.tv_nsec >= start.tv_nsec)));
  ;
}


x86 assembly (clang, -O0):
<test_monotonic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2eb9(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    0x2ea7(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x20(%rbp),%rcx
mov    $0x1,%al
cmp    -0x10(%rbp),%rcx
mov    %al,-0x21(%rbp)
jg     1186 <test_monotonic+0x66>
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x22(%rbp)
jne    1180 <test_monotonic+0x60>
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
setge  %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%esi
lea    0xe6b(%rip),%rdi
call   1040 <assertTrue@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_monotonic>:
push   %rbx
sub    $0x20,%rsp
mov    0x2ebc(%rip),%rbx
mov    (%rbx),%edi
lea    0x10(%rsp),%rsi
call   1030 <clock_gettime@plt>
mov    (%rbx),%edi
mov    %rsp,%rsi
call   1030 <clock_gettime@plt>
mov    0x10(%rsp),%rax
mov    $0x1,%esi
cmp    %rax,(%rsp)
jg     1167 <test_monotonic+0x47>
sete   %al
mov    0x8(%rsp),%rcx
cmp    0x18(%rsp),%rcx
setge  %cl
and    %al,%cl
movzbl %cl,%esi
lea    0xe92(%rip),%rdi
call   1040 <assertTrue@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
@CLOCK_MONOTONIC = global i32 0
@.str = [96 x i8] c"(end.tv_sec > start.tv_sec) || ((end.tv_sec == start.tv_sec) && (end.tv_nsec >= start.tv_nsec))\00"
define void @test_monotonic() {
%1 = alloca %struct.timespec
%2 = alloca %struct.timespec
%3 = load i32, i32* @CLOCK_MONOTONIC
%4 = call i32 @clock_gettime(i32 %3, %struct.timespec* %1)
%5 = load i32, i32* @CLOCK_MONOTONIC
%6 = call i32 @clock_gettime(i32 %5, %struct.timespec* %2)
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%8 = load i64, i64* %7
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%10 = load i64, i64* %9
%11 = icmp sgt i64 %8, %10
br i1 %11, label %26, label %12
12: ; preds = %0
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%14 = load i64, i64* %13
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%16 = load i64, i64* %15
%17 = icmp eq i64 %14, %16
br i1 %17, label %18, label %24
18: ; preds = %12
%19 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
%20 = load i64, i64* %19
%21 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
%22 = load i64, i64* %21
%23 = icmp sge i64 %20, %22
br label %24
24: ; preds = %18, %12
%25 = phi i1 [ false, %12 ], [ %23, %18 ]
br label %26
26: ; preds = %24, %0
%27 = phi i1 [ true, %0 ], [ %25, %24 ]
%28 = zext i1 %27 to i32
%29 = call i32 @assertTrue(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str, i64 0, i64 0), i32 %28)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
@CLOCK_MONOTONIC = global i32 0
@.str = [96 x i8] c"(end.tv_sec > start.tv_sec) || ((end.tv_sec == start.tv_sec) && (end.tv_nsec >= start.tv_nsec))\00"
define void @test_monotonic() {
%1 = alloca %struct.timespec
%2 = alloca %struct.timespec
%3 = bitcast %struct.timespec* %1 to i8*
%4 = bitcast %struct.timespec* %2 to i8*
%5 = load i32, i32* @CLOCK_MONOTONIC
%6 = call i32 @clock_gettime(i32 %5, %struct.timespec* %1)
%7 = load i32, i32* @CLOCK_MONOTONIC
%8 = call i32 @clock_gettime(i32 %7, %struct.timespec* %2)
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%10 = load i64, i64* %9
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%12 = load i64, i64* %11
%13 = icmp sgt i64 %10, %12
br i1 %13, label %23, label %14
14: ; preds = %0
%15 = icmp eq i64 %10, %12
%16 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%17 = load i64, i64* %16
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%19 = load i64, i64* %18
%20 = icmp sge i64 %17, %19
%21 = select i1 %15, i1 %20, i1 false
%22 = zext i1 %21 to i32
br label %23
23: ; preds = %14, %0
%24 = phi i32 [ 1, %0 ], [ %22, %14 ]
%25 = call i32 @assertTrue(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str, i64 0, i64 0), i32 %24)
ret void
}