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

/* Variables and functions */
scalar_t__ pthread_mutex_init(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ pthread_mutexattr_init(int /*<<< orphan*/ *);
scalar_t__ test_setprotocol(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ test_setpshared(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ test_setrobust(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ test_settype(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int main(void) {
  pthread_mutex_t mutex;
  pthread_mutexattr_t attr;
  int result = 1;
  if (pthread_mutexattr_init(&attr) == 0 &&
      pthread_mutex_init(&mutex, NULL) == 0 &&
      test_settype(&mutex, &attr) == 0 && test_setrobust(&mutex, &attr) == 0 &&
      test_setpshared(&mutex, &attr) == 0 &&
      test_setprotocol(&mutex, &attr) == 0)
    result = 0;
  return result;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
lea    -0xc(%rbp),%rdi
call   1070 <pthread_mutexattr_init@plt>
cmp    $0x0,%rax
jne    1203 <main+0xa3>
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <pthread_mutex_init@plt>
cmp    $0x0,%rax
jne    1203 <main+0xa3>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <test_settype@plt>
cmp    $0x0,%rax
jne    1203 <main+0xa3>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <test_setrobust@plt>
cmp    $0x0,%rax
jne    1203 <main+0xa3>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1030 <test_setpshared@plt>
cmp    $0x0,%rax
jne    1203 <main+0xa3>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <test_setprotocol@plt>
cmp    $0x0,%rax
jne    1203 <main+0xa3>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
call   1070 <pthread_mutexattr_init@plt>
mov    $0x1,%ebx
test   %rax,%rax
jne    11dd <main+0x7d>
lea    0xc(%rsp),%rdi
xor    %esi,%esi
call   1080 <pthread_mutex_init@plt>
test   %rax,%rax
jne    11dd <main+0x7d>
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1060 <test_settype@plt>
test   %rax,%rax
jne    11dd <main+0x7d>
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1040 <test_setrobust@plt>
test   %rax,%rax
jne    11dd <main+0x7d>
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1030 <test_setpshared@plt>
test   %rax,%rax
jne    11dd <main+0x7d>
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1050 <test_setprotocol@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
%5 = call i64 @pthread_mutexattr_init(i32* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %23
7: ; preds = %0
%8 = call i64 @pthread_mutex_init(i32* %2, i32* null)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %7
%11 = call i64 @test_settype(i32* %2, i32* %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = call i64 @test_setrobust(i32* %2, i32* %3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = call i64 @test_setpshared(i32* %2, i32* %3)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = call i64 @test_setprotocol(i32* %2, i32* %3)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 0, i32* %4
br label %23
23: ; preds = %22, %19, %16, %13, %10, %7, %0
%24 = load i32, i32* %4
ret i32 %24
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i64 @pthread_mutexattr_init(i32* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %23
7: ; preds = %0
%8 = call i64 @pthread_mutex_init(i32* %1, i32* null)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %7
%11 = call i64 @test_settype(i32* %1, i32* %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = call i64 @test_setrobust(i32* %1, i32* %2)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = call i64 @test_setpshared(i32* %1, i32* %2)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = call i64 @test_setprotocol(i32* %1, i32* %2)
%21 = icmp ne i64 %20, 0
%22 = zext i1 %21 to i32
br label %23
23: ; preds = %19, %16, %13, %10, %7, %0
%24 = phi i32 [ 1, %16 ], [ 1, %13 ], [ 1, %10 ], [ 1, %7 ], [ 1, %0 ], [ %22, %19 ]
ret i32 %24
}