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

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ IPC_RMID;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int msgctl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int msgget(int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
void remove_it(void) {
  int msgid;
  if ((msgid = msgget((key_t)1234, 0666)) == -1) {
    perror("msgget");
    exit(errno);
  };
  if (msgctl(msgid, IPC_RMID, 0) == -1) {
    perror("msgctl");
    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    $0x4d2,%edi
mov    $0x1b6,%esi
call   1030 <msgget@plt>
mov    %eax,-0x4(%rbp)
cmp    $0xffffffff,%eax
jne    118d <remove_it+0x3d>
lea    0xe86(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2e41(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <msgctl@plt>
cmp    $0xffffffff,%eax
jne    11c3 <remove_it+0x73>
lea    0xe57(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<remove_it>:
push   %rax
mov    $0x4d2,%edi
mov    $0x1b6,%esi
call   1030 <msgget@plt>
cmp    $0xffffffff,%eax
jne    116e <remove_it+0x1e>
lea    0xe94(%rip),%rdi
jmp    118c <remove_it+0x3c>
mov    0x2e63(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
xor    %edx,%edx
call   1050 <msgctl@plt>
cmp    $0xffffffff,%eax
jne    119f <remove_it+0x4f>
lea    0xe7b(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xe68(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"msgget\00"
@errno = global i32 0
@IPC_RMID = global i32 0
@.str.1 = [7 x i8] c"msgctl\00"
@.str.2 = [38 x i8] c"Message Queue successfully destroyed\0A\00"
@EXIT_SUCCESS = global i32 0
define void @remove_it() {
%1 = alloca i32
%2 = call i32 @msgget(i32 1234, i32 438)
store i32 %2, i32* %1
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %8
4: ; preds = %0
%5 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @errno
%7 = call i32 @exit(i32 %6)
unreachable
8: ; preds = %0
%9 = load i32, i32* %1
%10 = load i32, i32* @IPC_RMID
%11 = call i32 @msgctl(i32 %9, i32 %10, i32 0)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @errno
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %8
%18 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* @EXIT_SUCCESS
%20 = call i32 @exit(i32 %19)
unreachable
}

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