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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *);
int pthread_condattr_getclock(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int pthread_condattr_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(void) {
  pthread_condattr_t condattr;
  clockid_t clockid;
  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_getclock(&condattr, &clockid);
  if (rc != 0) {
    printf("Test FAILED: Could not get the clock attribute\n");
    return 1;
  }
  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,-0x10(%rbp)
cmp    $0x0,%eax
je     1194 <main+0x54>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%edx
lea    0xe89(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xea6(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d9 <main+0x99>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1030 <pthread_condattr_getclock@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11c6 <main+0x86>
lea    0xe81(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d9 <main+0x99>
lea    0xe99(%rip),%rdi
call   1040 <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    0x8(%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    0xeee(%rip),%rdi
jmp    11a0 <main+0x60>
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1030 <pthread_condattr_getclock@plt>
xor    %ebx,%ebx
test   %eax,%eax
setne  %bl
lea    0xe94(%rip),%rax
lea    0xe99(%rip),%rdi
cmove  %rax,%rdi
call   1040 <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"
@.str.2 = [48 x i8] c"Test FAILED: Could not get the clock attribute\0A\00"
@.str.3 = [13 x i8] c"Test PASSED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @pthread_condattr_init(i32* %2)
store i32 %5, i32* %4
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = load i32, i32* %4
%10 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = 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
12: ; preds = %0
%13 = call i32 @pthread_condattr_getclock(i32* %2, i32* %3)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %20
18: ; preds = %12
%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, %7
%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"
@str = [12 x i8] c"Test PASSED\00"
@str.4 = [47 x i8] c"Test FAILED: Could not get the clock attribute\00"
@str.5 = [12 x i8] c"Test FAILED\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @pthread_condattr_init(i32* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %16
10: ; preds = %0
%11 = call i32 @pthread_condattr_getclock(i32* %1, i32* %2)
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([47 x i8], [47 x i8]* @str.4, i64 0, i64 0)
%14 = xor i1 %12, true
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %10, %7
%17 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.5, i64 0, i64 0), %7 ], [ %13, %10 ]
%18 = phi i32 [ 1, %7 ], [ %15, %10 ]
%19 = call i32 @puts(i8* dereferenceable(1) %17)
ret i32 %18
}