#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 subtract_and_add(struct timeval *Z, struct timeval *x, struct timeval *y) {
  struct timeval result;
  result.tv_sec = y->tv_sec - x->tv_sec;
  result.tv_usec = y->tv_usec - x->tv_usec;
  Z->tv_sec += result.tv_sec;
  Z->tv_usec += result.tv_usec;
  return;
}


x86 assembly (clang, -O0):
<subtract_and_add>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x10(%rbp),%rcx
sub    0x8(%rcx),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
sub    (%rcx),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%rax
add    0x8(%rax),%rcx
mov    %rcx,0x8(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x8(%rbp),%rax
add    (%rax),%rcx
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<subtract_and_add>:
movdqu (%rdx),%xmm0
movdqu (%rsi),%xmm1
psubq  %xmm1,%xmm0
movdqu (%rdi),%xmm1
paddq  %xmm0,%xmm1
movdqu %xmm1,(%rdi)
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
define void @subtract_and_add(%struct.timeval* %0, %struct.timeval* %1, %struct.timeval* %2) {
%4 = alloca %struct.timeval*
%5 = alloca %struct.timeval*
%6 = alloca %struct.timeval*
%7 = alloca %struct.timeval
store %struct.timeval* %0, %struct.timeval** %4
store %struct.timeval* %1, %struct.timeval** %5
store %struct.timeval* %2, %struct.timeval** %6
%8 = load %struct.timeval*, %struct.timeval** %6
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%10 = load i64, i64* %9
%11 = load %struct.timeval*, %struct.timeval** %5
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
%13 = load i64, i64* %12
%14 = sub nsw i64 %10, %13
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
store i64 %14, 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 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
store i64 %22, i64* %23
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%25 = load i64, i64* %24
%26 = load %struct.timeval*, %struct.timeval** %4
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %26, i32 0, i32 1
%28 = load i64, i64* %27
%29 = add nsw i64 %28, %25
store i64 %29, i64* %27
%30 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%31 = load i64, i64* %30
%32 = load %struct.timeval*, %struct.timeval** %4
%33 = getelementptr inbounds %struct.timeval, %struct.timeval* %32, i32 0, i32 0
%34 = load i64, i64* %33
%35 = add nsw i64 %34, %31
store i64 %35, i64* %33
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define void @subtract_and_add(%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 = bitcast %struct.timeval* %1 to <2 x i64>*
%7 = load <2 x i64>, <2 x i64>* %6
%8 = sub <2 x i64> %5, %7
%9 = bitcast %struct.timeval* %0 to <2 x i64>*
%10 = load <2 x i64>, <2 x i64>* %9
%11 = add nsw <2 x i64> %8, %10
%12 = bitcast %struct.timeval* %0 to <2 x i64>*
store <2 x i64> %11, <2 x i64>* %12
ret void
}