#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 {
  int tv_sec;
  int tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int timespec_compare(struct timespec *, struct timespec *);
void test_compare_timespec(void) {
  struct timespec a;
  struct timespec b;
  int rc;
  a.tv_sec = 10;
  a.tv_nsec = 0;
  ;
  b.tv_sec = 5;
  b.tv_nsec = 0;
  ;
  rc = timespec_compare(&a, &b);
  assert(rc == 1);
  a.tv_sec = 10;
  a.tv_nsec = 0;
  ;
  b.tv_sec = 50;
  b.tv_nsec = 0;
  ;
  rc = timespec_compare(&a, &b);
  assert(rc == -1);
  a.tv_sec = 44;
  a.tv_nsec = 0;
  ;
  b.tv_sec = 44;
  b.tv_nsec = 0;
  ;
  rc = timespec_compare(&a, &b);
  assert(rc == 0);
  a.tv_sec = 5;
  a.tv_nsec = 30;
  ;
  b.tv_sec = 5;
  b.tv_nsec = 29;
  ;
  rc = timespec_compare(&a, &b);
  assert(rc == 1);
  a.tv_sec = 5;
  a.tv_nsec = 16;
  ;
  b.tv_sec = 5;
  b.tv_nsec = 61;
  ;
  rc = timespec_compare(&a, &b);
  assert(rc == -1);
  a.tv_sec = 5;
  a.tv_nsec = 777;
  ;
  b.tv_sec = 5;
  b.tv_nsec = 777;
  ;
  rc = timespec_compare(&a, &b);
  assert(rc == 0);
  a.tv_sec = 6;
  a.tv_nsec = 0;
  ;
  b.tv_sec = 5;
  b.tv_nsec = 999999999;
  ;
  rc = timespec_compare(&a, &b);
  assert(rc == 1);
  a.tv_sec = 5;
  a.tv_nsec = 999999999;
  ;
  b.tv_sec = 6;
  b.tv_nsec = 0;
  ;
  rc = timespec_compare(&a, &b);
  assert(rc == -1);
  a.tv_sec = 44;
  a.tv_nsec = 999999999;
  ;
  b.tv_sec = 44;
  b.tv_nsec = 999999999;
  ;
  rc = timespec_compare(&a, &b);
  assert(rc == 0);
}


x86 assembly (clang, -O0):
<test_compare_timespec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0xa,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <timespec_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0xa,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
movl   $0x32,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <timespec_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x2c,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
movl   $0x2c,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <timespec_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x5,-0x8(%rbp)
movl   $0x1e,-0x4(%rbp)
movl   $0x5,-0x10(%rbp)
movl   $0x1d,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <timespec_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x5,-0x8(%rbp)
movl   $0x10,-0x4(%rbp)
movl   $0x5,-0x10(%rbp)
movl   $0x3d,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <timespec_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x5,-0x8(%rbp)
movl   $0x309,-0x4(%rbp)
movl   $0x5,-0x10(%rbp)
movl   $0x309,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <timespec_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x6,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x10(%rbp)
movl   $0x3b9ac9ff,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <timespec_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x5,-0x8(%rbp)
movl   $0x3b9ac9ff,-0x4(%rbp)
movl   $0x6,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <timespec_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x2c,-0x8(%rbp)
movl   $0x3b9ac9ff,-0x4(%rbp)
movl   $0x2c,-0x10(%rbp)
movl   $0x3b9ac9ff,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <timespec_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_compare_timespec>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0xa,0x8(%rsp)
movq   $0x5,(%rsp)
lea    0x8(%rsp),%r15
mov    %rsp,%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <timespec_compare@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1030 <assert@plt>
movq   $0xa,0x8(%rsp)
movq   $0x32,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <timespec_compare@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1030 <assert@plt>
movq   $0x2c,0x8(%rsp)
movq   $0x2c,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <timespec_compare@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
movabs $0x1e00000005,%rax
mov    %rax,0x8(%rsp)
movabs $0x1d00000005,%rax
mov    %rax,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <timespec_compare@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1030 <assert@plt>
movabs $0x1000000005,%rax
mov    %rax,0x8(%rsp)
movabs $0x3d00000005,%rax
mov    %rax,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <timespec_compare@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1030 <assert@plt>
movabs $0x30900000005,%rax
mov    %rax,0x8(%rsp)
mov    %rax,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <timespec_compare@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
movq   $0x6,0x8(%rsp)
movabs $0x3b9ac9ff00000005,%rbx
c9 9a 3b
mov    %rbx,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <timespec_compare@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1030 <assert@plt>
mov    %rbx,0x8(%rsp)
movq   $0x6,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <timespec_compare@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1030 <assert@plt>
movabs $0x3b9ac9ff0000002c,%rax
c9 9a 3b
mov    %rax,0x8(%rsp)
mov    %rax,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <timespec_compare@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
define void @test_compare_timespec() {
%1 = alloca %struct.timespec
%2 = alloca %struct.timespec
%3 = alloca i32
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 10, i32* %4
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 0, i32* %5
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
store i32 5, i32* %6
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
store i32 0, i32* %7
%8 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 1
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 10, i32* %13
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 0, i32* %14
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
store i32 50, i32* %15
%16 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
store i32 0, i32* %16
%17 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, -1
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 44, i32* %22
%23 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 0, i32* %23
%24 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
store i32 44, i32* %24
%25 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
store i32 0, i32* %25
%26 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
store i32 %26, i32* %3
%27 = load i32, i32* %3
%28 = icmp eq i32 %27, 0
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 5, i32* %31
%32 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 30, i32* %32
%33 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
store i32 5, i32* %33
%34 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
store i32 29, i32* %34
%35 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
store i32 %35, i32* %3
%36 = load i32, i32* %3
%37 = icmp eq i32 %36, 1
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 5, i32* %40
%41 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 16, i32* %41
%42 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
store i32 5, i32* %42
%43 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
store i32 61, i32* %43
%44 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
store i32 %44, i32* %3
%45 = load i32, i32* %3
%46 = icmp eq i32 %45, -1
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 5, i32* %49
%50 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 777, i32* %50
%51 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
store i32 5, i32* %51
%52 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
store i32 777, i32* %52
%53 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
store i32 %53, i32* %3
%54 = load i32, i32* %3
%55 = icmp eq i32 %54, 0
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
%58 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 6, i32* %58
%59 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 0, i32* %59
%60 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
store i32 5, i32* %60
%61 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
store i32 999999999, i32* %61
%62 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
store i32 %62, i32* %3
%63 = load i32, i32* %3
%64 = icmp eq i32 %63, 1
%65 = zext i1 %64 to i32
%66 = call i32 @assert(i32 %65)
%67 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 5, i32* %67
%68 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 999999999, i32* %68
%69 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
store i32 6, i32* %69
%70 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
store i32 0, i32* %70
%71 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
store i32 %71, i32* %3
%72 = load i32, i32* %3
%73 = icmp eq i32 %72, -1
%74 = zext i1 %73 to i32
%75 = call i32 @assert(i32 %74)
%76 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 44, i32* %76
%77 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 999999999, i32* %77
%78 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
store i32 44, i32* %78
%79 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
store i32 999999999, i32* %79
%80 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
store i32 %80, i32* %3
%81 = load i32, i32* %3
%82 = icmp eq i32 %81, 0
%83 = zext i1 %82 to i32
%84 = call i32 @assert(i32 %83)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
define void @test_compare_timespec() {
%1 = alloca %struct.timespec
%2 = alloca %struct.timespec
%3 = bitcast %struct.timespec* %1 to i8*
%4 = bitcast %struct.timespec* %2 to i8*
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
store i32 10, i32* %5
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
store i32 0, i32* %6
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
store i32 5, i32* %7
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
store i32 0, i32* %8
%9 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
%10 = icmp eq i32 %9, 1
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
store i32 10, i32* %5
store i32 0, i32* %6
store i32 50, i32* %7
store i32 0, i32* %8
%13 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
%14 = icmp eq i32 %13, -1
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
store i32 44, i32* %5
store i32 0, i32* %6
store i32 44, i32* %7
store i32 0, i32* %8
%17 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
store i32 5, i32* %5
store i32 30, i32* %6
store i32 5, i32* %7
store i32 29, i32* %8
%21 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
%22 = icmp eq i32 %21, 1
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
store i32 5, i32* %5
store i32 16, i32* %6
store i32 5, i32* %7
store i32 61, i32* %8
%25 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
%26 = icmp eq i32 %25, -1
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
store i32 5, i32* %5
store i32 777, i32* %6
store i32 5, i32* %7
store i32 777, i32* %8
%29 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
%30 = icmp eq i32 %29, 0
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
store i32 6, i32* %5
store i32 0, i32* %6
store i32 5, i32* %7
store i32 999999999, i32* %8
%33 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
%34 = icmp eq i32 %33, 1
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
store i32 5, i32* %5
store i32 999999999, i32* %6
store i32 6, i32* %7
store i32 0, i32* %8
%37 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
%38 = icmp eq i32 %37, -1
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
store i32 44, i32* %5
store i32 999999999, i32* %6
store i32 44, i32* %7
store i32 999999999, i32* %8
%41 = call i32 @timespec_compare(%struct.timespec* %1, %struct.timespec* %2)
%42 = icmp eq i32 %41, 0
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
ret void
}