#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 timeval_subtract(struct timeval *tve, struct timeval *tvs) {
  tve->tv_sec -= tvs->tv_sec;
  tve->tv_usec -= tvs->tv_usec;
  if (tve->tv_usec < 0) {
    tve->tv_sec--;
    tve->tv_usec += 1000000;
  }
}


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

x86 assembly (clang, -O2):
<timeval_subtract>:
movdqu (%rsi),%xmm1
movdqu (%rdi),%xmm0
psubq  %xmm1,%xmm0
movdqu %xmm0,(%rdi)
movq   %xmm0,%rax
test   %rax,%rax
js     111b <timeval_subtract+0x1b>
ret
paddq  0xedd(%rip),%xmm0
movdqu %xmm0,(%rdi)
ret

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

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