#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_mutexattr_t;
typedef int /*<<< orphan*/ pthread_mutex_t;

/* Variables and functions */
int /*<<< orphan*/ PTHREAD_MUTEX_RECURSIVE_NP;
int /*<<< orphan*/ *malloc(int);
int /*<<< orphan*/ printf(char *);
int pthread_mutex_init(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int pthread_mutexattr_init(int /*<<< orphan*/ *);
int pthread_mutexattr_settype(int /*<<< orphan*/ *, int /*<<< orphan*/);
pthread_mutex_t *doMalloc() {
  printf("\n##### in doMalloc #####\n\n");
  pthread_mutex_t *local;
  pthread_mutexattr_t mutexAttribute;
  local = malloc(sizeof(pthread_mutex_t));
  int status = pthread_mutexattr_init(&mutexAttribute);
  if (status != 0) {
  }
  status =
      pthread_mutexattr_settype(&mutexAttribute, PTHREAD_MUTEX_RECURSIVE_NP);
  if (status != 0) {
  }
  status = pthread_mutex_init(local, &mutexAttribute);
  if (status != 0) {
  }
  printf("\n##### out of doMalloc #####\n\n");
  return local;
}


x86 assembly (clang, -O0):
<doMalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
call   1060 <pthread_mutexattr_init@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     118d <doMalloc+0x3d>
jmp    118d <doMalloc+0x3d>
mov    0x2e54(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1040 <pthread_mutexattr_settype@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11b1 <doMalloc+0x61>
jmp    11b1 <doMalloc+0x61>
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <pthread_mutex_init@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11d0 <doMalloc+0x80>
jmp    11d0 <doMalloc+0x80>
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doMalloc>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rdi
call   1030 <puts@plt>
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1060 <pthread_mutexattr_init@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1040 <pthread_mutexattr_settype@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <pthread_mutex_init@plt>
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [27 x i8] c"\0A##### in doMalloc #####\0A\0A\00"
@PTHREAD_MUTEX_RECURSIVE_NP = global i32 0
@.str.1 = [31 x i8] c"\0A##### out of doMalloc #####\0A\0A\00"
define i32* @doMalloc() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%5 = call i32* @malloc(i32 4)
store i32* %5, i32** %1
%6 = call i32 @pthread_mutexattr_init(i32* %2)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %0
br label %10
10: ; preds = %9, %0
%11 = load i32, i32* @PTHREAD_MUTEX_RECURSIVE_NP
%12 = call i32 @pthread_mutexattr_settype(i32* %2, i32 %11)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10
br label %16
16: ; preds = %15, %10
%17 = load i32*, i32** %1
%18 = call i32 @pthread_mutex_init(i32* %17, i32* %2)
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
br label %22
22: ; preds = %21, %16
%23 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32*, i32** %1
ret i32* %24
}

LLVM IR (-O2):
@PTHREAD_MUTEX_RECURSIVE_NP = global i32 0
@str = [26 x i8] c"\0A##### in doMalloc #####\0A\00"
@str.2 = [30 x i8] c"\0A##### out of doMalloc #####\0A\00"
define i32* @doMalloc() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%3 = bitcast i32* %1 to i8*
%4 = tail call i32* @malloc(i32 4)
%5 = call i32 @pthread_mutexattr_init(i32* %1)
%6 = load i32, i32* @PTHREAD_MUTEX_RECURSIVE_NP
%7 = call i32 @pthread_mutexattr_settype(i32* %1, i32 %6)
%8 = call i32 @pthread_mutex_init(i32* %4, i32* %1)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.2, i64 0, i64 0))
ret i32* %4
}