#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 IPC_CREAT;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int msgget(int /*<<< orphan*/, int);
int /*<<< orphan*/ service_key(char *);
int /*<<< orphan*/ stderr;
int Q(char *service_name) {
  int q;
  key_t key = service_key(service_name);
  q = msgget(key, IPC_CREAT | 0777);
  if (q < 0) {
    fprintf(stderr, "could not create a msgQ for '%s'\n", service_name);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<Q>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <service_key@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    0x2e76(%rip),%rax
mov    (%rax),%esi
or     $0x1ff,%esi
call   1030 <msgget@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    119f <Q+0x5f>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe70(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Q>:
push   %rbx
mov    %rdi,%rbx
call   1040 <service_key@plt>
mov    0x2e88(%rip),%rcx
mov    $0x1ff,%esi
or     (%rcx),%esi
mov    %eax,%edi
call   1030 <msgget@plt>
test   %eax,%eax
js     1164 <Q+0x24>
pop    %rbx
ret
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@IPC_CREAT = global i32 0
@stderr = global i32 0
@.str = [34 x i8] c"could not create a msgQ for '%s'\0A\00"
define i32 @Q(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @service_key(i8* %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = load i32, i32* @IPC_CREAT
%10 = or i32 %9, 511
%11 = call i32 @msgget(i32 %8, i32 %10)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %1
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %3
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %1
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@IPC_CREAT = global i32 0
@stderr = global i32 0
@.str = [34 x i8] c"could not create a msgQ for '%s'\0A\00"
define i32 @Q(i8* %0) {
%2 = tail call i32 @service_key(i8* %0)
%3 = load i32, i32* @IPC_CREAT
%4 = or i32 %3, 511
%5 = tail call i32 @msgget(i32 %2, i32 %4)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %0)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %1
ret i32 undef
}