#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 */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ logdebug3(char *, char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ logwarn(char *, char const *, int /*<<< orphan*/);
scalar_t__ pthread_mutex_unlock(int /*<<< orphan*/ *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
void oml_unlock(pthread_mutex_t *mutexP, const char *mutexName) {
  if (mutexP) {
    logdebug3("%s unlocking %p\n", mutexName, mutexP);
    if (pthread_mutex_unlock(mutexP)) {
      logwarn("%s: Couldn't unlock mutex (%s)\n", mutexName, strerror(errno));
    }
  }
}


x86 assembly (clang, -O0):
<oml_unlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11af <oml_unlock+0x6f>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe96(%rip),%rdi
call   1040 <logdebug3@plt>
mov    -0x8(%rbp),%rdi
call   1050 <pthread_mutex_unlock@plt>
cmp    $0x0,%rax
je     11aa <oml_unlock+0x6a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
lea    0xe6c(%rip),%rdi
call   1030 <logwarn@plt>
jmp    11af <oml_unlock+0x6f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oml_unlock>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1191 <oml_unlock+0x51>
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeaa(%rip),%rdi
mov    %rbx,%rdx
call   1040 <logdebug3@plt>
mov    %rbx,%rdi
call   1050 <pthread_mutex_unlock@plt>
test   %rax,%rax
je     1191 <oml_unlock+0x51>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe91(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <logwarn@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [17 x i8] c"%s unlocking %p\0A\00"
@.str.1 = [32 x i8] c"%s: Couldn't unlock mutex (%s)\0A\00"
@errno = global i32 0
define void @oml_unlock(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%5 = load i32*, i32** %3
%6 = icmp ne i32* %5, null
br i1 %6, label %7, label %20
7: ; preds = %2
%8 = load i8*, i8** %4
%9 = load i32*, i32** %3
%10 = call i32 @logdebug3(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %8, i32* %9)
%11 = load i32*, i32** %3
%12 = call i64 @pthread_mutex_unlock(i32* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %7
%15 = load i8*, i8** %4
%16 = load i32, i32* @errno
%17 = call i32 @strerror(i32 %16)
%18 = call i32 @logwarn(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 %17)
br label %19
19: ; preds = %14, %7
br label %20
20: ; preds = %19, %2
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"%s unlocking %p\0A\00"
@.str.1 = [32 x i8] c"%s: Couldn't unlock mutex (%s)\0A\00"
@errno = global i32 0
define void @oml_unlock(i32* %0, i8* %1) {
%3 = icmp eq i32* %0, null
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = tail call i32 @logdebug3(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %1, i32* %0)
%6 = tail call i64 @pthread_mutex_unlock(i32* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = load i32, i32* @errno
%10 = tail call i32 @strerror(i32 %9)
%11 = tail call i32 @logwarn(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %10)
br label %12
12: ; preds = %4, %8, %2
ret void
}