#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ pthread_mutex_destroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutex_init(int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutex_lock(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutex_unlock(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main() {
  pthread_mutex_t mu1, mu2;
  pthread_mutex_init(&mu1, NULL);
  pthread_mutex_init(&mu2, NULL);
  pthread_mutex_lock(&mu1);
  pthread_mutex_lock(&mu2);
  pthread_mutex_unlock(&mu2);
  pthread_mutex_unlock(&mu1);
  pthread_mutex_lock(&mu2);
  pthread_mutex_lock(&mu1);
  pthread_mutex_unlock(&mu1);
  pthread_mutex_unlock(&mu2);
  pthread_mutex_destroy(&mu1);
  pthread_mutex_destroy(&mu2);
  fprintf(stderr, "PASS\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x4(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <pthread_mutex_init@plt>
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <pthread_mutex_init@plt>
lea    -0x4(%rbp),%rdi
call   1070 <pthread_mutex_lock@plt>
lea    -0x8(%rbp),%rdi
call   1070 <pthread_mutex_lock@plt>
lea    -0x8(%rbp),%rdi
call   1050 <pthread_mutex_unlock@plt>
lea    -0x4(%rbp),%rdi
call   1050 <pthread_mutex_unlock@plt>
lea    -0x8(%rbp),%rdi
call   1070 <pthread_mutex_lock@plt>
lea    -0x4(%rbp),%rdi
call   1070 <pthread_mutex_lock@plt>
lea    -0x4(%rbp),%rdi
call   1050 <pthread_mutex_unlock@plt>
lea    -0x8(%rbp),%rdi
call   1050 <pthread_mutex_unlock@plt>
lea    -0x4(%rbp),%rdi
call   1030 <pthread_mutex_destroy@plt>
lea    -0x8(%rbp),%rdi
call   1030 <pthread_mutex_destroy@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    0xe24(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0x4(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <pthread_mutex_init@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <pthread_mutex_init@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_lock@plt>
mov    %rbx,%rdi
call   1070 <pthread_mutex_lock@plt>
mov    %rbx,%rdi
call   1050 <pthread_mutex_unlock@plt>
mov    %r14,%rdi
call   1050 <pthread_mutex_unlock@plt>
mov    %rbx,%rdi
call   1070 <pthread_mutex_lock@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_lock@plt>
mov    %r14,%rdi
call   1050 <pthread_mutex_unlock@plt>
mov    %rbx,%rdi
call   1050 <pthread_mutex_unlock@plt>
mov    %r14,%rdi
call   1030 <pthread_mutex_destroy@plt>
mov    %rbx,%rdi
call   1030 <pthread_mutex_destroy@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [6 x i8] c"PASS\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @pthread_mutex_init(i32* %1, i32* null)
%4 = call i32 @pthread_mutex_init(i32* %2, i32* null)
%5 = call i32 @pthread_mutex_lock(i32* %1)
%6 = call i32 @pthread_mutex_lock(i32* %2)
%7 = call i32 @pthread_mutex_unlock(i32* %2)
%8 = call i32 @pthread_mutex_unlock(i32* %1)
%9 = call i32 @pthread_mutex_lock(i32* %2)
%10 = call i32 @pthread_mutex_lock(i32* %1)
%11 = call i32 @pthread_mutex_unlock(i32* %1)
%12 = call i32 @pthread_mutex_unlock(i32* %2)
%13 = call i32 @pthread_mutex_destroy(i32* %1)
%14 = call i32 @pthread_mutex_destroy(i32* %2)
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [6 x i8] c"PASS\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @pthread_mutex_init(i32* %1, i32* null)
%6 = call i32 @pthread_mutex_init(i32* %2, i32* null)
%7 = call i32 @pthread_mutex_lock(i32* %1)
%8 = call i32 @pthread_mutex_lock(i32* %2)
%9 = call i32 @pthread_mutex_unlock(i32* %2)
%10 = call i32 @pthread_mutex_unlock(i32* %1)
%11 = call i32 @pthread_mutex_lock(i32* %2)
%12 = call i32 @pthread_mutex_lock(i32* %1)
%13 = call i32 @pthread_mutex_unlock(i32* %1)
%14 = call i32 @pthread_mutex_unlock(i32* %2)
%15 = call i32 @pthread_mutex_destroy(i32* %1)
%16 = call i32 @pthread_mutex_destroy(i32* %2)
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
ret i32 0
}