#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*/ PTHREAD_MUTEX_INITIALIZER;
int /*<<< orphan*/ my_pthread_lvemutex_lock(int /*<<< orphan*/ *);
int /*<<< orphan*/ my_pthread_lvemutex_unlock(int /*<<< orphan*/ *);
int /*<<< orphan*/ my_release_slot();
int /*<<< orphan*/ my_reserve_slot();
int cahce() {
  pthread_mutex_t mt = PTHREAD_MUTEX_INITIALIZER;
  pthread_mutex_t mt2 = PTHREAD_MUTEX_INITIALIZER;
  my_reserve_slot();
  my_pthread_lvemutex_lock(&mt);
  my_pthread_lvemutex_lock(&mt2);
  my_pthread_lvemutex_unlock(&mt2);
  my_pthread_lvemutex_unlock(&mt);
  my_release_slot();
}


x86 assembly (clang, -O0):
<cahce>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e91(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e85(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <my_reserve_slot@plt>
lea    -0x8(%rbp),%rdi
call   1060 <my_pthread_lvemutex_lock@plt>
lea    -0xc(%rbp),%rdi
call   1060 <my_pthread_lvemutex_lock@plt>
lea    -0xc(%rbp),%rdi
call   1040 <my_pthread_lvemutex_unlock@plt>
lea    -0x8(%rbp),%rdi
call   1040 <my_pthread_lvemutex_unlock@plt>
mov    $0x0,%al
call   1050 <my_release_slot@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cahce>:
push   %r14
push   %rbx
push   %rax
mov    0x2e95(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    %eax,(%rsp)
xor    %eax,%eax
call   1030 <my_reserve_slot@plt>
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1060 <my_pthread_lvemutex_lock@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <my_pthread_lvemutex_lock@plt>
mov    %rbx,%rdi
call   1040 <my_pthread_lvemutex_unlock@plt>
mov    %r14,%rdi
call   1040 <my_pthread_lvemutex_unlock@plt>
xor    %eax,%eax
call   1050 <my_release_slot@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@PTHREAD_MUTEX_INITIALIZER = global i32 0
define i32 @cahce() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = load i32, i32* @PTHREAD_MUTEX_INITIALIZER
store i32 %4, i32* %2
%5 = load i32, i32* @PTHREAD_MUTEX_INITIALIZER
store i32 %5, i32* %3
%6 = call i32 (...) @my_reserve_slot()
%7 = call i32 @my_pthread_lvemutex_lock(i32* %2)
%8 = call i32 @my_pthread_lvemutex_lock(i32* %3)
%9 = call i32 @my_pthread_lvemutex_unlock(i32* %3)
%10 = call i32 @my_pthread_lvemutex_unlock(i32* %2)
%11 = call i32 (...) @my_release_slot()
%12 = load i32, i32* %1
ret i32 %12
}

LLVM IR (-O2):
@PTHREAD_MUTEX_INITIALIZER = global i32 0
define i32 @cahce() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = load i32, i32* @PTHREAD_MUTEX_INITIALIZER
store i32 %4, i32* %1
%5 = bitcast i32* %2 to i8*
store i32 %4, i32* %2
%6 = tail call i32 (...) @my_reserve_slot()
%7 = call i32 @my_pthread_lvemutex_lock(i32* %1)
%8 = call i32 @my_pthread_lvemutex_lock(i32* %2)
%9 = call i32 @my_pthread_lvemutex_unlock(i32* %2)
%10 = call i32 @my_pthread_lvemutex_unlock(i32* %1)
%11 = call i32 (...) @my_release_slot()
ret i32 undef
}