#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 time_after(struct timeval *last, struct timeval *tout,
               struct timeval *now) {
  if (now->tv_sec > last->tv_sec + tout->tv_sec)
    return 1;
  if (now->tv_sec == last->tv_sec + tout->tv_sec) {
    if (now->tv_usec > last->tv_usec + tout->tv_usec)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<time_after>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
mov    -0x18(%rbp),%rdx
add    (%rdx),%rcx
cmp    %rcx,%rax
jle    113a <time_after+0x3a>
movl   $0x1,-0x4(%rbp)
jmp    1191 <time_after+0x91>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
mov    -0x18(%rbp),%rdx
add    (%rdx),%rcx
cmp    %rcx,%rax
jne    118a <time_after+0x8a>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%rcx
mov    -0x18(%rbp),%rdx
add    0x8(%rdx),%rcx
cmp    %rcx,%rax
jle    1185 <time_after+0x85>
movl   $0x1,-0x4(%rbp)
jmp    1191 <time_after+0x91>
jmp    118a <time_after+0x8a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_after>:
mov    (%rsi),%rcx
add    (%rdi),%rcx
mov    $0x1,%eax
cmp    %rcx,(%rdx)
jg     1122 <time_after+0x22>
jne    1120 <time_after+0x20>
mov    0x8(%rsi),%rcx
add    0x8(%rdi),%rcx
cmp    %rcx,0x8(%rdx)
jg     1122 <time_after+0x22>
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
define i32 @time_after(%struct.timeval* %0, %struct.timeval* %1, %struct.timeval* %2) {
%4 = alloca i32
%5 = alloca %struct.timeval*
%6 = alloca %struct.timeval*
%7 = alloca %struct.timeval*
store %struct.timeval* %0, %struct.timeval** %5
store %struct.timeval* %1, %struct.timeval** %6
store %struct.timeval* %2, %struct.timeval** %7
%8 = load %struct.timeval*, %struct.timeval** %7
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%10 = load i64, i64* %9
%11 = load %struct.timeval*, %struct.timeval** %5
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
%13 = load i64, i64* %12
%14 = load %struct.timeval*, %struct.timeval** %6
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
%16 = load i64, i64* %15
%17 = add nsw i64 %13, %16
%18 = icmp sgt i64 %10, %17
br i1 %18, label %19, label %20
19: ; preds = %3
store i32 1, i32* %4
br label %47
20: ; preds = %3
%21 = load %struct.timeval*, %struct.timeval** %7
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %21, i32 0, i32 0
%23 = load i64, i64* %22
%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** %6
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %27, i32 0, i32 0
%29 = load i64, i64* %28
%30 = add nsw i64 %26, %29
%31 = icmp eq i64 %23, %30
br i1 %31, label %32, label %46
32: ; preds = %20
%33 = load %struct.timeval*, %struct.timeval** %7
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %33, i32 0, i32 1
%35 = load i64, i64* %34
%36 = load %struct.timeval*, %struct.timeval** %5
%37 = getelementptr inbounds %struct.timeval, %struct.timeval* %36, i32 0, i32 1
%38 = load i64, i64* %37
%39 = load %struct.timeval*, %struct.timeval** %6
%40 = getelementptr inbounds %struct.timeval, %struct.timeval* %39, i32 0, i32 1
%41 = load i64, i64* %40
%42 = add nsw i64 %38, %41
%43 = icmp sgt i64 %35, %42
br i1 %43, label %44, label %45
44: ; preds = %32
store i32 1, i32* %4
br label %47
45: ; preds = %32
br label %46
46: ; preds = %45, %20
store i32 0, i32* %4
br label %47
47: ; preds = %46, %44, %19
%48 = load i32, i32* %4
ret i32 %48
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define i32 @time_after(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1, %struct.timeval* nocapture %2) {
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%5 = load i64, i64* %4
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%7 = load i64, i64* %6
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%9 = load i64, i64* %8
%10 = add nsw i64 %9, %7
%11 = icmp sgt i64 %5, %10
br i1 %11, label %24, label %12
12: ; preds = %3
%13 = icmp eq i64 %5, %10
br i1 %13, label %14, label %23
14: ; preds = %12
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%16 = load i64, i64* %15
%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
%21 = add nsw i64 %20, %18
%22 = icmp sgt i64 %16, %21
br i1 %22, label %24, label %23
23: ; preds = %14, %12
br label %24
24: ; preds = %14, %3, %23
%25 = phi i32 [ 0, %23 ], [ 1, %3 ], [ 1, %14 ]
ret i32 %25
}