#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_lock(int /*<<< orphan*/ *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
void Pthread_mutex_lock(pthread_mutex_t *mutex) {
  if (pthread_mutex_lock(mutex) != 0)
    do {
      strerror(errno);
      puts("\n");
      err_quit("pthread mutex lock error");
    } while (1);
}


x86 assembly (clang, -O0):
<Pthread_mutex_lock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <pthread_mutex_lock@plt>
cmp    $0x0,%rax
je     119e <Pthread_mutex_lock+0x5e>
jmp    1164 <Pthread_mutex_lock+0x24>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7d(%rip),%rdi
call   1040 <err_quit@plt>
mov    $0x1,%al
test   $0x1,%al
jne    1164 <Pthread_mutex_lock+0x24>
jmp    1199 <Pthread_mutex_lock+0x59>
jmp    119e <Pthread_mutex_lock+0x5e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Pthread_mutex_lock>:
push   %r15
push   %r14
push   %rbx
call   1060 <pthread_mutex_lock@plt>
test   %rax,%rax
je     118a <Pthread_mutex_lock+0x4a>
mov    0x2e8a(%rip),%r15
lea    0xea3(%rip),%r14
lea    0xe9e(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
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_lock+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 lock error\00"
define void @Pthread_mutex_lock(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = call i64 @pthread_mutex_lock(i32* %3)
%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 lock error\00"
define void @Pthread_mutex_lock(i32* %0) {
%2 = tail call i64 @pthread_mutex_lock(i32* %0)
%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
}