#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;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ Usage();
unsigned int atoi(char *);
int /*<<< orphan*/ mq_open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ mq_receive(int /*<<< orphan*/, char *, int, unsigned int *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  mqd_t mqdes;
  char buf[128];
  size_t len;
  unsigned msg_prio;
  if (argc != 3) {
    Usage();
  }
  msg_prio = atoi(argv[2]);
  mqdes = mq_open(argv[1], O_RDONLY);
  mq_receive(mqdes, buf, sizeof(buf), &msg_prio);
  printf("Recv: %s\n", buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     117a <main+0x2a>
mov    $0x0,%al
call   1040 <Usage@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0xac(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e4c(%rip),%rax
mov    (%rax),%esi
call   1050 <mq_open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x80,%edx
lea    -0xac(%rbp),%rcx
call   1060 <mq_receive@plt>
lea    -0xa0(%rbp),%rsi
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x90,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
je     1167 <main+0x17>
xor    %eax,%eax
call   1040 <Usage@plt>
mov    0x10(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,0xc(%rsp)
mov    0x8(%rbx),%rdi
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
call   1050 <mq_open@plt>
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%rcx
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x80,%edx
call   1060 <mq_receive@plt>
lea    0xe5a(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [10 x i8] c"Recv: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [128 x 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, 3
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
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %9
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = load i32, i32* @O_RDONLY
%23 = call i32 @mq_open(i8* %21, i32 %22)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%26 = call i32 @mq_receive(i32 %24, i8* %25, i32 128, i32* %9)
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%28 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %27)
ret i32 0
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [10 x i8] c"Recv: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = icmp eq i32 %0, 3
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 (...) @Usage()
br label %10
10: ; preds = %8, %2
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
store i32 %13, i32* %4
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @O_RDONLY
%17 = tail call i32 @mq_open(i8* %15, i32 %16)
%18 = call i32 @mq_receive(i32 %17, i8* %5, i32 128, i32* %4)
%19 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %5)
ret i32 0
}