#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;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ pthread_mutexattr_gettype(int /*<<< orphan*/ *, int *);
scalar_t__ pthread_mutexattr_init(int /*<<< orphan*/ *);
int main() {
  int type = 0;
  pthread_mutexattr_t mutex_attr;
  if (pthread_mutexattr_init(&mutex_attr)) {
    printf("Failed to init mutex attr\n");
    return -1;
  }
  if (pthread_mutexattr_gettype(&mutex_attr, &type)) {
    printf("failed to get mutex attr type\n");
    return -1;
  }
  printf("type = 0x%x\n", type);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
call   1050 <pthread_mutexattr_init@plt>
cmp    $0x0,%rax
je     1173 <main+0x43>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b5 <main+0x85>
lea    -0xc(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1030 <pthread_mutexattr_gettype@plt>
cmp    $0x0,%rax
je     11a4 <main+0x74>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b5 <main+0x85>
mov    -0x8(%rbp),%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x8(%rsp)
lea    0xc(%rsp),%rdi
call   1060 <pthread_mutexattr_init@plt>
test   %rax,%rax
je     1165 <main+0x25>
lea    0xec8(%rip),%rdi
jmp    1180 <main+0x40>
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1030 <pthread_mutexattr_gettype@plt>
test   %rax,%rax
je     1192 <main+0x52>
lea    0xe8d(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x8(%rsp),%esi
lea    0xe63(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    118a <main+0x4a>

LLVM IR (-O0):
@.str = [27 x i8] c"Failed to init mutex attr\0A\00"
@.str.1 = [31 x i8] c"failed to get mutex attr type\0A\00"
@.str.2 = [13 x i8] c"type = 0x%x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%4 = call i64 @pthread_mutexattr_init(i32* %3)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %16
8: ; preds = %0
%9 = call i64 @pthread_mutexattr_gettype(i32* %3, i32* %2)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %16
13: ; preds = %8
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %13, %11, %6
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str.2 = [13 x i8] c"type = 0x%x\0A\00"
@str = [30 x i8] c"failed to get mutex attr type\00"
@str.3 = [26 x i8] c"Failed to init mutex attr\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
%5 = call i64 @pthread_mutexattr_init(i32* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.3, i64 0, i64 0))
br label %17
9: ; preds = %0
%10 = call i64 @pthread_mutexattr_gettype(i32* %2, i32* %1)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %17
14: ; preds = %9
%15 = load i32, i32* %1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %14, %12, %7
%18 = phi i32 [ -1, %7 ], [ -1, %12 ], [ 0, %14 ]
ret i32 %18
}