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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int timeval_compare(struct timeval *, struct timeval *);
void test_compare_timeval(void) {
  struct timeval a;
  struct timeval b;
  int rc;
  a.tv_sec = 10;
  a.tv_usec = 0;
  ;
  b.tv_sec = 5;
  b.tv_usec = 0;
  ;
  rc = timeval_compare(&a, &b);
  assert(rc == 1);
  a.tv_sec = 10;
  a.tv_usec = 0;
  ;
  b.tv_sec = 50;
  b.tv_usec = 0;
  ;
  rc = timeval_compare(&a, &b);
  assert(rc == -1);
  a.tv_sec = 44;
  a.tv_usec = 0;
  ;
  b.tv_sec = 44;
  b.tv_usec = 0;
  ;
  rc = timeval_compare(&a, &b);
  assert(rc == 0);
  a.tv_sec = 5;
  a.tv_usec = 30;
  ;
  b.tv_sec = 5;
  b.tv_usec = 29;
  ;
  rc = timeval_compare(&a, &b);
  assert(rc == 1);
  a.tv_sec = 5;
  a.tv_usec = 16;
  ;
  b.tv_sec = 5;
  b.tv_usec = 61;
  ;
  rc = timeval_compare(&a, &b);
  assert(rc == -1);
  a.tv_sec = 5;
  a.tv_usec = 777;
  ;
  b.tv_sec = 5;
  b.tv_usec = 777;
  ;
  rc = timeval_compare(&a, &b);
  assert(rc == 0);
  a.tv_sec = 6;
  a.tv_usec = 0;
  ;
  b.tv_sec = 5;
  b.tv_usec = 999999;
  ;
  rc = timeval_compare(&a, &b);
  assert(rc == 1);
  a.tv_sec = 5;
  a.tv_usec = 999999;
  ;
  b.tv_sec = 6;
  b.tv_usec = 0;
  ;
  rc = timeval_compare(&a, &b);
  assert(rc == -1);
  a.tv_sec = 44;
  a.tv_usec = 999999;
  ;
  b.tv_sec = 44;
  b.tv_usec = 999999;
  ;
  rc = timeval_compare(&a, &b);
  assert(rc == 0);
}


x86 assembly (clang, -O0):
<test_compare_timeval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0xa,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <timeval_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0xa,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
movl   $0x32,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <timeval_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x2c,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
movl   $0x2c,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <timeval_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x5,-0x8(%rbp)
movl   $0x1e,-0x4(%rbp)
movl   $0x5,-0x10(%rbp)
movl   $0x1d,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <timeval_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x5,-0x8(%rbp)
movl   $0x10,-0x4(%rbp)
movl   $0x5,-0x10(%rbp)
movl   $0x3d,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <timeval_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x5,-0x8(%rbp)
movl   $0x309,-0x4(%rbp)
movl   $0x5,-0x10(%rbp)
movl   $0x309,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <timeval_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x6,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x10(%rbp)
movl   $0xf423f,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <timeval_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x5,-0x8(%rbp)
movl   $0xf423f,-0x4(%rbp)
movl   $0x6,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <timeval_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x2c,-0x8(%rbp)
movl   $0xf423f,-0x4(%rbp)
movl   $0x2c,-0x10(%rbp)
movl   $0xf423f,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <timeval_compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_compare_timeval>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0xa,0x8(%rsp)
movq   $0x5,(%rsp)
lea    0x8(%rsp),%r15
mov    %rsp,%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <timeval_compare@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1040 <assert@plt>
movq   $0xa,0x8(%rsp)
movq   $0x32,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <timeval_compare@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1040 <assert@plt>
movq   $0x2c,0x8(%rsp)
movq   $0x2c,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <timeval_compare@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
movabs $0x1e00000005,%rax
mov    %rax,0x8(%rsp)
movabs $0x1d00000005,%rax
mov    %rax,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <timeval_compare@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1040 <assert@plt>
movabs $0x1000000005,%rax
mov    %rax,0x8(%rsp)
movabs $0x3d00000005,%rax
mov    %rax,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <timeval_compare@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1040 <assert@plt>
movabs $0x30900000005,%rax
mov    %rax,0x8(%rsp)
mov    %rax,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <timeval_compare@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
movq   $0x6,0x8(%rsp)
movabs $0xf423f00000005,%rbx
mov    %rbx,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <timeval_compare@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1040 <assert@plt>
mov    %rbx,0x8(%rsp)
movq   $0x6,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <timeval_compare@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1040 <assert@plt>
movabs $0xf423f0000002c,%rax
mov    %rax,0x8(%rsp)
mov    %rax,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <timeval_compare@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
define void @test_compare_timeval() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = alloca i32
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
store i32 10, i32* %4
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i32 0, i32* %5
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
store i32 5, i32* %6
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
store i32 0, i32* %7
%8 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 1
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
store i32 10, i32* %13
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i32 0, i32* %14
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
store i32 50, i32* %15
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
store i32 0, i32* %16
%17 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, -1
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
store i32 44, i32* %22
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i32 0, i32* %23
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
store i32 44, i32* %24
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
store i32 0, i32* %25
%26 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
store i32 %26, i32* %3
%27 = load i32, i32* %3
%28 = icmp eq i32 %27, 0
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
store i32 5, i32* %31
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i32 30, i32* %32
%33 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
store i32 5, i32* %33
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
store i32 29, i32* %34
%35 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
store i32 %35, i32* %3
%36 = load i32, i32* %3
%37 = icmp eq i32 %36, 1
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
store i32 5, i32* %40
%41 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i32 16, i32* %41
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
store i32 5, i32* %42
%43 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
store i32 61, i32* %43
%44 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
store i32 %44, i32* %3
%45 = load i32, i32* %3
%46 = icmp eq i32 %45, -1
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
store i32 5, i32* %49
%50 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i32 777, i32* %50
%51 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
store i32 5, i32* %51
%52 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
store i32 777, i32* %52
%53 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
store i32 %53, i32* %3
%54 = load i32, i32* %3
%55 = icmp eq i32 %54, 0
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
%58 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
store i32 6, i32* %58
%59 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i32 0, i32* %59
%60 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
store i32 5, i32* %60
%61 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
store i32 999999, i32* %61
%62 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
store i32 %62, i32* %3
%63 = load i32, i32* %3
%64 = icmp eq i32 %63, 1
%65 = zext i1 %64 to i32
%66 = call i32 @assert(i32 %65)
%67 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
store i32 5, i32* %67
%68 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i32 999999, i32* %68
%69 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
store i32 6, i32* %69
%70 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
store i32 0, i32* %70
%71 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
store i32 %71, i32* %3
%72 = load i32, i32* %3
%73 = icmp eq i32 %72, -1
%74 = zext i1 %73 to i32
%75 = call i32 @assert(i32 %74)
%76 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
store i32 44, i32* %76
%77 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i32 999999, i32* %77
%78 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
store i32 44, i32* %78
%79 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
store i32 999999, i32* %79
%80 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
store i32 %80, i32* %3
%81 = load i32, i32* %3
%82 = icmp eq i32 %81, 0
%83 = zext i1 %82 to i32
%84 = call i32 @assert(i32 %83)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define void @test_compare_timeval() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timeval* %2 to i8*
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
store i32 10, i32* %5
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
store i32 0, i32* %6
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
store i32 5, i32* %7
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
store i32 0, i32* %8
%9 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
%10 = icmp eq i32 %9, 1
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
store i32 10, i32* %5
store i32 0, i32* %6
store i32 50, i32* %7
store i32 0, i32* %8
%13 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
%14 = icmp eq i32 %13, -1
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
store i32 44, i32* %5
store i32 0, i32* %6
store i32 44, i32* %7
store i32 0, i32* %8
%17 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
store i32 5, i32* %5
store i32 30, i32* %6
store i32 5, i32* %7
store i32 29, i32* %8
%21 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
%22 = icmp eq i32 %21, 1
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
store i32 5, i32* %5
store i32 16, i32* %6
store i32 5, i32* %7
store i32 61, i32* %8
%25 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
%26 = icmp eq i32 %25, -1
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
store i32 5, i32* %5
store i32 777, i32* %6
store i32 5, i32* %7
store i32 777, i32* %8
%29 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
%30 = icmp eq i32 %29, 0
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
store i32 6, i32* %5
store i32 0, i32* %6
store i32 5, i32* %7
store i32 999999, i32* %8
%33 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
%34 = icmp eq i32 %33, 1
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
store i32 5, i32* %5
store i32 999999, i32* %6
store i32 6, i32* %7
store i32 0, i32* %8
%37 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
%38 = icmp eq i32 %37, -1
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
store i32 44, i32* %5
store i32 999999, i32* %6
store i32 44, i32* %7
store i32 999999, i32* %8
%41 = call i32 @timeval_compare(%struct.timeval* %1, %struct.timeval* %2)
%42 = icmp eq i32 %41, 0
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
ret void
}