#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
int pthread_mutex_init(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strerror(int);
void init_mutex(pthread_mutex_t *mutex, const char *mutex_desc) {
  int rc = pthread_mutex_init(mutex, NULL);
  if (rc != 0) {
    fprintf(stderr, "pthread_mutex_init failed for %s: %s\n", mutex_desc,
            strerror(rc));
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<init_mutex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <pthread_mutex_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11a6 <init_mutex+0x66>
mov    0x2e6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %rax,%rcx
lea    0xe69(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_mutex>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
xor    %esi,%esi
call   1060 <pthread_mutex_init@plt>
test   %eax,%eax
jne    1158 <init_mutex+0x18>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e81(%rip),%rcx
mov    (%rcx),%ebp
mov    %eax,%edi
call   1050 <strerror@plt>
lea    0xe91(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"pthread_mutex_init failed for %s: %s\0A\00"
define void @init_mutex(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
%6 = load i32*, i32** %3
%7 = call i32 @pthread_mutex_init(i32* %6, i32* null)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %4
%13 = load i32, i32* %5
%14 = call i8* @strerror(i32 %13)
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %14)
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %2
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"pthread_mutex_init failed for %s: %s\0A\00"
define void @init_mutex(i32* %0, i8* %1) {
%3 = tail call i32 @pthread_mutex_init(i32* %0, i32* null)
%4 = icmp eq i32 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i8* @strerror(i32 %3)
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %7)
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
ret void
}