#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_add(struct timespec *, struct timespec *,
                                struct timespec *);
void test_add_timespec(void) {
  struct timespec a;
  struct timespec b;
  struct timespec c;
  a.tv_sec = 1;
  a.tv_nsec = 10;
  ;
  b.tv_sec = 2;
  b.tv_nsec = 20;
  ;
  timespec_add(&c, &a, &b);
  assert(c.tv_sec == 3);
  assert(c.tv_nsec == 30);
  ;
  a.tv_sec = 1;
  a.tv_nsec = 999999999;
  ;
  b.tv_sec = 1;
  b.tv_nsec = 2;
  ;
  timespec_add(&c, &a, &b);
  assert(c.tv_sec == 3);
  assert(c.tv_nsec == 1);
  ;
  a.tv_sec = 1;
  a.tv_nsec = 999999999;
  ;
  b.tv_sec = 1;
  b.tv_nsec = 999999999;
  ;
  timespec_add(&c, &a, &b);
  assert(c.tv_sec == 3);
  assert(c.tv_nsec == 999999998);
  ;
}


x86 assembly (clang, -O0):
<test_add_timespec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0x8(%rbp)
movl   $0xa,-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_add@plt>
cmpl   $0x3,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x1e,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x1,-0x8(%rbp)
movl   $0x3b9ac9ff,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x2,-0xc(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <timespec_add@plt>
cmpl   $0x3,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x1,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x1,-0x8(%rbp)
movl   $0x3b9ac9ff,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x3b9ac9ff,-0xc(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <timespec_add@plt>
cmpl   $0x3,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x3b9ac9fe,-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_add_timespec>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movabs $0xa00000001,%rax
mov    %rax,0x10(%rsp)
movabs $0x1400000002,%rax
mov    %rax,0x8(%rsp)
mov    %rsp,%r12
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%r15
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <timespec_add@plt>
xor    %edi,%edi
cmpl   $0x3,(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x1e,0x4(%rsp)
sete   %dil
call   1040 <assert@plt>
movabs $0x3b9ac9ff00000001,%rbx
c9 9a 3b
mov    %rbx,0x10(%rsp)
movabs $0x200000001,%rax
mov    %rax,0x8(%rsp)
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <timespec_add@plt>
xor    %edi,%edi
cmpl   $0x3,(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x1,0x4(%rsp)
sete   %dil
call   1040 <assert@plt>
mov    %rbx,0x10(%rsp)
mov    %rbx,0x8(%rsp)
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <timespec_add@plt>
xor    %edi,%edi
cmpl   $0x3,(%rsp)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x3b9ac9fe,0x4(%rsp)
3b
sete   %dil
call   1040 <assert@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
define void @test_add_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 1, i32* %4
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 10, 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_add(%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, 3
%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, 30
%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 1, i32* %19
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 999999999, 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 2, i32* %22
%23 = call i32 @timespec_add(%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, 3
%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, 1
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
store i32 1, i32* %34
%35 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
store i32 999999999, i32* %35
%36 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
store i32 1, i32* %36
%37 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
store i32 999999999, i32* %37
%38 = call i32 @timespec_add(%struct.timespec* %3, %struct.timespec* %1, %struct.timespec* %2)
%39 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
%40 = load i32, i32* %39
%41 = icmp eq i32 %40, 3
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 1
%45 = load i32, i32* %44
%46 = icmp eq i32 %45, 999999998
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
define void @test_add_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 1, i32* %7
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
store i32 10, 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_add(%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, 3
%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, 30
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
store i32 1, i32* %7
store i32 999999999, i32* %8
store i32 1, i32* %9
store i32 2, i32* %10
%22 = call i32 @timespec_add(%struct.timespec* %3, %struct.timespec* %1, %struct.timespec* %2)
%23 = load i32, i32* %12
%24 = icmp eq i32 %23, 3
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i32, i32* %17
%28 = icmp eq i32 %27, 1
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
store i32 1, i32* %7
store i32 999999999, i32* %8
store i32 1, i32* %9
store i32 999999999, i32* %10
%31 = call i32 @timespec_add(%struct.timespec* %3, %struct.timespec* %1, %struct.timespec* %2)
%32 = load i32, i32* %12
%33 = icmp eq i32 %32, 3
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = load i32, i32* %17
%37 = icmp eq i32 %36, 999999998
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
ret void
}