#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*/ err_quit(char *);
int /*<<< orphan*/ errno;
scalar_t__ pthread_mutex_init(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
void Pthread_mutex_init(pthread_mutex_t *mutex) {
  if (pthread_mutex_init(mutex, NULL) != 0)
    do {
      strerror(errno);
      puts("\n");
      err_quit("pthread mutex init error");
    } while (1);
}


x86 assembly (clang, -O0):
<Pthread_mutex_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <pthread_mutex_init@plt>
cmp    $0x0,%rax
je     11a2 <Pthread_mutex_init+0x62>
jmp    1168 <Pthread_mutex_init+0x28>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
lea    0xe79(%rip),%rdi
call   1040 <err_quit@plt>
mov    $0x1,%al
test   $0x1,%al
jne    1168 <Pthread_mutex_init+0x28>
jmp    119d <Pthread_mutex_init+0x5d>
jmp    11a2 <Pthread_mutex_init+0x62>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Pthread_mutex_init>:
push   %r15
push   %r14
push   %rbx
xor    %esi,%esi
call   1060 <pthread_mutex_init@plt>
test   %rax,%rax
je     118a <Pthread_mutex_init+0x4a>
mov    0x2e88(%rip),%r15
lea    0xea1(%rip),%r14
lea    0xe9c(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    (%r15),%edi
call   1050 <strerror@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <err_quit@plt>
jmp    1170 <Pthread_mutex_init+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@errno = global i32 0
@.str = [2 x i8] c"\0A\00"
@.str.1 = [25 x i8] c"pthread mutex init error\00"
define void @Pthread_mutex_init(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = call i64 @pthread_mutex_init(i32* %3, i32* null)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %1
br label %7
7: ; preds = %12, %6
%8 = load i32, i32* @errno
%9 = call i32 @strerror(i32 %8)
%10 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @err_quit(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %7
br i1 true, label %7, label %13
13: ; preds = %12
br label %14
14: ; preds = %13, %1
ret void
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [2 x i8] c"\0A\00"
@.str.1 = [25 x i8] c"pthread mutex init error\00"
define void @Pthread_mutex_init(i32* %0) {
%2 = tail call i64 @pthread_mutex_init(i32* %0, i32* null)
%3 = icmp eq i64 %2, 0
br i1 %3, label %9, label %4
4: ; preds = %1, %4
%5 = load i32, i32* @errno
%6 = tail call i32 @strerror(i32 %5)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @err_quit(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %4
9: ; preds = %1
ret void
}