#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*/ O_RDWR;
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ mq_close(scalar_t__);
scalar_t__ mq_open(char *, int /*<<< orphan*/);
int mq_send(scalar_t__, char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
char *strerror(int);
void clientSend(void) {
  mqd_t cliHndl;
  int rc;
  printf("Client sending.\n");
  cliHndl = mq_open("/pax", O_RDWR);
  if (cliHndl < 0) {
    printf("   Error %d (%s) on client mq_open.\n", errno, strerror(errno));
    exit(1);
  }
  printf("   Client opened mqd_t of %d.\n", cliHndl);
  rc = mq_send(cliHndl, "Hello there!", sizeof("Hello there!"), 1);
  if (rc < 0) {
    printf("   Error %d (%s) on client mq_send.\n", errno, strerror(errno));
    exit(1);
  }
  mq_close(cliHndl);
}


x86 assembly (clang, -O0):
<clientSend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%esi
lea    0xe8b(%rip),%rdi
call   1060 <mq_open@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jge    11d2 <clientSend+0x72>
mov    0x2e37(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x10(%rbp),%esi
mov    %rax,%rdx
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rsi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe6b(%rip),%rsi
mov    $0xd,%edx
mov    $0x1,%ecx
call   1050 <mq_send@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1243 <clientSend+0xe3>
mov    0x2dc6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x14(%rbp),%esi
mov    %rax,%rdx
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1040 <mq_close@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clientSend>:
push   %rbx
lea    0xf03(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%esi
lea    0xe73(%rip),%rdi
call   1070 <mq_open@plt>
test   %rax,%rax
js     11d1 <clientSend+0x61>
mov    %rax,%rbx
lea    0xe89(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
mov    $0xd,%edx
mov    $0x1,%ecx
call   1060 <mq_send@plt>
test   %eax,%eax
js     11ea <clientSend+0x7a>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <mq_close@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1090 <strerror@plt>
lea    0xe1d(%rip),%rdi
jmp    1201 <clientSend+0x91>
mov    0x2de7(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1090 <strerror@plt>
lea    0xe55(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"Client sending.\0A\00"
@.str.1 = [5 x i8] c"/pax\00"
@O_RDWR = global i32 0
@.str.2 = [37 x i8] c" Error %d (%s) on client mq_open.\0A\00"
@errno = global i32 0
@.str.3 = [31 x i8] c" Client opened mqd_t of %d.\0A\00"
@.str.4 = [13 x i8] c"Hello there!\00"
@.str.5 = [37 x i8] c" Error %d (%s) on client mq_send.\0A\00"
define void @clientSend() {
%1 = alloca i64
%2 = alloca i32
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @O_RDWR
%5 = call i64 @mq_open(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %4)
store i64 %5, i64* %1
%6 = load i64, i64* %1
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %0
%9 = load i32, i32* @errno
%10 = load i32, i32* @errno
%11 = call i8* @strerror(i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %9, i8* %11)
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %0
%15 = load i64, i64* %1
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i64 %15)
%17 = load i64, i64* %1
%18 = call i32 @mq_send(i64 %17, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 13, i32 1)
store i32 %18, i32* %2
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %14
%22 = load i32, i32* @errno
%23 = load i32, i32* @errno
%24 = call i8* @strerror(i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %22, i8* %24)
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %14
%28 = load i64, i64* %1
%29 = call i32 @mq_close(i64 %28)
ret void
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"/pax\00"
@O_RDWR = global i32 0
@.str.2 = [37 x i8] c" Error %d (%s) on client mq_open.\0A\00"
@errno = global i32 0
@.str.3 = [31 x i8] c" Client opened mqd_t of %d.\0A\00"
@.str.4 = [13 x i8] c"Hello there!\00"
@.str.5 = [37 x i8] c" Error %d (%s) on client mq_send.\0A\00"
@str = [16 x i8] c"Client sending.\00"
define void @clientSend() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%2 = load i32, i32* @O_RDWR
%3 = tail call i64 @mq_open(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %0
%6 = load i32, i32* @errno
%7 = tail call i8* @strerror(i32 %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %6, i8* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i64 %3)
%12 = tail call i32 @mq_send(i64 %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 13, i32 1)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i32, i32* @errno
%16 = tail call i8* @strerror(i32 %15)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %15, i8* %16)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %10
%20 = tail call i32 @mq_close(i64 %3)
ret void
}