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

/* Variables and functions */
char *mutex_protocol_str(int);
char *mutex_pshared_str(int);
char *mutex_type_str(int);
int /*<<< orphan*/ printf(char *, ...);
int pthread_mutexattr_getprioceiling(char const *, int *);
int pthread_mutexattr_getprotocol(char const *, int *);
int pthread_mutexattr_getpshared(char const *, int *);
int pthread_mutexattr_gettype(char const *, int *);
void mutex_attr_show(const pthread_mutexattr_t *attr) {
  int rc;
  int val;
  printf("mutex attributes @ %10p:\n", attr);
  rc = pthread_mutexattr_gettype(attr, &val);
  if (rc != 0)
    printf("ERROR %d returned from pthread_mutexattr_gettype\n", rc);
  else
    printf("type=%s\n", mutex_type_str(val));
  rc = pthread_mutexattr_getprioceiling(attr, &val);
  if (rc != 0)
    printf("ERROR %d returned from pthread_mutexattr_getprioceiling\n", rc);
  else
    printf("prio_ceiling=%d\n", val);
  rc = pthread_mutexattr_getprotocol(attr, &val);
  if (rc != 0)
    printf("ERROR %d returned from pthread_mutexattr_getprotocol\n", rc);
  else
    printf("protocol=%s\n", mutex_protocol_str(val));
  rc = pthread_mutexattr_getpshared(attr, &val);
  if (rc != 0)
    printf("ERROR %d returned from pthread_mutexattr_getpshared\n", rc);
  else
    printf("pshared=%s\n", mutex_pshared_str(val));
}


x86 assembly (clang, -O0):
<mutex_attr_show>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <pthread_mutexattr_gettype@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11ce <mutex_attr_show+0x4e>
mov    -0xc(%rbp),%esi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    11e7 <mutex_attr_show+0x67>
mov    -0x10(%rbp),%edi
call   1040 <mutex_type_str@plt>
mov    %rax,%rsi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1090 <pthread_mutexattr_getprioceiling@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1217 <mutex_attr_show+0x97>
mov    -0xc(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1228 <mutex_attr_show+0xa8>
mov    -0x10(%rbp),%esi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   10a0 <pthread_mutexattr_getprotocol@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1258 <mutex_attr_show+0xd8>
mov    -0xc(%rbp),%esi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1271 <mutex_attr_show+0xf1>
mov    -0x10(%rbp),%edi
call   1060 <mutex_protocol_str@plt>
mov    %rax,%rsi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1080 <pthread_mutexattr_getpshared@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     12a1 <mutex_attr_show+0x121>
mov    -0xc(%rbp),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    12ba <mutex_attr_show+0x13a>
mov    -0x10(%rbp),%edi
call   1050 <mutex_pshared_str@plt>
mov    %rax,%rsi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mutex_attr_show>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xe71(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <pthread_mutexattr_gettype@plt>
test   %eax,%eax
je     11bc <mutex_attr_show+0x3c>
lea    0xe69(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    11d6 <mutex_attr_show+0x56>
mov    0xc(%rsp),%edi
call   1040 <mutex_type_str@plt>
lea    0xe80(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <pthread_mutexattr_getprioceiling@plt>
test   %eax,%eax
je     11f2 <mutex_attr_show+0x72>
lea    0xe67(%rip),%rdi
mov    %eax,%esi
jmp    11fd <mutex_attr_show+0x7d>
mov    0xc(%rsp),%esi
lea    0xe91(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   10a0 <pthread_mutexattr_getprotocol@plt>
test   %eax,%eax
je     1227 <mutex_attr_show+0xa7>
lea    0xe83(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1241 <mutex_attr_show+0xc1>
mov    0xc(%rsp),%edi
call   1060 <mutex_protocol_str@plt>
lea    0xe9e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <pthread_mutexattr_getpshared@plt>
test   %eax,%eax
je     1264 <mutex_attr_show+0xe4>
lea    0xe89(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    127e <mutex_attr_show+0xfe>
mov    0xc(%rsp),%edi
call   1050 <mutex_pshared_str@plt>
lea    0xea3(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"mutex attributes @ %10p:\0A\00"
@.str.1 = [50 x i8] c"ERROR %d returned from pthread_mutexattr_gettype\0A\00"
@.str.2 = [9 x i8] c"type=%s\0A\00"
@.str.3 = [57 x i8] c"ERROR %d returned from pthread_mutexattr_getprioceiling\0A\00"
@.str.4 = [17 x i8] c"prio_ceiling=%d\0A\00"
@.str.5 = [54 x i8] c"ERROR %d returned from pthread_mutexattr_getprotocol\0A\00"
@.str.6 = [13 x i8] c"protocol=%s\0A\00"
@.str.7 = [53 x i8] c"ERROR %d returned from pthread_mutexattr_getpshared\0A\00"
@.str.8 = [12 x i8] c"pshared=%s\0A\00"
define void @mutex_attr_show(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i8*, i8** %2
%8 = call i32 @pthread_mutexattr_gettype(i8* %7, i32* %4)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32, i32* %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %18
14: ; preds = %1
%15 = load i32, i32* %4
%16 = call i8* @mutex_type_str(i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %14, %11
%19 = load i8*, i8** %2
%20 = call i32 @pthread_mutexattr_getprioceiling(i8* %19, i32* %4)
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %29
26: ; preds = %18
%27 = load i32, i32* %4
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %26, %23
%30 = load i8*, i8** %2
%31 = call i32 @pthread_mutexattr_getprotocol(i8* %30, i32* %4)
store i32 %31, i32* %3
%32 = load i32, i32* %3
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %29
%35 = load i32, i32* %3
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i32 %35)
br label %41
37: ; preds = %29
%38 = load i32, i32* %4
%39 = call i8* @mutex_protocol_str(i32 %38)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %37, %34
%42 = load i8*, i8** %2
%43 = call i32 @pthread_mutexattr_getpshared(i8* %42, i32* %4)
store i32 %43, i32* %3
%44 = load i32, i32* %3
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %41
%47 = load i32, i32* %3
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0), i32 %47)
br label %53
49: ; preds = %41
%50 = load i32, i32* %4
%51 = call i8* @mutex_pshared_str(i32 %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %49, %46
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"mutex attributes @ %10p:\0A\00"
@.str.1 = [50 x i8] c"ERROR %d returned from pthread_mutexattr_gettype\0A\00"
@.str.2 = [9 x i8] c"type=%s\0A\00"
@.str.3 = [57 x i8] c"ERROR %d returned from pthread_mutexattr_getprioceiling\0A\00"
@.str.4 = [17 x i8] c"prio_ceiling=%d\0A\00"
@.str.5 = [54 x i8] c"ERROR %d returned from pthread_mutexattr_getprotocol\0A\00"
@.str.6 = [13 x i8] c"protocol=%s\0A\00"
@.str.7 = [53 x i8] c"ERROR %d returned from pthread_mutexattr_getpshared\0A\00"
@.str.8 = [12 x i8] c"pshared=%s\0A\00"
define void @mutex_attr_show(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = call i32 @pthread_mutexattr_gettype(i8* %0, i32* %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %5)
br label %13
9: ; preds = %1
%10 = load i32, i32* %2
%11 = call i8* @mutex_type_str(i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %9, %7
%14 = call i32 @pthread_mutexattr_getprioceiling(i8* %0, i32* %2)
%15 = icmp eq i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0), i32 %14)
br label %21
18: ; preds = %13
%19 = load i32, i32* %2
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %18, %16
%22 = call i32 @pthread_mutexattr_getprotocol(i8* %0, i32* %2)
%23 = icmp eq i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i32 %22)
br label %30
26: ; preds = %21
%27 = load i32, i32* %2
%28 = call i8* @mutex_protocol_str(i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %26, %24
%31 = call i32 @pthread_mutexattr_getpshared(i8* %0, i32* %2)
%32 = icmp eq i32 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %30
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0), i32 %31)
br label %39
35: ; preds = %30
%36 = load i32, i32* %2
%37 = call i8* @mutex_pshared_str(i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %35, %33
ret void
}