#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 /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int shm_open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ shm_unlink(char *);
void remove_it(void) {
  int shm_fd;
  if ((shm_fd = shm_open("/my_shm", O_RDWR, 0) == -1)) {
    perror("shm_open");
    exit(errno);
  };
  if (shm_unlink("/my_shm")) {
    perror("shm_unlink");
    exit(errno);
  };
  printf("Shared Memory Region successfully destroyed\n");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<remove_it>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
lea    0xe98(%rip),%rdi
xor    %edx,%edx
call   1060 <shm_open@plt>
cmp    $0xffffffff,%eax
sete   %al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,-0x4(%rbp)
test   $0x1,%al
jne    118d <remove_it+0x3d>
jmp    11a7 <remove_it+0x57>
lea    0xe74(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
lea    0xe52(%rip),%rdi
call   1070 <shm_unlink@plt>
cmp    $0x0,%rax
je     11d7 <remove_it+0x87>
lea    0xe4d(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
lea    0xe3e(%rip),%rdi
call   1030 <printf@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<remove_it>:
push   %rax
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
lea    0xe9f(%rip),%rdi
xor    %edx,%edx
call   1060 <shm_open@plt>
cmp    $0xffffffff,%eax
jne    1176 <remove_it+0x26>
lea    0xe94(%rip),%rdi
jmp    11a8 <remove_it+0x58>
lea    0xe83(%rip),%rdi
call   1070 <shm_unlink@plt>
test   %rax,%rax
jne    11a1 <remove_it+0x51>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
lea    0xe69(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"/my_shm\00"
@O_RDWR = global i32 0
@.str.1 = [9 x i8] c"shm_open\00"
@errno = global i32 0
@.str.2 = [11 x i8] c"shm_unlink\00"
@.str.3 = [45 x i8] c"Shared Memory Region successfully destroyed\0A\00"
@EXIT_SUCCESS = global i32 0
define void @remove_it() {
%1 = alloca i32
%2 = load i32, i32* @O_RDWR
%3 = call i32 @shm_open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %2, i32 0)
%4 = icmp eq i32 %3, -1
%5 = zext i1 %4 to i32
store i32 %5, i32* %1
br i1 %4, label %6, label %10
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @errno
%9 = call i32 @exit(i32 %8)
unreachable
10: ; preds = %0
%11 = call i64 @shm_unlink(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @errno
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %10
%18 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%19 = load i32, i32* @EXIT_SUCCESS
%20 = call i32 @exit(i32 %19)
unreachable
}

LLVM IR (-O2):
@.str = [8 x i8] c"/my_shm\00"
@O_RDWR = global i32 0
@.str.1 = [9 x i8] c"shm_open\00"
@errno = global i32 0
@.str.2 = [11 x i8] c"shm_unlink\00"
@EXIT_SUCCESS = global i32 0
@str = [44 x i8] c"Shared Memory Region successfully destroyed\00"
define void @remove_it() {
%1 = load i32, i32* @O_RDWR
%2 = tail call i32 @shm_open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %1, i32 0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %8
4: ; preds = %0
%5 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* @errno
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %0
%9 = tail call i64 @shm_unlink(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32, i32* @errno
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %8
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%17 = load i32, i32* @EXIT_SUCCESS
%18 = tail call i32 @exit(i32 %17)
unreachable
}