#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;
};
typedef int int64_t;

/* Variables and functions */
int64_t _microSecondDiff(struct timeval *t1, struct timeval *t0) {
  if (t1 && t0) {
    int64_t seconds = t1->tv_sec - t0->tv_sec;
    int64_t micros = t1->tv_usec - t0->tv_usec;
    return micros + (seconds * 1000000);
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<_microSecondDiff>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1156 <_microSecondDiff+0x56>
cmpq   $0x0,-0x18(%rbp)
je     1156 <_microSecondDiff+0x56>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
sub    (%rcx),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    -0x18(%rbp),%rcx
sub    0x4(%rcx),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
imul   $0xf4240,-0x1c(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    115d <_microSecondDiff+0x5d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_microSecondDiff>:
xor    %eax,%eax
test   %rdi,%rdi
je     111e <_microSecondDiff+0x1e>
test   %rsi,%rsi
je     111e <_microSecondDiff+0x1e>
mov    (%rdi),%eax
mov    0x4(%rdi),%ecx
sub    (%rsi),%eax
sub    0x4(%rsi),%ecx
imul   $0xf4240,%eax,%eax
add    %ecx,%eax
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
define i32 @_microSecondDiff(%struct.timeval* %0, %struct.timeval* %1) {
%3 = alloca i32
%4 = alloca %struct.timeval*
%5 = alloca %struct.timeval*
%6 = alloca i32
%7 = alloca i32
store %struct.timeval* %0, %struct.timeval** %4
store %struct.timeval* %1, %struct.timeval** %5
%8 = load %struct.timeval*, %struct.timeval** %4
%9 = icmp ne %struct.timeval* %8, null
br i1 %9, label %10, label %32
10: ; preds = %2
%11 = load %struct.timeval*, %struct.timeval** %5
%12 = icmp ne %struct.timeval* %11, null
br i1 %12, label %13, label %32
13: ; preds = %10
%14 = load %struct.timeval*, %struct.timeval** %4
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = load %struct.timeval*, %struct.timeval** %5
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = sub nsw i32 %16, %19
store i32 %20, i32* %6
%21 = load %struct.timeval*, %struct.timeval** %4
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %21, i32 0, i32 1
%23 = load i32, i32* %22
%24 = load %struct.timeval*, %struct.timeval** %5
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %24, i32 0, i32 1
%26 = load i32, i32* %25
%27 = sub nsw i32 %23, %26
store i32 %27, i32* %7
%28 = load i32, i32* %7
%29 = load i32, i32* %6
%30 = mul nsw i32 %29, 1000000
%31 = add nsw i32 %28, %30
store i32 %31, i32* %3
br label %33
32: ; preds = %10, %2
store i32 0, i32* %3
br label %33
33: ; preds = %32, %13
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define i32 @_microSecondDiff(%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 %6, label %19
6: ; preds = %2
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%8 = load i32, i32* %7
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%10 = load i32, i32* %9
%11 = sub nsw i32 %8, %10
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%15 = load i32, i32* %14
%16 = sub i32 %13, %15
%17 = mul nsw i32 %11, 1000000
%18 = add nsw i32 %16, %17
br label %19
19: ; preds = %2, %6
%20 = phi i32 [ %18, %6 ], [ 0, %2 ]
ret i32 %20
}