#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 */
long long int toddiff(struct timeval *tod1, struct timeval *tod2) {
  long long t1, t2;
  t1 = tod1->tv_sec * 1000000 + tod1->tv_usec;
  t2 = tod2->tv_sec * 1000000 + tod2->tv_usec;
  return t1 - t2;
}


x86 assembly (clang, -O0):
<toddiff>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
imul   $0xf4240,(%rax),%eax
mov    -0x8(%rbp),%rcx
add    0x4(%rcx),%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
imul   $0xf4240,(%rax),%eax
mov    -0x10(%rbp),%rcx
add    0x4(%rcx),%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
sub    -0x20(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<toddiff>:
movslq (%rdi),%rax
imul   $0xf4240,%rax,%rcx
movslq 0x4(%rdi),%rax
add    %rcx,%rax
movslq (%rsi),%rcx
imul   $0xf4240,%rcx,%rcx
movslq 0x4(%rsi),%rdx
add    %rcx,%rdx
sub    %rdx,%rax
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
define i64 @toddiff(%struct.timeval* %0, %struct.timeval* %1) {
%3 = alloca %struct.timeval*
%4 = alloca %struct.timeval*
%5 = alloca i64
%6 = alloca i64
store %struct.timeval* %0, %struct.timeval** %3
store %struct.timeval* %1, %struct.timeval** %4
%7 = load %struct.timeval*, %struct.timeval** %3
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = mul nsw i32 %9, 1000000
%11 = load %struct.timeval*, %struct.timeval** %3
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
%13 = load i32, i32* %12
%14 = add nsw i32 %10, %13
%15 = sext i32 %14 to i64
store i64 %15, i64* %5
%16 = load %struct.timeval*, %struct.timeval** %4
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = mul nsw i32 %18, 1000000
%20 = load %struct.timeval*, %struct.timeval** %4
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 1
%22 = load i32, i32* %21
%23 = add nsw i32 %19, %22
%24 = sext i32 %23 to i64
store i64 %24, i64* %6
%25 = load i64, i64* %5
%26 = load i64, i64* %6
%27 = sub nsw i64 %25, %26
ret i64 %27
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define i64 @toddiff(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1) {
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%4 = load i32, i32* %3
%5 = mul nsw i32 %4, 1000000
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%7 = load i32, i32* %6
%8 = add nsw i32 %5, %7
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%11 = load i32, i32* %10
%12 = mul nsw i32 %11, 1000000
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%14 = load i32, i32* %13
%15 = add nsw i32 %12, %14
%16 = sext i32 %15 to i64
%17 = sub nsw i64 %9, %16
ret i64 %17
}