#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*/ hol(int /*<<< orphan*/ **, int /*<<< orphan*/ **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ pthread_mutex_lock(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutex_unlock(int /*<<< orphan*/ *);
main() {
  pthread_mutex_t *mainl1;
  pthread_mutex_t *mainl2;
  printf("\n##### in main #####\n\n");
  hol(&mainl1, &mainl2);
  pthread_mutex_lock(mainl1);
  pthread_mutex_unlock(mainl1);
  pthread_mutex_lock(mainl2);
  pthread_mutex_unlock(mainl2);
  printf("\n##### out of main #####\n\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <hol@plt>
mov    -0x8(%rbp),%rdi
call   1060 <pthread_mutex_lock@plt>
mov    -0x8(%rbp),%rdi
call   1050 <pthread_mutex_unlock@plt>
mov    -0x10(%rbp),%rdi
call   1060 <pthread_mutex_lock@plt>
mov    -0x10(%rbp),%rdi
call   1050 <pthread_mutex_unlock@plt>
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1040 <hol@plt>
mov    0x10(%rsp),%rdi
call   1060 <pthread_mutex_lock@plt>
mov    0x10(%rsp),%rdi
call   1050 <pthread_mutex_unlock@plt>
mov    0x8(%rsp),%rdi
call   1060 <pthread_mutex_lock@plt>
mov    0x8(%rsp),%rdi
call   1050 <pthread_mutex_unlock@plt>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\0A##### in main #####\0A\0A\00"
@.str.1 = [27 x i8] c"\0A##### out of main #####\0A\0A\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca i32*
%3 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @hol(i32** %1, i32** %2)
%5 = load i32*, i32** %1
%6 = call i32 @pthread_mutex_lock(i32* %5)
%7 = load i32*, i32** %1
%8 = call i32 @pthread_mutex_unlock(i32* %7)
%9 = load i32*, i32** %2
%10 = call i32 @pthread_mutex_lock(i32* %9)
%11 = load i32*, i32** %2
%12 = call i32 @pthread_mutex_unlock(i32* %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [22 x i8] c"\0A##### in main #####\0A\00"
@str.2 = [26 x i8] c"\0A##### out of main #####\0A\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca i32*
%3 = bitcast i32** %1 to i8*
%4 = bitcast i32** %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%6 = call i32 @hol(i32** %1, i32** %2)
%7 = load i32*, i32** %1
%8 = call i32 @pthread_mutex_lock(i32* %7)
%9 = load i32*, i32** %1
%10 = call i32 @pthread_mutex_unlock(i32* %9)
%11 = load i32*, i32** %2
%12 = call i32 @pthread_mutex_lock(i32* %11)
%13 = load i32*, i32** %2
%14 = call i32 @pthread_mutex_unlock(i32* %13)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.2, i64 0, i64 0))
ret i32 0
}