#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 /*<<< orphan*/ timeval_subtract(struct timeval *, struct timeval *,
                                    struct timeval *);
void test_subtract_timeval() {
  struct timeval a;
  struct timeval b;
  struct timeval c;
  a.tv_sec = 10;
  a.tv_usec = 100;
  ;
  b.tv_sec = 2;
  b.tv_usec = 20;
  ;
  timeval_subtract(&c, &a, &b);
  assert(c.tv_sec == 8);
  assert(c.tv_usec == 80);
  ;
  a.tv_sec = 100;
  a.tv_usec = 1;
  ;
  b.tv_sec = 1;
  b.tv_usec = 20;
  ;
  timeval_subtract(&c, &a, &b);
  assert(c.tv_sec == 98);
  assert(c.tv_usec == 999981);
  ;
}


x86 assembly (clang, -O0):
<test_subtract_timeval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0xa,-0x8(%rbp)
movl   $0x64,-0x4(%rbp)
movl   $0x2,-0x10(%rbp)
movl   $0x14,-0xc(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1040 <timeval_subtract@plt>
cmpl   $0x8,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x50,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x64,-0x8(%rbp)
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x14,-0xc(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1040 <timeval_subtract@plt>
cmpl   $0x62,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0xf422d,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_subtract_timeval>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movabs $0x640000000a,%rax
mov    %rax,0x18(%rsp)
movabs $0x1400000002,%rax
mov    %rax,0x10(%rsp)
lea    0x8(%rsp),%rbx
lea    0x18(%rsp),%r14
lea    0x10(%rsp),%r15
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <timeval_subtract@plt>
xor    %edi,%edi
cmpl   $0x8,0x8(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x50,0xc(%rsp)
sete   %dil
call   1030 <assert@plt>
movabs $0x100000064,%rax
mov    %rax,0x18(%rsp)
movabs $0x1400000001,%rax
mov    %rax,0x10(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <timeval_subtract@plt>
xor    %edi,%edi
cmpl   $0x62,0x8(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0xf422d,0xc(%rsp)
sete   %dil
call   1030 <assert@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
define void @test_subtract_timeval() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%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 100, i32* %5
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
store i32 2, i32* %6
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
store i32 20, i32* %7
%8 = call i32 @timeval_subtract(%struct.timeval* %3, %struct.timeval* %1, %struct.timeval* %2)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 8
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 80
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
store i32 100, i32* %19
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i32 1, i32* %20
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
store i32 1, i32* %21
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
store i32 20, i32* %22
%23 = call i32 @timeval_subtract(%struct.timeval* %3, %struct.timeval* %1, %struct.timeval* %2)
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%25 = load i32, i32* %24
%26 = icmp eq i32 %25, 98
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 999981
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define void @test_subtract_timeval() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %1 to i8*
%5 = bitcast %struct.timeval* %2 to i8*
%6 = bitcast %struct.timeval* %3 to i8*
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
store i32 10, i32* %7
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
store i32 100, i32* %8
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
store i32 2, i32* %9
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
store i32 20, i32* %10
%11 = call i32 @timeval_subtract(%struct.timeval* %3, %struct.timeval* %1, %struct.timeval* %2)
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 8
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%18 = load i32, i32* %17
%19 = icmp eq i32 %18, 80
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
store i32 100, i32* %7
store i32 1, i32* %8
store i32 1, i32* %9
store i32 20, i32* %10
%22 = call i32 @timeval_subtract(%struct.timeval* %3, %struct.timeval* %1, %struct.timeval* %2)
%23 = load i32, i32* %12
%24 = icmp eq i32 %23, 98
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i32, i32* %17
%28 = icmp eq i32 %27, 999981
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
ret void
}