#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 */

/* Variables and functions */
int NAME_MAX;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ plrSD_getShmName(char *);
scalar_t__ shm_unlink(char *);
int plrSD_cleanupSharedData() {
  char shmName[NAME_MAX];
  plrSD_getShmName(shmName);
  if (shm_unlink(shmName) < 0) {
    perror("shm_unlink");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<plrSD_cleanupSharedData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x28(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
call   1030 <plrSD_getShmName@plt>
mov    -0x28(%rbp),%rdi
call   1050 <shm_unlink@plt>
cmp    $0x0,%rax
jge    119b <plrSD_cleanupSharedData+0x6b>
lea    0xe7d(%rip),%rdi
call   1040 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x1c(%rbp)
jmp    11a9 <plrSD_cleanupSharedData+0x79>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plrSD_cleanupSharedData>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    0x2e9b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
call   1030 <plrSD_getShmName@plt>
mov    %rbx,%rdi
call   1050 <shm_unlink@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
js     1171 <plrSD_cleanupSharedData+0x41>
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe88(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%eax
jmp    116a <plrSD_cleanupSharedData+0x3a>

LLVM IR (-O0):
@NAME_MAX = global i32 0
@.str = [11 x i8] c"shm_unlink\00"
define i32 @plrSD_cleanupSharedData() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
%5 = load i32, i32* @NAME_MAX
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
store i8* %7, i8** %2
%8 = alloca i8, i64 %6
store i64 %6, i64* %3
%9 = call i32 @plrSD_getShmName(i8* %8)
%10 = call i64 @shm_unlink(i8* %8)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
store i32 1, i32* %4
br label %15
14: ; preds = %0
store i32 0, i32* %1
store i32 1, i32* %4
br label %15
15: ; preds = %14, %12
%16 = load i8*, i8** %2
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@NAME_MAX = global i32 0
@.str = [11 x i8] c"shm_unlink\00"
define i32 @plrSD_cleanupSharedData() {
%1 = load i32, i32* @NAME_MAX
%2 = zext i32 %1 to i64
%3 = alloca i8, i64 %2
%4 = call i32 @plrSD_getShmName(i8* %3)
%5 = call i64 @shm_unlink(i8* %3)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %0, %7
%10 = phi i32 [ -1, %7 ], [ 0, %0 ]
ret i32 %10
}