#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int compare(struct timeval *tp, struct timeval *old_tp) {
  if (!(tp && old_tp)) {
    fprintf(stderr, "ERROR: missing structure for compare()\n");
    exit(1);
  }
  if ((tp->tv_sec < old_tp->tv_sec) ||
      ((tp->tv_sec = old_tp->tv_sec) && (tp->tv_usec < old_tp->tv_usec))) {
    fprintf(stderr, "New values (%d:%d) are older than old values (%d:%d)!\n",
            (int)tp->tv_sec, (int)tp->tv_usec, (int)old_tp->tv_sec,
            (int)old_tp->tv_usec);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1146 <compare+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1167 <compare+0x47>
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
jl     11a9 <compare+0x89>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
je     11f4 <compare+0xd4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    0x8(%rcx),%rax
jge    11f4 <compare+0xd4>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %eax,%edx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %eax,%r8d
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    %eax,%r9d
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11fb <compare+0xdb>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare>:
push   %rbx
test   %rdi,%rdi
je     1180 <compare+0x60>
test   %rsi,%rsi
je     1180 <compare+0x60>
mov    (%rdi),%rdx
mov    (%rsi),%rax
cmp    %rax,%rdx
jge    1143 <compare+0x23>
mov    0x8(%rdi),%rcx
mov    0x8(%rsi),%r9
mov    %rax,%r8
jmp    1163 <compare+0x43>
mov    %rax,(%rdi)
mov    $0x1,%ebx
test   %rax,%rax
je     117c <compare+0x5c>
mov    0x8(%rdi),%rcx
mov    0x8(%rsi),%r9
cmp    %r9,%rcx
jge    117c <compare+0x5c>
mov    (%rsi),%r8
mov    %rax,%rdx
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xeb5(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %ebx,%eax
pop    %rbx
ret
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@stderr = global i32 0
@.str = [40 x i8] c"ERROR: missing structure for compare()\0A\00"
@.str.1 = [55 x i8] c"New values (%d:%d) are older than old values (%d:%d)!\0A\00"
define i32 @compare(%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 = icmp ne %struct.timeval* %6, null
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load %struct.timeval*, %struct.timeval** %5
%10 = icmp ne %struct.timeval* %9, null
br i1 %10, label %15, label %11
11: ; preds = %8, %2
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %8
%16 = load %struct.timeval*, %struct.timeval** %4
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 0
%18 = load i64, i64* %17
%19 = load %struct.timeval*, %struct.timeval** %5
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 0
%21 = load i64, i64* %20
%22 = icmp slt i64 %18, %21
br i1 %22, label %38, label %23
23: ; preds = %15
%24 = load %struct.timeval*, %struct.timeval** %5
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %24, i32 0, i32 0
%26 = load i64, i64* %25
%27 = load %struct.timeval*, %struct.timeval** %4
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %27, i32 0, i32 0
store i64 %26, i64* %28
%29 = icmp ne i64 %26, 0
br i1 %29, label %30, label %57
30: ; preds = %23
%31 = load %struct.timeval*, %struct.timeval** %4
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %31, i32 0, i32 1
%33 = load i64, i64* %32
%34 = load %struct.timeval*, %struct.timeval** %5
%35 = getelementptr inbounds %struct.timeval, %struct.timeval* %34, i32 0, i32 1
%36 = load i64, i64* %35
%37 = icmp slt i64 %33, %36
br i1 %37, label %38, label %57
38: ; preds = %30, %15
%39 = load i32, i32* @stderr
%40 = load %struct.timeval*, %struct.timeval** %4
%41 = getelementptr inbounds %struct.timeval, %struct.timeval* %40, i32 0, i32 0
%42 = load i64, i64* %41
%43 = trunc i64 %42 to i32
%44 = load %struct.timeval*, %struct.timeval** %4
%45 = getelementptr inbounds %struct.timeval, %struct.timeval* %44, i32 0, i32 1
%46 = load i64, i64* %45
%47 = trunc i64 %46 to i32
%48 = load %struct.timeval*, %struct.timeval** %5
%49 = getelementptr inbounds %struct.timeval, %struct.timeval* %48, i32 0, i32 0
%50 = load i64, i64* %49
%51 = trunc i64 %50 to i32
%52 = load %struct.timeval*, %struct.timeval** %5
%53 = getelementptr inbounds %struct.timeval, %struct.timeval* %52, i32 0, i32 1
%54 = load i64, i64* %53
%55 = trunc i64 %54 to i32
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 %43, i32 %47, i32 %51, i32 %55)
store i32 0, i32* %3
br label %58
57: ; preds = %30, %23
store i32 1, i32* %3
br label %58
58: ; preds = %57, %38
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@stderr = global i32 0
@.str = [40 x i8] c"ERROR: missing structure for compare()\0A\00"
@.str.1 = [55 x i8] c"New values (%d:%d) are older than old values (%d:%d)!\0A\00"
define i32 @compare(%struct.timeval* %0, %struct.timeval* %1) {
%3 = icmp ne %struct.timeval* %0, null
%4 = icmp ne %struct.timeval* %1, null
%5 = and i1 %3, %4
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%12 = load i64, i64* %11
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%14 = load i64, i64* %13
%15 = icmp slt i64 %12, %14
br i1 %15, label %16, label %21
16: ; preds = %10
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%18 = load i64, i64* %17
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%20 = load i64, i64* %19
br label %31
21: ; preds = %10
store i64 %14, i64* %11
%22 = icmp eq i64 %14, 0
br i1 %22, label %42, label %23
23: ; preds = %21
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%25 = load i64, i64* %24
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%27 = load i64, i64* %26
%28 = icmp slt i64 %25, %27
br i1 %28, label %29, label %42
29: ; preds = %23
%30 = load i64, i64* %13
br label %31
31: ; preds = %29, %16
%32 = phi i64 [ %27, %29 ], [ %20, %16 ]
%33 = phi i64 [ %30, %29 ], [ %14, %16 ]
%34 = phi i64 [ %25, %29 ], [ %18, %16 ]
%35 = phi i64 [ %14, %29 ], [ %12, %16 ]
%36 = load i32, i32* @stderr
%37 = trunc i64 %35 to i32
%38 = trunc i64 %34 to i32
%39 = trunc i64 %33 to i32
%40 = trunc i64 %32 to i32
%41 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 %38, i32 %39, i32 %40)
br label %42
42: ; preds = %21, %23, %31
%43 = phi i32 [ 0, %31 ], [ 1, %23 ], [ 1, %21 ]
ret i32 %43
}