#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*/ pthread_cond_t;

/* Variables and functions */
int /*<<< orphan*/ PTHREAD_PROCESS_SHARED;
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ pthread_cond_init(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_condattr_destroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_condattr_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_condattr_setpshared(int /*<<< orphan*/ *,
                                               int /*<<< orphan*/);
int main(void) {
  int ret;
  pthread_condattr_t attr;
  pthread_cond_t condition;
  pthread_condattr_init(&attr);
  pthread_condattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
  printf("%s\n", pthread_cond_init(&condition, &attr) ? "fail" : "ok");
  pthread_condattr_destroy(&attr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
call   1070 <pthread_condattr_init@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1050 <pthread_condattr_setpshared@plt>
lea    -0x10(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <pthread_cond_init@plt>
mov    %rax,%rcx
lea    0xe78(%rip),%rsi
lea    0xe6c(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
lea    -0xc(%rbp),%rdi
call   1040 <pthread_condattr_destroy@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <pthread_condattr_init@plt>
mov    0x2e77(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <pthread_condattr_setpshared@plt>
lea    0x8(%rsp),%rdi
mov    %rbx,%rsi
call   1060 <pthread_cond_init@plt>
test   %rax,%rax
lea    0xe7f(%rip),%rax
lea    0xe73(%rip),%rsi
cmove  %rax,%rsi
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <pthread_condattr_destroy@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@PTHREAD_PROCESS_SHARED = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [5 x i8] c"fail\00"
@.str.2 = [3 x i8] c"ok\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* %3)
%6 = load i32, i32* @PTHREAD_PROCESS_SHARED
%7 = call i32 @pthread_condattr_setpshared(i32* %3, i32 %6)
%8 = call i64 @pthread_cond_init(i32* %4, i32* %3)
%9 = icmp ne i64 %8, 0
%10 = zext i1 %9 to i64
%11 = select i1 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = call i32 @pthread_condattr_destroy(i32* %3)
ret i32 0
}

LLVM IR (-O2):
@PTHREAD_PROCESS_SHARED = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [5 x i8] c"fail\00"
@.str.2 = [3 x i8] c"ok\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 = load i32, i32* @PTHREAD_PROCESS_SHARED
%7 = call i32 @pthread_condattr_setpshared(i32* %1, i32 %6)
%8 = call i64 @pthread_cond_init(i32* %2, i32* %1)
%9 = icmp eq i64 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = call i32 @pthread_condattr_destroy(i32* %1)
ret i32 0
}