#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 {
  long long tv_sec;
  scalar_t__ tv_nsec;
};
typedef scalar_t__ int64_t;

/* Variables and functions */
int /*<<< orphan*/ assert(struct timespec const *);
int64_t get_time_diff_nsec(const struct timespec *start,
                           const struct timespec *end) {
  assert(start);
  assert(end);
  return (((end->tv_sec - start->tv_sec) * 1000000000LL)) + end->tv_nsec -
         start->tv_nsec;
}


x86 assembly (clang, -O0):
<get_time_diff_nsec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
sub    (%rcx),%rax
imul   $0x3b9aca00,%rax,%rax
mov    -0x10(%rbp),%rcx
add    0x8(%rcx),%rax
mov    -0x8(%rbp),%rcx
sub    0x8(%rcx),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_time_diff_nsec>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <assert@plt>
mov    %rbx,%rdi
call   1030 <assert@plt>
mov    (%rbx),%rax
sub    (%r14),%rax
imul   $0x3b9aca00,%rax,%rax
add    0x8(%rbx),%rax
sub    0x8(%r14),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
define i64 @get_time_diff_nsec(%struct.timespec* %0, %struct.timespec* %1) {
%3 = tail call i32 @assert(%struct.timespec* %0)
%4 = tail call i32 @assert(%struct.timespec* %1)
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%6 = load i64, i64* %5
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 0
%8 = load i64, i64* %7
%9 = sub nsw i64 %6, %8
%10 = mul nsw i64 %9, 1000000000
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%12 = load i64, i64* %11
%13 = add nsw i64 %10, %12
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 1
%15 = load i64, i64* %14
%16 = sub i64 %13, %15
ret i64 %16
}