#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*/ IPC_RMID;
int atoi(char *);
int /*<<< orphan*/ exit(int);
scalar_t__ msgctl(int, int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  int qid;
  if (argc != 2) {
    puts("USAGE: del_msgq.c <queue ID >");
    exit(1);
  }
  qid = atoi(argv[1]);
  system("ipcs -q");
  if ((msgctl(qid, IPC_RMID, NULL)) < 0) {
    perror("msgctl");
    exit(1);
  }
  system("ipcs -q");
  printf("successfully removed %d  queue\n", qid);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11a6 <main+0x36>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    0xe61(%rip),%rdi
call   1040 <system@plt>
mov    -0x14(%rbp),%edi
mov    0x2e14(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <msgctl@plt>
cmp    $0x0,%rax
jge    11f7 <main+0x87>
lea    0xe3e(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xe20(%rip),%rdi
call   1040 <system@plt>
mov    -0x14(%rbp),%esi
lea    0xe20(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    11ba <main+0x4a>
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebx
lea    0xe96(%rip),%rdi
call   1040 <system@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %edx,%edx
call   1060 <msgctl@plt>
test   %rax,%rax
jns    11d0 <main+0x60>
lea    0xe7b(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xe3f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xe47(%rip),%rdi
call   1040 <system@plt>
lea    0xe4a(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"USAGE: del_msgq.c <queue ID >\00"
@.str.1 = [8 x i8] c"ipcs -q\00"
@IPC_RMID = global i32 0
@.str.2 = [7 x i8] c"msgctl\00"
@.str.3 = [32 x i8] c"successfully removed %d queue\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 @puts(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %6
%17 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* %6
%19 = load i32, i32* @IPC_RMID
%20 = call i64 @msgctl(i32 %18, i32 %19, i32* null)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %12
%23 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %12
%26 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* %6
%28 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [30 x i8] c"USAGE: del_msgq.c <queue ID >\00"
@.str.1 = [8 x i8] c"ipcs -q\00"
@IPC_RMID = global i32 0
@.str.2 = [7 x i8] c"msgctl\00"
@.str.3 = [32 x i8] c"successfully removed %d queue\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = tail call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @IPC_RMID
%13 = tail call i64 @msgctl(i32 %10, i32 %12, i32* null)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %7
%16 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %7
%19 = tail call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%20 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%21 = tail call i32 @exit(i32 0)
unreachable
}