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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ timespec_subtract(struct timespec *, struct timespec *,
                                     struct timespec *);
void test_subtract_timespec() {
  struct timespec a;
  struct timespec b;
  struct timespec c;
  a.tv_sec = 10;
  a.tv_nsec = 100;
  ;
  b.tv_sec = 2;
  b.tv_nsec = 20;
  ;
  timespec_subtract(&c, &a, &b);
  assert(c.tv_sec == 8);
  assert(c.tv_nsec == 80);
  ;
  a.tv_sec = 100;
  a.tv_nsec = 1;
  ;
  b.tv_sec = 1;
  b.tv_nsec = 20;
  ;
  timespec_subtract(&c, &a, &b);
  assert(c.tv_sec == 98);
  assert(c.tv_nsec == 999999981);
  ;
}


x86 assembly (clang, -O0):
<test_subtract_timespec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0xa,-0x8(%rbp)
movl   $0x64,-0x4(%rbp)
movl   $0x2,-0x10(%rbp)
movl   $0x14,-0xc(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <timespec_subtract@plt>
cmpl   $0x8,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x50,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x64,-0x8(%rbp)
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x14,-0xc(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <timespec_subtract@plt>
cmpl   $0x62,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x3b9ac9ed,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_subtract_timespec>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movabs $0x640000000a,%rax
mov    %rax,0x18(%rsp)
movabs $0x1400000002,%rax
mov    %rax,0x10(%rsp)
lea    0x8(%rsp),%rbx
lea    0x18(%rsp),%r14
lea    0x10(%rsp),%r15
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <timespec_subtract@plt>
xor    %edi,%edi
cmpl   $0x8,0x8(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x50,0xc(%rsp)
sete   %dil
call   1040 <assert@plt>
movabs $0x100000064,%rax
mov    %rax,0x18(%rsp)
movabs $0x1400000001,%rax
mov    %rax,0x10(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <timespec_subtract@plt>
xor    %edi,%edi
cmpl   $0x62,0x8(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x3b9ac9ed,0xc(%rsp)
3b
sete   %dil
call   1040 <assert@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
define void @test_subtract_timespec() {
%1 = alloca %struct.timespec
%2 = alloca %struct.timespec
%3 = alloca %struct.timespec
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 10, i32* %4
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 100, i32* %5
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
store i32 2, i32* %6
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
store i32 20, i32* %7
%8 = call i32 @timespec_subtract(%struct.timespec* %3, %struct.timespec* %1, %struct.timespec* %2)
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 8
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 1
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 80
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 100, i32* %19
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 1, i32* %20
%21 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
store i32 1, i32* %21
%22 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
store i32 20, i32* %22
%23 = call i32 @timespec_subtract(%struct.timespec* %3, %struct.timespec* %1, %struct.timespec* %2)
%24 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
%25 = load i32, i32* %24
%26 = icmp eq i32 %25, 98
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 1
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 999999981
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
define void @test_subtract_timespec() {
%1 = alloca %struct.timespec
%2 = alloca %struct.timespec
%3 = alloca %struct.timespec
%4 = bitcast %struct.timespec* %1 to i8*
%5 = bitcast %struct.timespec* %2 to i8*
%6 = bitcast %struct.timespec* %3 to i8*
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
store i32 10, i32* %7
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
store i32 100, i32* %8
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
store i32 2, i32* %9
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
store i32 20, i32* %10
%11 = call i32 @timespec_subtract(%struct.timespec* %3, %struct.timespec* %1, %struct.timespec* %2)
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 8
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
%18 = load i32, i32* %17
%19 = icmp eq i32 %18, 80
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
store i32 100, i32* %7
store i32 1, i32* %8
store i32 1, i32* %9
store i32 20, i32* %10
%22 = call i32 @timespec_subtract(%struct.timespec* %3, %struct.timespec* %1, %struct.timespec* %2)
%23 = load i32, i32* %12
%24 = icmp eq i32 %23, 98
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i32, i32* %17
%28 = icmp eq i32 %27, 999999981
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
ret void
}