#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*/ printf(char *, char *);
int pthread_mutex_init(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
char *strerror(int);
bool pthread_wrapper_create_mutex(pthread_mutex_t *m) {
  int err;
  if (!m)
    return false;
  err = pthread_mutex_init(m, NULL);
  if (err) {
    printf("Error: Mutex init failed:%s", strerror(err));
    return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<pthread_wrapper_create_mutex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1153 <pthread_wrapper_create_mutex+0x23>
movl   $0x0,-0x4(%rbp)
jmp    1197 <pthread_wrapper_create_mutex+0x67>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <pthread_mutex_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1190 <pthread_wrapper_create_mutex+0x60>
mov    -0x14(%rbp),%edi
call   1040 <strerror@plt>
mov    %rax,%rsi
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1197 <pthread_wrapper_create_mutex+0x67>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pthread_wrapper_create_mutex>:
push   %rbx
xor    %ebx,%ebx
test   %rdi,%rdi
je     1160 <pthread_wrapper_create_mutex+0x30>
xor    %esi,%esi
call   1050 <pthread_mutex_init@plt>
test   %eax,%eax
je     115b <pthread_wrapper_create_mutex+0x2b>
mov    %eax,%edi
call   1040 <strerror@plt>
lea    0xeaf(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
jmp    1160 <pthread_wrapper_create_mutex+0x30>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Error: Mutex init failed:%s\00"
define i32 @pthread_wrapper_create_mutex(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
%5 = load i32*, i32** %3
%6 = icmp ne i32* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 0, i32* %2
br label %18
8: ; preds = %1
%9 = load i32*, i32** %3
%10 = call i32 @pthread_mutex_init(i32* %9, i32* null)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = load i32, i32* %4
%15 = call i8* @strerror(i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 0, i32* %2
br label %18
17: ; preds = %8
store i32 1, i32* %2
br label %18
18: ; preds = %17, %13, %7
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@.str = [28 x i8] c"Error: Mutex init failed:%s\00"
define i32 @pthread_wrapper_create_mutex(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %9, label %3
3: ; preds = %1
%4 = tail call i32 @pthread_mutex_init(i32* %0, i32* null)
%5 = icmp eq i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i8* @strerror(i32 %4)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %3, %1, %6
%10 = phi i32 [ 0, %6 ], [ 0, %1 ], [ 1, %3 ]
ret i32 %10
}