#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 timespec {
  scalar_t__ tv_nsec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ normalize_timespec(struct timespec *);
void timespecsub(const struct timespec *a, const struct timespec *b,
                 struct timespec *res) {
  res->tv_sec = a->tv_sec - b->tv_sec;
  res->tv_nsec = a->tv_nsec - b->tv_nsec;
  normalize_timespec(res);
}


x86 assembly (clang, -O0):
<timespecsub>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x10(%rbp),%rax
sub    0x8(%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
sub    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <normalize_timespec@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timespecsub>:
movdqu (%rdi),%xmm0
movdqu (%rsi),%xmm1
psubq  %xmm1,%xmm0
movdqu %xmm0,(%rdx)
mov    %rdx,%rdi
jmp    1030 <normalize_timespec@plt>

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
define void @timespecsub(%struct.timespec* %0, %struct.timespec* %1, %struct.timespec* %2) {
%4 = alloca %struct.timespec*
%5 = alloca %struct.timespec*
%6 = alloca %struct.timespec*
store %struct.timespec* %0, %struct.timespec** %4
store %struct.timespec* %1, %struct.timespec** %5
store %struct.timespec* %2, %struct.timespec** %6
%7 = load %struct.timespec*, %struct.timespec** %4
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 1
%9 = load i64, i64* %8
%10 = load %struct.timespec*, %struct.timespec** %5
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 1
%12 = load i64, i64* %11
%13 = sub nsw i64 %9, %12
%14 = load %struct.timespec*, %struct.timespec** %6
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %14, i32 0, i32 1
store i64 %13, i64* %15
%16 = load %struct.timespec*, %struct.timespec** %4
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %16, i32 0, i32 0
%18 = load i64, i64* %17
%19 = load %struct.timespec*, %struct.timespec** %5
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %19, i32 0, i32 0
%21 = load i64, i64* %20
%22 = sub nsw i64 %18, %21
%23 = load %struct.timespec*, %struct.timespec** %6
%24 = getelementptr inbounds %struct.timespec, %struct.timespec* %23, i32 0, i32 0
store i64 %22, i64* %24
%25 = load %struct.timespec*, %struct.timespec** %6
%26 = call i32 @normalize_timespec(%struct.timespec* %25)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
define void @timespecsub(%struct.timespec* nocapture %0, %struct.timespec* nocapture %1, %struct.timespec* %2) {
%4 = bitcast %struct.timespec* %0 to <2 x i64>*
%5 = load <2 x i64>, <2 x i64>* %4
%6 = bitcast %struct.timespec* %1 to <2 x i64>*
%7 = load <2 x i64>, <2 x i64>* %6
%8 = sub nsw <2 x i64> %5, %7
%9 = bitcast %struct.timespec* %2 to <2 x i64>*
store <2 x i64> %8, <2 x i64>* %9
%10 = tail call i32 @normalize_timespec(%struct.timespec* %2)
ret void
}