#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 */

/* Variables and functions */
int /*<<< orphan*/ dump(void *, int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, int);
int posix_memalign(void **, int, int);
int pq_check_base(int, int, void *);
int pq_gen(int, int, void *);
int /*<<< orphan*/ pq_gen_base(int, int, void **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ rand_buffer(void *, int);
int /*<<< orphan*/ srand(int);
int main(int argc, char *argv[]) {
  int i, j, k, ret, fail = 0;
  void *buffs[16 + 2];
  char *tmp_buf[16 + 2];
  printf("Test pq_gen_test ");
  srand(0x1234);
  for (i = 0; i < 16 + 2; i++) {
    void *buf;
    ret = posix_memalign(&buf, 32, 1024);
    if (ret) {
      printf("alloc error: Fail");
      return 1;
    }
    buffs[i] = buf;
  }
  for (i = 0; i < 16 + 2; i++)
    memset(buffs[i], 0, 1024);
  pq_gen(16 + 2, 1024, buffs);
  for (i = 0; i < 1024; i++) {
    if (((char *)buffs[16])[i] != 0)
      fail++;
  }
  for (i = 0; i < 1024; i++) {
    if (((char *)buffs[16 + 1])[i] != 0)
      fail++;
  }
  if (fail > 0) {
    printf("fail zero test %d\n", fail);
    return 1;
  } else
    putchar('.');
  for (i = 0; i < 16 + 2; i++)
    rand_buffer(buffs[i], 1024);
  ret = pq_gen(16 + 2, 1024, buffs);
  fail |= pq_check_base(16 + 2, 1024, buffs);
  if (fail > 0) {
    int t;
    printf(" Fail rand test1 fail=%d, ret=%d\n", fail, ret);
    for (t = 0; t < 16 + 2; t++)
      dump(buffs[t], 15);
    printf(" reference function p,q\n");
    pq_gen_base(16 + 2, 1024, buffs);
    for (t = 16; t < 16 + 2; t++)
      dump(buffs[t], 15);
    return 1;
  } else
    putchar('.');
  for (j = 4; j <= 16 + 2; j++) {
    for (i = 0; i < j; i++)
      rand_buffer(buffs[i], 1024);
    pq_gen(j, 1024, buffs);
    fail |= pq_check_base(j, 1024, buffs);
    if (fail > 0) {
      printf("fail rand test %d sources\n", j);
      return 1;
    } else
      putchar('.');
  }
  fflush(0);
  k = 0;
  while (k <= 1024) {
    for (j = 4; j <= 16 + 2; j++) {
      for (i = 0; i < j; i++)
        rand_buffer(buffs[i], k);
      ret = pq_gen(j, k, buffs);
      fail |= pq_check_base(j, k, buffs);
      if (fail > 0) {
        printf("fail rand test %d sources, len=%d, fail="
               "%d, ret=%d\n",
               j, k, fail, ret);
        return 1;
      }
    }
    putchar('.');
    k += 32;
  }
  k = 0;
  while (k <= 1024) {
    for (j = 0; j < (16 + 2); j++) {
      rand_buffer(buffs[j], 1024 - k);
      tmp_buf[j] = (char *)buffs[j] + k;
    }
    ret = pq_gen(16 + 2, 1024 - k, (void *)tmp_buf);
    fail |= pq_check_base(16 + 2, 1024 - k, (void *)tmp_buf);
    if (fail > 0) {
      printf("fail end test - offset: %d, len: %d, fail: %d, "
             "ret: %d\n",
             k, 1024 - k, fail, ret);
      return 1;
    }
    putchar('.');
    fflush(0);
    k += 32;
  }
  if (!fail)
    printf(" done: Pass\n");
  return fail;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1234,%edi
call   1090 <srand@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x12,-0x14(%rbp)
jge    1257 <main+0xa7>
lea    -0x158(%rbp),%rdi
mov    $0x20,%esi
mov    $0x400,%edx
call   10d0 <posix_memalign@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1236 <main+0x86>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1766 <main+0x5b6>
mov    -0x158(%rbp),%rcx
movslq -0x14(%rbp),%rax
mov    %rcx,-0xc0(%rbp,%rax,8)
ff
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ef <main+0x3f>
movl   $0x0,-0x14(%rbp)
cmpl   $0x12,-0x14(%rbp)
jge    128e <main+0xde>
movslq -0x14(%rbp),%rax
mov    -0xc0(%rbp,%rax,8),%rdi
ff
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    125e <main+0xae>
lea    -0xc0(%rbp),%rdx
mov    $0x12,%edi
mov    $0x400,%esi
call   1040 <pq_gen@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x400,-0x14(%rbp)
jge    12e9 <main+0x139>
mov    -0x40(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     12d6 <main+0x126>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12db <main+0x12b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12ab <main+0xfb>
movl   $0x0,-0x14(%rbp)
cmpl   $0x400,-0x14(%rbp)
jge    132e <main+0x17e>
mov    -0x38(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     131b <main+0x16b>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1320 <main+0x170>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12f0 <main+0x140>
cmpl   $0x0,-0x24(%rbp)
jle    1355 <main+0x1a5>
mov    -0x24(%rbp),%esi
lea    0xce2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1766 <main+0x5b6>
mov    $0x2e,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x12,-0x14(%rbp)
jge    1394 <main+0x1e4>
movslq -0x14(%rbp),%rax
mov    -0xc0(%rbp,%rax,8),%rdi
ff
mov    $0x400,%esi
call   10a0 <rand_buffer@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1366 <main+0x1b6>
lea    -0xc0(%rbp),%rdx
mov    $0x12,%edi
mov    $0x400,%esi
call   1040 <pq_gen@plt>
mov    %eax,-0x20(%rbp)
lea    -0xc0(%rbp),%rdx
mov    $0x12,%edi
mov    $0x400,%esi
call   10c0 <pq_check_base@plt>
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    149f <main+0x2ef>
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xc57(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x15c(%rbp)
cmpl   $0x12,-0x15c(%rbp)
jge    142b <main+0x27b>
movslq -0x15c(%rbp),%rax
mov    -0xc0(%rbp,%rax,8),%rdi
ff
mov    $0xf,%esi
call   1080 <dump@plt>
mov    -0x15c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x15c(%rbp)
jmp    13f1 <main+0x241>
lea    0xc27(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xc0(%rbp),%rdx
mov    $0x12,%edi
mov    $0x400,%esi
call   1050 <pq_gen_base@plt>
movl   $0x10,-0x15c(%rbp)
cmpl   $0x12,-0x15c(%rbp)
jge    1493 <main+0x2e3>
movslq -0x15c(%rbp),%rax
mov    -0xc0(%rbp,%rax,8),%rdi
ff
mov    $0xf,%esi
call   1080 <dump@plt>
mov    -0x15c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x15c(%rbp)
jmp    1459 <main+0x2a9>
movl   $0x1,-0x4(%rbp)
jmp    1766 <main+0x5b6>
mov    $0x2e,%edi
call   1030 <putchar@plt>
movl   $0x4,-0x18(%rbp)
cmpl   $0x12,-0x18(%rbp)
jg     1563 <main+0x3b3>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    14f1 <main+0x341>
movslq -0x14(%rbp),%rax
mov    -0xc0(%rbp,%rax,8),%rdi
ff
mov    $0x400,%esi
call   10a0 <rand_buffer@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    14c1 <main+0x311>
mov    -0x18(%rbp),%edi
lea    -0xc0(%rbp),%rdx
mov    $0x400,%esi
call   1040 <pq_gen@plt>
mov    -0x18(%rbp),%edi
lea    -0xc0(%rbp),%rdx
mov    $0x400,%esi
call   10c0 <pq_check_base@plt>
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    1546 <main+0x396>
mov    -0x18(%rbp),%esi
lea    0xb3f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1766 <main+0x5b6>
mov    $0x2e,%edi
call   1030 <putchar@plt>
jmp    1555 <main+0x3a5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    14b0 <main+0x300>
xor    %edi,%edi
call   10b0 <fflush@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x400,-0x1c(%rbp)
jg     164d <main+0x49d>
movl   $0x4,-0x18(%rbp)
cmpl   $0x12,-0x18(%rbp)
jg     1635 <main+0x485>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    15c4 <main+0x414>
movslq -0x14(%rbp),%rax
mov    -0xc0(%rbp,%rax,8),%rdi
ff
mov    -0x1c(%rbp),%esi
call   10a0 <rand_buffer@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1596 <main+0x3e6>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
lea    -0xc0(%rbp),%rdx
call   1040 <pq_gen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
lea    -0xc0(%rbp),%rdx
call   10c0 <pq_check_base@plt>
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    1622 <main+0x472>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0xa7e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1766 <main+0x5b6>
jmp    1627 <main+0x477>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1585 <main+0x3d5>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x1c(%rbp)
jmp    1571 <main+0x3c1>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x400,-0x1c(%rbp)
jg     1748 <main+0x598>
movl   $0x0,-0x18(%rbp)
cmpl   $0x12,-0x18(%rbp)
jge    16b8 <main+0x508>
movslq -0x18(%rbp),%rax
mov    -0xc0(%rbp,%rax,8),%rdi
ff
mov    $0x400,%esi
sub    -0x1c(%rbp),%esi
call   10a0 <rand_buffer@plt>
movslq -0x18(%rbp),%rax
mov    -0xc0(%rbp,%rax,8),%rcx
ff
movslq -0x1c(%rbp),%rax
add    %rax,%rcx
movslq -0x18(%rbp),%rax
mov    %rcx,-0x150(%rbp,%rax,8)
ff
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1668 <main+0x4b8>
mov    $0x400,%esi
sub    -0x1c(%rbp),%esi
lea    -0x150(%rbp),%rdx
mov    $0x12,%edi
call   1040 <pq_gen@plt>
mov    %eax,-0x20(%rbp)
mov    $0x400,%esi
sub    -0x1c(%rbp),%esi
lea    -0x150(%rbp),%rdx
mov    $0x12,%edi
call   10c0 <pq_check_base@plt>
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    1729 <main+0x579>
mov    -0x1c(%rbp),%esi
mov    $0x400,%edx
sub    -0x1c(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0x9ab(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1766 <main+0x5b6>
mov    $0x2e,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x1c(%rbp)
jmp    1654 <main+0x4a4>
cmpl   $0x0,-0x24(%rbp)
jne    1760 <main+0x5b0>
lea    0x9a0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
lea    0xe38(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1234,%edi
call   10a0 <srand@plt>
lea    0x90(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x20,%esi
mov    $0x400,%edx
call   10e0 <posix_memalign@plt>
test   %eax,%eax
jne    1516 <main+0x356>
mov    0x90(%rsp),%rax
mov    %rax,(%rsp,%rbp,8)
add    $0x1,%rbp
cmp    $0x12,%rbp
jne    1200 <main+0x40>
mov    (%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x18(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x20(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x28(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x30(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x38(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x40(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x48(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x50(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x58(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x60(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x68(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x70(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x78(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x80(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x88(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    %rsp,%rdx
mov    $0x12,%edi
mov    $0x400,%esi
call   1040 <pq_gen@plt>
pxor   %xmm1,%xmm1
mov    0x80(%rsp),%rax
pcmpeqd %xmm2,%xmm2
movdqa 0xc6d(%rip),%xmm0
pxor   %xmm4,%xmm4
pxor   %xmm3,%xmm3
nopl   0x0(%rax,%rax,1)
movd   (%rax,%rbx,1),%xmm6
movd   0x4(%rax,%rbx,1),%xmm5
pcmpeqb %xmm1,%xmm6
pxor   %xmm2,%xmm6
punpcklbw %xmm6,%xmm6
punpcklwd %xmm6,%xmm6
pand   %xmm0,%xmm6
paddd  %xmm4,%xmm6
pcmpeqb %xmm1,%xmm5
pxor   %xmm2,%xmm5
punpcklbw %xmm5,%xmm5
punpcklwd %xmm5,%xmm5
pand   %xmm0,%xmm5
paddd  %xmm3,%xmm5
movd   0x8(%rax,%rbx,1),%xmm4
movd   0xc(%rax,%rbx,1),%xmm3
pcmpeqb %xmm1,%xmm4
pxor   %xmm2,%xmm4
punpcklbw %xmm4,%xmm4
punpcklwd %xmm4,%xmm4
pand   %xmm0,%xmm4
paddd  %xmm6,%xmm4
pcmpeqb %xmm1,%xmm3
pxor   %xmm2,%xmm3
punpcklbw %xmm3,%xmm3
punpcklwd %xmm3,%xmm3
pand   %xmm0,%xmm3
paddd  %xmm5,%xmm3
add    $0x10,%rbx
cmp    $0x400,%rbx
jne    13a0 <main+0x1e0>
paddd  %xmm4,%xmm3
pshufd $0xee,%xmm3,%xmm1
paddd  %xmm3,%xmm1
pshufd $0x55,%xmm1,%xmm2
paddd  %xmm1,%xmm2
mov    0x88(%rsp),%rax
pxor   %xmm1,%xmm1
pxor   %xmm4,%xmm4
movss  %xmm2,%xmm4
xor    %ecx,%ecx
pcmpeqd %xmm3,%xmm3
pxor   %xmm2,%xmm2
nopl   0x0(%rax)
movd   (%rax,%rcx,1),%xmm6
movd   0x4(%rax,%rcx,1),%xmm5
pcmpeqb %xmm1,%xmm6
pxor   %xmm3,%xmm6
punpcklbw %xmm6,%xmm6
punpcklwd %xmm6,%xmm6
pand   %xmm0,%xmm6
paddd  %xmm4,%xmm6
pcmpeqb %xmm1,%xmm5
pxor   %xmm3,%xmm5
punpcklbw %xmm5,%xmm5
punpcklwd %xmm5,%xmm5
pand   %xmm0,%xmm5
paddd  %xmm2,%xmm5
movd   0x8(%rax,%rcx,1),%xmm4
movd   0xc(%rax,%rcx,1),%xmm2
pcmpeqb %xmm1,%xmm4
pxor   %xmm3,%xmm4
punpcklbw %xmm4,%xmm4
punpcklwd %xmm4,%xmm4
pand   %xmm0,%xmm4
paddd  %xmm6,%xmm4
pcmpeqb %xmm1,%xmm2
pxor   %xmm3,%xmm2
punpcklbw %xmm2,%xmm2
punpcklwd %xmm2,%xmm2
pand   %xmm0,%xmm2
paddd  %xmm5,%xmm2
add    $0x10,%rcx
cmp    $0x400,%rcx
jne    1460 <main+0x2a0>
paddd  %xmm4,%xmm2
pshufd $0xee,%xmm2,%xmm0
paddd  %xmm2,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%esi
test   %esi,%esi
je     153f <main+0x37f>
lea    0xb27(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1524 <main+0x364>
lea    0xb05(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%r12d
mov    %r12d,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    (%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x8(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x10(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x18(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x20(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x28(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x30(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x38(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x40(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x48(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x50(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x58(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x60(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x68(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x70(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x78(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x80(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    0x88(%rsp),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
mov    %rsp,%rbp
mov    $0x12,%edi
mov    $0x400,%esi
mov    %rbp,%rdx
call   1040 <pq_gen@plt>
mov    %eax,%ebx
mov    $0x12,%edi
mov    $0x400,%esi
mov    %rbp,%rdx
call   10d0 <pq_check_base@plt>
mov    %eax,%r12d
test   %eax,%eax
jle    17fd <main+0x63d>
lea    0x9b0(%rip),%rdi
mov    %r12d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x8(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x10(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x18(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x20(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x28(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x30(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x38(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x40(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x48(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x50(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x58(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x60(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x68(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x70(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x78(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x80(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x88(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
lea    0x93f(%rip),%rdi
call   1060 <puts@plt>
mov    %rsp,%rdx
mov    $0x12,%edi
mov    $0x400,%esi
call   1050 <pq_gen_base@plt>
mov    0x80(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
mov    0x88(%rsp),%rdi
mov    $0xf,%esi
call   1090 <dump@plt>
jmp    1524 <main+0x364>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    $0x4,%ebp
mov    %rsp,%r14
nop
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rsp,%rbx,8),%rdi
mov    $0x400,%esi
call   10b0 <rand_buffer@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1820 <main+0x660>
mov    %ebp,%edi
mov    $0x400,%esi
mov    %r14,%rdx
call   1040 <pq_gen@plt>
mov    %ebp,%edi
mov    $0x400,%esi
mov    %r14,%rdx
call   10d0 <pq_check_base@plt>
or     %eax,%r12d
jg     1bca <main+0xa0a>
mov    $0x2e,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    $0x13,%rbp
jne    1810 <main+0x650>
xor    %r13d,%r13d
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    %rsp,%r14
mov    $0x4,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rsp,%rbp,8),%rdi
mov    %r13d,%esi
call   10b0 <rand_buffer@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    18a0 <main+0x6e0>
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r14,%rdx
call   1040 <pq_gen@plt>
mov    %eax,%r15d
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r14,%rdx
call   10d0 <pq_check_base@plt>
or     %eax,%r12d
jg     1bd8 <main+0xa18>
add    $0x1,%rbx
cmp    $0x13,%rbx
jne    1890 <main+0x6d0>
mov    $0x2e,%edi
call   1030 <putchar@plt>
lea    0x20(%r13),%eax
cmp    $0x3e1,%r13d
mov    %eax,%r13d
jb     187f <main+0x6bf>
mov    $0xffffffffffffffe0,%r14
mov    $0x400,%ebp
lea    0x90(%rsp),%r15
mov    %r12d,%r13d
mov    (%rsp),%rdi
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    (%rsp),%rax
mov    0x8(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0x90(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x8(%rsp),%rax
mov    0x10(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0x98(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x10(%rsp),%rax
mov    0x18(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0xa0(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x18(%rsp),%rax
mov    0x20(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0xa8(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x20(%rsp),%rax
mov    0x28(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0xb0(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x28(%rsp),%rax
mov    0x30(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0xb8(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x30(%rsp),%rax
mov    0x38(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0xc0(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x38(%rsp),%rax
mov    0x40(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0xc8(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x40(%rsp),%rax
mov    0x48(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0xd0(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x48(%rsp),%rax
mov    0x50(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0xd8(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x50(%rsp),%rax
mov    0x58(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0xe0(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x58(%rsp),%rax
mov    0x60(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0xe8(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x60(%rsp),%rax
mov    0x68(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0xf0(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x68(%rsp),%rax
mov    0x70(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0xf8(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x70(%rsp),%rax
mov    0x78(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0x100(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x78(%rsp),%rax
mov    0x80(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0x108(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x80(%rsp),%rax
mov    0x88(%rsp),%rdi
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0x110(%rsp)
mov    %ebp,%esi
call   10b0 <rand_buffer@plt>
mov    0x88(%rsp),%rax
add    %r14,%rax
add    $0x20,%rax
mov    %rax,0x118(%rsp)
mov    $0x12,%edi
mov    %ebp,%esi
mov    %r15,%rdx
call   1040 <pq_gen@plt>
mov    %eax,%ebx
mov    $0x12,%edi
mov    %ebp,%esi
mov    %r15,%rdx
call   10d0 <pq_check_base@plt>
mov    %eax,%r12d
or     %r13d,%r12d
jg     1bf6 <main+0xa36>
mov    $0x2e,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
add    $0x20,%r14
add    $0xffffffe0,%ebp
cmp    $0x3e1,%r14
jb     1913 <main+0x753>
test   %r12d,%r12d
jne    152a <main+0x36a>
lea    0x533(%rip),%rdi
call   1060 <puts@plt>
xor    %r12d,%r12d
jmp    152a <main+0x36a>
lea    0x498(%rip),%rdi
mov    %ebp,%esi
jmp    150d <main+0x34d>
lea    0x4a5(%rip),%rdi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1524 <main+0x364>
add    $0x20,%r14d
lea    0x4b7(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %r12d,%ecx
mov    %ebx,%r8d
jmp    1bea <main+0xa2a>

LLVM IR (-O0):
@.str = [18 x i8] c"Test pq_gen_test \00"
@.str.1 = [18 x i8] c"alloc error: Fail\00"
@.str.2 = [19 x i8] c"fail zero test %d\0A\00"
@.str.3 = [34 x i8] c" Fail rand test1 fail=%d, ret=%d\0A\00"
@.str.4 = [25 x i8] c" reference function p,q\0A\00"
@.str.5 = [27 x i8] c"fail rand test %d sources\0A\00"
@.str.6 = [52 x i8] c"fail rand test %d sources, len=%d, fail=%d, ret=%d\0A\00"
@.str.7 = [56 x i8] c"fail end test - offset: %d, len: %d, fail: %d, ret: %d\0A\00"
@.str.8 = [13 x i8] c" done: Pass\0A\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 i32
%10 = alloca i32
%11 = alloca [18 x i8*]
%12 = alloca [18 x i8*]
%13 = alloca i8*
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @srand(i32 4660)
store i32 0, i32* %6
br label %17
17: ; preds = %31, %2
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 18
br i1 %19, label %20, label %34
20: ; preds = %17
%21 = call i32 @posix_memalign(i8** %13, i32 32, i32 1024)
store i32 %21, i32* %9
%22 = load i32, i32* %9
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %313
26: ; preds = %20
%27 = load i8*, i8** %13
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 %29
store i8* %27, i8** %30
br label %31
31: ; preds = %26
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %17
34: ; preds = %17
store i32 0, i32* %6
br label %35
35: ; preds = %44, %34
%36 = load i32, i32* %6
%37 = icmp slt i32 %36, 18
br i1 %37, label %38, label %47
38: ; preds = %35
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 %40
%42 = load i8*, i8** %41
%43 = call i32 @memset(i8* %42, i32 0, i32 1024)
br label %44
44: ; preds = %38
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
br label %35
47: ; preds = %35
%48 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 0
%49 = bitcast i8** %48 to i8*
%50 = call i32 @pq_gen(i32 18, i32 1024, i8* %49)
store i32 0, i32* %6
br label %51
51: ; preds = %67, %47
%52 = load i32, i32* %6
%53 = icmp slt i32 %52, 1024
br i1 %53, label %54, label %70
54: ; preds = %51
%55 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 16
%56 = load i8*, i8** %55
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %54
%64 = load i32, i32* %10
%65 = add nsw i32 %64, 1
store i32 %65, i32* %10
br label %66
66: ; preds = %63, %54
br label %67
67: ; preds = %66
%68 = load i32, i32* %6
%69 = add nsw i32 %68, 1
store i32 %69, i32* %6
br label %51
70: ; preds = %51
store i32 0, i32* %6
br label %71
71: ; preds = %87, %70
%72 = load i32, i32* %6
%73 = icmp slt i32 %72, 1024
br i1 %73, label %74, label %90
74: ; preds = %71
%75 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 17
%76 = load i8*, i8** %75
%77 = load i32, i32* %6
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %76, i64 %78
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %74
%84 = load i32, i32* %10
%85 = add nsw i32 %84, 1
store i32 %85, i32* %10
br label %86
86: ; preds = %83, %74
br label %87
87: ; preds = %86
%88 = load i32, i32* %6
%89 = add nsw i32 %88, 1
store i32 %89, i32* %6
br label %71
90: ; preds = %71
%91 = load i32, i32* %10
%92 = icmp sgt i32 %91, 0
br i1 %92, label %93, label %96
93: ; preds = %90
%94 = load i32, i32* %10
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %94)
store i32 1, i32* %3
br label %313
96: ; preds = %90
%97 = call i32 @putchar(i8 signext 46)
br label %98
98: ; preds = %96
store i32 0, i32* %6
br label %99
99: ; preds = %108, %98
%100 = load i32, i32* %6
%101 = icmp slt i32 %100, 18
br i1 %101, label %102, label %111
102: ; preds = %99
%103 = load i32, i32* %6
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 %104
%106 = load i8*, i8** %105
%107 = call i32 @rand_buffer(i8* %106, i32 1024)
br label %108
108: ; preds = %102
%109 = load i32, i32* %6
%110 = add nsw i32 %109, 1
store i32 %110, i32* %6
br label %99
111: ; preds = %99
%112 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 0
%113 = bitcast i8** %112 to i8*
%114 = call i32 @pq_gen(i32 18, i32 1024, i8* %113)
store i32 %114, i32* %9
%115 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 0
%116 = bitcast i8** %115 to i8*
%117 = call i32 @pq_check_base(i32 18, i32 1024, i8* %116)
%118 = load i32, i32* %10
%119 = or i32 %118, %117
store i32 %119, i32* %10
%120 = load i32, i32* %10
%121 = icmp sgt i32 %120, 0
br i1 %121, label %122, label %155
122: ; preds = %111
%123 = load i32, i32* %10
%124 = load i32, i32* %9
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %123, i32 %124)
store i32 0, i32* %14
br label %126
126: ; preds = %135, %122
%127 = load i32, i32* %14
%128 = icmp slt i32 %127, 18
br i1 %128, label %129, label %138
129: ; preds = %126
%130 = load i32, i32* %14
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 %131
%133 = load i8*, i8** %132
%134 = call i32 @dump(i8* %133, i32 15)
br label %135
135: ; preds = %129
%136 = load i32, i32* %14
%137 = add nsw i32 %136, 1
store i32 %137, i32* %14
br label %126
138: ; preds = %126
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%140 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 0
%141 = call i32 @pq_gen_base(i32 18, i32 1024, i8** %140)
store i32 16, i32* %14
br label %142
142: ; preds = %151, %138
%143 = load i32, i32* %14
%144 = icmp slt i32 %143, 18
br i1 %144, label %145, label %154
145: ; preds = %142
%146 = load i32, i32* %14
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 %147
%149 = load i8*, i8** %148
%150 = call i32 @dump(i8* %149, i32 15)
br label %151
151: ; preds = %145
%152 = load i32, i32* %14
%153 = add nsw i32 %152, 1
store i32 %153, i32* %14
br label %142
154: ; preds = %142
store i32 1, i32* %3
br label %313
155: ; preds = %111
%156 = call i32 @putchar(i8 signext 46)
br label %157
157: ; preds = %155
store i32 4, i32* %7
br label %158
158: ; preds = %194, %157
%159 = load i32, i32* %7
%160 = icmp sle i32 %159, 18
br i1 %160, label %161, label %197
161: ; preds = %158
store i32 0, i32* %6
br label %162
162: ; preds = %172, %161
%163 = load i32, i32* %6
%164 = load i32, i32* %7
%165 = icmp slt i32 %163, %164
br i1 %165, label %166, label %175
166: ; preds = %162
%167 = load i32, i32* %6
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 %168
%170 = load i8*, i8** %169
%171 = call i32 @rand_buffer(i8* %170, i32 1024)
br label %172
172: ; preds = %166
%173 = load i32, i32* %6
%174 = add nsw i32 %173, 1
store i32 %174, i32* %6
br label %162
175: ; preds = %162
%176 = load i32, i32* %7
%177 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 0
%178 = bitcast i8** %177 to i8*
%179 = call i32 @pq_gen(i32 %176, i32 1024, i8* %178)
%180 = load i32, i32* %7
%181 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 0
%182 = bitcast i8** %181 to i8*
%183 = call i32 @pq_check_base(i32 %180, i32 1024, i8* %182)
%184 = load i32, i32* %10
%185 = or i32 %184, %183
store i32 %185, i32* %10
%186 = load i32, i32* %10
%187 = icmp sgt i32 %186, 0
br i1 %187, label %188, label %191
188: ; preds = %175
%189 = load i32, i32* %7
%190 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %189)
store i32 1, i32* %3
br label %313
191: ; preds = %175
%192 = call i32 @putchar(i8 signext 46)
br label %193
193: ; preds = %191
br label %194
194: ; preds = %193
%195 = load i32, i32* %7
%196 = add nsw i32 %195, 1
store i32 %196, i32* %7
br label %158
197: ; preds = %158
%198 = call i32 @fflush(i32 0)
store i32 0, i32* %8
br label %199
199: ; preds = %246, %197
%200 = load i32, i32* %8
%201 = icmp sle i32 %200, 1024
br i1 %201, label %202, label %250
202: ; preds = %199
store i32 4, i32* %7
br label %203
203: ; preds = %243, %202
%204 = load i32, i32* %7
%205 = icmp sle i32 %204, 18
br i1 %205, label %206, label %246
206: ; preds = %203
store i32 0, i32* %6
br label %207
207: ; preds = %218, %206
%208 = load i32, i32* %6
%209 = load i32, i32* %7
%210 = icmp slt i32 %208, %209
br i1 %210, label %211, label %221
211: ; preds = %207
%212 = load i32, i32* %6
%213 = sext i32 %212 to i64
%214 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 %213
%215 = load i8*, i8** %214
%216 = load i32, i32* %8
%217 = call i32 @rand_buffer(i8* %215, i32 %216)
br label %218
218: ; preds = %211
%219 = load i32, i32* %6
%220 = add nsw i32 %219, 1
store i32 %220, i32* %6
br label %207
221: ; preds = %207
%222 = load i32, i32* %7
%223 = load i32, i32* %8
%224 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 0
%225 = bitcast i8** %224 to i8*
%226 = call i32 @pq_gen(i32 %222, i32 %223, i8* %225)
store i32 %226, i32* %9
%227 = load i32, i32* %7
%228 = load i32, i32* %8
%229 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 0
%230 = bitcast i8** %229 to i8*
%231 = call i32 @pq_check_base(i32 %227, i32 %228, i8* %230)
%232 = load i32, i32* %10
%233 = or i32 %232, %231
store i32 %233, i32* %10
%234 = load i32, i32* %10
%235 = icmp sgt i32 %234, 0
br i1 %235, label %236, label %242
236: ; preds = %221
%237 = load i32, i32* %7
%238 = load i32, i32* %8
%239 = load i32, i32* %10
%240 = load i32, i32* %9
%241 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0), i32 %237, i32 %238, i32 %239, i32 %240)
store i32 1, i32* %3
br label %313
242: ; preds = %221
br label %243
243: ; preds = %242
%244 = load i32, i32* %7
%245 = add nsw i32 %244, 1
store i32 %245, i32* %7
br label %203
246: ; preds = %203
%247 = call i32 @putchar(i8 signext 46)
%248 = load i32, i32* %8
%249 = add nsw i32 %248, 32
store i32 %249, i32* %8
br label %199
250: ; preds = %199
store i32 0, i32* %8
br label %251
251: ; preds = %301, %250
%252 = load i32, i32* %8
%253 = icmp sle i32 %252, 1024
br i1 %253, label %254, label %306
254: ; preds = %251
store i32 0, i32* %7
br label %255
255: ; preds = %276, %254
%256 = load i32, i32* %7
%257 = icmp slt i32 %256, 18
br i1 %257, label %258, label %279
258: ; preds = %255
%259 = load i32, i32* %7
%260 = sext i32 %259 to i64
%261 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 %260
%262 = load i8*, i8** %261
%263 = load i32, i32* %8
%264 = sub nsw i32 1024, %263
%265 = call i32 @rand_buffer(i8* %262, i32 %264)
%266 = load i32, i32* %7
%267 = sext i32 %266 to i64
%268 = getelementptr inbounds [18 x i8*], [18 x i8*]* %11, i64 0, i64 %267
%269 = load i8*, i8** %268
%270 = load i32, i32* %8
%271 = sext i32 %270 to i64
%272 = getelementptr inbounds i8, i8* %269, i64 %271
%273 = load i32, i32* %7
%274 = sext i32 %273 to i64
%275 = getelementptr inbounds [18 x i8*], [18 x i8*]* %12, i64 0, i64 %274
store i8* %272, i8** %275
br label %276
276: ; preds = %258
%277 = load i32, i32* %7
%278 = add nsw i32 %277, 1
store i32 %278, i32* %7
br label %255
279: ; preds = %255
%280 = load i32, i32* %8
%281 = sub nsw i32 1024, %280
%282 = getelementptr inbounds [18 x i8*], [18 x i8*]* %12, i64 0, i64 0
%283 = bitcast i8** %282 to i8*
%284 = call i32 @pq_gen(i32 18, i32 %281, i8* %283)
store i32 %284, i32* %9
%285 = load i32, i32* %8
%286 = sub nsw i32 1024, %285
%287 = getelementptr inbounds [18 x i8*], [18 x i8*]* %12, i64 0, i64 0
%288 = bitcast i8** %287 to i8*
%289 = call i32 @pq_check_base(i32 18, i32 %286, i8* %288)
%290 = load i32, i32* %10
%291 = or i32 %290, %289
store i32 %291, i32* %10
%292 = load i32, i32* %10
%293 = icmp sgt i32 %292, 0
br i1 %293, label %294, label %301
294: ; preds = %279
%295 = load i32, i32* %8
%296 = load i32, i32* %8
%297 = sub nsw i32 1024, %296
%298 = load i32, i32* %10
%299 = load i32, i32* %9
%300 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.7, i64 0, i64 0), i32 %295, i32 %297, i32 %298, i32 %299)
store i32 1, i32* %3
br label %313
301: ; preds = %279
%302 = call i32 @putchar(i8 signext 46)
%303 = call i32 @fflush(i32 0)
%304 = load i32, i32* %8
%305 = add nsw i32 %304, 32
store i32 %305, i32* %8
br label %251
306: ; preds = %251
%307 = load i32, i32* %10
%308 = icmp ne i32 %307, 0
br i1 %308, label %311, label %309
309: ; preds = %306
%310 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %311
311: ; preds = %309, %306
%312 = load i32, i32* %10
store i32 %312, i32* %3
br label %313
313: ; preds = %311, %294, %236, %188, %154, %93, %24
%314 = load i32, i32* %3
ret i32 %314
}

LLVM IR (-O2):
@.str = [18 x i8] c"Test pq_gen_test \00"
@.str.1 = [18 x i8] c"alloc error: Fail\00"
@.str.2 = [19 x i8] c"fail zero test %d\0A\00"
@.str.3 = [34 x i8] c" Fail rand test1 fail=%d, ret=%d\0A\00"
@.str.5 = [27 x i8] c"fail rand test %d sources\0A\00"
@.str.6 = [52 x i8] c"fail rand test %d sources, len=%d, fail=%d, ret=%d\0A\00"
@.str.7 = [56 x i8] c"fail end test - offset: %d, len: %d, fail: %d, ret: %d\0A\00"
@str = [12 x i8] c" done: Pass\00"
@str.9 = [24 x i8] c" reference function p,q\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [18 x i8*]
%4 = alloca [18 x i8*]
%5 = alloca i8*
%6 = bitcast [18 x i8*]* %3 to i8*
%7 = bitcast [18 x i8*]* %4 to i8*
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @srand(i32 4660)
%10 = bitcast i8** %5 to i8*
br label %11
11: ; preds = %2, %17
%12 = phi i64 [ 0, %2 ], [ %20, %17 ]
%13 = call i32 @posix_memalign(i8** %5, i32 32, i32 1024)
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %405
17: ; preds = %11
%18 = load i8*, i8** %5
%19 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 %12
store i8* %18, i8** %19
%20 = add nuw nsw i64 %12, 1
%21 = icmp eq i64 %20, 18
br i1 %21, label %22, label %11
22: ; preds = %17
%23 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 0
%24 = load i8*, i8** %23
%25 = call i32 @memset(i8* %24, i32 0, i32 1024)
%26 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @memset(i8* %27, i32 0, i32 1024)
%29 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @memset(i8* %30, i32 0, i32 1024)
%32 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 3
%33 = load i8*, i8** %32
%34 = call i32 @memset(i8* %33, i32 0, i32 1024)
%35 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 4
%36 = load i8*, i8** %35
%37 = call i32 @memset(i8* %36, i32 0, i32 1024)
%38 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 5
%39 = load i8*, i8** %38
%40 = call i32 @memset(i8* %39, i32 0, i32 1024)
%41 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 6
%42 = load i8*, i8** %41
%43 = call i32 @memset(i8* %42, i32 0, i32 1024)
%44 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 7
%45 = load i8*, i8** %44
%46 = call i32 @memset(i8* %45, i32 0, i32 1024)
%47 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 8
%48 = load i8*, i8** %47
%49 = call i32 @memset(i8* %48, i32 0, i32 1024)
%50 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 9
%51 = load i8*, i8** %50
%52 = call i32 @memset(i8* %51, i32 0, i32 1024)
%53 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 10
%54 = load i8*, i8** %53
%55 = call i32 @memset(i8* %54, i32 0, i32 1024)
%56 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 11
%57 = load i8*, i8** %56
%58 = call i32 @memset(i8* %57, i32 0, i32 1024)
%59 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 12
%60 = load i8*, i8** %59
%61 = call i32 @memset(i8* %60, i32 0, i32 1024)
%62 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 13
%63 = load i8*, i8** %62
%64 = call i32 @memset(i8* %63, i32 0, i32 1024)
%65 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 14
%66 = load i8*, i8** %65
%67 = call i32 @memset(i8* %66, i32 0, i32 1024)
%68 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 15
%69 = load i8*, i8** %68
%70 = call i32 @memset(i8* %69, i32 0, i32 1024)
%71 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 16
%72 = load i8*, i8** %71
%73 = call i32 @memset(i8* %72, i32 0, i32 1024)
%74 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 17
%75 = load i8*, i8** %74
%76 = call i32 @memset(i8* %75, i32 0, i32 1024)
%77 = call i32 @pq_gen(i32 18, i32 1024, i8* %6)
%78 = load i8*, i8** %71
br label %79
79: ; preds = %79, %22
%80 = phi i64 [ 0, %22 ], [ %108, %79 ]
%81 = phi <4 x i32> [ zeroinitializer, %22 ], [ %106, %79 ]
%82 = phi <4 x i32> [ zeroinitializer, %22 ], [ %107, %79 ]
%83 = getelementptr inbounds i8, i8* %78, i64 %80
%84 = bitcast i8* %83 to <4 x i8>*
%85 = load <4 x i8>, <4 x i8>* %84
%86 = getelementptr inbounds i8, i8* %83, i64 4
%87 = bitcast i8* %86 to <4 x i8>*
%88 = load <4 x i8>, <4 x i8>* %87
%89 = icmp ne <4 x i8> %85, zeroinitializer
%90 = icmp ne <4 x i8> %88, zeroinitializer
%91 = zext <4 x i1> %89 to <4 x i32>
%92 = zext <4 x i1> %90 to <4 x i32>
%93 = add <4 x i32> %81, %91
%94 = add <4 x i32> %82, %92
%95 = or i64 %80, 8
%96 = getelementptr inbounds i8, i8* %78, i64 %95
%97 = bitcast i8* %96 to <4 x i8>*
%98 = load <4 x i8>, <4 x i8>* %97
%99 = getelementptr inbounds i8, i8* %96, i64 4
%100 = bitcast i8* %99 to <4 x i8>*
%101 = load <4 x i8>, <4 x i8>* %100
%102 = icmp ne <4 x i8> %98, zeroinitializer
%103 = icmp ne <4 x i8> %101, zeroinitializer
%104 = zext <4 x i1> %102 to <4 x i32>
%105 = zext <4 x i1> %103 to <4 x i32>
%106 = add <4 x i32> %93, %104
%107 = add <4 x i32> %94, %105
%108 = add nuw nsw i64 %80, 16
%109 = icmp eq i64 %108, 1024
br i1 %109, label %110, label %79
110: ; preds = %79
%111 = add <4 x i32> %107, %106
%112 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %111)
%113 = load i8*, i8** %74
%114 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %112, i64 0
br label %115
115: ; preds = %115, %110
%116 = phi i64 [ 0, %110 ], [ %144, %115 ]
%117 = phi <4 x i32> [ %114, %110 ], [ %142, %115 ]
%118 = phi <4 x i32> [ zeroinitializer, %110 ], [ %143, %115 ]
%119 = getelementptr inbounds i8, i8* %113, i64 %116
%120 = bitcast i8* %119 to <4 x i8>*
%121 = load <4 x i8>, <4 x i8>* %120
%122 = getelementptr inbounds i8, i8* %119, i64 4
%123 = bitcast i8* %122 to <4 x i8>*
%124 = load <4 x i8>, <4 x i8>* %123
%125 = icmp ne <4 x i8> %121, zeroinitializer
%126 = icmp ne <4 x i8> %124, zeroinitializer
%127 = zext <4 x i1> %125 to <4 x i32>
%128 = zext <4 x i1> %126 to <4 x i32>
%129 = add <4 x i32> %117, %127
%130 = add <4 x i32> %118, %128
%131 = or i64 %116, 8
%132 = getelementptr inbounds i8, i8* %113, i64 %131
%133 = bitcast i8* %132 to <4 x i8>*
%134 = load <4 x i8>, <4 x i8>* %133
%135 = getelementptr inbounds i8, i8* %132, i64 4
%136 = bitcast i8* %135 to <4 x i8>*
%137 = load <4 x i8>, <4 x i8>* %136
%138 = icmp ne <4 x i8> %134, zeroinitializer
%139 = icmp ne <4 x i8> %137, zeroinitializer
%140 = zext <4 x i1> %138 to <4 x i32>
%141 = zext <4 x i1> %139 to <4 x i32>
%142 = add <4 x i32> %129, %140
%143 = add <4 x i32> %130, %141
%144 = add nuw nsw i64 %116, 16
%145 = icmp eq i64 %144, 1024
br i1 %145, label %146, label %115
146: ; preds = %115
%147 = add <4 x i32> %143, %142
%148 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %147)
%149 = icmp eq i32 %148, 0
br i1 %149, label %152, label %150
150: ; preds = %146
%151 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %148)
br label %405
152: ; preds = %146
%153 = call i32 @putchar(i8 signext 46)
%154 = load i8*, i8** %23
%155 = call i32 @rand_buffer(i8* %154, i32 1024)
%156 = load i8*, i8** %26
%157 = call i32 @rand_buffer(i8* %156, i32 1024)
%158 = load i8*, i8** %29
%159 = call i32 @rand_buffer(i8* %158, i32 1024)
%160 = load i8*, i8** %32
%161 = call i32 @rand_buffer(i8* %160, i32 1024)
%162 = load i8*, i8** %35
%163 = call i32 @rand_buffer(i8* %162, i32 1024)
%164 = load i8*, i8** %38
%165 = call i32 @rand_buffer(i8* %164, i32 1024)
%166 = load i8*, i8** %41
%167 = call i32 @rand_buffer(i8* %166, i32 1024)
%168 = load i8*, i8** %44
%169 = call i32 @rand_buffer(i8* %168, i32 1024)
%170 = load i8*, i8** %47
%171 = call i32 @rand_buffer(i8* %170, i32 1024)
%172 = load i8*, i8** %50
%173 = call i32 @rand_buffer(i8* %172, i32 1024)
%174 = load i8*, i8** %53
%175 = call i32 @rand_buffer(i8* %174, i32 1024)
%176 = load i8*, i8** %56
%177 = call i32 @rand_buffer(i8* %176, i32 1024)
%178 = load i8*, i8** %59
%179 = call i32 @rand_buffer(i8* %178, i32 1024)
%180 = load i8*, i8** %62
%181 = call i32 @rand_buffer(i8* %180, i32 1024)
%182 = load i8*, i8** %65
%183 = call i32 @rand_buffer(i8* %182, i32 1024)
%184 = load i8*, i8** %68
%185 = call i32 @rand_buffer(i8* %184, i32 1024)
%186 = load i8*, i8** %71
%187 = call i32 @rand_buffer(i8* %186, i32 1024)
%188 = load i8*, i8** %74
%189 = call i32 @rand_buffer(i8* %188, i32 1024)
%190 = call i32 @pq_gen(i32 18, i32 1024, i8* %6)
%191 = call i32 @pq_check_base(i32 18, i32 1024, i8* %6)
%192 = icmp sgt i32 %191, 0
br i1 %192, label %193, label %237
193: ; preds = %152
%194 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %191, i32 %190)
%195 = load i8*, i8** %23
%196 = call i32 @dump(i8* %195, i32 15)
%197 = load i8*, i8** %26
%198 = call i32 @dump(i8* %197, i32 15)
%199 = load i8*, i8** %29
%200 = call i32 @dump(i8* %199, i32 15)
%201 = load i8*, i8** %32
%202 = call i32 @dump(i8* %201, i32 15)
%203 = load i8*, i8** %35
%204 = call i32 @dump(i8* %203, i32 15)
%205 = load i8*, i8** %38
%206 = call i32 @dump(i8* %205, i32 15)
%207 = load i8*, i8** %41
%208 = call i32 @dump(i8* %207, i32 15)
%209 = load i8*, i8** %44
%210 = call i32 @dump(i8* %209, i32 15)
%211 = load i8*, i8** %47
%212 = call i32 @dump(i8* %211, i32 15)
%213 = load i8*, i8** %50
%214 = call i32 @dump(i8* %213, i32 15)
%215 = load i8*, i8** %53
%216 = call i32 @dump(i8* %215, i32 15)
%217 = load i8*, i8** %56
%218 = call i32 @dump(i8* %217, i32 15)
%219 = load i8*, i8** %59
%220 = call i32 @dump(i8* %219, i32 15)
%221 = load i8*, i8** %62
%222 = call i32 @dump(i8* %221, i32 15)
%223 = load i8*, i8** %65
%224 = call i32 @dump(i8* %223, i32 15)
%225 = load i8*, i8** %68
%226 = call i32 @dump(i8* %225, i32 15)
%227 = load i8*, i8** %71
%228 = call i32 @dump(i8* %227, i32 15)
%229 = load i8*, i8** %74
%230 = call i32 @dump(i8* %229, i32 15)
%231 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.9, i64 0, i64 0))
%232 = call i32 @pq_gen_base(i32 18, i32 1024, i8** %23)
%233 = load i8*, i8** %71
%234 = call i32 @dump(i8* %233, i32 15)
%235 = load i8*, i8** %74
%236 = call i32 @dump(i8* %235, i32 15)
br label %405
237: ; preds = %152
%238 = call i32 @putchar(i8 signext 46)
br label %239
239: ; preds = %237, %258
%240 = phi i64 [ 4, %237 ], [ %260, %258 ]
%241 = phi i32 [ %191, %237 ], [ %253, %258 ]
br label %242
242: ; preds = %239, %242
%243 = phi i64 [ 0, %239 ], [ %247, %242 ]
%244 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 %243
%245 = load i8*, i8** %244
%246 = call i32 @rand_buffer(i8* %245, i32 1024)
%247 = add nuw nsw i64 %243, 1
%248 = icmp eq i64 %247, %240
br i1 %248, label %249, label %242
249: ; preds = %242
%250 = trunc i64 %240 to i32
%251 = call i32 @pq_gen(i32 %250, i32 1024, i8* %6)
%252 = call i32 @pq_check_base(i32 %250, i32 1024, i8* %6)
%253 = or i32 %252, %241
%254 = icmp sgt i32 %253, 0
br i1 %254, label %255, label %258
255: ; preds = %249
%256 = trunc i64 %240 to i32
%257 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %256)
br label %405
258: ; preds = %249
%259 = call i32 @putchar(i8 signext 46)
%260 = add nuw nsw i64 %240, 1
%261 = icmp eq i64 %260, 19
br i1 %261, label %262, label %239
262: ; preds = %258
%263 = call i32 @fflush(i32 0)
br label %264
264: ; preds = %262, %289
%265 = phi i32 [ %253, %262 ], [ %281, %289 ]
%266 = phi i32 [ 0, %262 ], [ %291, %289 ]
br label %267
267: ; preds = %264, %286
%268 = phi i64 [ 4, %264 ], [ %287, %286 ]
%269 = phi i32 [ %265, %264 ], [ %281, %286 ]
br label %270
270: ; preds = %267, %270
%271 = phi i64 [ 0, %267 ], [ %275, %270 ]
%272 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 %271
%273 = load i8*, i8** %272
%274 = call i32 @rand_buffer(i8* %273, i32 %266)
%275 = add nuw nsw i64 %271, 1
%276 = icmp eq i64 %275, %268
br i1 %276, label %277, label %270
277: ; preds = %270
%278 = trunc i64 %268 to i32
%279 = call i32 @pq_gen(i32 %278, i32 %266, i8* %6)
%280 = call i32 @pq_check_base(i32 %278, i32 %266, i8* %6)
%281 = or i32 %280, %269
%282 = icmp sgt i32 %281, 0
br i1 %282, label %283, label %286
283: ; preds = %277
%284 = trunc i64 %268 to i32
%285 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0), i32 %284, i32 %266, i32 %281, i32 %279)
br label %405
286: ; preds = %277
%287 = add nuw nsw i64 %268, 1
%288 = icmp eq i64 %287, 19
br i1 %288, label %289, label %267
289: ; preds = %286
%290 = call i32 @putchar(i8 signext 46)
%291 = add nuw nsw i32 %266, 32
%292 = icmp ult i32 %266, 993
br i1 %292, label %264, label %293
293: ; preds = %289
%294 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 0
%295 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 1
%296 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 2
%297 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 3
%298 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 4
%299 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 5
%300 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 6
%301 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 7
%302 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 8
%303 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 9
%304 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 10
%305 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 11
%306 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 12
%307 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 13
%308 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 14
%309 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 15
%310 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 16
%311 = getelementptr inbounds [18 x i8*], [18 x i8*]* %4, i64 0, i64 17
br label %312
312: ; preds = %293, %396
%313 = phi i64 [ 0, %293 ], [ %399, %396 ]
%314 = phi i32 [ %281, %293 ], [ %391, %396 ]
%315 = load i8*, i8** %23
%316 = trunc i64 %313 to i32
%317 = sub nuw nsw i32 1024, %316
%318 = call i32 @rand_buffer(i8* %315, i32 %317)
%319 = load i8*, i8** %23
%320 = getelementptr inbounds i8, i8* %319, i64 %313
store i8* %320, i8** %294
%321 = load i8*, i8** %26
%322 = call i32 @rand_buffer(i8* %321, i32 %317)
%323 = load i8*, i8** %26
%324 = getelementptr inbounds i8, i8* %323, i64 %313
store i8* %324, i8** %295
%325 = load i8*, i8** %29
%326 = call i32 @rand_buffer(i8* %325, i32 %317)
%327 = load i8*, i8** %29
%328 = getelementptr inbounds i8, i8* %327, i64 %313
store i8* %328, i8** %296
%329 = load i8*, i8** %32
%330 = call i32 @rand_buffer(i8* %329, i32 %317)
%331 = load i8*, i8** %32
%332 = getelementptr inbounds i8, i8* %331, i64 %313
store i8* %332, i8** %297
%333 = load i8*, i8** %35
%334 = call i32 @rand_buffer(i8* %333, i32 %317)
%335 = load i8*, i8** %35
%336 = getelementptr inbounds i8, i8* %335, i64 %313
store i8* %336, i8** %298
%337 = load i8*, i8** %38
%338 = call i32 @rand_buffer(i8* %337, i32 %317)
%339 = load i8*, i8** %38
%340 = getelementptr inbounds i8, i8* %339, i64 %313
store i8* %340, i8** %299
%341 = load i8*, i8** %41
%342 = call i32 @rand_buffer(i8* %341, i32 %317)
%343 = load i8*, i8** %41
%344 = getelementptr inbounds i8, i8* %343, i64 %313
store i8* %344, i8** %300
%345 = load i8*, i8** %44
%346 = call i32 @rand_buffer(i8* %345, i32 %317)
%347 = load i8*, i8** %44
%348 = getelementptr inbounds i8, i8* %347, i64 %313
store i8* %348, i8** %301
%349 = load i8*, i8** %47
%350 = call i32 @rand_buffer(i8* %349, i32 %317)
%351 = load i8*, i8** %47
%352 = getelementptr inbounds i8, i8* %351, i64 %313
store i8* %352, i8** %302
%353 = load i8*, i8** %50
%354 = call i32 @rand_buffer(i8* %353, i32 %317)
%355 = load i8*, i8** %50
%356 = getelementptr inbounds i8, i8* %355, i64 %313
store i8* %356, i8** %303
%357 = load i8*, i8** %53
%358 = call i32 @rand_buffer(i8* %357, i32 %317)
%359 = load i8*, i8** %53
%360 = getelementptr inbounds i8, i8* %359, i64 %313
store i8* %360, i8** %304
%361 = load i8*, i8** %56
%362 = call i32 @rand_buffer(i8* %361, i32 %317)
%363 = load i8*, i8** %56
%364 = getelementptr inbounds i8, i8* %363, i64 %313
store i8* %364, i8** %305
%365 = load i8*, i8** %59
%366 = call i32 @rand_buffer(i8* %365, i32 %317)
%367 = load i8*, i8** %59
%368 = getelementptr inbounds i8, i8* %367, i64 %313
store i8* %368, i8** %306
%369 = load i8*, i8** %62
%370 = call i32 @rand_buffer(i8* %369, i32 %317)
%371 = load i8*, i8** %62
%372 = getelementptr inbounds i8, i8* %371, i64 %313
store i8* %372, i8** %307
%373 = load i8*, i8** %65
%374 = call i32 @rand_buffer(i8* %373, i32 %317)
%375 = load i8*, i8** %65
%376 = getelementptr inbounds i8, i8* %375, i64 %313
store i8* %376, i8** %308
%377 = load i8*, i8** %68
%378 = call i32 @rand_buffer(i8* %377, i32 %317)
%379 = load i8*, i8** %68
%380 = getelementptr inbounds i8, i8* %379, i64 %313
store i8* %380, i8** %309
%381 = load i8*, i8** %71
%382 = call i32 @rand_buffer(i8* %381, i32 %317)
%383 = load i8*, i8** %71
%384 = getelementptr inbounds i8, i8* %383, i64 %313
store i8* %384, i8** %310
%385 = load i8*, i8** %74
%386 = call i32 @rand_buffer(i8* %385, i32 %317)
%387 = load i8*, i8** %74
%388 = getelementptr inbounds i8, i8* %387, i64 %313
store i8* %388, i8** %311
%389 = call i32 @pq_gen(i32 18, i32 %317, i8* %7)
%390 = call i32 @pq_check_base(i32 18, i32 %317, i8* %7)
%391 = or i32 %390, %314
%392 = icmp sgt i32 %391, 0
br i1 %392, label %393, label %396
393: ; preds = %312
%394 = trunc i64 %313 to i32
%395 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.7, i64 0, i64 0), i32 %394, i32 %317, i32 %391, i32 %389)
br label %405
396: ; preds = %312
%397 = call i32 @putchar(i8 signext 46)
%398 = call i32 @fflush(i32 0)
%399 = add nuw nsw i64 %313, 32
%400 = icmp ult i64 %313, 993
br i1 %400, label %312, label %401
401: ; preds = %396
%402 = icmp eq i32 %391, 0
br i1 %402, label %403, label %405
403: ; preds = %401
%404 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %405
405: ; preds = %193, %15, %401, %403, %393, %283, %255, %150
%406 = phi i32 [ 1, %15 ], [ 1, %150 ], [ 1, %255 ], [ 1, %283 ], [ 1, %393 ], [ 0, %403 ], [ %391, %401 ], [ 1, %193 ]
ret i32 %406
}