#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_usec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
void utimediff(struct timeval *diff, struct timeval *start,
               struct timeval *stop) {
  diff->tv_sec = stop->tv_sec - start->tv_sec;
  diff->tv_usec = stop->tv_usec - start->tv_usec;
  if (diff->tv_usec < 0) {
    diff->tv_sec--;
    start->tv_usec -= stop->tv_usec;
    diff->tv_usec = 1000000 - start->tv_usec;
  }
}


x86 assembly (clang, -O0):
<utimediff>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x10(%rbp),%rax
sub    0x8(%rax),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
sub    (%rax),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jge    1182 <utimediff+0x82>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,0x8(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
sub    %rdx,%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    $0xf4240,%ecx
sub    (%rax),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<utimediff>:
movdqu (%rdx),%xmm0
movdqu (%rsi),%xmm1
psubq  %xmm1,%xmm0
movdqu %xmm0,(%rdi)
movq   %xmm0,%rax
test   %rax,%rax
js     111b <utimediff+0x1b>
ret
pshufd $0xee,%xmm0,%xmm0
movq   %xmm0,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,0x8(%rdi)
mov    (%rsi),%rax
sub    (%rdx),%rax
mov    %rax,(%rsi)
mov    $0xf4240,%ecx
sub    %rax,%rcx
mov    %rcx,(%rdi)
ret

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

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define void @utimediff(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1, %struct.timeval* nocapture %2) {
%4 = bitcast %struct.timeval* %2 to <2 x i64>*
%5 = load <2 x i64>, <2 x i64>* %4
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%7 = bitcast %struct.timeval* %1 to <2 x i64>*
%8 = load <2 x i64>, <2 x i64>* %7
%9 = sub nsw <2 x i64> %5, %8
%10 = bitcast %struct.timeval* %0 to <2 x i64>*
store <2 x i64> %9, <2 x i64>* %10
%11 = extractelement <2 x i64> %9, i64 0
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %3
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%17 = extractelement <2 x i64> %9, i64 1
%18 = add nsw i64 %17, -1
store i64 %18, i64* %16
%19 = load i64, i64* %15
%20 = load i64, i64* %6
%21 = sub nsw i64 %20, %19
store i64 %21, i64* %6
%22 = sub nsw i64 1000000, %21
store i64 %22, i64* %14
br label %23
23: ; preds = %13, %3
ret void
}