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

/* Variables and functions */
scalar_t__ hybris_check_android_shared_mutex(int);
int pthread_mutex_unlock(int /*<<< orphan*/ *);
int my_pthread_mutex_unlock(pthread_mutex_t *__mutex) {
  if (!__mutex) {
    ;
    return 0;
  }
  int value = (*(int *)__mutex);
  if (hybris_check_android_shared_mutex(value)) {
    ;
    return 0;
  }
  if (value <= 0xFFFF) {

    ;
    return 0;
  }
  pthread_mutex_t *realmutex = (pthread_mutex_t *)value;
  return pthread_mutex_unlock(realmutex);
}


x86 assembly (clang, -O0):
<my_pthread_mutex_unlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <my_pthread_mutex_unlock+0x23>
movl   $0x0,-0x4(%rbp)
jmp    1197 <my_pthread_mutex_unlock+0x77>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <hybris_check_android_shared_mutex@plt>
cmp    $0x0,%rax
je     116a <my_pthread_mutex_unlock+0x4a>
movl   $0x0,-0x4(%rbp)
jmp    1197 <my_pthread_mutex_unlock+0x77>
cmpl   $0xffff,-0x14(%rbp)
jg     1183 <my_pthread_mutex_unlock+0x63>
movl   $0x0,-0x4(%rbp)
jmp    1197 <my_pthread_mutex_unlock+0x77>
movslq -0x14(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <pthread_mutex_unlock@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_pthread_mutex_unlock>:
push   %rbx
test   %rdi,%rdi
je     1145 <my_pthread_mutex_unlock+0x25>
mov    (%rdi),%ebx
mov    %ebx,%edi
call   1030 <hybris_check_android_shared_mutex@plt>
cmp    $0x10000,%ebx
jl     1145 <my_pthread_mutex_unlock+0x25>
test   %rax,%rax
jne    1145 <my_pthread_mutex_unlock+0x25>
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <pthread_mutex_unlock@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @my_pthread_mutex_unlock(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32*
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 0, i32* %2
br label %26
9: ; preds = %1
%10 = load i32*, i32** %3
%11 = load i32, i32* %10
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = call i64 @hybris_check_android_shared_mutex(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %9
store i32 0, i32* %2
br label %26
16: ; preds = %9
%17 = load i32, i32* %4
%18 = icmp sle i32 %17, 65535
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 0, i32* %2
br label %26
20: ; preds = %16
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i32*
store i32* %23, i32** %5
%24 = load i32*, i32** %5
%25 = call i32 @pthread_mutex_unlock(i32* %24)
store i32 %25, i32* %2
br label %26
26: ; preds = %20, %19, %15, %8
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
define i32 @my_pthread_mutex_unlock(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %13, label %3
3: ; preds = %1
%4 = load i32, i32* %0
%5 = tail call i64 @hybris_check_android_shared_mutex(i32 %4)
%6 = icmp ne i64 %5, 0
%7 = icmp slt i32 %4, 65536
%8 = or i1 %7, %6
br i1 %8, label %13, label %9
9: ; preds = %3
%10 = zext i32 %4 to i64
%11 = inttoptr i64 %10 to i32*
%12 = tail call i32 @pthread_mutex_unlock(i32* %11)
br label %13
13: ; preds = %9, %3, %1
%14 = phi i32 [ 0, %1 ], [ %12, %9 ], [ 0, %3 ]
ret i32 %14
}