#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 */
struct mq_attr {
  int mq_maxmsg;
  int mq_msgsize;
  scalar_t__ mq_curmsgs;
  scalar_t__ mq_flags;
};
typedef scalar_t__ pid_t;
typedef scalar_t__ mqd_t;

/* Variables and functions */
int /*<<< orphan*/ O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int errno;
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ free(char *);
int getpid();
scalar_t__ malloc(int /*<<< orphan*/);
scalar_t__ mq_close(scalar_t__);
scalar_t__ mq_getattr(scalar_t__, struct mq_attr *);
scalar_t__ mq_open(char *, int /*<<< orphan*/, ...);
scalar_t__ mq_receive(scalar_t__, char *, int, int /*<<< orphan*/ *);
scalar_t__ mq_send(scalar_t__, char *, int, int);
scalar_t__ mq_unlink(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int);
int /*<<< orphan*/ wait(int *);
int main() {
  pid_t childid;
  int childec;
  mqd_t mqd;
  struct mq_attr attr;
  char *buffer;
  attr.mq_flags = 0;
  attr.mq_maxmsg = 10;
  attr.mq_msgsize = 1024;
  attr.mq_curmsgs = 0;
  mqd = mq_open("/yummypipe", O_CREAT, 0644, &attr);
  if (!(0 <= mqd))
    fprintf(stderr, "Error %s. Error : %s \n", "creating queue",
            strerror(errno));
  ;
  childid = fork();
  if (childid > 0) {
    printf("I'm parent. pid : %d\n", getpid());
    mqd = mq_open("/yummypipe", O_RDONLY);
    if (!(0 <= mqd))
      fprintf(stderr, "Error %s. Error : %s \n", "opening queue",
              strerror(errno));
    ;
    if (!(0 <= mq_getattr(mqd, &attr)))
      fprintf(stderr, "Error %s. Error : %s \n", "reading attributes",
              strerror(errno));
    ;
    buffer = (char *)malloc(attr.mq_msgsize + 1);
    if (!(0 <= mq_receive(mqd, buffer, attr.mq_msgsize, NULL)))
      fprintf(stderr, "Error %s. Error : %s \n", "reading queue",
              strerror(errno));
    ;
    wait(&childec);
    printf("waited for child, exit code : %d\n", childec);
    printf("Data received : %s \n", buffer);
    free(buffer);
    if (!(0 <= mq_close(mqd)))
      fprintf(stderr, "Error %s. Error : %s \n", "closing queue",
              strerror(errno));
    ;
    if (!(0 <= mq_unlink("/yummypipe")))
      fprintf(stderr, "Error %s. Error : %s \n", "unlinking queue",
              strerror(errno));
    ;
  } else if (childid == 0) {
    printf("I'm child. pid : %d\n", getpid());
    mqd = mq_open("/yummypipe", O_WRONLY);
    if (!(0 <= mqd))
      fprintf(stderr, "Error %s. Error : %s \n", "opening queue",
              strerror(errno));
    ;
    if (!(0 <= mq_send(mqd, "YOLO!", sizeof("YOLO!"), 1)))
      fprintf(stderr, "Error %s. Error : %s \n", "writing queue",
              strerror(errno));
    ;
    if (!(0 <= mq_close(mqd)))
      fprintf(stderr, "Error %s. Error : %s \n", "closing queue",
              strerror(errno));
    ;
  } else {
    printf("Failed to fork. Error code : %d \n", errno);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0xa,-0x38(%rbp)
movl   $0x400,-0x34(%rbp)
movq   $0x0,-0x30(%rbp)
mov    0x2de4(%rip),%rax
mov    (%rax),%esi
lea    0xde3(%rip),%rdi
mov    $0x1a4,%edx
lea    -0x38(%rbp),%rcx
mov    $0x0,%al
call   1090 <mq_open@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jle    1270 <main+0x90>
mov    0x2d8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    %rax,%rcx
lea    0xda7(%rip),%rsi
lea    0xdb7(%rip),%rdx
call   1080 <fprintf@plt>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jle    147a <main+0x29a>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d3c(%rip),%rax
mov    (%rax),%esi
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1090 <mq_open@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jle    12f7 <main+0x117>
mov    0x2d05(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2cf1(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x48(%rbp),%edi
mov    %rax,%rcx
lea    0xd20(%rip),%rsi
lea    0xd55(%rip),%rdx
call   1080 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1100 <mq_getattr@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    1345 <main+0x165>
mov    0x2cb7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    %rax,%rcx
lea    0xcd2(%rip),%rsi
lea    0xd15(%rip),%rdx
call   1080 <fprintf@plt>
mov    -0x34(%rbp),%edi
add    $0x1,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x34(%rbp),%edx
xor    %eax,%eax
mov    %eax,%ecx
call   10b0 <mq_receive@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    13a9 <main+0x1c9>
mov    0x2c53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2c3f(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x50(%rbp),%edi
mov    %rax,%rcx
lea    0xc6e(%rip),%rsi
lea    0xcc4(%rip),%rdx
call   1080 <fprintf@plt>
lea    -0x14(%rbp),%rdi
call   10e0 <wait@plt>
mov    -0x14(%rbp),%esi
lea    0xcba(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rsi
lea    0xcca(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1060 <mq_close@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    1428 <main+0x248>
mov    0x2bd4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    0x2bc0(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x54(%rbp),%edi
mov    %rax,%rcx
lea    0xbef(%rip),%rsi
lea    0xc8a(%rip),%rdx
call   1080 <fprintf@plt>
lea    0xbd1(%rip),%rdi
call   10c0 <mq_unlink@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    1475 <main+0x295>
mov    0x2b87(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    0x2b73(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x58(%rbp),%edi
mov    %rax,%rcx
lea    0xba2(%rip),%rsi
lea    0xc4b(%rip),%rdx
call   1080 <fprintf@plt>
jmp    15bc <main+0x3dc>
cmpq   $0x0,-0x10(%rbp)
jne    15a0 <main+0x3c0>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xc36(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2b15(%rip),%rax
mov    (%rax),%esi
lea    0xb54(%rip),%rdi
mov    $0x0,%al
call   1090 <mq_open@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jle    14f6 <main+0x316>
mov    0x2b06(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    0x2af2(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x5c(%rbp),%edi
mov    %rax,%rcx
lea    0xb21(%rip),%rsi
lea    0xb56(%rip),%rdx
call   1080 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xbdf(%rip),%rsi
mov    $0x6,%edx
mov    $0x1,%ecx
call   1070 <mq_send@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    1551 <main+0x371>
mov    0x2aab(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    0x2a97(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x60(%rbp),%edi
mov    %rax,%rcx
lea    0xac6(%rip),%rsi
lea    0xb9a(%rip),%rdx
call   1080 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <mq_close@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    159b <main+0x3bb>
mov    0x2a61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    0x2a4d(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x64(%rbp),%edi
mov    %rax,%rcx
lea    0xa7c(%rip),%rsi
lea    0xb17(%rip),%rdx
call   1080 <fprintf@plt>
jmp    15b7 <main+0x3d7>
mov    0x2a21(%rip),%rax
mov    (%rax),%esi
lea    0xb44(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    15bc <main+0x3dc>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movabs $0x4000000000a,%rax
mov    %rax,0x8(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x10(%rsp)
mov    0x2df2(%rip),%rax
mov    (%rax),%esi
lea    0xdf1(%rip),%rdi
lea    0x8(%rsp),%rcx
mov    $0x1a4,%edx
xor    %eax,%eax
call   1090 <mq_open@plt>
test   %rax,%rax
jns    1254 <main+0x74>
mov    0x2da4(%rip),%rax
mov    (%rax),%ebx
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xdc8(%rip),%rsi
lea    0xdd8(%rip),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
call   1080 <fprintf@plt>
xor    %eax,%eax
call   10f0 <fork@plt>
test   %rax,%rax
jle    1418 <main+0x238>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xdbf(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%esi
lea    0xd75(%rip),%rdi
xor    %eax,%eax
call   1090 <mq_open@plt>
mov    %rax,%r14
test   %rax,%rax
jns    12c9 <main+0xe9>
mov    0x2d2f(%rip),%rax
mov    (%rax),%ebx
mov    0x2d1e(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xd53(%rip),%rsi
lea    0xd88(%rip),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
call   1080 <fprintf@plt>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1100 <mq_getattr@plt>
test   %rax,%rax
jns    130a <main+0x12a>
mov    0x2cee(%rip),%rax
mov    (%rax),%ebx
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xd12(%rip),%rsi
lea    0xd55(%rip),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
call   1080 <fprintf@plt>
mov    0xc(%rsp),%edi
add    $0x1,%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%edx
mov    %r14,%rdi
mov    %rax,%rsi
xor    %ecx,%ecx
call   10b0 <mq_receive@plt>
test   %rax,%rax
jns    135e <main+0x17e>
mov    0x2c9a(%rip),%rax
mov    (%rax),%ebp
mov    0x2c89(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xcbe(%rip),%rsi
lea    0xd14(%rip),%rdx
mov    %ebp,%edi
mov    %rax,%rcx
call   1080 <fprintf@plt>
lea    0x4(%rsp),%rdi
call   10e0 <wait@plt>
mov    0x4(%rsp),%esi
lea    0xd03(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd17(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1060 <mq_close@plt>
test   %rax,%rax
jns    13cf <main+0x1ef>
mov    0x2c29(%rip),%rax
mov    (%rax),%ebx
mov    0x2c18(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xc4d(%rip),%rsi
lea    0xce8(%rip),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
call   1080 <fprintf@plt>
lea    0xc2a(%rip),%rdi
call   10c0 <mq_unlink@plt>
test   %rax,%rax
jns    14f5 <main+0x315>
mov    0x2be5(%rip),%rax
mov    (%rax),%ebx
mov    0x2bd4(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xc09(%rip),%rsi
lea    0xcb2(%rip),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
call   1080 <fprintf@plt>
jmp    14f5 <main+0x315>
je     1436 <main+0x256>
mov    0x2ba7(%rip),%rax
mov    (%rax),%esi
lea    0xcca(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    14f5 <main+0x315>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xc87(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2b64(%rip),%rax
mov    (%rax),%esi
lea    0xba3(%rip),%rdi
xor    %eax,%eax
call   1090 <mq_open@plt>
mov    %rax,%rbx
test   %rax,%rax
jns    149b <main+0x2bb>
mov    0x2b5d(%rip),%rax
mov    (%rax),%ebp
mov    0x2b4c(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xb81(%rip),%rsi
lea    0xbb6(%rip),%rdx
mov    %ebp,%edi
mov    %rax,%rcx
call   1080 <fprintf@plt>
lea    0xc3e(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
mov    $0x1,%ecx
call   1070 <mq_send@plt>
test   %rax,%rax
jns    14e8 <main+0x308>
mov    0x2b10(%rip),%rax
mov    (%rax),%ebp
mov    0x2aff(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xb34(%rip),%rsi
lea    0xc08(%rip),%rdx
mov    %ebp,%edi
mov    %rax,%rcx
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   1060 <mq_close@plt>
test   %rax,%rax
js     1500 <main+0x320>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2ac9(%rip),%rax
mov    (%rax),%ebx
mov    0x2ab8(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xaed(%rip),%rsi
lea    0xb88(%rip),%rdx
jmp    1409 <main+0x229>

LLVM IR (-O0):
%struct.mq_attr = type { i32, i32, i64, i64 }
@.str = [11 x i8] c"/yummypipe\00"
@O_CREAT = global i32 0
@stderr = global i32 0
@.str.1 = [23 x i8] c"Error %s. Error : %s \0A\00"
@.str.2 = [15 x i8] c"creating queue\00"
@errno = global i32 0
@.str.3 = [22 x i8] c"I'm parent. pid : %d\0A\00"
@O_RDONLY = global i32 0
@.str.4 = [14 x i8] c"opening queue\00"
@.str.5 = [19 x i8] c"reading attributes\00"
@.str.6 = [14 x i8] c"reading queue\00"
@.str.7 = [34 x i8] c"waited for child, exit code : %d\0A\00"
@.str.8 = [21 x i8] c"Data received : %s \0A\00"
@.str.9 = [14 x i8] c"closing queue\00"
@.str.10 = [16 x i8] c"unlinking queue\00"
@.str.11 = [21 x i8] c"I'm child. pid : %d\0A\00"
@O_WRONLY = global i32 0
@.str.12 = [6 x i8] c"YOLO!\00"
@.str.13 = [14 x i8] c"writing queue\00"
@.str.14 = [34 x i8] c"Failed to fork. Error code : %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca i64
%5 = alloca %struct.mq_attr
%6 = alloca i8*
store i32 0, i32* %1
%7 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %5, i32 0, i32 3
store i64 0, i64* %7
%8 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %5, i32 0, i32 0
store i32 10, i32* %8
%9 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %5, i32 0, i32 1
store i32 1024, i32* %9
%10 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %5, i32 0, i32 2
store i64 0, i64* %10
%11 = load i32, i32* @O_CREAT
%12 = call i64 (i8*, i32, ...) @mq_open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %11, i32 420, %struct.mq_attr* %5)
store i64 %12, i64* %4
%13 = load i64, i64* %4
%14 = icmp sle i64 0, %13
br i1 %14, label %20, label %15
15: ; preds = %0
%16 = load i32, i32* @stderr
%17 = load i32, i32* @errno
%18 = call i8* @strerror(i32 %17)
%19 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %15, %0
%21 = call i64 (...) @fork()
store i64 %21, i64* %2
%22 = load i64, i64* %2
%23 = icmp sgt i64 %22, 0
br i1 %23, label %24, label %87
24: ; preds = %20
%25 = call i32 (...) @getpid()
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load i32, i32* @O_RDONLY
%28 = call i64 (i8*, i32, ...) @mq_open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %27)
store i64 %28, i64* %4
%29 = load i64, i64* %4
%30 = icmp sle i64 0, %29
br i1 %30, label %36, label %31
31: ; preds = %24
%32 = load i32, i32* @stderr
%33 = load i32, i32* @errno
%34 = call i8* @strerror(i32 %33)
%35 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %31, %24
%37 = load i64, i64* %4
%38 = call i64 @mq_getattr(i64 %37, %struct.mq_attr* %5)
%39 = icmp sle i64 0, %38
br i1 %39, label %45, label %40
40: ; preds = %36
%41 = load i32, i32* @stderr
%42 = load i32, i32* @errno
%43 = call i8* @strerror(i32 %42)
%44 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %40, %36
%46 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %5, i32 0, i32 1
%47 = load i32, i32* %46
%48 = add nsw i32 %47, 1
%49 = call i64 @malloc(i32 %48)
%50 = inttoptr i64 %49 to i8*
store i8* %50, i8** %6
%51 = load i64, i64* %4
%52 = load i8*, i8** %6
%53 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %5, i32 0, i32 1
%54 = load i32, i32* %53
%55 = call i64 @mq_receive(i64 %51, i8* %52, i32 %54, i32* null)
%56 = icmp sle i64 0, %55
br i1 %56, label %62, label %57
57: ; preds = %45
%58 = load i32, i32* @stderr
%59 = load i32, i32* @errno
%60 = call i8* @strerror(i32 %59)
%61 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %60)
br label %62
62: ; preds = %57, %45
%63 = call i32 @wait(i32* %3)
%64 = load i32, i32* %3
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %64)
%66 = load i8*, i8** %6
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %66)
%68 = load i8*, i8** %6
%69 = call i32 @free(i8* %68)
%70 = load i64, i64* %4
%71 = call i64 @mq_close(i64 %70)
%72 = icmp sle i64 0, %71
br i1 %72, label %78, label %73
73: ; preds = %62
%74 = load i32, i32* @stderr
%75 = load i32, i32* @errno
%76 = call i8* @strerror(i32 %75)
%77 = call i32 @fprintf(i32 %74, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %76)
br label %78
78: ; preds = %73, %62
%79 = call i64 @mq_unlink(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%80 = icmp sle i64 0, %79
br i1 %80, label %86, label %81
81: ; preds = %78
%82 = load i32, i32* @stderr
%83 = load i32, i32* @errno
%84 = call i8* @strerror(i32 %83)
%85 = call i32 @fprintf(i32 %82, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %84)
br label %86
86: ; preds = %81, %78
br label %125
87: ; preds = %20
%88 = load i64, i64* %2
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %121
90: ; preds = %87
%91 = call i32 (...) @getpid()
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i32 %91)
%93 = load i32, i32* @O_WRONLY
%94 = call i64 (i8*, i32, ...) @mq_open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %93)
store i64 %94, i64* %4
%95 = load i64, i64* %4
%96 = icmp sle i64 0, %95
br i1 %96, label %102, label %97
97: ; preds = %90
%98 = load i32, i32* @stderr
%99 = load i32, i32* @errno
%100 = call i8* @strerror(i32 %99)
%101 = call i32 @fprintf(i32 %98, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %100)
br label %102
102: ; preds = %97, %90
%103 = load i64, i64* %4
%104 = call i64 @mq_send(i64 %103, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 6, i32 1)
%105 = icmp sle i64 0, %104
br i1 %105, label %111, label %106
106: ; preds = %102
%107 = load i32, i32* @stderr
%108 = load i32, i32* @errno
%109 = call i8* @strerror(i32 %108)
%110 = call i32 @fprintf(i32 %107, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i8* %109)
br label %111
111: ; preds = %106, %102
%112 = load i64, i64* %4
%113 = call i64 @mq_close(i64 %112)
%114 = icmp sle i64 0, %113
br i1 %114, label %120, label %115
115: ; preds = %111
%116 = load i32, i32* @stderr
%117 = load i32, i32* @errno
%118 = call i8* @strerror(i32 %117)
%119 = call i32 @fprintf(i32 %116, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %118)
br label %120
120: ; preds = %115, %111
br label %124
121: ; preds = %87
%122 = load i32, i32* @errno
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.14, i64 0, i64 0), i32 %122)
br label %124
124: ; preds = %121, %120
br label %125
125: ; preds = %124, %86
ret i32 0
}

LLVM IR (-O2):
%struct.mq_attr = type { i32, i32, i64, i64 }
@.str = [11 x i8] c"/yummypipe\00"
@O_CREAT = global i32 0
@stderr = global i32 0
@.str.1 = [23 x i8] c"Error %s. Error : %s \0A\00"
@.str.2 = [15 x i8] c"creating queue\00"
@errno = global i32 0
@.str.3 = [22 x i8] c"I'm parent. pid : %d\0A\00"
@O_RDONLY = global i32 0
@.str.4 = [14 x i8] c"opening queue\00"
@.str.5 = [19 x i8] c"reading attributes\00"
@.str.6 = [14 x i8] c"reading queue\00"
@.str.7 = [34 x i8] c"waited for child, exit code : %d\0A\00"
@.str.8 = [21 x i8] c"Data received : %s \0A\00"
@.str.9 = [14 x i8] c"closing queue\00"
@.str.10 = [16 x i8] c"unlinking queue\00"
@.str.11 = [21 x i8] c"I'm child. pid : %d\0A\00"
@O_WRONLY = global i32 0
@.str.12 = [6 x i8] c"YOLO!\00"
@.str.13 = [14 x i8] c"writing queue\00"
@.str.14 = [34 x i8] c"Failed to fork. Error code : %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.mq_attr
%3 = bitcast i32* %1 to i8*
%4 = bitcast %struct.mq_attr* %2 to i8*
%5 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %2, i64 0, i32 0
store i32 10, i32* %5
%6 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %2, i64 0, i32 1
store i32 1024, i32* %6
%7 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %2, i64 0, i32 2
%8 = bitcast i64* %7 to <2 x i64>*
store <2 x i64> zeroinitializer, <2 x i64>* %8
%9 = load i32, i32* @O_CREAT
%10 = call i64 (i8*, i32, ...) @mq_open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %9, i32 420, %struct.mq_attr* %2)
%11 = icmp sgt i64 %10, -1
br i1 %11, label %17, label %12
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = load i32, i32* @errno
%15 = call i8* @strerror(i32 %14)
%16 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %12, %0
%18 = call i64 (...) @fork()
%19 = icmp sgt i64 %18, 0
br i1 %19, label %20, label %73
20: ; preds = %17
%21 = call i32 (...) @getpid()
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = load i32, i32* @O_RDONLY
%24 = call i64 (i8*, i32, ...) @mq_open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = icmp sgt i64 %24, -1
br i1 %25, label %31, label %26
26: ; preds = %20
%27 = load i32, i32* @stderr
%28 = load i32, i32* @errno
%29 = call i8* @strerror(i32 %28)
%30 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %26, %20
%32 = call i64 @mq_getattr(i64 %24, %struct.mq_attr* %2)
%33 = icmp sgt i64 %32, -1
br i1 %33, label %39, label %34
34: ; preds = %31
%35 = load i32, i32* @stderr
%36 = load i32, i32* @errno
%37 = call i8* @strerror(i32 %36)
%38 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %34, %31
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
%42 = call i64 @malloc(i32 %41)
%43 = inttoptr i64 %42 to i8*
%44 = load i32, i32* %6
%45 = call i64 @mq_receive(i64 %24, i8* %43, i32 %44, i32* null)
%46 = icmp sgt i64 %45, -1
br i1 %46, label %52, label %47
47: ; preds = %39
%48 = load i32, i32* @stderr
%49 = load i32, i32* @errno
%50 = call i8* @strerror(i32 %49)
%51 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %47, %39
%53 = call i32 @wait(i32* %1)
%54 = load i32, i32* %1
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %54)
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %43)
%57 = call i32 @free(i8* %43)
%58 = call i64 @mq_close(i64 %24)
%59 = icmp sgt i64 %58, -1
br i1 %59, label %65, label %60
60: ; preds = %52
%61 = load i32, i32* @stderr
%62 = load i32, i32* @errno
%63 = call i8* @strerror(i32 %62)
%64 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %63)
br label %65
65: ; preds = %60, %52
%66 = call i64 @mq_unlink(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%67 = icmp sgt i64 %66, -1
br i1 %67, label %105, label %68
68: ; preds = %65
%69 = load i32, i32* @stderr
%70 = load i32, i32* @errno
%71 = call i8* @strerror(i32 %70)
%72 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %71)
br label %105
73: ; preds = %17
%74 = icmp eq i64 %18, 0
br i1 %74, label %75, label %102
75: ; preds = %73
%76 = call i32 (...) @getpid()
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i32 %76)
%78 = load i32, i32* @O_WRONLY
%79 = call i64 (i8*, i32, ...) @mq_open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %78)
%80 = icmp sgt i64 %79, -1
br i1 %80, label %86, label %81
81: ; preds = %75
%82 = load i32, i32* @stderr
%83 = load i32, i32* @errno
%84 = call i8* @strerror(i32 %83)
%85 = call i32 @fprintf(i32 %82, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %84)
br label %86
86: ; preds = %81, %75
%87 = call i64 @mq_send(i64 %79, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 6, i32 1)
%88 = icmp sgt i64 %87, -1
br i1 %88, label %94, label %89
89: ; preds = %86
%90 = load i32, i32* @stderr
%91 = load i32, i32* @errno
%92 = call i8* @strerror(i32 %91)
%93 = call i32 @fprintf(i32 %90, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i8* %92)
br label %94
94: ; preds = %89, %86
%95 = call i64 @mq_close(i64 %79)
%96 = icmp sgt i64 %95, -1
br i1 %96, label %105, label %97
97: ; preds = %94
%98 = load i32, i32* @stderr
%99 = load i32, i32* @errno
%100 = call i8* @strerror(i32 %99)
%101 = call i32 @fprintf(i32 %98, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %100)
br label %105
102: ; preds = %73
%103 = load i32, i32* @errno
%104 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.14, i64 0, i64 0), i32 %103)
br label %105
105: ; preds = %102, %97, %94, %65, %68
ret i32 0
}