#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_nsec;
  scalar_t__ tv_sec;
};
typedef int /*<<< orphan*/ clocks;
typedef int clockid_t;

/* Variables and functions */
int CLOCK_MONOTONIC;
int CLOCK_REALTIME;
scalar_t__ EINVAL;
scalar_t__ EPERM;
scalar_t__ clock_getres(int, struct timespec *);
scalar_t__ clock_gettime(int, struct timespec *);
scalar_t__ clock_settime(int, struct timespec *);
scalar_t__ errno;
int /*<<< orphan*/ printf(char *, ...);
int main() {
  clockid_t clocks[] = {CLOCK_REALTIME, CLOCK_MONOTONIC};
  for (int i = 0; i < (int)(sizeof(clocks) / sizeof(*clocks)); ++i) {
    printf("%sTests for clockid_t=%d\n-----------------\n", i == 0 ? "" : "\n",
           clocks[i]);
    struct timespec ts;
    int rv = clock_getres(clocks[i], &ts);
    if (rv)
      printf("clock_getres failed\n");
    else if (ts.tv_sec || ts.tv_nsec > 50000000)
      printf("clock_getres resolution not enough (%ld.%09ld)\n",
             (long)ts.tv_sec, ts.tv_nsec);
    else
      printf("clock_getres resolution OK\n");
    rv = clock_gettime(clocks[i], &ts);
    printf(rv ? "clock_gettime failed\n" : "clock_gettime OK\n");
    errno = 0;
    if (clock_settime(clocks[i], &ts) == 0)
      printf("clock_settime should have failed\n");
    else if (errno == EPERM && clocks[i] == CLOCK_REALTIME)
      printf("clock_settime failed with EPERM (OK)\n");
    else if (errno == EINVAL && clocks[i] == CLOCK_MONOTONIC)
      printf("clock_settime failed with EINVAL (OK)\n");
    else
      printf("clock_settime failed with wrong error code\n");
  }
  clockid_t bogus = 42;
  struct timespec ts;
  printf("\nTests for clockid_t=%d\n-----------------\n", bogus);
  if (clock_gettime(bogus, &ts) == 0 || errno != EINVAL)
    printf("clock_gettime should have failed\n");
  else
    printf("clock_gettime failed with EINVAL (OK)\n");
  if (clock_getres(bogus, &ts) == 0 || errno != EINVAL)
    printf("clock_getres should have failed\n");
  else
    printf("clock_getres failed with EINVAL (OK)\n");
  if (clock_settime(bogus, &ts) == 0 || errno != EINVAL)
    printf("clock_settime should have failed\n");
  else
    printf("clock_settime failed with EINVAL (OK)\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x2,-0x10(%rbp)
jge    133e <main+0x1fe>
mov    -0x10(%rbp),%ecx
lea    0x1040(%rip),%rsi
lea    0x103a(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rsi
movslq -0x10(%rbp),%rax
mov    -0xc(%rbp,%rax,4),%edx
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x10(%rbp),%rax
mov    -0xc(%rbp,%rax,4),%edi
lea    -0x20(%rbp),%rsi
call   1050 <clock_getres@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11d7 <main+0x97>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121c <main+0xdc>
cmpq   $0x0,-0x18(%rbp)
jne    11ef <main+0xaf>
cmpl   $0x2faf080,-0x20(%rbp)
jle    1209 <main+0xc9>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1217 <main+0xd7>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121c <main+0xdc>
movslq -0x10(%rbp),%rax
mov    -0xc(%rbp,%rax,4),%edi
lea    -0x20(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
lea    0xe69(%rip),%rdi
lea    0xe4c(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d82(%rip),%rax
movq   $0x0,(%rax)
movslq -0x10(%rbp),%rax
mov    -0xc(%rbp,%rax,4),%edi
lea    -0x20(%rbp),%rsi
call   1060 <clock_settime@plt>
cmp    $0x0,%rax
jne    128b <main+0x14b>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    132b <main+0x1eb>
mov    0x2d46(%rip),%rax
mov    (%rax),%rax
mov    0x2d1c(%rip),%rcx
cmp    (%rcx),%rax
jne    12cf <main+0x18f>
movslq -0x10(%rbp),%rax
mov    -0xc(%rbp,%rax,4),%eax
mov    0x2d14(%rip),%rcx
cmp    (%rcx),%eax
jne    12cf <main+0x18f>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1326 <main+0x1e6>
mov    0x2d02(%rip),%rax
mov    (%rax),%rax
mov    0x2cf0(%rip),%rcx
cmp    (%rcx),%rax
jne    1313 <main+0x1d3>
movslq -0x10(%rbp),%rax
mov    -0xc(%rbp,%rax,4),%eax
mov    0x2cf0(%rip),%rcx
cmp    (%rcx),%eax
jne    1313 <main+0x1d3>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1321 <main+0x1e1>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1326 <main+0x1e6>
jmp    132b <main+0x1eb>
jmp    1330 <main+0x1f0>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116e <main+0x2e>
movl   $0x2a,-0x28(%rbp)
mov    -0x28(%rbp),%esi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%edi
lea    -0x38(%rbp),%rsi
call   1030 <clock_gettime@plt>
cmp    $0x0,%rax
je     1386 <main+0x246>
mov    0x2c65(%rip),%rax
mov    (%rax),%rax
mov    0x2c53(%rip),%rcx
cmp    (%rcx),%rax
je     1399 <main+0x259>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13a7 <main+0x267>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%edi
lea    -0x38(%rbp),%rsi
call   1050 <clock_getres@plt>
cmp    $0x0,%rax
je     13d7 <main+0x297>
mov    0x2c14(%rip),%rax
mov    (%rax),%rax
mov    0x2c02(%rip),%rcx
cmp    (%rcx),%rax
je     13ea <main+0x2aa>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13f8 <main+0x2b8>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%edi
lea    -0x38(%rbp),%rsi
call   1060 <clock_settime@plt>
cmp    $0x0,%rax
je     1428 <main+0x2e8>
mov    0x2bc3(%rip),%rax
mov    (%rax),%rax
mov    0x2bb1(%rip),%rcx
cmp    (%rcx),%rax
je     143b <main+0x2fb>
lea    0xc86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1449 <main+0x309>
lea    0xcbb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e63(%rip),%rax
mov    (%rax),%ebp
mov    0x2e7a(%rip),%rax
mov    (%rax),%r14d
lea    0xe88(%rip),%rdi
lea    0xedc(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %ebp,%edi
call   1060 <clock_getres@plt>
test   %eax,%eax
je     11a1 <main+0x51>
lea    0x104e(%rip),%rdi
jmp    11be <main+0x6e>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%edx
test   %rsi,%rsi
jne    11c5 <main+0x75>
cmp    $0x2faf081,%edx
jge    11c5 <main+0x75>
lea    0xf7d(%rip),%rdi
call   1030 <puts@plt>
jmp    11d3 <main+0x83>
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x8(%rsp),%r15
mov    %ebp,%edi
mov    %r15,%rsi
call   1040 <clock_gettime@plt>
test   %eax,%eax
lea    0xe87(%rip),%r13
lea    0xe6a(%rip),%rbx
mov    %rbx,%rdi
cmove  %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2dd1(%rip),%r12
movq   $0x0,(%r12)
mov    %ebp,%edi
mov    %r15,%rsi
call   1070 <clock_settime@plt>
test   %rax,%rax
je     1242 <main+0xf2>
mov    (%r12),%rax
mov    0x2d8f(%rip),%rcx
cmp    (%rcx),%rax
jne    124b <main+0xfb>
mov    0x2d93(%rip),%rcx
cmp    (%rcx),%ebp
jne    124b <main+0xfb>
lea    0xf67(%rip),%rdi
jmp    1274 <main+0x124>
lea    0xf83(%rip),%rdi
jmp    1274 <main+0x124>
mov    0x2d7e(%rip),%rcx
mov    0x2d8f(%rip),%rdx
cmp    (%rdx),%ebp
lea    0xf1f(%rip),%rdi
lea    0xeed(%rip),%rdx
cmovne %rdx,%rdi
cmp    (%rcx),%rax
cmovne %rdx,%rdi
call   1030 <puts@plt>
lea    0xd80(%rip),%rdi
lea    0xdd3(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %r14d,%edi
call   1060 <clock_getres@plt>
test   %eax,%eax
je     12b0 <main+0x160>
lea    0xf44(%rip),%rdi
call   1030 <puts@plt>
jmp    12e2 <main+0x192>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%edx
test   %rsi,%rsi
jne    12d4 <main+0x184>
cmp    $0x2faf080,%edx
jg     12d4 <main+0x184>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
jmp    12e2 <main+0x192>
lea    0xd51(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x8(%rsp),%rbp
mov    %r14d,%edi
mov    %rbp,%rsi
call   1040 <clock_gettime@plt>
test   %eax,%eax
cmove  %r13,%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movq   $0x0,(%r12)
mov    %r14d,%edi
mov    %rbp,%rsi
call   1070 <clock_settime@plt>
lea    0xeb0(%rip),%r15
mov    %r15,%rdi
test   %rax,%rax
je     1373 <main+0x223>
mov    (%r12),%rax
mov    0x2c89(%rip),%rcx
cmp    (%rcx),%rax
jne    1349 <main+0x1f9>
mov    0x2c8d(%rip),%rcx
cmp    (%rcx),%r14d
jne    1349 <main+0x1f9>
lea    0xe60(%rip),%rdi
jmp    1373 <main+0x223>
mov    0x2c80(%rip),%rcx
mov    0x2c91(%rip),%rdx
cmp    (%rdx),%r14d
lea    0xe20(%rip),%rdi
lea    0xdee(%rip),%rdx
cmovne %rdx,%rdi
cmp    (%rcx),%rax
cmovne %rdx,%rdi
call   1030 <puts@plt>
lea    0xd05(%rip),%rdi
mov    $0x2a,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x8(%rsp),%rbx
mov    $0x2a,%edi
mov    %rbx,%rsi
call   1040 <clock_gettime@plt>
mov    (%r12),%rcx
mov    0x2c28(%rip),%rbp
cmp    0x0(%rbp),%rcx
lea    0xcfc(%rip),%rdi
lea    0xd60(%rip),%rcx
cmovne %rcx,%rdi
test   %rax,%rax
cmove  %rcx,%rdi
call   1030 <puts@plt>
mov    $0x2a,%edi
mov    %rbx,%rsi
call   1060 <clock_getres@plt>
mov    (%r12),%rcx
cmp    0x0(%rbp),%rcx
lea    0xcef(%rip),%rdi
lea    0xd0d(%rip),%rcx
cmovne %rcx,%rdi
test   %rax,%rax
cmove  %rcx,%rdi
call   1030 <puts@plt>
mov    $0x2a,%edi
mov    %rbx,%rsi
call   1070 <clock_settime@plt>
mov    (%r12),%rcx
cmp    0x0(%rbp),%rcx
lea    0xd68(%rip),%rdi
cmovne %r15,%rdi
test   %rax,%rax
cmove  %r15,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i64 }
@CLOCK_REALTIME = global i32 0
@CLOCK_MONOTONIC = global i32 0
@.str = [44 x i8] c"%sTests for clockid_t=%d\0A-----------------\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [21 x i8] c"clock_getres failed\0A\00"
@.str.4 = [48 x i8] c"clock_getres resolution not enough (%ld.%09ld)\0A\00"
@.str.5 = [28 x i8] c"clock_getres resolution OK\0A\00"
@.str.6 = [22 x i8] c"clock_gettime failed\0A\00"
@.str.7 = [18 x i8] c"clock_gettime OK\0A\00"
@errno = global i64 0
@.str.8 = [34 x i8] c"clock_settime should have failed\0A\00"
@EPERM = global i64 0
@.str.9 = [38 x i8] c"clock_settime failed with EPERM (OK)\0A\00"
@EINVAL = global i64 0
@.str.10 = [39 x i8] c"clock_settime failed with EINVAL (OK)\0A\00"
@.str.11 = [44 x i8] c"clock_settime failed with wrong error code\0A\00"
@.str.12 = [43 x i8] c"\0ATests for clockid_t=%d\0A-----------------\0A\00"
@.str.13 = [34 x i8] c"clock_gettime should have failed\0A\00"
@.str.14 = [39 x i8] c"clock_gettime failed with EINVAL (OK)\0A\00"
@.str.15 = [33 x i8] c"clock_getres should have failed\0A\00"
@.str.16 = [38 x i8] c"clock_getres failed with EINVAL (OK)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca i32
%4 = alloca %struct.timespec
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.timespec
store i32 0, i32* %1
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%9 = load i32, i32* @CLOCK_REALTIME
store i32 %9, i32* %8
%10 = getelementptr inbounds i32, i32* %8, i64 1
%11 = load i32, i32* @CLOCK_MONOTONIC
store i32 %11, i32* %10
store i32 0, i32* %3
br label %12
12: ; preds = %103, %0
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %106
15: ; preds = %12
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i64
%19 = select i1 %17, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %19, i32 %23)
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = call i64 @clock_getres(i32 %28, %struct.timespec* %4)
%30 = trunc i64 %29 to i32
store i32 %30, i32* %5
%31 = load i32, i32* %5
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %15
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %52
35: ; preds = %15
%36 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 1
%37 = load i64, i64* %36
%38 = icmp ne i64 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %35
%40 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%41 = load i32, i32* %40
%42 = icmp sgt i32 %41, 50000000
br i1 %42, label %43, label %49
43: ; preds = %39, %35
%44 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 1
%45 = load i64, i64* %44
%46 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i64 %45, i32 %47)
br label %51
49: ; preds = %39
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %51
51: ; preds = %49, %43
br label %52
52: ; preds = %51, %33
%53 = load i32, i32* %3
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = call i64 @clock_gettime(i32 %56, %struct.timespec* %4)
%58 = trunc i64 %57 to i32
store i32 %58, i32* %5
%59 = load i32, i32* %5
%60 = icmp ne i32 %59, 0
%61 = zext i1 %60 to i64
%62 = select i1 %60, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0)
%63 = call i32 (i8*, ...) @printf(i8* %62)
store i64 0, i64* @errno
%64 = load i32, i32* %3
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 %65
%67 = load i32, i32* %66
%68 = call i64 @clock_settime(i32 %67, %struct.timespec* %4)
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %52
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0))
br label %102
72: ; preds = %52
%73 = load i64, i64* @errno
%74 = load i64, i64* @EPERM
%75 = icmp eq i64 %73, %74
br i1 %75, label %76, label %85
76: ; preds = %72
%77 = load i32, i32* %3
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 %78
%80 = load i32, i32* %79
%81 = load i32, i32* @CLOCK_REALTIME
%82 = icmp eq i32 %80, %81
br i1 %82, label %83, label %85
83: ; preds = %76
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0))
br label %101
85: ; preds = %76, %72
%86 = load i64, i64* @errno
%87 = load i64, i64* @EINVAL
%88 = icmp eq i64 %86, %87
br i1 %88, label %89, label %98
89: ; preds = %85
%90 = load i32, i32* %3
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 %91
%93 = load i32, i32* %92
%94 = load i32, i32* @CLOCK_MONOTONIC
%95 = icmp eq i32 %93, %94
br i1 %95, label %96, label %98
96: ; preds = %89
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0))
br label %100
98: ; preds = %89, %85
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.11, i64 0, i64 0))
br label %100
100: ; preds = %98, %96
br label %101
101: ; preds = %100, %83
br label %102
102: ; preds = %101, %70
br label %103
103: ; preds = %102
%104 = load i32, i32* %3
%105 = add nsw i32 %104, 1
store i32 %105, i32* %3
br label %12
106: ; preds = %12
store i32 42, i32* %6
%107 = load i32, i32* %6
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0), i32 %107)
%109 = load i32, i32* %6
%110 = call i64 @clock_gettime(i32 %109, %struct.timespec* %7)
%111 = icmp eq i64 %110, 0
br i1 %111, label %116, label %112
112: ; preds = %106
%113 = load i64, i64* @errno
%114 = load i64, i64* @EINVAL
%115 = icmp ne i64 %113, %114
br i1 %115, label %116, label %118
116: ; preds = %112, %106
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0))
br label %120
118: ; preds = %112
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.14, i64 0, i64 0))
br label %120
120: ; preds = %118, %116
%121 = load i32, i32* %6
%122 = call i64 @clock_getres(i32 %121, %struct.timespec* %7)
%123 = icmp eq i64 %122, 0
br i1 %123, label %128, label %124
124: ; preds = %120
%125 = load i64, i64* @errno
%126 = load i64, i64* @EINVAL
%127 = icmp ne i64 %125, %126
br i1 %127, label %128, label %130
128: ; preds = %124, %120
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.15, i64 0, i64 0))
br label %132
130: ; preds = %124
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.16, i64 0, i64 0))
br label %132
132: ; preds = %130, %128
%133 = load i32, i32* %6
%134 = call i64 @clock_settime(i32 %133, %struct.timespec* %7)
%135 = icmp eq i64 %134, 0
br i1 %135, label %140, label %136
136: ; preds = %132
%137 = load i64, i64* @errno
%138 = load i64, i64* @EINVAL
%139 = icmp ne i64 %137, %138
br i1 %139, label %140, label %142
140: ; preds = %136, %132
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0))
br label %144
142: ; preds = %136
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0))
br label %144
144: ; preds = %142, %140
ret i32 0
}

LLVM IR (-O2):
%struct.timespec = type { i32, i64 }
@CLOCK_REALTIME = global i32 0
@CLOCK_MONOTONIC = global i32 0
@.str = [44 x i8] c"%sTests for clockid_t=%d\0A-----------------\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"\0A\00"
@.str.4 = [48 x i8] c"clock_getres resolution not enough (%ld.%09ld)\0A\00"
@.str.6 = [22 x i8] c"clock_gettime failed\0A\00"
@.str.7 = [18 x i8] c"clock_gettime OK\0A\00"
@errno = global i64 0
@EPERM = global i64 0
@EINVAL = global i64 0
@.str.12 = [43 x i8] c"\0ATests for clockid_t=%d\0A-----------------\0A\00"
@str = [38 x i8] c"clock_gettime failed with EINVAL (OK)\00"
@str.17 = [37 x i8] c"clock_getres failed with EINVAL (OK)\00"
@str.20 = [32 x i8] c"clock_getres should have failed\00"
@str.21 = [33 x i8] c"clock_gettime should have failed\00"
@str.22 = [27 x i8] c"clock_getres resolution OK\00"
@str.23 = [43 x i8] c"clock_settime failed with wrong error code\00"
@str.24 = [38 x i8] c"clock_settime failed with EINVAL (OK)\00"
@str.25 = [37 x i8] c"clock_settime failed with EPERM (OK)\00"
@str.26 = [33 x i8] c"clock_settime should have failed\00"
@str.27 = [20 x i8] c"clock_getres failed\00"
define i32 @main() {
%1 = alloca %struct.timespec
%2 = alloca %struct.timespec
%3 = load i32, i32* @CLOCK_REALTIME
%4 = load i32, i32* @CLOCK_MONOTONIC
%5 = bitcast %struct.timespec* %1 to i8*
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%9 = call i64 @clock_getres(i32 %3, %struct.timespec* %1)
%10 = trunc i64 %9 to i32
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.27, i64 0, i64 0))
br label %24
14: ; preds = %0
%15 = load i64, i64* %6
%16 = icmp ne i64 %15, 0
%17 = load i32, i32* %7
%18 = icmp sgt i32 %17, 50000000
%19 = select i1 %16, i1 true, i1 %18
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i64 %15, i32 %17)
br label %24
22: ; preds = %14
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.22, i64 0, i64 0))
br label %24
24: ; preds = %20, %22, %12
%25 = call i64 @clock_gettime(i32 %3, %struct.timespec* %1)
%26 = trunc i64 %25 to i32
%27 = icmp eq i32 %26, 0
%28 = select i1 %27, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %28)
store i64 0, i64* @errno
%30 = call i64 @clock_settime(i32 %3, %struct.timespec* %1)
%31 = icmp eq i64 %30, 0
br i1 %31, label %46, label %32
32: ; preds = %24
%33 = load i64, i64* @errno
%34 = load i64, i64* @EPERM
%35 = icmp eq i64 %33, %34
%36 = load i32, i32* @CLOCK_REALTIME
%37 = icmp eq i32 %3, %36
%38 = select i1 %35, i1 %37, i1 false
br i1 %38, label %46, label %39
39: ; preds = %32
%40 = load i64, i64* @EINVAL
%41 = icmp eq i64 %33, %40
%42 = load i32, i32* @CLOCK_MONOTONIC
%43 = icmp eq i32 %3, %42
%44 = select i1 %41, i1 %43, i1 false
%45 = select i1 %44, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @str.24, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @str.23, i64 0, i64 0)
br label %46
46: ; preds = %39, %32, %24
%47 = phi i8* [ getelementptr inbounds ([33 x i8], [33 x i8]* @str.26, i64 0, i64 0), %24 ], [ getelementptr inbounds ([37 x i8], [37 x i8]* @str.25, i64 0, i64 0), %32 ], [ %45, %39 ]
%48 = call i32 @puts(i8* dereferenceable(1) %47)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %4)
%50 = call i64 @clock_getres(i32 %4, %struct.timespec* %1)
%51 = trunc i64 %50 to i32
%52 = icmp eq i32 %51, 0
br i1 %52, label %55, label %53
53: ; preds = %46
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.27, i64 0, i64 0))
br label %65
55: ; preds = %46
%56 = load i64, i64* %6
%57 = icmp ne i64 %56, 0
%58 = load i32, i32* %7
%59 = icmp sgt i32 %58, 50000000
%60 = select i1 %57, i1 true, i1 %59
br i1 %60, label %63, label %61
61: ; preds = %55
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.22, i64 0, i64 0))
br label %65
63: ; preds = %55
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i64 %56, i32 %58)
br label %65
65: ; preds = %63, %61, %53
%66 = call i64 @clock_gettime(i32 %4, %struct.timespec* %1)
%67 = trunc i64 %66 to i32
%68 = icmp eq i32 %67, 0
%69 = select i1 %68, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0)
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %69)
store i64 0, i64* @errno
%71 = call i64 @clock_settime(i32 %4, %struct.timespec* %1)
%72 = icmp eq i64 %71, 0
br i1 %72, label %87, label %73
73: ; preds = %65
%74 = load i64, i64* @errno
%75 = load i64, i64* @EPERM
%76 = icmp eq i64 %74, %75
%77 = load i32, i32* @CLOCK_REALTIME
%78 = icmp eq i32 %4, %77
%79 = select i1 %76, i1 %78, i1 false
br i1 %79, label %87, label %80
80: ; preds = %73
%81 = load i64, i64* @EINVAL
%82 = icmp eq i64 %74, %81
%83 = load i32, i32* @CLOCK_MONOTONIC
%84 = icmp eq i32 %4, %83
%85 = select i1 %82, i1 %84, i1 false
%86 = select i1 %85, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @str.24, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @str.23, i64 0, i64 0)
br label %87
87: ; preds = %65, %73, %80
%88 = phi i8* [ %86, %80 ], [ getelementptr inbounds ([37 x i8], [37 x i8]* @str.25, i64 0, i64 0), %73 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @str.26, i64 0, i64 0), %65 ]
%89 = call i32 @puts(i8* dereferenceable(1) %88)
%90 = bitcast %struct.timespec* %2 to i8*
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0), i32 42)
%92 = call i64 @clock_gettime(i32 42, %struct.timespec* %2)
%93 = icmp eq i64 %92, 0
%94 = load i64, i64* @errno
%95 = load i64, i64* @EINVAL
%96 = icmp eq i64 %94, %95
%97 = select i1 %96, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str.21, i64 0, i64 0)
%98 = select i1 %93, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str.21, i64 0, i64 0), i8* %97
%99 = call i32 @puts(i8* dereferenceable(1) %98)
%100 = call i64 @clock_getres(i32 42, %struct.timespec* %2)
%101 = icmp eq i64 %100, 0
%102 = load i64, i64* @errno
%103 = load i64, i64* @EINVAL
%104 = icmp eq i64 %102, %103
%105 = select i1 %104, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @str.17, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @str.20, i64 0, i64 0)
%106 = select i1 %101, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @str.20, i64 0, i64 0), i8* %105
%107 = call i32 @puts(i8* dereferenceable(1) %106)
%108 = call i64 @clock_settime(i32 42, %struct.timespec* %2)
%109 = icmp eq i64 %108, 0
%110 = load i64, i64* @errno
%111 = load i64, i64* @EINVAL
%112 = icmp eq i64 %110, %111
%113 = select i1 %112, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @str.24, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str.26, i64 0, i64 0)
%114 = select i1 %109, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str.26, i64 0, i64 0), i8* %113
%115 = call i32 @puts(i8* dereferenceable(1) %114)
ret i32 0
}