#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*/ balance_timespec_m(struct timespec *);
struct timespec sub_timespec(struct timespec a, struct timespec b) {
  struct timespec result;
  result.tv_sec = a.tv_sec - b.tv_sec;
  result.tv_nsec = a.tv_nsec - b.tv_nsec;
  balance_timespec_m(&result);
  return result;
}


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

x86 assembly (clang, -O2):
<sub_timespec>:
sub    $0x18,%rsp
sub    %rcx,%rsi
mov    %rsi,0x10(%rsp)
sub    %rdx,%rdi
mov    %rdi,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <balance_timespec_m@plt>
mov    0x8(%rsp),%rax
mov    0x10(%rsp),%rdx
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
define { i64, i64 } @sub_timespec(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca %struct.timespec
%6 = sub nsw i64 %1, %3
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
store i64 %6, i64* %7
%8 = sub nsw i64 %0, %2
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
store i64 %8, i64* %9
%10 = call i32 @balance_timespec_m(%struct.timespec* %5)
%11 = load i64, i64* %9
%12 = insertvalue { i64, i64 } poison, i64 %11, 0
%13 = load i64, i64* %7
%14 = insertvalue { i64, i64 } %12, i64 %13, 1
ret { i64, i64 } %14
}