#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 */
typedef int /*<<< orphan*/ pthread_condattr_t;

/* Variables and functions */
int EINVAL;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *);
int pthread_condattr_init(int /*<<< orphan*/ *);
int pthread_condattr_setclock(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ stderr;
int main(void) {
  pthread_condattr_t condattr;
  int rc;
  if ((rc = pthread_condattr_init(&condattr)) != 0) {
    fprintf(stderr, "Error at pthread_condattr_init(), rc=%d\n", rc);
    printf("Test FAILED\n");
    return 1;
  }
  rc = pthread_condattr_setclock(&condattr, -100);
  if (rc != EINVAL) {
    printf("Test PASSED: *NOTE: Test passed while passing an invalid clockid, "
           "but the standard says 'may' fail\n");
    return 0;
  }
  printf("Test PASSED\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1060 <pthread_condattr_init@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
je     1194 <main+0x54>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xe89(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e2 <main+0xa2>
lea    -0x8(%rbp),%rdi
mov    $0xffffff9c,%esi
call   1040 <pthread_condattr_setclock@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e29(%rip),%rcx
cmp    (%rcx),%eax
je     11cf <main+0x8f>
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e2 <main+0xa2>
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdi
call   1060 <pthread_condattr_init@plt>
test   %eax,%eax
je     1178 <main+0x38>
mov    0x2e86(%rip),%rcx
mov    (%rcx),%edi
lea    0xe9d(%rip),%rsi
mov    %eax,%edx
call   1050 <fprintf@plt>
mov    $0x1,%ebx
lea    0xf22(%rip),%rdi
jmp    11a4 <main+0x64>
lea    0xc(%rsp),%rdi
mov    $0xffffff9c,%esi
call   1040 <pthread_condattr_setclock@plt>
mov    0x2e4a(%rip),%rcx
cmp    (%rcx),%eax
lea    0xe92(%rip),%rax
lea    0xe97(%rip),%rdi
cmove  %rax,%rdi
xor    %ebx,%ebx
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [41 x i8] c"Error at pthread_condattr_init(), rc=%d\0A\00"
@.str.1 = [13 x i8] c"Test FAILED\0A\00"
@EINVAL = global i32 0
@.str.2 = [100 x i8] c"Test PASSED: *NOTE: Test passed while passing an invalid clockid, but the standard says 'may' fail\0A\00"
@.str.3 = [13 x i8] c"Test PASSED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @pthread_condattr_init(i32* %2)
store i32 %4, i32* %3
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = load i32, i32* %3
%9 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %20
11: ; preds = %0
%12 = call i32 @pthread_condattr_setclock(i32* %2, i32 -100)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = load i32, i32* @EINVAL
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 @printf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %20
18: ; preds = %11
%19 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %20
20: ; preds = %18, %16, %6
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"Error at pthread_condattr_init(), rc=%d\0A\00"
@EINVAL = global i32 0
@str = [12 x i8] c"Test PASSED\00"
@str.4 = [99 x i8] c"Test PASSED: *NOTE: Test passed while passing an invalid clockid, but the standard says 'may' fail\00"
@str.5 = [12 x i8] c"Test FAILED\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @pthread_condattr_init(i32* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %3)
br label %13
8: ; preds = %0
%9 = call i32 @pthread_condattr_setclock(i32* %1, i32 -100)
%10 = load i32, i32* @EINVAL
%11 = icmp eq i32 %9, %10
%12 = select i1 %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([99 x i8], [99 x i8]* @str.4, i64 0, i64 0)
br label %13
13: ; preds = %8, %5
%14 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.5, i64 0, i64 0), %5 ], [ %12, %8 ]
%15 = phi i32 [ 1, %5 ], [ 0, %8 ]
%16 = call i32 @puts(i8* dereferenceable(1) %14)
ret i32 %15
}