#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_sec;
  scalar_t__ tv_usec;
};

/* Variables and functions */
void sub_time(struct timeval *t1, struct timeval *t2) {
  t1->tv_sec -= t2->tv_sec;
  t1->tv_usec -= t2->tv_usec;
  if (t1->tv_usec < 0) {
    t1->tv_sec--;
    t1->tv_usec += 1000000;
  }
  if (t1->tv_sec < 0) {
    t1->tv_sec = 0;
    t1->tv_usec = 0;
  }
}


x86 assembly (clang, -O0):
<sub_time>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
sub    %rdx,%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
sub    %rdx,%rcx
mov    %rcx,0x8(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jge    1167 <sub_time+0x67>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
add    $0xf4240,%rcx
mov    %rcx,0x8(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jge    118c <sub_time+0x8c>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<sub_time>:
movdqu (%rsi),%xmm1
movdqu (%rdi),%xmm0
psubq  %xmm1,%xmm0
movdqu %xmm0,(%rdi)
pshufd $0xee,%xmm0,%xmm1
movq   %xmm1,%rax
test   %rax,%rax
jns    112b <sub_time+0x2b>
paddq  0xed9(%rip),%xmm0
movdqu %xmm0,(%rdi)
movq   %xmm0,%rax
test   %rax,%rax
js     1136 <sub_time+0x36>
ret
pxor   %xmm0,%xmm0
movdqu %xmm0,(%rdi)
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
define void @sub_time(%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 0
%7 = load i64, i64* %6
%8 = load %struct.timeval*, %struct.timeval** %3
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%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 1
%14 = load i64, i64* %13
%15 = load %struct.timeval*, %struct.timeval** %3
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 1
%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 1
%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 0
%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 1
%30 = load i64, i64* %29
%31 = add nsw i64 %30, 1000000
store i64 %31, i64* %29
br label %32
32: ; preds = %23, %2
%33 = load %struct.timeval*, %struct.timeval** %3
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %33, i32 0, i32 0
%35 = load i64, i64* %34
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %32
%38 = load %struct.timeval*, %struct.timeval** %3
%39 = getelementptr inbounds %struct.timeval, %struct.timeval* %38, i32 0, i32 0
store i64 0, i64* %39
%40 = load %struct.timeval*, %struct.timeval** %3
%41 = getelementptr inbounds %struct.timeval, %struct.timeval* %40, i32 0, i32 1
store i64 0, i64* %41
br label %42
42: ; preds = %37, %32
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define void @sub_time(%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 1
%10 = icmp slt i64 %9, 0
%11 = extractelement <2 x i64> %7, i64 0
br i1 %10, label %12, label %16
12: ; preds = %2
%13 = add nsw <2 x i64> %7, <i64 -1, i64 1000000>
%14 = bitcast %struct.timeval* %0 to <2 x i64>*
store <2 x i64> %13, <2 x i64>* %14
%15 = extractelement <2 x i64> %13, i64 0
br label %16
16: ; preds = %2, %12
%17 = phi i64 [ %15, %12 ], [ %11, %2 ]
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = bitcast %struct.timeval* %0 to i8*
br label %21
21: ; preds = %19, %16
ret void
}