#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 /*<<< orphan*/ EXIT_SUCCESS;
int O_WRONLY;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ mq_open(char *, int);
int mq_send(scalar_t__, char *, int, unsigned int);
int /*<<< orphan*/ perror(char *);
int main() {
  int flags, opt;
  mqd_t mqd;
  unsigned int prio = 60;
  flags = O_WRONLY;
  mqd = mq_open("/mymq", flags);
  if (mqd == (mqd_t)-1)
    perror("mq_open");
  if (mq_send(mqd, "writing message to queue", 25, prio) == -1)
    perror("mq_send");
  prio = 70;
  if (mq_send(mqd, "writing message to queue", 25, prio) == -1)
    perror("mq_send");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3c,-0x1c(%rbp)
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe94(%rip),%rdi
call   1040 <mq_open@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0xffffffffffffffff,-0x18(%rbp)
jne    118c <main+0x4c>
lea    0xe7f(%rip),%rdi
call   1050 <perror@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%ecx
lea    0xe74(%rip),%rsi
mov    $0x19,%edx
call   1030 <mq_send@plt>
cmp    $0xffffffff,%eax
jne    11b9 <main+0x79>
lea    0xe73(%rip),%rdi
call   1050 <perror@plt>
movl   $0x46,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%ecx
lea    0xe40(%rip),%rsi
mov    $0x19,%edx
call   1030 <mq_send@plt>
cmp    $0xffffffff,%eax
jne    11ed <main+0xad>
lea    0xe3f(%rip),%rdi
call   1050 <perror@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e88(%rip),%rax
mov    (%rax),%esi
lea    0xeaf(%rip),%rdi
call   1040 <mq_open@plt>
mov    %rax,%rbx
cmp    $0xffffffffffffffff,%rax
jne    116b <main+0x2b>
lea    0xea0(%rip),%rdi
call   1050 <perror@plt>
lea    0xe9c(%rip),%rsi
mov    %rbx,%rdi
mov    $0x19,%edx
mov    $0x3c,%ecx
call   1030 <mq_send@plt>
cmp    $0xffffffff,%eax
jne    1195 <main+0x55>
lea    0xe97(%rip),%rdi
call   1050 <perror@plt>
lea    0xe72(%rip),%rsi
mov    %rbx,%rdi
mov    $0x19,%edx
mov    $0x46,%ecx
call   1030 <mq_send@plt>
cmp    $0xffffffff,%eax
jne    11bf <main+0x7f>
lea    0xe6d(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@O_WRONLY = global i32 0
@.str = [6 x i8] c"/mymq\00"
@.str.1 = [8 x i8] c"mq_open\00"
@.str.2 = [25 x i8] c"writing message to queue\00"
@.str.3 = [8 x i8] c"mq_send\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
store i32 0, i32* %1
store i32 60, i32* %5
%6 = load i32, i32* @O_WRONLY
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = call i64 @mq_open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %7)
store i64 %8, i64* %4
%9 = load i64, i64* %4
%10 = icmp eq i64 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %0
%14 = load i64, i64* %4
%15 = load i32, i32* %5
%16 = call i32 @mq_send(i64 %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 25, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %18, %13
store i32 70, i32* %5
%21 = load i64, i64* %4
%22 = load i32, i32* %5
%23 = call i32 @mq_send(i64 %21, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 25, i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %20
%28 = load i32, i32* @EXIT_SUCCESS
%29 = call i32 @exit(i32 %28)
unreachable
}

LLVM IR (-O2):
@O_WRONLY = global i32 0
@.str = [6 x i8] c"/mymq\00"
@.str.1 = [8 x i8] c"mq_open\00"
@.str.2 = [25 x i8] c"writing message to queue\00"
@.str.3 = [8 x i8] c"mq_send\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = load i32, i32* @O_WRONLY
%2 = tail call i64 @mq_open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp eq i64 %2, -1
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %4, %0
%7 = tail call i32 @mq_send(i64 %2, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 25, i32 60)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
%12 = tail call i32 @mq_send(i64 %2, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 25, i32 70)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = load i32, i32* @EXIT_SUCCESS
%18 = tail call i32 @exit(i32 %17)
unreachable
}