#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*/ PTHREAD_MUTEX_ERRORCHECK;
int /*<<< orphan*/ PTHREAD_MUTEX_RECURSIVE;
int /*<<< orphan*/ pthread_mutexattr_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutexattr_settype(int /*<<< orphan*/ *,
                                             int /*<<< orphan*/);
void hybris_set_mutex_attr(int android_value, pthread_mutexattr_t *attr) {
  pthread_mutexattr_init(attr);
  if (android_value & 0x4000) {
    pthread_mutexattr_settype(attr, PTHREAD_MUTEX_RECURSIVE);
  } else if (android_value & 0x8000) {
    pthread_mutexattr_settype(attr, PTHREAD_MUTEX_ERRORCHECK);
  }
}


x86 assembly (clang, -O0):
<hybris_set_mutex_attr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <pthread_mutexattr_init@plt>
mov    -0x4(%rbp),%eax
and    $0x4000,%eax
cmp    $0x0,%eax
je     1160 <hybris_set_mutex_attr+0x40>
mov    -0x10(%rbp),%rdi
mov    0x2ea4(%rip),%rax
mov    (%rax),%esi
call   1030 <pthread_mutexattr_settype@plt>
jmp    1188 <hybris_set_mutex_attr+0x68>
mov    -0x4(%rbp),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     1183 <hybris_set_mutex_attr+0x63>
mov    -0x10(%rbp),%rdi
mov    0x2e54(%rip),%rax
mov    (%rax),%esi
call   1030 <pthread_mutexattr_settype@plt>
jmp    1188 <hybris_set_mutex_attr+0x68>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hybris_set_mutex_attr>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1040 <pthread_mutexattr_init@plt>
test   $0x4000,%ebp
jne    1147 <hybris_set_mutex_attr+0x27>
test   $0x8000,%ebp
jne    1150 <hybris_set_mutex_attr+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2eaa(%rip),%rax
jmp    1157 <hybris_set_mutex_attr+0x37>
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <pthread_mutexattr_settype@plt>

LLVM IR (-O0):
@PTHREAD_MUTEX_RECURSIVE = global i32 0
@PTHREAD_MUTEX_ERRORCHECK = global i32 0
define void @hybris_set_mutex_attr(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
store i32 %0, i32* %3
store i32* %1, i32** %4
%5 = load i32*, i32** %4
%6 = call i32 @pthread_mutexattr_init(i32* %5)
%7 = load i32, i32* %3
%8 = and i32 %7, 16384
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32*, i32** %4
%12 = load i32, i32* @PTHREAD_MUTEX_RECURSIVE
%13 = call i32 @pthread_mutexattr_settype(i32* %11, i32 %12)
br label %23
14: ; preds = %2
%15 = load i32, i32* %3
%16 = and i32 %15, 32768
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i32*, i32** %4
%20 = load i32, i32* @PTHREAD_MUTEX_ERRORCHECK
%21 = call i32 @pthread_mutexattr_settype(i32* %19, i32 %20)
br label %22
22: ; preds = %18, %14
br label %23
23: ; preds = %22, %10
ret void
}

LLVM IR (-O2):
@PTHREAD_MUTEX_RECURSIVE = global i32 0
@PTHREAD_MUTEX_ERRORCHECK = global i32 0
define void @hybris_set_mutex_attr(i32 %0, i32* %1) {
%3 = tail call i32 @pthread_mutexattr_init(i32* %1)
%4 = and i32 %0, 16384
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = and i32 %0, 32768
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %6, %2
%10 = phi i32* [ @PTHREAD_MUTEX_RECURSIVE, %2 ], [ @PTHREAD_MUTEX_ERRORCHECK, %6 ]
%11 = load i32, i32* %10
%12 = tail call i32 @pthread_mutexattr_settype(i32* %1, i32 %11)
br label %13
13: ; preds = %9, %6
ret void
}