#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 {
  int tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ TIMER_ABSTIME;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ clock_nanosleep(int /*<<< orphan*/, int /*<<< orphan*/,
                                   struct timespec *, int /*<<< orphan*/ *);
int decode(char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getBinaryData(char *, int, int);
int /*<<< orphan*/ popElement1(char *);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ pthread_exit(char *);
int pushElement2(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int /*<<< orphan*/ tnorm(struct timespec *);
void *msg_io(void *arg) {
  int cmd, i, j = 0, res;
  int data0, data1, data2, data3;
  int data4, data5, data6, data7;
  char msg[50] = "", oldPKMsg[50] = "", oldKPMsg[50] = "";
  char word[(64)] = "", wordk[(64)] = "";
  long unsigned index = 0;
  struct timespec t;
  strncpy(wordk,
          "1111111111111111111111111111111111111111111111111111111111111111",
          (64));
  clock_gettime(CLOCK_MONOTONIC, &t);
  while (1) {
    t.tv_nsec += (5000000);
    ;
    tnorm(&t);
    clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &t, NULL);
    for (i = 0; i < (64); i++)
      popElement1(&word[i]);
    cmd = decode(word, msg);
    data0 = getBinaryData(word, 0, 8);
    data1 = getBinaryData(word, 8, 8);
    data2 = getBinaryData(word, 16, 8);
    data3 = getBinaryData(word, 24, 8);
    data4 = getBinaryData(word, 32, 8);
    data5 = getBinaryData(word, 40, 8);
    data6 = getBinaryData(word, 48, 8);
    data7 = getBinaryData(word, 56, 8);
    if ((cmd == 0xff && strcmp(msg, oldKPMsg) != 0) ||
        (cmd != 0xff && strcmp(msg, oldPKMsg) != 0)) {
      printf("index:%lu,%-50s", index++, msg);
      printf(" data: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
             data0, data1, data2, data3, data4, data5, data6, data7);
      fflush(stdout);
      if (cmd == 0xff)
        strcpy(oldKPMsg, msg);
      else
        strcpy(oldPKMsg, msg);
    }
    if (j == 400) {
      strncpy(
          wordk,
          "1111111111111111111111111111111111111111111111111111111111111111",
          (64));
      for (i = 0; i < (64); i++) {
        res = pushElement2(&wordk[i]);
        if (res == 0) {
          fprintf(stderr, "msg_io: fifo write error\n");
          exit(EXIT_FAILURE);
        }
      }
    } else if (j == 800) {
      strncpy(
          wordk,
          "1111111111111111111111111111111111111111111111111111111111111111",
          (64));
      for (i = 0; i < (64); i++) {
        res = pushElement2(&wordk[i]);
        if (res == 0) {
          fprintf(stderr, "msg_io: fifo write error\n");
          exit(EXIT_FAILURE);
        }
      }
    } else if (j == 1200) {
      strncpy(
          wordk,
          "1111111111111111111111111111111111111111111111111111111111111111",
          (64));
      for (i = 0; i < (64); i++) {
        res = pushElement2(&wordk[i]);
        if (res == 0) {
          fprintf(stderr, "msg_io: fifo write error\n");
          exit(EXIT_FAILURE);
        }
      }
    } else if (j == 1600) {
      strncpy(
          wordk,
          "1111111111111111111111111111111111111111111111111111111111111111",
          (64));
      for (i = 0; i < (64); i++) {
        res = pushElement2(&wordk[i]);
        if (res == 0) {
          fprintf(stderr, "msg_io: fifo write error\n");
          exit(EXIT_FAILURE);
        }
      }
    }
    if (j < 2000)
      j++;
    else
      j = 0;
  }
  pthread_exit("message io thread finished");
}


x86 assembly (clang, -O0):
<msg_io>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1070 <memset@plt>
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1070 <memset@plt>
lea    -0xf0(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1070 <memset@plt>
lea    -0x130(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    -0x170(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
movq   $0x0,-0x178(%rbp)
lea    -0x170(%rbp),%rdi
lea    0xd85(%rip),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
lea    -0x180(%rbp),%rsi
call   1050 <clock_gettime@plt>
mov    -0x180(%rbp),%eax
add    $0x4c4b40,%eax
mov    %eax,-0x180(%rbp)
lea    -0x180(%rbp),%rdi
call   10f0 <tnorm@plt>
mov    0x2d22(%rip),%rax
mov    (%rax),%edi
mov    0x2d21(%rip),%rax
mov    (%rax),%esi
lea    -0x180(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1110 <clock_nanosleep@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x40,-0x10(%rbp)
jge    130b <msg_io+0x11b>
movslq -0x10(%rbp),%rax
lea    -0x130(%rbp),%rdi
add    %rax,%rdi
call   10a0 <popElement1@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    12e0 <msg_io+0xf0>
lea    -0x130(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   10d0 <decode@plt>
mov    %eax,-0xc(%rbp)
lea    -0x130(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10e0 <getBinaryData@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x130(%rbp),%rdi
mov    $0x8,%edx
mov    %edx,%esi
call   10e0 <getBinaryData@plt>
mov    %eax,-0x20(%rbp)
lea    -0x130(%rbp),%rdi
mov    $0x10,%esi
mov    $0x8,%edx
call   10e0 <getBinaryData@plt>
mov    %eax,-0x24(%rbp)
lea    -0x130(%rbp),%rdi
mov    $0x18,%esi
mov    $0x8,%edx
call   10e0 <getBinaryData@plt>
mov    %eax,-0x28(%rbp)
lea    -0x130(%rbp),%rdi
mov    $0x20,%esi
mov    $0x8,%edx
call   10e0 <getBinaryData@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x130(%rbp),%rdi
mov    $0x28,%esi
mov    $0x8,%edx
call   10e0 <getBinaryData@plt>
mov    %eax,-0x30(%rbp)
lea    -0x130(%rbp),%rdi
mov    $0x30,%esi
mov    $0x8,%edx
call   10e0 <getBinaryData@plt>
mov    %eax,-0x34(%rbp)
lea    -0x130(%rbp),%rdi
mov    $0x38,%esi
mov    $0x8,%edx
call   10e0 <getBinaryData@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0xff,-0xc(%rbp)
jne    1407 <msg_io+0x217>
lea    -0x70(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    142e <msg_io+0x23e>
cmpl   $0xff,-0xc(%rbp)
je     14d3 <msg_io+0x2e3>
lea    -0x70(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     14d3 <msg_io+0x2e3>
mov    -0x178(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x178(%rbp)
mov    %eax,%esi
lea    -0x70(%rbp),%rdx
lea    0xbf1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    -0x30(%rbp),%r11d
mov    -0x34(%rbp),%r10d
mov    -0x38(%rbp),%eax
lea    0xbd7(%rip),%rdi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2b2b(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
cmpl   $0xff,-0xc(%rbp)
jne    14be <msg_io+0x2ce>
lea    -0xf0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    14ce <msg_io+0x2de>
lea    -0xb0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    14d3 <msg_io+0x2e3>
cmpl   $0x190,-0x14(%rbp)
jne    1564 <msg_io+0x374>
lea    -0x170(%rbp),%rdi
lea    0xb12(%rip),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x40,-0x10(%rbp)
jge    155f <msg_io+0x36f>
movslq -0x10(%rbp),%rax
lea    -0x170(%rbp),%rdi
add    %rax,%rdi
call   10c0 <pushElement2@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    154c <msg_io+0x35c>
mov    0x2aa0(%rip),%rax
mov    (%rax),%edi
lea    0xb58(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x2a83(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
jmp    1551 <msg_io+0x361>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    14ff <msg_io+0x30f>
jmp    1726 <msg_io+0x536>
cmpl   $0x320,-0x14(%rbp)
jne    15f5 <msg_io+0x405>
lea    -0x170(%rbp),%rdi
lea    0xa81(%rip),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x40,-0x10(%rbp)
jge    15f0 <msg_io+0x400>
movslq -0x10(%rbp),%rax
lea    -0x170(%rbp),%rdi
add    %rax,%rdi
call   10c0 <pushElement2@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    15dd <msg_io+0x3ed>
mov    0x2a0f(%rip),%rax
mov    (%rax),%edi
lea    0xac7(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x29f2(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
jmp    15e2 <msg_io+0x3f2>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1590 <msg_io+0x3a0>
jmp    1721 <msg_io+0x531>
cmpl   $0x4b0,-0x14(%rbp)
jne    1686 <msg_io+0x496>
lea    -0x170(%rbp),%rdi
lea    0x9f0(%rip),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x40,-0x10(%rbp)
jge    1681 <msg_io+0x491>
movslq -0x10(%rbp),%rax
lea    -0x170(%rbp),%rdi
add    %rax,%rdi
call   10c0 <pushElement2@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    166e <msg_io+0x47e>
mov    0x297e(%rip),%rax
mov    (%rax),%edi
lea    0xa36(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x2961(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
jmp    1673 <msg_io+0x483>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1621 <msg_io+0x431>
jmp    171c <msg_io+0x52c>
cmpl   $0x640,-0x14(%rbp)
jne    1717 <msg_io+0x527>
lea    -0x170(%rbp),%rdi
lea    0x95f(%rip),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x40,-0x10(%rbp)
jge    1712 <msg_io+0x522>
movslq -0x10(%rbp),%rax
lea    -0x170(%rbp),%rdi
add    %rax,%rdi
call   10c0 <pushElement2@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    16ff <msg_io+0x50f>
mov    0x28ed(%rip),%rax
mov    (%rax),%edi
lea    0x9a5(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x28d0(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
jmp    1704 <msg_io+0x514>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    16b2 <msg_io+0x4c2>
jmp    1717 <msg_io+0x527>
jmp    171c <msg_io+0x52c>
jmp    1721 <msg_io+0x531>
jmp    1726 <msg_io+0x536>
cmpl   $0x7d0,-0x14(%rbp)
jge    1741 <msg_io+0x551>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1748 <msg_io+0x558>
movl   $0x0,-0x14(%rbp)
jmp    129a <msg_io+0xaa>

x86 assembly (clang, -O2):
<msg_io>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x178,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movw   $0x0,0x120(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movw   $0x0,0xe0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movw   $0x0,0xa0(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
lea    0xd6e(%rip),%rsi
lea    0x30(%rsp),%rdi
mov    $0x40,%edx
call   1030 <strncpy@plt>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1050 <clock_gettime@plt>
lea    0xf0(%rsp),%r14
xor    %eax,%eax
xor    %ecx,%ecx
mov    %rcx,0x20(%rsp)
jmp    12e1 <msg_io+0x101>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x7d0,%ebp
lea    0x1(%rbp),%eax
mov    $0x0,%ecx
cmovge %ecx,%eax
mov    %rax,0x8(%rsp)
addl   $0x4c4b40,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   10e0 <tnorm@plt>
mov    0x2ce1(%rip),%rax
mov    (%rax),%edi
mov    0x2ce0(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1100 <clock_nanosleep@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
lea    (%rsp,%rbx,1),%rdi
add    $0x130,%rdi
call   1090 <popElement1@plt>
add    $0x1,%rbx
cmp    $0x40,%rbx
jne    1320 <msg_io+0x140>
lea    0x130(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   10c0 <decode@plt>
mov    %r14,%rbp
mov    %eax,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10d0 <getBinaryData@plt>
mov    %eax,0x1c(%rsp)
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x8,%edx
call   10d0 <getBinaryData@plt>
mov    %eax,0x18(%rsp)
mov    %rbx,%rdi
mov    $0x10,%esi
mov    $0x8,%edx
call   10d0 <getBinaryData@plt>
mov    %eax,0x14(%rsp)
mov    %rbx,%rdi
mov    $0x18,%esi
mov    $0x8,%edx
call   10d0 <getBinaryData@plt>
mov    %eax,0x10(%rsp)
mov    %rbx,%rdi
mov    $0x20,%esi
mov    $0x8,%edx
call   10d0 <getBinaryData@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
mov    $0x28,%esi
mov    $0x8,%edx
call   10d0 <getBinaryData@plt>
mov    %rax,0x28(%rsp)
mov    %rbx,%rdi
mov    $0x30,%esi
mov    $0x8,%edx
call   10d0 <getBinaryData@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    $0x38,%esi
mov    $0x8,%edx
call   10d0 <getBinaryData@plt>
mov    %eax,%r12d
mov    %rbp,%rdi
cmp    $0xff,%r14d
jne    1420 <msg_io+0x240>
lea    0x70(%rsp),%rbx
jmp    1428 <msg_io+0x248>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xb0(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
mov    %rbp,%r14
je     14a2 <msg_io+0x2c2>
mov    0x20(%rsp),%rsi
lea    0x1(%rsi),%rbp
lea    0xbf9(%rip),%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
sub    $0x8,%rsp
lea    0xbf4(%rip),%rdi
mov    0x24(%rsp),%esi
mov    0x20(%rsp),%edx
mov    0x1c(%rsp),%ecx
mov    0x18(%rsp),%r8d
mov    %r13d,%r9d
xor    %eax,%eax
push   %r12
push   %r15
push   0x40(%rsp)
call   1060 <printf@plt>
add    $0x20,%rsp
mov    0x2b35(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %rbp,0x20(%rsp)
mov    0x8(%rsp),%rbp
cmp    $0x4af,%ebp
jg     1510 <msg_io+0x330>
cmp    $0x190,%ebp
je     1570 <msg_io+0x390>
cmp    $0x320,%ebp
jne    12d0 <msg_io+0xf0>
lea    0x30(%rsp),%rdi
lea    0xb2d(%rip),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
xor    %ebx,%ebx
nop
lea    (%rsp,%rbx,1),%rdi
add    $0x30,%rdi
call   10b0 <pushElement2@plt>
test   %eax,%eax
je     15f0 <msg_io+0x410>
add    $0x1,%rbx
cmp    $0x40,%rbx
jne    14e0 <msg_io+0x300>
jmp    12d0 <msg_io+0xf0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x4b0,%ebp
je     15b0 <msg_io+0x3d0>
cmp    $0x640,%ebp
jne    12d0 <msg_io+0xf0>
lea    0x30(%rsp),%rdi
lea    0xacc(%rip),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
xor    %ebx,%ebx
lea    (%rsp,%rbx,1),%rdi
add    $0x30,%rdi
call   10b0 <pushElement2@plt>
test   %eax,%eax
je     15f0 <msg_io+0x410>
add    $0x1,%rbx
cmp    $0x40,%rbx
jne    1540 <msg_io+0x360>
jmp    12d0 <msg_io+0xf0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x30(%rsp),%rdi
lea    0xa84(%rip),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
lea    (%rsp,%rbx,1),%rdi
add    $0x30,%rdi
call   10b0 <pushElement2@plt>
test   %eax,%eax
je     15f0 <msg_io+0x410>
add    $0x1,%rbx
cmp    $0x40,%rbx
jne    1590 <msg_io+0x3b0>
jmp    12d0 <msg_io+0xf0>
lea    0x30(%rsp),%rdi
lea    0xa44(%rip),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
lea    (%rsp,%rbx,1),%rdi
add    $0x30,%rdi
call   10b0 <pushElement2@plt>
test   %eax,%eax
je     15f0 <msg_io+0x410>
add    $0x1,%rbx
cmp    $0x40,%rbx
jne    15d0 <msg_io+0x3f0>
jmp    12d0 <msg_io+0xf0>
mov    0x29d9(%rip),%rax
mov    (%rax),%edi
lea    0xa91(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x29bc(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.timespec = type { i32 }
@.str = [65 x i8] c"1111111111111111111111111111111111111111111111111111111111111111\00"
@CLOCK_MONOTONIC = global i32 0
@TIMER_ABSTIME = global i32 0
@.str.1 = [16 x i8] c"index:%lu,%-50s\00"
@.str.2 = [64 x i8] c" data: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\0A\00"
@stdout = global i32 0
@stderr = global i32 0
@.str.3 = [26 x i8] c"msg_io: fifo write error\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @msg_io(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca [50 x i8]
%16 = alloca [50 x i8]
%17 = alloca [50 x i8]
%18 = alloca [64 x i8]
%19 = alloca [64 x i8]
%20 = alloca i64
%21 = alloca %struct.timespec
store i8* %0, i8** %2
store i32 0, i32* %5
%22 = bitcast [50 x i8]* %15 to i8*
%23 = bitcast [50 x i8]* %16 to i8*
%24 = bitcast [50 x i8]* %17 to i8*
%25 = bitcast [64 x i8]* %18 to i8*
%26 = bitcast [64 x i8]* %19 to i8*
store i64 0, i64* %20
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%28 = call i32 @strncpy(i8* %27, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 64)
%29 = load i32, i32* @CLOCK_MONOTONIC
%30 = call i32 @clock_gettime(i32 %29, %struct.timespec* %21)
br label %31
31: ; preds = %1, %227
%32 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 0
%33 = load i32, i32* %32
%34 = add nsw i32 %33, 5000000
store i32 %34, i32* %32
%35 = call i32 @tnorm(%struct.timespec* %21)
%36 = load i32, i32* @CLOCK_MONOTONIC
%37 = load i32, i32* @TIMER_ABSTIME
%38 = call i32 @clock_nanosleep(i32 %36, i32 %37, %struct.timespec* %21, i32* null)
store i32 0, i32* %4
br label %39
39: ; preds = %47, %31
%40 = load i32, i32* %4
%41 = icmp slt i32 %40, 64
br i1 %41, label %42, label %50
42: ; preds = %39
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [64 x i8], [64 x i8]* %18, i64 0, i64 %44
%46 = call i32 @popElement1(i8* %45)
br label %47
47: ; preds = %42
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 1
store i32 %49, i32* %4
br label %39
50: ; preds = %39
%51 = getelementptr inbounds [64 x i8], [64 x i8]* %18, i64 0, i64 0
%52 = getelementptr inbounds [50 x i8], [50 x i8]* %15, i64 0, i64 0
%53 = call i32 @decode(i8* %51, i8* %52)
store i32 %53, i32* %3
%54 = getelementptr inbounds [64 x i8], [64 x i8]* %18, i64 0, i64 0
%55 = call i32 @getBinaryData(i8* %54, i32 0, i32 8)
store i32 %55, i32* %7
%56 = getelementptr inbounds [64 x i8], [64 x i8]* %18, i64 0, i64 0
%57 = call i32 @getBinaryData(i8* %56, i32 8, i32 8)
store i32 %57, i32* %8
%58 = getelementptr inbounds [64 x i8], [64 x i8]* %18, i64 0, i64 0
%59 = call i32 @getBinaryData(i8* %58, i32 16, i32 8)
store i32 %59, i32* %9
%60 = getelementptr inbounds [64 x i8], [64 x i8]* %18, i64 0, i64 0
%61 = call i32 @getBinaryData(i8* %60, i32 24, i32 8)
store i32 %61, i32* %10
%62 = getelementptr inbounds [64 x i8], [64 x i8]* %18, i64 0, i64 0
%63 = call i32 @getBinaryData(i8* %62, i32 32, i32 8)
store i32 %63, i32* %11
%64 = getelementptr inbounds [64 x i8], [64 x i8]* %18, i64 0, i64 0
%65 = call i32 @getBinaryData(i8* %64, i32 40, i32 8)
store i32 %65, i32* %12
%66 = getelementptr inbounds [64 x i8], [64 x i8]* %18, i64 0, i64 0
%67 = call i32 @getBinaryData(i8* %66, i32 48, i32 8)
store i32 %67, i32* %13
%68 = getelementptr inbounds [64 x i8], [64 x i8]* %18, i64 0, i64 0
%69 = call i32 @getBinaryData(i8* %68, i32 56, i32 8)
store i32 %69, i32* %14
%70 = load i32, i32* %3
%71 = icmp eq i32 %70, 255
br i1 %71, label %72, label %77
72: ; preds = %50
%73 = getelementptr inbounds [50 x i8], [50 x i8]* %15, i64 0, i64 0
%74 = getelementptr inbounds [50 x i8], [50 x i8]* %17, i64 0, i64 0
%75 = call i64 @strcmp(i8* %73, i8* %74)
%76 = icmp ne i64 %75, 0
br i1 %76, label %85, label %77
77: ; preds = %72, %50
%78 = load i32, i32* %3
%79 = icmp ne i32 %78, 255
br i1 %79, label %80, label %113
80: ; preds = %77
%81 = getelementptr inbounds [50 x i8], [50 x i8]* %15, i64 0, i64 0
%82 = getelementptr inbounds [50 x i8], [50 x i8]* %16, i64 0, i64 0
%83 = call i64 @strcmp(i8* %81, i8* %82)
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %113
85: ; preds = %80, %72
%86 = load i64, i64* %20
%87 = add i64 %86, 1
store i64 %87, i64* %20
%88 = trunc i64 %86 to i32
%89 = getelementptr inbounds [50 x i8], [50 x i8]* %15, i64 0, i64 0
%90 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %88, i8* %89)
%91 = load i32, i32* %7
%92 = load i32, i32* %8
%93 = load i32, i32* %9
%94 = load i32, i32* %10
%95 = load i32, i32* %11
%96 = load i32, i32* %12
%97 = load i32, i32* %13
%98 = load i32, i32* %14
%99 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i32 %91, i32 %92, i32 %93, i32 %94, i32 %95, i32 %96, i32 %97, i32 %98)
%100 = load i32, i32* @stdout
%101 = call i32 @fflush(i32 %100)
%102 = load i32, i32* %3
%103 = icmp eq i32 %102, 255
br i1 %103, label %104, label %108
104: ; preds = %85
%105 = getelementptr inbounds [50 x i8], [50 x i8]* %17, i64 0, i64 0
%106 = getelementptr inbounds [50 x i8], [50 x i8]* %15, i64 0, i64 0
%107 = call i32 @strcpy(i8* %105, i8* %106)
br label %112
108: ; preds = %85
%109 = getelementptr inbounds [50 x i8], [50 x i8]* %16, i64 0, i64 0
%110 = getelementptr inbounds [50 x i8], [50 x i8]* %15, i64 0, i64 0
%111 = call i32 @strcpy(i8* %109, i8* %110)
br label %112
112: ; preds = %108, %104
br label %113
113: ; preds = %112, %80, %77
%114 = load i32, i32* %5
%115 = icmp eq i32 %114, 400
br i1 %115, label %116, label %139
116: ; preds = %113
%117 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%118 = call i32 @strncpy(i8* %117, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 64)
store i32 0, i32* %4
br label %119
119: ; preds = %135, %116
%120 = load i32, i32* %4
%121 = icmp slt i32 %120, 64
br i1 %121, label %122, label %138
122: ; preds = %119
%123 = load i32, i32* %4
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 %124
%126 = call i32 @pushElement2(i8* %125)
store i32 %126, i32* %6
%127 = load i32, i32* %6
%128 = icmp eq i32 %127, 0
br i1 %128, label %129, label %134
129: ; preds = %122
%130 = load i32, i32* @stderr
%131 = call i32 @fprintf(i32 %130, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%132 = load i32, i32* @EXIT_FAILURE
%133 = call i32 @exit(i32 %132)
unreachable
134: ; preds = %122
br label %135
135: ; preds = %134
%136 = load i32, i32* %4
%137 = add nsw i32 %136, 1
store i32 %137, i32* %4
br label %119
138: ; preds = %119
br label %220
139: ; preds = %113
%140 = load i32, i32* %5
%141 = icmp eq i32 %140, 800
br i1 %141, label %142, label %165
142: ; preds = %139
%143 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%144 = call i32 @strncpy(i8* %143, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 64)
store i32 0, i32* %4
br label %145
145: ; preds = %161, %142
%146 = load i32, i32* %4
%147 = icmp slt i32 %146, 64
br i1 %147, label %148, label %164
148: ; preds = %145
%149 = load i32, i32* %4
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 %150
%152 = call i32 @pushElement2(i8* %151)
store i32 %152, i32* %6
%153 = load i32, i32* %6
%154 = icmp eq i32 %153, 0
br i1 %154, label %155, label %160
155: ; preds = %148
%156 = load i32, i32* @stderr
%157 = call i32 @fprintf(i32 %156, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%158 = load i32, i32* @EXIT_FAILURE
%159 = call i32 @exit(i32 %158)
unreachable
160: ; preds = %148
br label %161
161: ; preds = %160
%162 = load i32, i32* %4
%163 = add nsw i32 %162, 1
store i32 %163, i32* %4
br label %145
164: ; preds = %145
br label %219
165: ; preds = %139
%166 = load i32, i32* %5
%167 = icmp eq i32 %166, 1200
br i1 %167, label %168, label %191
168: ; preds = %165
%169 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%170 = call i32 @strncpy(i8* %169, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 64)
store i32 0, i32* %4
br label %171
171: ; preds = %187, %168
%172 = load i32, i32* %4
%173 = icmp slt i32 %172, 64
br i1 %173, label %174, label %190
174: ; preds = %171
%175 = load i32, i32* %4
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 %176
%178 = call i32 @pushElement2(i8* %177)
store i32 %178, i32* %6
%179 = load i32, i32* %6
%180 = icmp eq i32 %179, 0
br i1 %180, label %181, label %186
181: ; preds = %174
%182 = load i32, i32* @stderr
%183 = call i32 @fprintf(i32 %182, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%184 = load i32, i32* @EXIT_FAILURE
%185 = call i32 @exit(i32 %184)
unreachable
186: ; preds = %174
br label %187
187: ; preds = %186
%188 = load i32, i32* %4
%189 = add nsw i32 %188, 1
store i32 %189, i32* %4
br label %171
190: ; preds = %171
br label %218
191: ; preds = %165
%192 = load i32, i32* %5
%193 = icmp eq i32 %192, 1600
br i1 %193, label %194, label %217
194: ; preds = %191
%195 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 0
%196 = call i32 @strncpy(i8* %195, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 64)
store i32 0, i32* %4
br label %197
197: ; preds = %213, %194
%198 = load i32, i32* %4
%199 = icmp slt i32 %198, 64
br i1 %199, label %200, label %216
200: ; preds = %197
%201 = load i32, i32* %4
%202 = sext i32 %201 to i64
%203 = getelementptr inbounds [64 x i8], [64 x i8]* %19, i64 0, i64 %202
%204 = call i32 @pushElement2(i8* %203)
store i32 %204, i32* %6
%205 = load i32, i32* %6
%206 = icmp eq i32 %205, 0
br i1 %206, label %207, label %212
207: ; preds = %200
%208 = load i32, i32* @stderr
%209 = call i32 @fprintf(i32 %208, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%210 = load i32, i32* @EXIT_FAILURE
%211 = call i32 @exit(i32 %210)
unreachable
212: ; preds = %200
br label %213
213: ; preds = %212
%214 = load i32, i32* %4
%215 = add nsw i32 %214, 1
store i32 %215, i32* %4
br label %197
216: ; preds = %197
br label %217
217: ; preds = %216, %191
br label %218
218: ; preds = %217, %190
br label %219
219: ; preds = %218, %164
br label %220
220: ; preds = %219, %138
%221 = load i32, i32* %5
%222 = icmp slt i32 %221, 2000
br i1 %222, label %223, label %226
223: ; preds = %220
%224 = load i32, i32* %5
%225 = add nsw i32 %224, 1
store i32 %225, i32* %5
br label %227
226: ; preds = %220
store i32 0, i32* %5
br label %227
227: ; preds = %226, %223
br label %31
}

LLVM IR (-O2):
%struct.timespec = type { i32 }
@.str = [65 x i8] c"1111111111111111111111111111111111111111111111111111111111111111\00"
@CLOCK_MONOTONIC = global i32 0
@TIMER_ABSTIME = global i32 0
@.str.1 = [16 x i8] c"index:%lu,%-50s\00"
@.str.2 = [64 x i8] c" data: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\0A\00"
@stdout = global i32 0
@stderr = global i32 0
@.str.3 = [26 x i8] c"msg_io: fifo write error\0A\00"
@EXIT_FAILURE = global i32 0
define noalias i8* @msg_io(i8* nocapture readnone %0) {
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = alloca [64 x i8]
%6 = alloca [64 x i8]
%7 = alloca %struct.timespec
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%13 = bitcast %struct.timespec* %7 to i8*
%14 = call i32 @strncpy(i8* %12, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 64)
%15 = load i32, i32* @CLOCK_MONOTONIC
%16 = call i32 @clock_gettime(i32 %15, %struct.timespec* %7)
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i64 0, i32 0
br label %18
18: ; preds = %121, %1
%19 = phi i32 [ 0, %1 ], [ %124, %121 ]
%20 = phi i64 [ 0, %1 ], [ %60, %121 ]
%21 = load i32, i32* %17
%22 = add nsw i32 %21, 5000000
store i32 %22, i32* %17
%23 = call i32 @tnorm(%struct.timespec* %7)
%24 = load i32, i32* @CLOCK_MONOTONIC
%25 = load i32, i32* @TIMER_ABSTIME
%26 = call i32 @clock_nanosleep(i32 %24, i32 %25, %struct.timespec* %7, i32* null)
br label %27
27: ; preds = %18, %27
%28 = phi i64 [ 0, %18 ], [ %31, %27 ]
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 %28
%30 = call i32 @popElement1(i8* %29)
%31 = add nuw nsw i64 %28, 1
%32 = icmp eq i64 %31, 64
br i1 %32, label %33, label %27
33: ; preds = %27
%34 = call i32 @decode(i8* %11, i8* %8)
%35 = call i32 @getBinaryData(i8* %11, i32 0, i32 8)
%36 = call i32 @getBinaryData(i8* %11, i32 8, i32 8)
%37 = call i32 @getBinaryData(i8* %11, i32 16, i32 8)
%38 = call i32 @getBinaryData(i8* %11, i32 24, i32 8)
%39 = call i32 @getBinaryData(i8* %11, i32 32, i32 8)
%40 = call i32 @getBinaryData(i8* %11, i32 40, i32 8)
%41 = call i32 @getBinaryData(i8* %11, i32 48, i32 8)
%42 = call i32 @getBinaryData(i8* %11, i32 56, i32 8)
%43 = icmp eq i32 %34, 255
br i1 %43, label %44, label %47
44: ; preds = %33
%45 = call i64 @strcmp(i8* %8, i8* %10)
%46 = icmp eq i64 %45, 0
br i1 %46, label %59, label %50
47: ; preds = %33
%48 = call i64 @strcmp(i8* %8, i8* %9)
%49 = icmp eq i64 %48, 0
br i1 %49, label %59, label %50
50: ; preds = %47, %44
%51 = phi i8* [ %9, %47 ], [ %10, %44 ]
%52 = add i64 %20, 1
%53 = trunc i64 %20 to i32
%54 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %53, i8* %8)
%55 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i32 %35, i32 %36, i32 %37, i32 %38, i32 %39, i32 %40, i32 %41, i32 %42)
%56 = load i32, i32* @stdout
%57 = call i32 @fflush(i32 %56)
%58 = call i32 @strcpy(i8* %51, i8* %8)
br label %59
59: ; preds = %50, %44, %47
%60 = phi i64 [ %20, %47 ], [ %20, %44 ], [ %52, %50 ]
switch i32 %19, label %121 [
i32 400, label %61
i32 800, label %76
i32 1200, label %91
i32 1600, label %106
]
61: ; preds = %59
%62 = call i32 @strncpy(i8* %12, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 64)
br label %66
63: ; preds = %66
%64 = add nuw nsw i64 %67, 1
%65 = icmp eq i64 %64, 64
br i1 %65, label %121, label %66
66: ; preds = %61, %63
%67 = phi i64 [ 0, %61 ], [ %64, %63 ]
%68 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %67
%69 = call i32 @pushElement2(i8* %68)
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %63
71: ; preds = %66
%72 = load i32, i32* @stderr
%73 = call i32 @fprintf(i32 %72, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%74 = load i32, i32* @EXIT_FAILURE
%75 = call i32 @exit(i32 %74)
unreachable
76: ; preds = %59
%77 = call i32 @strncpy(i8* %12, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 64)
br label %81
78: ; preds = %81
%79 = add nuw nsw i64 %82, 1
%80 = icmp eq i64 %79, 64
br i1 %80, label %121, label %81
81: ; preds = %76, %78
%82 = phi i64 [ 0, %76 ], [ %79, %78 ]
%83 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %82
%84 = call i32 @pushElement2(i8* %83)
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %78
86: ; preds = %81
%87 = load i32, i32* @stderr
%88 = call i32 @fprintf(i32 %87, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%89 = load i32, i32* @EXIT_FAILURE
%90 = call i32 @exit(i32 %89)
unreachable
91: ; preds = %59
%92 = call i32 @strncpy(i8* %12, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 64)
br label %96
93: ; preds = %96
%94 = add nuw nsw i64 %97, 1
%95 = icmp eq i64 %94, 64
br i1 %95, label %121, label %96
96: ; preds = %91, %93
%97 = phi i64 [ 0, %91 ], [ %94, %93 ]
%98 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %97
%99 = call i32 @pushElement2(i8* %98)
%100 = icmp eq i32 %99, 0
br i1 %100, label %101, label %93
101: ; preds = %96
%102 = load i32, i32* @stderr
%103 = call i32 @fprintf(i32 %102, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%104 = load i32, i32* @EXIT_FAILURE
%105 = call i32 @exit(i32 %104)
unreachable
106: ; preds = %59
%107 = call i32 @strncpy(i8* %12, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 64)
br label %111
108: ; preds = %111
%109 = add nuw nsw i64 %112, 1
%110 = icmp eq i64 %109, 64
br i1 %110, label %121, label %111
111: ; preds = %106, %108
%112 = phi i64 [ 0, %106 ], [ %109, %108 ]
%113 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %112
%114 = call i32 @pushElement2(i8* %113)
%115 = icmp eq i32 %114, 0
br i1 %115, label %116, label %108
116: ; preds = %111
%117 = load i32, i32* @stderr
%118 = call i32 @fprintf(i32 %117, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%119 = load i32, i32* @EXIT_FAILURE
%120 = call i32 @exit(i32 %119)
unreachable
121: ; preds = %108, %93, %78, %63, %59
%122 = icmp slt i32 %19, 2000
%123 = add nsw i32 %19, 1
%124 = select i1 %122, i32 %123, i32 0
br label %18
}