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

/* Variables and functions */
int errno;
int /*<<< orphan*/ exit(int);
int mq_receive(int, char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
char *strerror(int);
void serverReceive(mqd_t svrHndl) {
  int rc;
  char buffer[2048];
  printf("Server receiving on mqd_t %d.\n", svrHndl);
  rc = mq_receive(svrHndl, buffer, sizeof(buffer), NULL);
  if (rc < 0) {
    printf("   Error %d (%s) on server mq_receive.\n", errno, strerror(errno));
    exit(1);
  }
  printf("   Received [%s].\n", buffer);
}


x86 assembly (clang, -O0):
<serverReceive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x810(%rbp),%rsi
mov    $0x800,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <mq_receive@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11c2 <serverReceive+0x82>
mov    0x2e55(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x814(%rbp)
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x814(%rbp),%esi
mov    %rax,%rdx
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    -0x810(%rbp),%rsi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serverReceive>:
push   %rbx
sub    $0x800,%rsp
mov    %edi,%ebx
lea    0xeaf(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x800,%edx
xor    %ecx,%ecx
call   1040 <mq_receive@plt>
test   %eax,%eax
js     1189 <serverReceive+0x49>
lea    0xed1(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x800,%rsp
pop    %rbx
ret
mov    0x2e50(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1060 <strerror@plt>
lea    0xe7f(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"Server receiving on mqd_t %d.\0A\00"
@.str.1 = [40 x i8] c" Error %d (%s) on server mq_receive.\0A\00"
@errno = global i32 0
@.str.2 = [19 x i8] c" Received [%s].\0A\00"
define void @serverReceive(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2048 x i8]
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %2
%8 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%9 = call i32 @mq_receive(i32 %7, i8* %8, i32 2048, i32* null)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %1
%13 = load i32, i32* @errno
%14 = load i32, i32* @errno
%15 = call i8* @strerror(i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %13, i8* %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %1
%19 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %19)
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"Server receiving on mqd_t %d.\0A\00"
@.str.1 = [40 x i8] c" Error %d (%s) on server mq_receive.\0A\00"
@errno = global i32 0
@.str.2 = [19 x i8] c" Received [%s].\0A\00"
define void @serverReceive(i32 %0) {
%2 = alloca [2048 x i8]
%3 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %0)
%5 = call i32 @mq_receive(i32 %0, i8* %3, i32 2048, i32* null)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i32, i32* @errno
%9 = call i8* @strerror(i32 %8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %8, i8* %9)
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %1
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %3)
ret void
}