#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;
  long tv_nsec;
};

/* Variables and functions */
bool timespec_normalized(const struct timespec *ts) {
  if (ts->tv_sec < 0)
    return false;
  if (ts->tv_nsec < 0)
    return false;
  if (ts->tv_nsec >= 1000000000L)
    return false;
  return true;
}


x86 assembly (clang, -O0):
<timespec_normalized>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jge    1122 <timespec_normalized+0x22>
movl   $0x0,-0x4(%rbp)
jmp    1162 <timespec_normalized+0x62>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jge    113d <timespec_normalized+0x3d>
movl   $0x0,-0x4(%rbp)
jmp    1162 <timespec_normalized+0x62>
mov    -0x10(%rbp),%rax
cmpq   $0x3b9aca00,0x8(%rax)
3b
jl     115b <timespec_normalized+0x5b>
movl   $0x0,-0x4(%rbp)
jmp    1162 <timespec_normalized+0x62>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<timespec_normalized>:
xor    %eax,%eax
cmpq   $0x0,(%rdi)
js     111d <timespec_normalized+0x1d>
mov    0x8(%rdi),%rcx
test   %rcx,%rcx
js     111d <timespec_normalized+0x1d>
xor    %eax,%eax
cmp    $0x3b9aca00,%rcx
setb   %al
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
define i32 @timespec_normalized(%struct.timespec* %0) {
%2 = alloca i32
%3 = alloca %struct.timespec*
store %struct.timespec* %0, %struct.timespec** %3
%4 = load %struct.timespec*, %struct.timespec** %3
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%6 = load i64, i64* %5
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %22
9: ; preds = %1
%10 = load %struct.timespec*, %struct.timespec** %3
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 1
%12 = load i64, i64* %11
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9
store i32 0, i32* %2
br label %22
15: ; preds = %9
%16 = load %struct.timespec*, %struct.timespec** %3
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %16, i32 0, i32 1
%18 = load i64, i64* %17
%19 = icmp sge i64 %18, 1000000000
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 0, i32* %2
br label %22
21: ; preds = %15
store i32 1, i32* %2
br label %22
22: ; preds = %21, %20, %14, %8
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
define i32 @timespec_normalized(%struct.timespec* nocapture %0) {
%2 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 0
%3 = load i64, i64* %2
%4 = icmp slt i64 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %1
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 1
%7 = load i64, i64* %6
%8 = icmp slt i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = icmp ult i64 %7, 1000000000
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %9, %5, %1
%13 = phi i32 [ 0, %1 ], [ 0, %5 ], [ %11, %9 ]
ret i32 %13
}