#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_PROCESS_SHARED;
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*/ pthread_mutexattr_destroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutexattr_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutexattr_setpshared(int /*<<< orphan*/ *,
                                                int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main() {
  pthread_mutex_t mutex;
  pthread_mutexattr_t attr;
  pthread_mutexattr_init(&attr);
  pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
  pthread_mutex_init(&mutex, &attr);
  pthread_mutexattr_destroy(&attr);
  pthread_mutex_lock(&mutex);
  pthread_mutex_unlock(&mutex);
  pthread_mutex_destroy(&mutex);
  fprintf(stderr, "Finished.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
call   1070 <pthread_mutexattr_init@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1050 <pthread_mutexattr_setpshared@plt>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1080 <pthread_mutex_init@plt>
lea    -0xc(%rbp),%rdi
call   1090 <pthread_mutexattr_destroy@plt>
lea    -0x8(%rbp),%rdi
call   10a0 <pthread_mutex_lock@plt>
lea    -0x8(%rbp),%rdi
call   1060 <pthread_mutex_unlock@plt>
lea    -0x8(%rbp),%rdi
call   1030 <pthread_mutex_destroy@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
lea    0xe15(%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
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <pthread_mutexattr_init@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <pthread_mutexattr_setpshared@plt>
lea    0x4(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <pthread_mutex_init@plt>
mov    %rbx,%rdi
call   1090 <pthread_mutexattr_destroy@plt>
mov    %r14,%rdi
call   10a0 <pthread_mutex_lock@plt>
mov    %r14,%rdi
call   1060 <pthread_mutex_unlock@plt>
mov    %r14,%rdi
call   1030 <pthread_mutex_destroy@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xe20(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@PTHREAD_PROCESS_SHARED = global i32 0
@stderr = global i32 0
@.str = [11 x i8] c"Finished.\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_mutexattr_init(i32* %2)
%6 = load i32, i32* @PTHREAD_PROCESS_SHARED
%7 = call i32 @pthread_mutexattr_setpshared(i32* %2, i32 %6)
%8 = call i32 @pthread_mutex_init(i32* %1, i32* %2)
%9 = call i32 @pthread_mutexattr_destroy(i32* %2)
%10 = call i32 @pthread_mutex_lock(i32* %1)
%11 = call i32 @pthread_mutex_unlock(i32* %1)
%12 = call i32 @pthread_mutex_destroy(i32* %1)
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
ret i32 0
}