#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 mqd_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ mq_close(int);
int mq_open(char *, int /*<<< orphan*/, int /*<<< orphan*/,
            int /*<<< orphan*/ *);
scalar_t__ mq_unlink(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
void remove_it(void) {
  mqd_t msg_fd;
  if ((msg_fd = mq_open("/my_mq", O_RDWR, 0, NULL)) == -1) {
    perror("mq_open");
    exit(errno);
  };
  if (mq_close(msg_fd)) {
    perror("mq_close");
    exit(errno);
  };
  if (mq_unlink("/my_mq")) {
    perror("mq_unlink");
    exit(errno);
  };
  printf("Message Queue successfully destroyed\n");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<remove_it>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
lea    0xe88(%rip),%rdi
xor    %edx,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1050 <mq_open@plt>
mov    %eax,-0x4(%rbp)
cmp    $0xffffffff,%eax
jne    11a9 <remove_it+0x49>
lea    0xe71(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%edi
call   1040 <mq_close@plt>
cmp    $0x0,%rax
je     11d5 <remove_it+0x75>
lea    0xe4d(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xe24(%rip),%rdi
call   1080 <mq_unlink@plt>
cmp    $0x0,%rax
je     1205 <remove_it+0xa5>
lea    0xe26(%rip),%rdi
call   1060 <perror@plt>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xe16(%rip),%rdi
call   1030 <printf@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<remove_it>:
push   %rax
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
lea    0xe8f(%rip),%rdi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <mq_open@plt>
cmp    $0xffffffff,%eax
jne    1188 <remove_it+0x28>
lea    0xe81(%rip),%rdi
jmp    11cf <remove_it+0x6f>
mov    %eax,%edi
call   1040 <mq_close@plt>
test   %rax,%rax
jne    11bf <remove_it+0x5f>
lea    0xe65(%rip),%rdi
call   1080 <mq_unlink@plt>
test   %rax,%rax
jne    11c8 <remove_it+0x68>
lea    0xe76(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xe49(%rip),%rdi
jmp    11cf <remove_it+0x6f>
lea    0xe49(%rip),%rdi
call   1060 <perror@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"/my_mq\00"
@O_RDWR = global i32 0
@.str.1 = [8 x i8] c"mq_open\00"
@errno = global i32 0
@.str.2 = [9 x i8] c"mq_close\00"
@.str.3 = [10 x i8] c"mq_unlink\00"
@.str.4 = [38 x i8] c"Message Queue 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 @mq_open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %2, i32 0, i32* null)
store i32 %3, i32* %1
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @errno
%8 = call i32 @exit(i32 %7)
unreachable
9: ; preds = %0
%10 = load i32, i32* %1
%11 = call i64 @mq_close(i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @errno
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %9
%18 = call i64 @mq_unlink(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32, i32* @errno
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %17
%25 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%26 = load i32, i32* @EXIT_SUCCESS
%27 = call i32 @exit(i32 %26)
unreachable
}

LLVM IR (-O2):
@.str = [7 x i8] c"/my_mq\00"
@O_RDWR = global i32 0
@.str.1 = [8 x i8] c"mq_open\00"
@errno = global i32 0
@.str.2 = [9 x i8] c"mq_close\00"
@.str.3 = [10 x i8] c"mq_unlink\00"
@EXIT_SUCCESS = global i32 0
@str = [37 x i8] c"Message Queue successfully destroyed\00"
define void @remove_it() {
%1 = load i32, i32* @O_RDWR
%2 = tail call i32 @mq_open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %1, i32 0, i32* null)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %8
4: ; preds = %0
%5 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 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 @mq_close(i32 %2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 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 i64 @mq_unlink(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %15
%19 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32, i32* @errno
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %15
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%24 = load i32, i32* @EXIT_SUCCESS
%25 = tail call i32 @exit(i32 %24)
unreachable
}