#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 timeval {
  scalar_t__ tv_sec;
  scalar_t__ tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ tkh_timeval_minus_eq(struct timeval *,
                                        struct timeval const *);
int tkh_timeval_compare(const struct timeval *tva, const struct timeval *tvb) {
  struct timeval tv = *tva;
  tkh_timeval_minus_eq(&tv, tvb);
  if (tv.tv_sec < 0)
    return -1;
  else if (tv.tv_sec > 0 || tv.tv_usec > 0)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<tkh_timeval_compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    %rcx,-0x28(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
lea    -0x28(%rbp),%rdi
call   1030 <tkh_timeval_minus_eq@plt>
cmpq   $0x0,-0x28(%rbp)
jge    1157 <tkh_timeval_compare+0x47>
movl   $0xffffffff,-0x4(%rbp)
jmp    1180 <tkh_timeval_compare+0x70>
cmpq   $0x0,-0x28(%rbp)
jg     116d <tkh_timeval_compare+0x5d>
cmpq   $0x0,-0x20(%rbp)
jle    1179 <tkh_timeval_compare+0x69>
movl   $0x1,-0x4(%rbp)
jmp    1180 <tkh_timeval_compare+0x70>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tkh_timeval_compare>:
sub    $0x18,%rsp
movups (%rdi),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
call   1030 <tkh_timeval_minus_eq@plt>
cmpq   $0x0,(%rsp)
js     1140 <tkh_timeval_compare+0x30>
setne  %al
cmpq   $0x0,0x8(%rsp)
setg   %cl
or     %al,%cl
movzbl %cl,%eax
add    $0x18,%rsp
ret
mov    $0xffffffff,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
define i32 @tkh_timeval_compare(%struct.timeval* %0, %struct.timeval* %1) {
%3 = alloca i32
%4 = alloca %struct.timeval*
%5 = alloca %struct.timeval*
%6 = alloca %struct.timeval
store %struct.timeval* %0, %struct.timeval** %4
store %struct.timeval* %1, %struct.timeval** %5
%7 = load %struct.timeval*, %struct.timeval** %4
%8 = bitcast %struct.timeval* %6 to i8*
%9 = bitcast %struct.timeval* %7 to i8*
%10 = load %struct.timeval*, %struct.timeval** %5
%11 = call i32 @tkh_timeval_minus_eq(%struct.timeval* %6, %struct.timeval* %10)
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%13 = load i64, i64* %12
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 -1, i32* %3
br label %26
16: ; preds = %2
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%18 = load i64, i64* %17
%19 = icmp sgt i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %16
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%22 = load i64, i64* %21
%23 = icmp sgt i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20, %16
store i32 1, i32* %3
br label %26
25: ; preds = %20
store i32 0, i32* %3
br label %26
26: ; preds = %25, %24, %15
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define i32 @tkh_timeval_compare(%struct.timeval* nocapture %0, %struct.timeval* %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = bitcast %struct.timeval* %0 to i8*
%6 = call i32 @tkh_timeval_minus_eq(%struct.timeval* %3, %struct.timeval* %1)
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%8 = load i64, i64* %7
%9 = icmp slt i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %2
%11 = icmp ne i64 %8, 0
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%13 = load i64, i64* %12
%14 = icmp sgt i64 %13, 0
%15 = select i1 %11, i1 true, i1 %14
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %10, %2
%18 = phi i32 [ -1, %2 ], [ %16, %10 ]
ret i32 %18
}