#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 PTHREAD_MUTEX_ERRORCHECK;
int PTHREAD_MUTEX_NORMAL;
int PTHREAD_MUTEX_RECURSIVE;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ pthread_mutexattr_gettype(int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ pthread_mutexattr_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ puts(char *);
int main(int argc, char *argv[]) {
  pthread_mutexattr_t mutexattr;
  int type;
  pthread_mutexattr_init(&mutexattr);
  pthread_mutexattr_gettype(&mutexattr, &type);
  if (type == PTHREAD_MUTEX_NORMAL)
    printf("PTHREAD_MUTEX_NORMAL");
  else if (type == PTHREAD_MUTEX_ERRORCHECK)
    printf("PTHREAD_MUTEX_ERRORCHECK");
  else if (type == PTHREAD_MUTEX_RECURSIVE)
    printf("PTHREAD_MUTEX_RECURSIVE");
  else
    printf("PTHREAD_MUTEX_DEFAULT");
  puts("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1060 <pthread_mutexattr_init@plt>
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <pthread_mutexattr_gettype@plt>
mov    -0x18(%rbp),%eax
mov    0x2e6a(%rip),%rcx
cmp    (%rcx),%eax
jne    118f <main+0x4f>
lea    0xe7b(%rip),%rdi
call   1050 <printf@plt>
jmp    11eb <main+0xab>
mov    -0x18(%rbp),%eax
mov    0x2e2f(%rip),%rcx
cmp    (%rcx),%eax
jne    11b2 <main+0x72>
lea    0xe6d(%rip),%rdi
call   1050 <printf@plt>
jmp    11e6 <main+0xa6>
mov    -0x18(%rbp),%eax
mov    0x2e3c(%rip),%rcx
cmp    (%rcx),%eax
jne    11d5 <main+0x95>
lea    0xe63(%rip),%rdi
call   1050 <printf@plt>
jmp    11e1 <main+0xa1>
lea    0xe6a(%rip),%rdi
call   1050 <printf@plt>
jmp    11e6 <main+0xa6>
jmp    11eb <main+0xab>
lea    0xe6a(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <pthread_mutexattr_init@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <pthread_mutexattr_gettype@plt>
mov    0x8(%rsp),%eax
mov    0x2e76(%rip),%rcx
cmp    (%rcx),%eax
jne    1177 <main+0x37>
lea    0xe8b(%rip),%rdi
jmp    11a6 <main+0x66>
mov    0x2e4a(%rip),%rcx
cmp    (%rcx),%eax
jne    118b <main+0x4b>
lea    0xe8c(%rip),%rdi
jmp    11a6 <main+0x66>
mov    0x2e66(%rip),%rcx
cmp    (%rcx),%eax
lea    0xe93(%rip),%rax
lea    0xea4(%rip),%rdi
cmove  %rax,%rdi
call   1050 <printf@plt>
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@PTHREAD_MUTEX_NORMAL = global i32 0
@.str = [21 x i8] c"PTHREAD_MUTEX_NORMAL\00"
@PTHREAD_MUTEX_ERRORCHECK = global i32 0
@.str.1 = [25 x i8] c"PTHREAD_MUTEX_ERRORCHECK\00"
@PTHREAD_MUTEX_RECURSIVE = global i32 0
@.str.2 = [24 x i8] c"PTHREAD_MUTEX_RECURSIVE\00"
@.str.3 = [22 x i8] c"PTHREAD_MUTEX_DEFAULT\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @pthread_mutexattr_init(i32* %6)
%9 = call i32 @pthread_mutexattr_gettype(i32* %6, i32* %7)
%10 = load i32, i32* %7
%11 = load i32, i32* @PTHREAD_MUTEX_NORMAL
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %31
15: ; preds = %2
%16 = load i32, i32* %7
%17 = load i32, i32* @PTHREAD_MUTEX_ERRORCHECK
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %30
21: ; preds = %15
%22 = load i32, i32* %7
%23 = load i32, i32* @PTHREAD_MUTEX_RECURSIVE
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %29
27: ; preds = %21
%28 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
br label %30
30: ; preds = %29, %19
br label %31
31: ; preds = %30, %13
%32 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@PTHREAD_MUTEX_NORMAL = global i32 0
@.str = [21 x i8] c"PTHREAD_MUTEX_NORMAL\00"
@PTHREAD_MUTEX_ERRORCHECK = global i32 0
@.str.1 = [25 x i8] c"PTHREAD_MUTEX_ERRORCHECK\00"
@PTHREAD_MUTEX_RECURSIVE = global i32 0
@.str.2 = [24 x i8] c"PTHREAD_MUTEX_RECURSIVE\00"
@.str.3 = [22 x i8] c"PTHREAD_MUTEX_DEFAULT\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i32 @pthread_mutexattr_init(i32* %3)
%8 = call i32 @pthread_mutexattr_gettype(i32* %3, i32* %4)
%9 = load i32, i32* %4
%10 = load i32, i32* @PTHREAD_MUTEX_NORMAL
%11 = icmp eq i32 %9, %10
br i1 %11, label %19, label %12
12: ; preds = %2
%13 = load i32, i32* @PTHREAD_MUTEX_ERRORCHECK
%14 = icmp eq i32 %9, %13
br i1 %14, label %19, label %15
15: ; preds = %12
%16 = load i32, i32* @PTHREAD_MUTEX_RECURSIVE
%17 = icmp eq i32 %9, %16
%18 = select i1 %17, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0)
br label %19
19: ; preds = %15, %12, %2
%20 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), %12 ], [ %18, %15 ]
%21 = call i32 @printf(i8* dereferenceable(1) %20)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}