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

/* Variables and functions */
int IPC_CREAT;
int /*<<< orphan*/ exit(int);
int msgget(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ system(char *);
int main(void) {
  int qid;
  key_t key;
  key = 112;
  qid = msgget(key, IPC_CREAT | 0666);
  if (qid < 0) {
    perror("msgget");
    exit(1);
  }
  printf("created queue id : %d \n", qid);
  system("ipcs -q");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x70,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2e70(%rip),%rax
mov    (%rax),%esi
or     $0x1b6,%esi
call   1030 <msgget@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11a0 <main+0x50>
lea    0xe6f(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%esi
lea    0xe5d(%rip),%rdi
call   1050 <printf@plt>
lea    0xe69(%rip),%rdi
call   1040 <system@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e88(%rip),%rax
mov    $0x1b6,%esi
or     (%rax),%esi
mov    $0x70,%edi
call   1030 <msgget@plt>
test   %eax,%eax
jns    1183 <main+0x33>
lea    0xe8c(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe7d(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
lea    0xe87(%rip),%rdi
call   1040 <system@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@IPC_CREAT = global i32 0
@.str = [7 x i8] c"msgget\00"
@.str.1 = [24 x i8] c"created queue id : %d \0A\00"
@.str.2 = [8 x i8] c"ipcs -q\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 112, i32* %3
%4 = load i32, i32* %3
%5 = load i32, i32* @IPC_CREAT
%6 = or i32 %5, 438
%7 = call i32 @msgget(i32 %4, i32 %6)
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %0
%14 = load i32, i32* %2
%15 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@IPC_CREAT = global i32 0
@.str = [7 x i8] c"msgget\00"
@.str.1 = [24 x i8] c"created queue id : %d \0A\00"
@.str.2 = [8 x i8] c"ipcs -q\00"
define i32 @main() {
%1 = load i32, i32* @IPC_CREAT
%2 = or i32 %1, 438
%3 = tail call i32 @msgget(i32 112, i32 %2)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%10 = tail call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @exit(i32 0)
unreachable
}