#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 timespec {
  scalar_t__ tv_nsec;
  scalar_t__ tv_sec;
};
struct mq_attr {
  int mq_msgsize;
  int mq_maxmsg;
};
typedef scalar_t__ ssize_t;
typedef scalar_t__ mqd_t;

/* Variables and functions */
int O_CREAT;
int O_RDWR;
int S_IRUSR;
int S_IWUSR;
int getpid();
scalar_t__ mq_close(scalar_t__);
scalar_t__ mq_open(char *, int, int, struct mq_attr *);
scalar_t__ mq_send(scalar_t__, char const *, scalar_t__, int);
scalar_t__ mq_timedreceive(scalar_t__, char *, int, int /*<<< orphan*/ *,
                           struct timespec *);
scalar_t__ mq_unlink(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcmp(char *, char *);
scalar_t__ strlen(char const *);
scalar_t__ time(int /*<<< orphan*/ *);
int main(void) {
  char mqname[50], msgrv1[40], msgrv2[40];
  const char *msgptr1 = "test message1";
  const char *msgptr2 = "test message2 with differnet length";
  mqd_t mqdes;
  int prio1 = 1, prio2 = 2;
  struct timespec ts;
  struct mq_attr attr;
  int unresolved = 0, failure = 0;
  sprintf(mqname,
          "/"
          "mq_timedreceive"
          "_"
          "11-1"
          "_%d",
          getpid());
  attr.mq_msgsize = 40;
  attr.mq_maxmsg = 40;
  mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
  if (mqdes == (mqd_t)-1) {
    perror("unexpected error: "
           "mq_timedreceive"
           " "
           "11-1"
           ": "
           "mq_open");
    unresolved = 1;
  }
  if (mq_send(mqdes, msgptr1, strlen(msgptr1), prio1) != 0) {
    perror("unexpected error: "
           "mq_timedreceive"
           " "
           "11-1"
           ": "
           "mq_send");
    unresolved = 1;
  }
  if (mq_send(mqdes, msgptr2, strlen(msgptr2), prio2) != 0) {
    perror("unexpected error: "
           "mq_timedreceive"
           " "
           "11-1"
           ": "
           "mq_send");
    unresolved = 1;
  }
  ts.tv_sec = time(NULL) + 1;
  ts.tv_nsec = 0;
  if (mq_timedreceive(mqdes, msgrv1, 40, NULL, &ts) !=
      (ssize_t)strlen(msgptr2)) {
    printf("FAIL: mq_timedreceive didn't return the selected "
           "message size correctly\n");
    failure = 1;
  }
  if (mq_timedreceive(mqdes, msgrv2, 40, NULL, &ts) !=
      (ssize_t)strlen(msgptr1)) {
    printf("FAIL: mq_timedreceive didn't return the selected "
           "message size correctly\n");
    failure = 1;
  }
  if (!strcmp(msgrv1, msgrv2)) {
    printf("FAIL: mq_timedreceive received the same message "
           "twice\n");
    failure = 1;
  }
  if (mq_close(mqdes) != 0) {
    perror("unexpected error: "
           "mq_timedreceive"
           " "
           "11-1"
           ": "
           "mq_close");
    unresolved = 1;
  }
  if (mq_unlink(mqname) != 0) {
    perror("unexpected error: "
           "mq_timedreceive"
           " "
           "11-1"
           ": "
           "mq_unlink");
    unresolved = 1;
  }
  if (failure == 1) {
    printf("Test FAILED\n");
    return 1;
  }
  if (unresolved == 1) {
    printf("Test UNRESOLVED\n");
    return 2;
  }
  printf("Test PASSED\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe27(%rip),%rax
mov    %rax,-0xa8(%rbp)
lea    0xe27(%rip),%rax
mov    %rax,-0xb0(%rbp)
movl   $0x1,-0xbc(%rbp)
movl   $0x2,-0xc0(%rbp)
movl   $0x0,-0xdc(%rbp)
movl   $0x0,-0xe0(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0xe8(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0xe8(%rbp),%rdi
mov    %eax,%edx
lea    0xdfa(%rip),%rsi
call   10d0 <sprintf@plt>
movl   $0x28,-0xd8(%rbp)
movl   $0x28,-0xd4(%rbp)
lea    -0x40(%rbp),%rdi
mov    0x2d9c(%rip),%rax
mov    (%rax),%esi
mov    0x2d7b(%rip),%rax
or     (%rax),%esi
mov    0x2d5a(%rip),%rax
mov    (%rax),%edx
mov    0x2d61(%rip),%rax
or     (%rax),%edx
lea    -0xd8(%rbp),%rcx
call   10a0 <mq_open@plt>
mov    %rax,-0xb8(%rbp)
cmpq   $0xffffffffffffffff,-0xb8(%rbp)
ff
jne    12b0 <main+0xf0>
lea    0xdaa(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0xdc(%rbp)
mov    -0xb8(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    -0xa8(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    -0xa8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xf8(%rbp),%rdi
mov    -0xf0(%rbp),%rsi
mov    %rax,%rdx
mov    -0xbc(%rbp),%ecx
call   1080 <mq_send@plt>
cmp    $0x0,%rax
je     1314 <main+0x154>
lea    0xd76(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0xdc(%rbp)
mov    -0xb8(%rbp),%rax
mov    %rax,-0x108(%rbp)
mov    -0xb0(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    -0xb0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x108(%rbp),%rdi
mov    -0x100(%rbp),%rsi
mov    %rax,%rdx
mov    -0xc0(%rbp),%ecx
call   1080 <mq_send@plt>
cmp    $0x0,%rax
je     1378 <main+0x1b8>
lea    0xd12(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0xdc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <time@plt>
add    $0x1,%rax
mov    %rax,-0xc8(%rbp)
movq   $0x0,-0xd0(%rbp)
mov    -0xb8(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    $0x28,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0xd0(%rbp),%r8
call   1040 <mq_timedreceive@plt>
mov    %rax,-0x110(%rbp)
mov    -0xb0(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x110(%rbp),%rax
cmp    %rcx,%rax
je     13f3 <main+0x233>
lea    0xcc7(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0xe0(%rbp)
mov    -0xb8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x28,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0xd0(%rbp),%r8
call   1040 <mq_timedreceive@plt>
mov    %rax,-0x118(%rbp)
mov    -0xa8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x118(%rbp),%rax
cmp    %rcx,%rax
je     1452 <main+0x292>
lea    0xc68(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0xe0(%rbp)
lea    -0x70(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    1481 <main+0x2c1>
lea    0xc82(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0xe0(%rbp)
mov    -0xb8(%rbp),%rdi
call   1070 <mq_close@plt>
cmp    $0x0,%rax
je     14ad <main+0x2ed>
lea    0xc8d(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0xdc(%rbp)
lea    -0x40(%rbp),%rdi
call   10e0 <mq_unlink@plt>
cmp    $0x0,%rax
je     14d6 <main+0x316>
lea    0xc95(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0xdc(%rbp)
cmpl   $0x1,-0xe0(%rbp)
jne    14fb <main+0x33b>
lea    0xca4(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1533 <main+0x373>
cmpl   $0x1,-0xdc(%rbp)
jne    1520 <main+0x360>
lea    0xc8c(%rip),%rdi
call   1060 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1533 <main+0x373>
lea    0xc85(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xc0,%rsp
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe66(%rip),%rsi
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
mov    %eax,%edx
call   10c0 <sprintf@plt>
movabs $0x2800000028,%rax
mov    %rax,0x8(%rsp)
mov    0x2e04(%rip),%rax
mov    0x2de5(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2dc2(%rip),%rax
mov    0x2dcb(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
call   1090 <mq_open@plt>
mov    %rax,%rbx
cmp    $0xffffffffffffffff,%rax
je     1376 <main+0x1c6>
lea    0xdce(%rip),%rsi
mov    $0xd,%edx
mov    %rbx,%rdi
mov    $0x1,%ecx
call   1070 <mq_send@plt>
test   %rax,%rax
jne    138d <main+0x1dd>
lea    0xdba(%rip),%rsi
mov    $0x23,%edx
mov    %rbx,%rdi
mov    $0x2,%ecx
call   1070 <mq_send@plt>
test   %rax,%rax
jne    13a4 <main+0x1f4>
xor    %ebp,%ebp
xor    %edi,%edi
call   10a0 <time@plt>
add    $0x1,%rax
mov    %rax,0x18(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x50(%rsp),%rsi
lea    0x10(%rsp),%r8
mov    %rbx,%rdi
mov    $0x28,%edx
xor    %ecx,%ecx
call   1050 <mq_timedreceive@plt>
cmp    $0x23,%rax
je     12ba <main+0x10a>
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
lea    0x20(%rsp),%rsi
lea    0x10(%rsp),%r8
mov    %rbx,%rdi
mov    $0x28,%edx
xor    %ecx,%ecx
call   1050 <mq_timedreceive@plt>
cmp    $0xd,%rax
je     12ea <main+0x13a>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
lea    0x50(%rsp),%rdi
lea    0x20(%rsp),%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
jne    130e <main+0x15e>
lea    0xe0a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
mov    %rbx,%rdi
call   1060 <mq_close@plt>
test   %rax,%rax
jne    13bb <main+0x20b>
lea    0x80(%rsp),%rdi
call   10d0 <mq_unlink@plt>
test   %rax,%rax
jne    13d2 <main+0x222>
test   %ebp,%ebp
je     1347 <main+0x197>
mov    $0x1,%ebx
lea    0xe1b(%rip),%rdi
jmp    1363 <main+0x1b3>
test   %r14d,%r14d
je     135a <main+0x1aa>
mov    $0x2,%ebx
lea    0xdf8(%rip),%rdi
jmp    1363 <main+0x1b3>
xor    %ebx,%ebx
lea    0xde1(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0xc0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xcce(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%r14d
jmp    122b <main+0x7b>
lea    0xce7(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%r14d
jmp    124d <main+0x9d>
lea    0xcd0(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%r14d
jmp    126f <main+0xbf>
lea    0xce9(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%r14d
jmp    131f <main+0x16f>
lea    0xd03(%rip),%rdi
call   10b0 <perror@plt>
test   %ebp,%ebp
jne    1339 <main+0x189>
jmp    134c <main+0x19c>

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
%struct.mq_attr = type { i32, i32 }
@.str = [14 x i8] c"test message1\00"
@.str.1 = [36 x i8] c"test message2 with differnet length\00"
@.str.2 = [25 x i8] c"/mq_timedreceive_11-1_%d\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.3 = [48 x i8] c"unexpected error: mq_timedreceive 11-1: mq_open\00"
@.str.4 = [48 x i8] c"unexpected error: mq_timedreceive 11-1: mq_send\00"
@.str.5 = [73 x i8] c"FAIL: mq_timedreceive didn't return the selected message size correctly\0A\00"
@.str.6 = [55 x i8] c"FAIL: mq_timedreceive received the same message twice\0A\00"
@.str.7 = [49 x i8] c"unexpected error: mq_timedreceive 11-1: mq_close\00"
@.str.8 = [50 x i8] c"unexpected error: mq_timedreceive 11-1: mq_unlink\00"
@.str.9 = [13 x i8] c"Test FAILED\0A\00"
@.str.10 = [17 x i8] c"Test UNRESOLVED\0A\00"
@.str.11 = [13 x i8] c"Test PASSED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca [40 x i8]
%4 = alloca [40 x i8]
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.timespec
%11 = alloca %struct.mq_attr
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8** %6
store i32 1, i32* %8
store i32 2, i32* %9
store i32 0, i32* %12
store i32 0, i32* %13
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%15 = call i32 (...) @getpid()
%16 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %11, i32 0, i32 0
store i32 40, i32* %17
%18 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %11, i32 0, i32 1
store i32 40, i32* %18
%19 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%20 = load i32, i32* @O_CREAT
%21 = load i32, i32* @O_RDWR
%22 = or i32 %20, %21
%23 = load i32, i32* @S_IRUSR
%24 = load i32, i32* @S_IWUSR
%25 = or i32 %23, %24
%26 = call i64 @mq_open(i8* %19, i32 %22, i32 %25, %struct.mq_attr* %11)
store i64 %26, i64* %7
%27 = load i64, i64* %7
%28 = icmp eq i64 %27, -1
br i1 %28, label %29, label %31
29: ; preds = %0
%30 = call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %12
br label %31
31: ; preds = %29, %0
%32 = load i64, i64* %7
%33 = load i8*, i8** %5
%34 = load i8*, i8** %5
%35 = call i64 @strlen(i8* %34)
%36 = load i32, i32* %8
%37 = call i64 @mq_send(i64 %32, i8* %33, i64 %35, i32 %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %31
%40 = call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %12
br label %41
41: ; preds = %39, %31
%42 = load i64, i64* %7
%43 = load i8*, i8** %6
%44 = load i8*, i8** %6
%45 = call i64 @strlen(i8* %44)
%46 = load i32, i32* %9
%47 = call i64 @mq_send(i64 %42, i8* %43, i64 %45, i32 %46)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %41
%50 = call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %12
br label %51
51: ; preds = %49, %41
%52 = call i64 @time(i32* null)
%53 = add nsw i64 %52, 1
%54 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 1
store i64 %53, i64* %54
%55 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 0
store i64 0, i64* %55
%56 = load i64, i64* %7
%57 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%58 = call i64 @mq_timedreceive(i64 %56, i8* %57, i32 40, i32* null, %struct.timespec* %10)
%59 = load i8*, i8** %6
%60 = call i64 @strlen(i8* %59)
%61 = icmp ne i64 %58, %60
br i1 %61, label %62, label %64
62: ; preds = %51
%63 = call i32 @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %13
br label %64
64: ; preds = %62, %51
%65 = load i64, i64* %7
%66 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%67 = call i64 @mq_timedreceive(i64 %65, i8* %66, i32 40, i32* null, %struct.timespec* %10)
%68 = load i8*, i8** %5
%69 = call i64 @strlen(i8* %68)
%70 = icmp ne i64 %67, %69
br i1 %70, label %71, label %73
71: ; preds = %64
%72 = call i32 @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %13
br label %73
73: ; preds = %71, %64
%74 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%75 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%76 = call i32 @strcmp(i8* %74, i8* %75)
%77 = icmp ne i32 %76, 0
br i1 %77, label %80, label %78
78: ; preds = %73
%79 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %13
br label %80
80: ; preds = %78, %73
%81 = load i64, i64* %7
%82 = call i64 @mq_close(i64 %81)
%83 = icmp ne i64 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %80
%85 = call i32 @perror(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %12
br label %86
86: ; preds = %84, %80
%87 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%88 = call i64 @mq_unlink(i8* %87)
%89 = icmp ne i64 %88, 0
br i1 %89, label %90, label %92
90: ; preds = %86
%91 = call i32 @perror(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %12
br label %92
92: ; preds = %90, %86
%93 = load i32, i32* %13
%94 = icmp eq i32 %93, 1
br i1 %94, label %95, label %97
95: ; preds = %92
%96 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %1
br label %104
97: ; preds = %92
%98 = load i32, i32* %12
%99 = icmp eq i32 %98, 1
br i1 %99, label %100, label %102
100: ; preds = %97
%101 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
store i32 2, i32* %1
br label %104
102: ; preds = %97
%103 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %1
br label %104
104: ; preds = %102, %100, %95
%105 = load i32, i32* %1
ret i32 %105
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
%struct.mq_attr = type { i32, i32 }
@.str = [14 x i8] c"test message1\00"
@.str.1 = [36 x i8] c"test message2 with differnet length\00"
@.str.2 = [25 x i8] c"/mq_timedreceive_11-1_%d\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.3 = [48 x i8] c"unexpected error: mq_timedreceive 11-1: mq_open\00"
@.str.4 = [48 x i8] c"unexpected error: mq_timedreceive 11-1: mq_send\00"
@.str.7 = [49 x i8] c"unexpected error: mq_timedreceive 11-1: mq_close\00"
@.str.8 = [50 x i8] c"unexpected error: mq_timedreceive 11-1: mq_unlink\00"
@str = [54 x i8] c"FAIL: mq_timedreceive received the same message twice\00"
@str.12 = [12 x i8] c"Test PASSED\00"
@str.13 = [16 x i8] c"Test UNRESOLVED\00"
@str.14 = [12 x i8] c"Test FAILED\00"
@str.16 = [72 x i8] c"FAIL: mq_timedreceive didn't return the selected message size correctly\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [40 x i8]
%3 = alloca [40 x i8]
%4 = alloca %struct.timespec
%5 = alloca %struct.mq_attr
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%9 = bitcast %struct.timespec* %4 to i8*
%10 = bitcast %struct.mq_attr* %5 to i8*
%11 = tail call i32 (...) @getpid()
%12 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %5, i64 0, i32 0
store i32 40, i32* %13
%14 = getelementptr inbounds %struct.mq_attr, %struct.mq_attr* %5, i64 0, i32 1
store i32 40, i32* %14
%15 = load i32, i32* @O_CREAT
%16 = load i32, i32* @O_RDWR
%17 = or i32 %16, %15
%18 = load i32, i32* @S_IRUSR
%19 = load i32, i32* @S_IWUSR
%20 = or i32 %19, %18
%21 = call i64 @mq_open(i8* %6, i32 %17, i32 %20, %struct.mq_attr* %5)
%22 = icmp eq i64 %21, -1
br i1 %22, label %23, label %25
23: ; preds = %0
%24 = call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %23, %0
%26 = phi i32 [ 1, %23 ], [ 0, %0 ]
%27 = call i64 @mq_send(i64 %21, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 13, i32 1)
%28 = icmp eq i64 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %29, %25
%32 = phi i32 [ 1, %29 ], [ %26, %25 ]
%33 = call i64 @mq_send(i64 %21, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i64 35, i32 2)
%34 = icmp eq i64 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %31
%36 = call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
br label %37
37: ; preds = %35, %31
%38 = phi i32 [ 1, %35 ], [ %32, %31 ]
%39 = call i64 @time(i32* null)
%40 = add nsw i64 %39, 1
%41 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 1
store i64 %40, i64* %41
%42 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 0
store i64 0, i64* %42
%43 = call i64 @mq_timedreceive(i64 %21, i8* %7, i32 40, i32* null, %struct.timespec* %4)
%44 = icmp eq i64 %43, 35
br i1 %44, label %47, label %45
45: ; preds = %37
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @str.16, i64 0, i64 0))
br label %47
47: ; preds = %45, %37
%48 = phi i32 [ 1, %45 ], [ 0, %37 ]
%49 = call i64 @mq_timedreceive(i64 %21, i8* %8, i32 40, i32* null, %struct.timespec* %4)
%50 = icmp eq i64 %49, 13
br i1 %50, label %53, label %51
51: ; preds = %47
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @str.16, i64 0, i64 0))
br label %53
53: ; preds = %51, %47
%54 = phi i32 [ 1, %51 ], [ %48, %47 ]
%55 = call i32 @strcmp(i8* %7, i8* %8)
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %53
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
br label %59
59: ; preds = %57, %53
%60 = phi i32 [ %54, %53 ], [ 1, %57 ]
%61 = call i64 @mq_close(i64 %21)
%62 = icmp eq i64 %61, 0
br i1 %62, label %65, label %63
63: ; preds = %59
%64 = call i32 @perror(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0))
br label %65
65: ; preds = %63, %59
%66 = phi i32 [ 1, %63 ], [ %38, %59 ]
%67 = call i64 @mq_unlink(i8* %6)
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %65
%70 = icmp eq i32 %60, 1
br i1 %70, label %77, label %74
71: ; preds = %65
%72 = call i32 @perror(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.8, i64 0, i64 0))
%73 = icmp eq i32 %60, 1
br i1 %73, label %77, label %76
74: ; preds = %69
%75 = icmp eq i32 %66, 1
br i1 %75, label %76, label %77
76: ; preds = %71, %74
br label %77
77: ; preds = %74, %69, %71, %76
%78 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.13, i64 0, i64 0), %76 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.14, i64 0, i64 0), %71 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.14, i64 0, i64 0), %69 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.12, i64 0, i64 0), %74 ]
%79 = phi i32 [ 2, %76 ], [ 1, %71 ], [ 1, %69 ], [ 0, %74 ]
%80 = call i32 @puts(i8* dereferenceable(1) %78)
ret i32 %79
}