#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;
  int tv_usec;
};

/* Variables and functions */
bool TIMEVAL_IS_VALID(const struct timeval *tv) {
  return tv != NULL && tv->tv_sec >= 0 && tv->tv_usec >= 0 &&
         tv->tv_usec < 1000000;
}


x86 assembly (clang, -O0):
<TIMEVAL_IS_VALID>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x9(%rbp)
je     114f <TIMEVAL_IS_VALID+0x4f>
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
cmpq   $0x0,(%rcx)
mov    %al,-0x9(%rbp)
jl     114f <TIMEVAL_IS_VALID+0x4f>
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
cmpl   $0x0,0x8(%rcx)
mov    %al,-0x9(%rbp)
jl     114f <TIMEVAL_IS_VALID+0x4f>
mov    -0x8(%rbp),%rax
cmpl   $0xf4240,0x8(%rax)
setl   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<TIMEVAL_IS_VALID>:
xor    %eax,%eax
test   %rdi,%rdi
je     111f <TIMEVAL_IS_VALID+0x1f>
cmpq   $0x0,(%rdi)
js     111f <TIMEVAL_IS_VALID+0x1f>
mov    0x8(%rdi),%ecx
test   %ecx,%ecx
js     111f <TIMEVAL_IS_VALID+0x1f>
xor    %eax,%eax
cmp    $0xf4240,%ecx
setb   %al
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i32 }
define i32 @TIMEVAL_IS_VALID(%struct.timeval* %0) {
%2 = alloca %struct.timeval*
store %struct.timeval* %0, %struct.timeval** %2
%3 = load %struct.timeval*, %struct.timeval** %2
%4 = icmp ne %struct.timeval* %3, null
br i1 %4, label %5, label %20
5: ; preds = %1
%6 = load %struct.timeval*, %struct.timeval** %2
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%8 = load i64, i64* %7
%9 = icmp sge i64 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %5
%11 = load %struct.timeval*, %struct.timeval** %2
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
%13 = load i32, i32* %12
%14 = icmp sge i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %10
%16 = load %struct.timeval*, %struct.timeval** %2
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 1
%18 = load i32, i32* %17
%19 = icmp slt i32 %18, 1000000
br label %20
20: ; preds = %15, %10, %5, %1
%21 = phi i1 [ false, %10 ], [ false, %5 ], [ false, %1 ], [ %19, %15 ]
%22 = zext i1 %21 to i32
ret i32 %22
}

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