#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*/ mqd_t;

/* Variables and functions */
int /*<<< orphan*/ O_WRONLY;
void *atoi(char *);
scalar_t__ calloc(size_t, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ mq_open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ mq_send(int /*<<< orphan*/, char *, size_t, unsigned int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char **argv) {
  mqd_t mqd;
  char *ptr;
  size_t len;
  unsigned int prio;
  if (argc != 4) {
    perror("./mq_send mqueue_name size prio!\n");
  }
  len = atoi(argv[2]);
  prio = atoi(argv[3]);
  mqd = mq_open(argv[1], O_WRONLY);
  ptr = (char *)calloc(len, sizeof(char));
  strcpy(ptr, "Akagi201");
  mq_send(mqd, ptr, len, prio);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     119c <main+0x2c>
lea    0xe69(%rip),%rdi
call   1070 <perror@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e0c(%rip),%rax
mov    (%rax),%esi
call   1060 <mq_open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe2f(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
call   1040 <mq_send@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x4,%edi
je     118b <main+0x1b>
lea    0xe7a(%rip),%rdi
call   1070 <perror@plt>
mov    0x10(%rbx),%rdi
call   1080 <atoi@plt>
mov    %rax,%r14
mov    0x18(%rbx),%rdi
call   1080 <atoi@plt>
mov    %rax,%r15
mov    0x8(%rbx),%rdi
mov    0x2e2a(%rip),%rax
mov    (%rax),%esi
call   1060 <mq_open@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
lea    0xe54(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15d,%ecx
call   1040 <mq_send@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"./mq_send mqueue_name size prio!\0A\00"
@O_WRONLY = global i32 0
@.str.1 = [9 x i8] c"Akagi201\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 4
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
%18 = call i8* @atoi(i8* %17)
%19 = ptrtoint i8* %18 to i64
store i64 %19, i64* %8
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 3
%22 = load i8*, i8** %21
%23 = call i8* @atoi(i8* %22)
%24 = ptrtoint i8* %23 to i32
store i32 %24, i32* %9
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = load i32, i32* @O_WRONLY
%29 = call i32 @mq_open(i8* %27, i32 %28)
store i32 %29, i32* %6
%30 = load i64, i64* %8
%31 = call i64 @calloc(i64 %30, i32 1)
%32 = inttoptr i64 %31 to i8*
store i8* %32, i8** %7
%33 = load i8*, i8** %7
%34 = call i32 @strcpy(i8* %33, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%35 = load i32, i32* %6
%36 = load i8*, i8** %7
%37 = load i64, i64* %8
%38 = load i32, i32* %9
%39 = call i32 @mq_send(i32 %35, i8* %36, i64 %37, i32 %38)
%40 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [34 x i8] c"./mq_send mqueue_name size prio!\0A\00"
@O_WRONLY = global i32 0
@.str.1 = [9 x i8] c"Akagi201\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i8* @atoi(i8* %8)
%10 = ptrtoint i8* %9 to i64
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = tail call i8* @atoi(i8* %12)
%14 = ptrtoint i8* %13 to i64
%15 = trunc i64 %14 to i32
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = load i32, i32* @O_WRONLY
%19 = tail call i32 @mq_open(i8* %17, i32 %18)
%20 = tail call i64 @calloc(i64 %10, i32 1)
%21 = inttoptr i64 %20 to i8*
%22 = tail call i32 @strcpy(i8* %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%23 = tail call i32 @mq_send(i32 %19, i8* %21, i64 %10, i32 %15)
%24 = tail call i32 @exit(i32 0)
unreachable
}