#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 timeval {
  double tv_sec;
  double tv_usec;
};
typedef scalar_t__ mqd_t;

/* Variables and functions */
int O_NONBLOCK;
int O_RDWR;
double atof(char *);
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int mq_close(scalar_t__);
scalar_t__ mq_open(char *, int);
int mq_receive(scalar_t__, char *, int, int /*<<< orphan*/);
int mq_send(scalar_t__, char *, int, int /*<<< orphan*/);
int mq_unlink(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, double, ...);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
int sqrt(int);
int /*<<< orphan*/ stdout;
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  int N, P, id;
  double start_time, end_time;
  N = atoi(argv[1]);
  start_time = atof(argv[2]);
  P = atoi(argv[3]);
  id = atoi(argv[4]);
  struct timeval tv;
  mqd_t qdes;
  char *qname = "/m5mathew_mailbox";
  qdes = mq_open(qname, O_RDWR | O_NONBLOCK);
  if (qdes == (mqd_t)-1) {
    perror("mq_open() consumer reg queue failed");
    exit(1);
  }
  mqd_t qdes_cs;
  char *qname_cs = "/m5mathew_mailbox_cs";
  qdes_cs = mq_open(qname_cs, O_RDWR);
  if (qdes_cs == -1) {
    perror("mq_open() for consumption failed");
    exit(1);
  }
  char num_prod_cons[5];
  int producers, consumers, message, root_val;
  while (1) {
    if (mq_receive(qdes, (char *)&message, sizeof(int), 0) == -1) {
      if (mq_receive(qdes_cs, num_prod_cons, sizeof(int), 0) == -1) {
        perror("qdes_cs empty");
        fflush(stdout);
      } else {
        producers = atoi(strtok(num_prod_cons, " "));
        consumers = atoi(strtok(NULL, " "));
        if (producers == 0) {
          consumers--;
          sprintf(num_prod_cons, " %d %d ", producers, consumers);
          if (mq_send(qdes_cs, num_prod_cons, sizeof(int), 0) == -1) {
            perror("mq_send() failed");
          }
          break;
        } else {
          sprintf(num_prod_cons, " %d %d ", producers, consumers);
          if (mq_send(qdes_cs, num_prod_cons, sizeof(int), 0) == -1) {
            perror("mq_send() failed");
          }
        }
      }
    }
    root_val = sqrt(message);
    if (root_val * root_val == message) {
      printf("%i %i %i\n", id, message, root_val);
    }
  }
  if (consumers == 0) {
    gettimeofday(&tv, NULL);
    end_time = tv.tv_sec + tv.tv_usec / 1000000.0;
    double time_elapsed = end_time - start_time;
    printf("System execution time: %f", time_elapsed);
    if (mq_close(qdes) == -1) {
      perror("mq_close() failed");
      exit(2);
    }
    if (mq_unlink(qname) != 0) {
      perror("mq_unlink() failed");
      exit(3);
    }
    if (mq_close(qdes_cs) == -1) {
      perror("mq_close() failed");
      exit(2);
    }
    if (mq_unlink(qname_cs) == -1) {
      perror("mq_unlink() failed");
      exit(3);
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
lea    0xdb6(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
mov    0x2d87(%rip),%rax
mov    (%rax),%esi
mov    0x2d76(%rip),%rax
or     (%rax),%esi
call   1080 <mq_open@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0xffffffffffffffff,-0x48(%rbp)
jne    1296 <main+0xa6>
lea    0xd93(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    0xda1(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
mov    0x2d3c(%rip),%rax
mov    (%rax),%esi
call   1080 <mq_open@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0xffffffffffffffff,-0x58(%rbp)
jne    12d8 <main+0xe8>
lea    0xd8a(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
jmp    12dd <main+0xed>
mov    -0x48(%rbp),%rdi
lea    -0x74(%rbp),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   10a0 <mq_receive@plt>
cmp    $0xffffffff,%eax
jne    1411 <main+0x221>
mov    -0x58(%rbp),%rdi
lea    -0x65(%rbp),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   10a0 <mq_receive@plt>
cmp    $0xffffffff,%eax
jne    1336 <main+0x146>
lea    0xd56(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2ca6(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
jmp    140c <main+0x21c>
lea    -0x65(%rbp),%rdi
lea    0xd47(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x6c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd2c(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0x0,-0x6c(%rbp)
jne    13c3 <main+0x1d3>
mov    -0x70(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x70(%rbp)
lea    -0x65(%rbp),%rdi
mov    -0x6c(%rbp),%edx
mov    -0x70(%rbp),%ecx
lea    0xcf2(%rip),%rsi
call   10f0 <sprintf@plt>
mov    -0x58(%rbp),%rdi
lea    -0x65(%rbp),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1070 <mq_send@plt>
cmp    $0xffffffff,%eax
jne    13be <main+0x1ce>
lea    0xcd1(%rip),%rdi
call   10b0 <perror@plt>
jmp    144a <main+0x25a>
lea    -0x65(%rbp),%rdi
mov    -0x6c(%rbp),%edx
mov    -0x70(%rbp),%ecx
lea    0xcae(%rip),%rsi
call   10f0 <sprintf@plt>
mov    -0x58(%rbp),%rdi
lea    -0x65(%rbp),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1070 <mq_send@plt>
cmp    $0xffffffff,%eax
jne    1402 <main+0x212>
lea    0xc8d(%rip),%rdi
call   10b0 <perror@plt>
jmp    1407 <main+0x217>
jmp    140c <main+0x21c>
jmp    1411 <main+0x221>
mov    -0x74(%rbp),%edi
call   10e0 <sqrt@plt>
mov    %eax,-0x78(%rbp)
mov    -0x78(%rbp),%eax
imul   -0x78(%rbp),%eax
cmp    -0x74(%rbp),%eax
jne    1445 <main+0x255>
cvtsi2sdl -0x1c(%rbp),%xmm0
mov    -0x74(%rbp),%esi
mov    -0x78(%rbp),%edx
lea    0xc5d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    12dd <main+0xed>
cmpl   $0x0,-0x70(%rbp)
jne    1547 <main+0x357>
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  0xb8d(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
lea    0xc0a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1060 <mq_close@plt>
cmp    $0xffffffff,%eax
jne    14ca <main+0x2da>
lea    0xc04(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x2,%edi
call   1100 <exit@plt>
mov    -0x50(%rbp),%rdi
call   1110 <mq_unlink@plt>
cmp    $0x0,%eax
je     14f2 <main+0x302>
lea    0xbee(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x3,%edi
call   1100 <exit@plt>
mov    -0x58(%rbp),%rdi
call   1060 <mq_close@plt>
cmp    $0xffffffff,%eax
jne    151a <main+0x32a>
lea    0xbb4(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x2,%edi
call   1100 <exit@plt>
mov    -0x60(%rbp),%rdi
call   1110 <mq_unlink@plt>
cmp    $0xffffffff,%eax
jne    1542 <main+0x352>
lea    0xb9e(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x3,%edi
call   1100 <exit@plt>
jmp    1547 <main+0x357>
xor    %edi,%edi
call   1100 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x18(%rsp)
mov    0x20(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,%ebx
mov    0x2dc6(%rip),%rbp
mov    0x2db7(%rip),%rax
mov    (%rax),%esi
or     0x0(%rbp),%esi
lea    0xdd3(%rip),%rdi
call   1080 <mq_open@plt>
cmp    $0xffffffffffffffff,%rax
jne    1249 <main+0x59>
lea    0xdd3(%rip),%rdi
jmp    1268 <main+0x78>
mov    %rax,%r14
mov    0x0(%rbp),%esi
lea    0xde8(%rip),%rdi
call   1080 <mq_open@plt>
cmp    $0xffffffffffffffff,%rax
jne    1277 <main+0x87>
lea    0xdeb(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    %rax,%r15
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  %xmm0,0x20(%rsp)
lea    0xc(%rsp),%r12
lea    0x13(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   10a0 <mq_receive@plt>
cmp    $0xffffffff,%eax
jne    1334 <main+0x144>
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   10a0 <mq_receive@plt>
cmp    $0xffffffff,%eax
je     1367 <main+0x177>
mov    %r13,%rdi
lea    0xdac(%rip),%rbx
mov    %rbx,%rsi
call   10c0 <strtok@plt>
mov    %rax,%rdi
call   10d0 <atoi@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
mov    %rax,%rdi
call   10d0 <atoi@plt>
mov    %eax,%ebx
test   %ebp,%ebp
je     1391 <main+0x1a1>
mov    %r13,%rdi
lea    0xd6e(%rip),%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
call   10f0 <sprintf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1070 <mq_send@plt>
cmp    $0xffffffff,%eax
je     1383 <main+0x193>
mov    0xc(%rsp),%edi
call   10e0 <sqrt@plt>
mov    %eax,%esi
imul   %eax,%esi
cmp    0xc(%rsp),%esi
jne    12a0 <main+0xb0>
lea    0xd48(%rip),%rdi
movsd  0x20(%rsp),%xmm0
mov    %eax,%edx
mov    $0x1,%al
call   1040 <printf@plt>
jmp    12a0 <main+0xb0>
lea    0xd06(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c56(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
jmp    1334 <main+0x144>
lea    0xd00(%rip),%rdi
call   10b0 <perror@plt>
jmp    1334 <main+0x144>
add    $0xffffffff,%ebx
lea    0xce7(%rip),%rsi
lea    0x13(%rsp),%rbp
mov    %rbp,%rdi
xor    %edx,%edx
mov    %ebx,%ecx
call   10f0 <sprintf@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1070 <mq_send@plt>
cmp    $0xffffffff,%eax
jne    13cf <main+0x1df>
lea    0xcc0(%rip),%rdi
call   10b0 <perror@plt>
test   %ebx,%ebx
jne    1472 <main+0x282>
lea    0x28(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
movsd  0x30(%rsp),%xmm0
divsd  0xc0f(%rip),%xmm0
addsd  0x28(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
lea    0xca1(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r14,%rdi
call   1060 <mq_close@plt>
cmp    $0xffffffff,%eax
je     1435 <main+0x245>
lea    0xbe9(%rip),%rdi
call   1110 <mq_unlink@plt>
test   %eax,%eax
jne    145c <main+0x26c>
mov    %r15,%rdi
call   1060 <mq_close@plt>
cmp    $0xffffffff,%eax
jne    144b <main+0x25b>
lea    0xc83(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x2,%edi
call   1100 <exit@plt>
lea    0xbec(%rip),%rdi
call   1110 <mq_unlink@plt>
cmp    $0xffffffff,%eax
jne    1472 <main+0x282>
lea    0xc6e(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x3,%edi
call   1100 <exit@plt>
xor    %edi,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { double, double }
@.str = [18 x i8] c"/m5mathew_mailbox\00"
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [36 x i8] c"mq_open() consumer reg queue failed\00"
@.str.2 = [21 x i8] c"/m5mathew_mailbox_cs\00"
@.str.3 = [33 x i8] c"mq_open() for consumption failed\00"
@.str.4 = [14 x i8] c"qdes_cs empty\00"
@stdout = global i32 0
@.str.5 = [2 x i8] c" \00"
@.str.6 = [8 x i8] c" %d %d \00"
@.str.7 = [17 x i8] c"mq_send() failed\00"
@.str.8 = [10 x i8] c"%i %i %i\0A\00"
@.str.9 = [26 x i8] c"System execution time: %f\00"
@.str.10 = [18 x i8] c"mq_close() failed\00"
@.str.11 = [19 x i8] c"mq_unlink() failed\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca %struct.timeval
%12 = alloca i64
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i8*
%16 = alloca [5 x i8]
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %6
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call double @atof(i8* %28)
store double %29, double* %9
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 3
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %7
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 4
%36 = load i8*, i8** %35
%37 = call i32 @atoi(i8* %36)
store i32 %37, i32* %8
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8** %13
%38 = load i8*, i8** %13
%39 = load i32, i32* @O_RDWR
%40 = load i32, i32* @O_NONBLOCK
%41 = or i32 %39, %40
%42 = call i64 @mq_open(i8* %38, i32 %41)
store i64 %42, i64* %12
%43 = load i64, i64* %12
%44 = icmp eq i64 %43, -1
br i1 %44, label %45, label %48
45: ; preds = %2
%46 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %2
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8** %15
%49 = load i8*, i8** %15
%50 = load i32, i32* @O_RDWR
%51 = call i64 @mq_open(i8* %49, i32 %50)
store i64 %51, i64* %14
%52 = load i64, i64* %14
%53 = icmp eq i64 %52, -1
br i1 %53, label %54, label %57
54: ; preds = %48
%55 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %48
br label %58
58: ; preds = %57, %122
%59 = load i64, i64* %12
%60 = bitcast i32* %19 to i8*
%61 = call i32 @mq_receive(i64 %59, i8* %60, i32 4, i32 0)
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %108
63: ; preds = %58
%64 = load i64, i64* %14
%65 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 0
%66 = call i32 @mq_receive(i64 %64, i8* %65, i32 4, i32 0)
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %72
68: ; preds = %63
%69 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%70 = load i32, i32* @stdout
%71 = call i32 @fflush(i32 %70)
br label %107
72: ; preds = %63
%73 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 0
%74 = call i8* @strtok(i8* %73, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%75 = call i32 @atoi(i8* %74)
store i32 %75, i32* %17
%76 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%77 = call i32 @atoi(i8* %76)
store i32 %77, i32* %18
%78 = load i32, i32* %17
%79 = icmp eq i32 %78, 0
br i1 %79, label %80, label %94
80: ; preds = %72
%81 = load i32, i32* %18
%82 = add nsw i32 %81, -1
store i32 %82, i32* %18
%83 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 0
%84 = load i32, i32* %17
%85 = load i32, i32* %18
%86 = call i32 @sprintf(i8* %83, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %84, i32 %85)
%87 = load i64, i64* %14
%88 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 0
%89 = call i32 @mq_send(i64 %87, i8* %88, i32 4, i32 0)
%90 = icmp eq i32 %89, -1
br i1 %90, label %91, label %93
91: ; preds = %80
%92 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %93
93: ; preds = %91, %80
br label %123
94: ; preds = %72
%95 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 0
%96 = load i32, i32* %17
%97 = load i32, i32* %18
%98 = call i32 @sprintf(i8* %95, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %96, i32 %97)
%99 = load i64, i64* %14
%100 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 0
%101 = call i32 @mq_send(i64 %99, i8* %100, i32 4, i32 0)
%102 = icmp eq i32 %101, -1
br i1 %102, label %103, label %105
103: ; preds = %94
%104 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %105
105: ; preds = %103, %94
br label %106
106: ; preds = %105
br label %107
107: ; preds = %106, %68
br label %108
108: ; preds = %107, %58
%109 = load i32, i32* %19
%110 = call i32 @sqrt(i32 %109)
store i32 %110, i32* %20
%111 = load i32, i32* %20
%112 = load i32, i32* %20
%113 = mul nsw i32 %111, %112
%114 = load i32, i32* %19
%115 = icmp eq i32 %113, %114
br i1 %115, label %116, label %122
116: ; preds = %108
%117 = load i32, i32* %8
%118 = sitofp i32 %117 to double
%119 = load i32, i32* %19
%120 = load i32, i32* %20
%121 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), double %118, i32 %119, i32 %120)
br label %122
122: ; preds = %116, %108
br label %58
123: ; preds = %93
%124 = load i32, i32* %18
%125 = icmp eq i32 %124, 0
br i1 %125, label %126, label %167
126: ; preds = %123
%127 = call i32 @gettimeofday(%struct.timeval* %11, i32* null)
%128 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
%129 = load double, double* %128
%130 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
%131 = load double, double* %130
%132 = fdiv double %131, 1.000000e+06
%133 = fadd double %129, %132
store double %133, double* %10
%134 = load double, double* %10
%135 = load double, double* %9
%136 = fsub double %134, %135
store double %136, double* %21
%137 = load double, double* %21
%138 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), double %137)
%139 = load i64, i64* %12
%140 = call i32 @mq_close(i64 %139)
%141 = icmp eq i32 %140, -1
br i1 %141, label %142, label %145
142: ; preds = %126
%143 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%144 = call i32 @exit(i32 2)
unreachable
145: ; preds = %126
%146 = load i8*, i8** %13
%147 = call i32 @mq_unlink(i8* %146)
%148 = icmp ne i32 %147, 0
br i1 %148, label %149, label %152
149: ; preds = %145
%150 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%151 = call i32 @exit(i32 3)
unreachable
152: ; preds = %145
%153 = load i64, i64* %14
%154 = call i32 @mq_close(i64 %153)
%155 = icmp eq i32 %154, -1
br i1 %155, label %156, label %159
156: ; preds = %152
%157 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%158 = call i32 @exit(i32 2)
unreachable
159: ; preds = %152
%160 = load i8*, i8** %15
%161 = call i32 @mq_unlink(i8* %160)
%162 = icmp eq i32 %161, -1
br i1 %162, label %163, label %166
163: ; preds = %159
%164 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%165 = call i32 @exit(i32 3)
unreachable
166: ; preds = %159
br label %167
167: ; preds = %166, %123
%168 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
@.str = [18 x i8] c"/m5mathew_mailbox\00"
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [36 x i8] c"mq_open() consumer reg queue failed\00"
@.str.2 = [21 x i8] c"/m5mathew_mailbox_cs\00"
@.str.3 = [33 x i8] c"mq_open() for consumption failed\00"
@.str.4 = [14 x i8] c"qdes_cs empty\00"
@stdout = global i32 0
@.str.5 = [2 x i8] c" \00"
@.str.6 = [8 x i8] c" %d %d \00"
@.str.7 = [17 x i8] c"mq_send() failed\00"
@.str.8 = [10 x i8] c"%i %i %i\0A\00"
@.str.9 = [26 x i8] c"System execution time: %f\00"
@.str.10 = [18 x i8] c"mq_close() failed\00"
@.str.11 = [19 x i8] c"mq_unlink() failed\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = alloca [5 x i8]
%5 = alloca i32
%6 = getelementptr inbounds i8*, i8** %1, i64 2
%7 = load i8*, i8** %6
%8 = tail call double @atof(i8* %7)
%9 = getelementptr inbounds i8*, i8** %1, i64 4
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = bitcast %struct.timeval* %3 to i8*
%13 = load i32, i32* @O_RDWR
%14 = load i32, i32* @O_NONBLOCK
%15 = or i32 %14, %13
%16 = tail call i64 @mq_open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = icmp eq i64 %16, -1
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = tail call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i32, i32* @O_RDWR
%23 = tail call i64 @mq_open(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = icmp eq i64 %23, -1
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = tail call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %21
%29 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%30 = bitcast i32* %5 to i8*
%31 = sitofp i32 %11 to double
br label %32
32: ; preds = %69, %28
%33 = call i32 @mq_receive(i64 %16, i8* %30, i32 4, i32 0)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %61
35: ; preds = %32
%36 = call i32 @mq_receive(i64 %23, i8* %29, i32 4, i32 0)
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%40 = load i32, i32* @stdout
%41 = call i32 @fflush(i32 %40)
br label %61
42: ; preds = %35
%43 = call i8* @strtok(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%44 = call i32 @atoi(i8* %43)
%45 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%46 = call i32 @atoi(i8* %45)
%47 = icmp eq i32 %44, 0
br i1 %47, label %48, label %55
48: ; preds = %42
%49 = add nsw i32 %46, -1
%50 = call i32 @sprintf(i8* %29, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 0, i32 %49)
%51 = call i32 @mq_send(i64 %23, i8* %29, i32 4, i32 0)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %70
53: ; preds = %48
%54 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %70
55: ; preds = %42
%56 = call i32 @sprintf(i8* %29, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %44, i32 %46)
%57 = call i32 @mq_send(i64 %23, i8* %29, i32 4, i32 0)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %61
61: ; preds = %38, %55, %59, %32
%62 = load i32, i32* %5
%63 = call i32 @sqrt(i32 %62)
%64 = mul nsw i32 %63, %63
%65 = load i32, i32* %5
%66 = icmp eq i32 %64, %65
br i1 %66, label %67, label %69
67: ; preds = %61
%68 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), double %31, i32 %64, i32 %63)
br label %69
69: ; preds = %67, %61
br label %32
70: ; preds = %48, %53
%71 = icmp eq i32 %49, 0
br i1 %71, label %72, label %105
72: ; preds = %70
%73 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%74 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%75 = load double, double* %74
%76 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%77 = load double, double* %76
%78 = fdiv double %77, 1.000000e+06
%79 = fadd double %75, %78
%80 = fsub double %79, %8
%81 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), double %80)
%82 = call i32 @mq_close(i64 %16)
%83 = icmp eq i32 %82, -1
br i1 %83, label %84, label %87
84: ; preds = %72
%85 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%86 = call i32 @exit(i32 2)
unreachable
87: ; preds = %72
%88 = call i32 @mq_unlink(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%89 = icmp eq i32 %88, 0
br i1 %89, label %93, label %90
90: ; preds = %87
%91 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%92 = call i32 @exit(i32 3)
unreachable
93: ; preds = %87
%94 = call i32 @mq_close(i64 %23)
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %99
96: ; preds = %93
%97 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%98 = call i32 @exit(i32 2)
unreachable
99: ; preds = %93
%100 = call i32 @mq_unlink(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%101 = icmp eq i32 %100, -1
br i1 %101, label %102, label %105
102: ; preds = %99
%103 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%104 = call i32 @exit(i32 3)
unreachable
105: ; preds = %99, %70
%106 = call i32 @exit(i32 0)
unreachable
}