#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;
int /*<<< orphan*/ Usage();
unsigned int atoi(char *);
int /*<<< orphan*/ mq_open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ mq_send(int /*<<< orphan*/, char *, size_t, unsigned int);
int strlen(char *);
int main(int argc, char **argv) {
  mqd_t mqdes;
  char *msg_str = NULL;
  size_t len;
  unsigned msg_prio;
  if (argc != 4) {
    Usage();
  }
  msg_str = argv[2];
  len = strlen(msg_str) + 1;
  msg_prio = atoi(argv[3]);
  mqdes = mq_open(argv[1], O_WRONLY);
  mq_send(mqdes, msg_str, len, msg_prio);
  return 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)
movq   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     117f <main+0x2f>
mov    $0x0,%al
call   1050 <Usage@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e1c(%rip),%rax
mov    (%rax),%esi
call   1060 <mq_open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
call   1040 <mq_send@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x4,%edi
je     1166 <main+0x16>
xor    %eax,%eax
call   1050 <Usage@plt>
mov    0x10(%rbx),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
movslq %eax,%r15
mov    0x18(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%rdi
mov    0x2e4a(%rip),%rax
mov    (%rax),%esi
call   1060 <mq_open@plt>
mov    %eax,%edi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %ebp,%ecx
call   1040 <mq_send@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_WRONLY = global i32 0
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
store i8* null, i8** %7
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 4
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (...) @Usage()
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
store i8* %17, i8** %7
%18 = load i8*, i8** %7
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %19, 1
%21 = sext i32 %20 to i64
store i64 %21, i64* %8
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 3
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %9
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = load i32, i32* @O_WRONLY
%30 = call i32 @mq_open(i8* %28, i32 %29)
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = load i8*, i8** %7
%33 = load i64, i64* %8
%34 = load i32, i32* %9
%35 = call i32 @mq_send(i32 %31, i8* %32, i64 %33, i32 %34)
ret i32 0
}

LLVM IR (-O2):
@O_WRONLY = global i32 0
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 (...) @Usage()
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32 @strlen(i8* %8)
%10 = add nsw i32 %9, 1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8*, i8** %1, i64 3
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = load i32, i32* @O_WRONLY
%18 = tail call i32 @mq_open(i8* %16, i32 %17)
%19 = tail call i32 @mq_send(i32 %18, i8* %8, i64 %11, i32 %14)
ret i32 0
}