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

/* Variables and functions */
int O_CREAT;
int O_NONBLOCK;
int O_RDONLY;
int /*<<< orphan*/ exit(int);
scalar_t__ mq_open(char *, int);
int /*<<< orphan*/ notifySetup(scalar_t__ *);
int /*<<< orphan*/ pause();
int /*<<< orphan*/ perror(char *);
int main(int argc, char *argv[]) {
  mqd_t mqd;
  mqd = mq_open("/mymq", O_CREAT | O_RDONLY | O_NONBLOCK);
  if (mqd == (mqd_t)-1) {
    perror("mq_open");
    exit(1);
  }
  notifySetup(&mqd);
  pause();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
mov    0x2e69(%rip),%rax
or     (%rax),%esi
mov    0x2e68(%rip),%rax
or     (%rax),%esi
lea    0xe7f(%rip),%rdi
call   1030 <mq_open@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0xffffffffffffffff,-0x18(%rbp)
jne    11ab <main+0x5b>
lea    0xe6a(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x18(%rbp),%rdi
call   1060 <notifySetup@plt>
mov    $0x0,%al
call   1040 <pause@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2ea0(%rip),%rax
mov    0x2e79(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e76(%rip),%rax
or     (%rax),%esi
lea    0xe8d(%rip),%rdi
call   1030 <mq_open@plt>
mov    %rax,(%rsp)
cmp    $0xffffffffffffffff,%rax
je     1195 <main+0x45>
mov    %rsp,%rdi
call   1060 <notifySetup@plt>
xor    %eax,%eax
call   1040 <pause@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe6a(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"/mymq\00"
@O_CREAT = global i32 0
@O_RDONLY = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [8 x i8] c"mq_open\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i64
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = load i32, i32* @O_CREAT
%7 = load i32, i32* @O_RDONLY
%8 = or i32 %6, %7
%9 = load i32, i32* @O_NONBLOCK
%10 = or i32 %8, %9
%11 = call i64 @mq_open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %10)
store i64 %11, i64* %5
%12 = load i64, i64* %5
%13 = icmp eq i64 %12, -1
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = call i32 @notifySetup(i64* %5)
%19 = call i32 (...) @pause()
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"/mymq\00"
@O_CREAT = global i32 0
@O_RDONLY = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [8 x i8] c"mq_open\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = load i32, i32* @O_CREAT
%6 = load i32, i32* @O_RDONLY
%7 = or i32 %6, %5
%8 = load i32, i32* @O_NONBLOCK
%9 = or i32 %7, %8
%10 = tail call i64 @mq_open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %9)
store i64 %10, i64* %3
%11 = icmp eq i64 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = call i32 @notifySetup(i64* %3)
%17 = call i32 (...) @pause()
ret i32 0
}