#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*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ timespec_add_nsec(struct timespec *, int);
int /*<<< orphan*/ timespec_add_sec(struct timespec *, int);
int test_timespec_utils(void) {
  struct timespec ts;
  ts.tv_sec = 0;
  ts.tv_nsec = 0;
  timespec_add_sec(&ts, 1);
  do {
    if ((ts.tv_sec) != (1)) {
      fprintf(stderr, "failed on line %d: %s\n", 32, "ts.tv_sec");
      return 1;
    }
  } while (0);
  ;
  do {
    if ((ts.tv_nsec) != (0)) {
      fprintf(stderr, "failed on line %d: %s\n", 33, "ts.tv_nsec");
      return 1;
    }
  } while (0);
  ;
  timespec_add_nsec(&ts, 1000);
  do {
    if ((ts.tv_sec) != (1)) {
      fprintf(stderr, "failed on line %d: %s\n", 35, "ts.tv_sec");
      return 1;
    }
  } while (0);
  ;
  do {
    if ((ts.tv_nsec) != (1000)) {
      fprintf(stderr, "failed on line %d: %s\n", 36, "ts.tv_nsec");
      return 1;
    }
  } while (0);
  ;
  timespec_add_nsec(&ts, 999999000);
  do {
    if ((ts.tv_sec) != (2)) {
      fprintf(stderr, "failed on line %d: %s\n", 38, "ts.tv_sec");
      return 1;
    }
  } while (0);
  ;
  do {
    if ((ts.tv_nsec) != (0)) {
      fprintf(stderr, "failed on line %d: %s\n", 39, "ts.tv_nsec");
      return 1;
    }
  } while (0);
  ;
  return 0;
}


x86 assembly (clang, -O0):
<test_timespec_utils>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1050 <timespec_add_sec@plt>
cmpl   $0x1,-0x10(%rbp)
je     118b <test_timespec_utils+0x5b>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
lea    0xe92(%rip),%rsi
mov    $0x20,%edx
lea    0xe9d(%rip),%rcx
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f1 <test_timespec_utils+0x1c1>
jmp    1190 <test_timespec_utils+0x60>
jmp    1195 <test_timespec_utils+0x65>
cmpl   $0x0,-0xc(%rbp)
je     11cc <test_timespec_utils+0x9c>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    0xe51(%rip),%rsi
mov    $0x21,%edx
lea    0xe66(%rip),%rcx
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f1 <test_timespec_utils+0x1c1>
jmp    11d1 <test_timespec_utils+0xa1>
lea    -0x10(%rbp),%rdi
mov    $0x3e8,%esi
call   1030 <timespec_add_nsec@plt>
cmpl   $0x1,-0x10(%rbp)
je     1216 <test_timespec_utils+0xe6>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
lea    0xe07(%rip),%rsi
mov    $0x23,%edx
lea    0xe12(%rip),%rcx
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f1 <test_timespec_utils+0x1c1>
jmp    121b <test_timespec_utils+0xeb>
jmp    1220 <test_timespec_utils+0xf0>
cmpl   $0x3e8,-0xc(%rbp)
je     125a <test_timespec_utils+0x12a>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
lea    0xdc3(%rip),%rsi
mov    $0x24,%edx
lea    0xdd8(%rip),%rcx
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f1 <test_timespec_utils+0x1c1>
jmp    125f <test_timespec_utils+0x12f>
lea    -0x10(%rbp),%rdi
mov    $0x3b9ac618,%esi
call   1030 <timespec_add_nsec@plt>
cmpl   $0x2,-0x10(%rbp)
je     12a4 <test_timespec_utils+0x174>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    0xd79(%rip),%rsi
mov    $0x26,%edx
lea    0xd84(%rip),%rcx
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f1 <test_timespec_utils+0x1c1>
jmp    12a9 <test_timespec_utils+0x179>
jmp    12ae <test_timespec_utils+0x17e>
cmpl   $0x0,-0xc(%rbp)
je     12e5 <test_timespec_utils+0x1b5>
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
lea    0xd38(%rip),%rsi
mov    $0x27,%edx
lea    0xd4d(%rip),%rcx
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f1 <test_timespec_utils+0x1c1>
jmp    12ea <test_timespec_utils+0x1ba>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_timespec_utils>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x1,%ebx
mov    $0x1,%esi
call   1050 <timespec_add_sec@plt>
cmpl   $0x1,0x8(%rsp)
jne    117e <test_timespec_utils+0x4e>
cmpl   $0x0,0xc(%rsp)
je     11a7 <test_timespec_utils+0x77>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
lea    0xeaa(%rip),%rcx
mov    $0x21,%edx
jmp    119a <test_timespec_utils+0x6a>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
lea    0xe82(%rip),%rcx
mov    $0x20,%edx
call   1040 <fprintf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0x8(%rsp),%rdi
mov    $0x3e8,%esi
call   1030 <timespec_add_nsec@plt>
cmpl   $0x1,0x8(%rsp)
jne    1206 <test_timespec_utils+0xd6>
cmpl   $0x3e8,0xc(%rsp)
jne    1227 <test_timespec_utils+0xf7>
lea    0x8(%rsp),%rdi
mov    $0x3b9ac618,%esi
call   1030 <timespec_add_nsec@plt>
cmpl   $0x2,0x8(%rsp)
jne    1248 <test_timespec_utils+0x118>
cmpl   $0x0,0xc(%rsp)
je     1269 <test_timespec_utils+0x139>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
lea    0xe08(%rip),%rsi
lea    0xe22(%rip),%rcx
mov    $0x27,%edx
jmp    119a <test_timespec_utils+0x6a>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
lea    0xdea(%rip),%rsi
lea    0xdfa(%rip),%rcx
mov    $0x23,%edx
jmp    119a <test_timespec_utils+0x6a>
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
lea    0xdc9(%rip),%rsi
lea    0xde3(%rip),%rcx
mov    $0x24,%edx
jmp    119a <test_timespec_utils+0x6a>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
lea    0xda8(%rip),%rsi
lea    0xdb8(%rip),%rcx
mov    $0x26,%edx
jmp    119a <test_timespec_utils+0x6a>
xor    %ebx,%ebx
jmp    119f <test_timespec_utils+0x6f>

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
@stderr = global i32 0
@.str = [23 x i8] c"failed on line %d: %s\0A\00"
@.str.1 = [10 x i8] c"ts.tv_sec\00"
@.str.2 = [11 x i8] c"ts.tv_nsec\00"
define i32 @test_timespec_utils() {
%1 = alloca i32
%2 = alloca %struct.timespec
%3 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
store i32 0, i32* %3
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
store i32 0, i32* %4
%5 = call i32 @timespec_add_sec(%struct.timespec* %2, i32 1)
br label %6
6: ; preds = %0
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%8 = load i32, i32* %7
%9 = icmp ne i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %62
13: ; preds = %6
br label %14
14: ; preds = %13
br label %15
15: ; preds = %14
%16 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
%17 = load i32, i32* %16
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 33, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %62
22: ; preds = %15
br label %23
23: ; preds = %22
%24 = call i32 @timespec_add_nsec(%struct.timespec* %2, i32 1000)
br label %25
25: ; preds = %23
%26 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%27 = load i32, i32* %26
%28 = icmp ne i32 %27, 1
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 35, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %62
32: ; preds = %25
br label %33
33: ; preds = %32
br label %34
34: ; preds = %33
%35 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
%36 = load i32, i32* %35
%37 = icmp ne i32 %36, 1000
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 36, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %62
41: ; preds = %34
br label %42
42: ; preds = %41
%43 = call i32 @timespec_add_nsec(%struct.timespec* %2, i32 999999000)
br label %44
44: ; preds = %42
%45 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%46 = load i32, i32* %45
%47 = icmp ne i32 %46, 2
br i1 %47, label %48, label %51
48: ; preds = %44
%49 = load i32, i32* @stderr
%50 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 38, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %62
51: ; preds = %44
br label %52
52: ; preds = %51
br label %53
53: ; preds = %52
%54 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
%55 = load i32, i32* %54
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %53
%58 = load i32, i32* @stderr
%59 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 39, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %62
60: ; preds = %53
br label %61
61: ; preds = %60
store i32 0, i32* %1
br label %62
62: ; preds = %61, %57, %48, %38, %29, %19, %10
%63 = load i32, i32* %1
ret i32 %63
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
@stderr = global i32 0
@.str = [23 x i8] c"failed on line %d: %s\0A\00"
@.str.1 = [10 x i8] c"ts.tv_sec\00"
@.str.2 = [11 x i8] c"ts.tv_nsec\00"
define i32 @test_timespec_utils() {
%1 = alloca %struct.timespec
%2 = bitcast %struct.timespec* %1 to i8*
%3 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
store i32 0, i32* %3
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
store i32 0, i32* %4
%5 = call i32 @timespec_add_sec(%struct.timespec* %1, i32 1)
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 1
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %43
11: ; preds = %0
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 33, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %43
17: ; preds = %11
%18 = call i32 @timespec_add_nsec(%struct.timespec* %1, i32 1000)
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, 1
br i1 %20, label %24, label %21
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 35, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %43
24: ; preds = %17
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 1000
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 36, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %43
30: ; preds = %24
%31 = call i32 @timespec_add_nsec(%struct.timespec* %1, i32 999999000)
%32 = load i32, i32* %3
%33 = icmp eq i32 %32, 2
br i1 %33, label %37, label %34
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 38, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %43
37: ; preds = %30
%38 = load i32, i32* %4
%39 = icmp eq i32 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = load i32, i32* @stderr
%42 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 39, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %43
43: ; preds = %37, %40, %34, %27, %21, %14, %8
%44 = phi i32 [ 1, %8 ], [ 1, %14 ], [ 1, %21 ], [ 1, %27 ], [ 1, %34 ], [ 1, %40 ], [ 0, %37 ]
ret i32 %44
}