#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 */
bool tv_leq(const struct timeval *a, const struct timeval *b) {
  if (a->tv_sec != b->tv_sec)
    return a->tv_sec < b->tv_sec;
  else
    return a->tv_usec <= b->tv_usec;
}


x86 assembly (clang, -O0):
<tv_leq>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
je     113e <tv_leq+0x3e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
setl   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1159 <tv_leq+0x59>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    0x8(%rcx),%rax
setle  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<tv_leq>:
mov    (%rsi),%rax
cmp    %rax,(%rdi)
jne    1117 <tv_leq+0x17>
mov    0x8(%rdi),%rax
cmp    0x8(%rsi),%rax
setle  %al
movzbl %al,%eax
ret
setl   %al
movzbl %al,%eax
ret

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

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