#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 */
typedef scalar_t__ int64_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(scalar_t__ *, scalar_t__ *, int);
int /*<<< orphan*/ sorter_binary_insertion_sort(scalar_t__ *, int);
int /*<<< orphan*/ sorter_grail_merge_buffers_left(scalar_t__ *, scalar_t__ *,
                                                   scalar_t__ *, int, int, int,
                                                   int, int);
int /*<<< orphan*/ sorter_grail_merge_buffers_left_with_x_buf(scalar_t__ *,
                                                              scalar_t__ *,
                                                              scalar_t__ *, int,
                                                              int, int, int);
int /*<<< orphan*/ sorter_grail_swap1(scalar_t__ *, scalar_t__ *);
int /*<<< orphan*/ sorter_grail_swap_n(scalar_t__ *, scalar_t__ *, int);
void sorter_grail_combine_blocks(int64_t *keys, int64_t *arr, int len, int LL,
                                 int lblock, int havebuf, int64_t *xbuf) {
  int M, b, NBlk, midkey, lrest, u, p, v, kc, nbl2, llast;
  int64_t *arr1;
  M = len / (2 * LL);
  lrest = len % (2 * LL);
  if (lrest <= LL) {
    len -= lrest;
    lrest = 0;
  }
  if (xbuf) {
    memcpy(xbuf, arr - lblock, lblock * sizeof(int64_t));
  }
  for (b = 0; b <= M; b++) {
    if (b == M && lrest == 0) {
      break;
    }
    arr1 = arr + b * 2 * LL;
    NBlk = (b == M ? lrest : 2 * LL) / lblock;
    sorter_binary_insertion_sort(keys, NBlk + (b == M ? 1 : 0));
    midkey = LL / lblock;
    for (u = 1; u < NBlk; u++) {
      p = u - 1;
      for (v = u; v < NBlk; v++) {
        kc = ((*(arr1 + p * lblock)) - (*(arr1 + v * lblock)));
        if (kc > 0 || (kc == 0 && ((*(keys + p)) - (*(keys + v))) > 0)) {
          p = v;
        }
      }
      if (p != u - 1) {
        sorter_grail_swap_n(arr1 + (u - 1) * lblock, arr1 + p * lblock, lblock);
        sorter_grail_swap1(keys + (u - 1), keys + p);
        if (midkey == u - 1 || midkey == p) {
          midkey ^= (u - 1) ^ p;
        }
      }
    }
    nbl2 = llast = 0;
    if (b == M) {
      llast = lrest % lblock;
    }
    if (llast != 0) {
      while (nbl2 < NBlk && ((*(arr1 + NBlk * lblock)) -
                             (*(arr1 + (NBlk - nbl2 - 1) * lblock))) < 0) {
        nbl2++;
      }
    }
    if (xbuf) {
      sorter_grail_merge_buffers_left_with_x_buf(
          keys, keys + midkey, arr1, NBlk - nbl2, lblock, nbl2, llast);
    } else {
      sorter_grail_merge_buffers_left(keys, keys + midkey, arr1, NBlk - nbl2,
                                      lblock, havebuf, nbl2, llast);
    }
  }
  if (xbuf) {
    for (p = len; --p >= 0;) {
      arr[p] = arr[p - lblock];
    }
    memcpy(arr - lblock, xbuf, lblock * sizeof(int64_t));
  } else if (havebuf)
    while (--len >= 0) {
      sorter_grail_swap1(arr + len, arr + len - lblock);
    }
}


x86 assembly (clang, -O0):
<sorter_grail_combine_blocks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
mov    %edx,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11be <sorter_grail_combine_blocks+0x5e>
mov    -0x34(%rbp),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x34(%rbp)
cmpq   $0x0,0x10(%rbp)
je     11f0 <sorter_grail_combine_blocks+0x90>
mov    0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x1c(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
shl    $0x3,%rax
add    %rax,%rsi
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     150a <sorter_grail_combine_blocks+0x3aa>
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    121e <sorter_grail_combine_blocks+0xbe>
cmpl   $0x0,-0x34(%rbp)
jne    121e <sorter_grail_combine_blocks+0xbe>
jmp    150a <sorter_grail_combine_blocks+0x3aa>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x1,%ecx
imul   -0x18(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    1251 <sorter_grail_combine_blocks+0xf1>
mov    -0x34(%rbp),%eax
mov    %eax,-0x5c(%rbp)
jmp    125a <sorter_grail_combine_blocks+0xfa>
mov    -0x18(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%r8d
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %r8d,%edx
cmove  %ecx,%eax
add    %eax,%esi
call   1080 <sorter_binary_insertion_sort@plt>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %eax,-0x30(%rbp)
movl   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    13e3 <sorter_grail_combine_blocks+0x283>
mov    -0x38(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1334 <sorter_grail_combine_blocks+0x1d4>
mov    -0x58(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x58(%rbp),%rcx
mov    -0x40(%rbp),%edx
imul   -0x1c(%rbp),%edx
movslq %edx,%rdx
sub    (%rcx,%rdx,8),%rax
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jg     131b <sorter_grail_combine_blocks+0x1bb>
cmpl   $0x0,-0x44(%rbp)
jne    1321 <sorter_grail_combine_blocks+0x1c1>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x8(%rbp),%rcx
movslq -0x40(%rbp),%rdx
sub    (%rcx,%rdx,8),%rax
cmp    $0x0,%rax
jle    1321 <sorter_grail_combine_blocks+0x1c1>
mov    -0x40(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    1326 <sorter_grail_combine_blocks+0x1c6>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    12b2 <sorter_grail_combine_blocks+0x152>
mov    -0x3c(%rbp),%eax
mov    -0x38(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     13d0 <sorter_grail_combine_blocks+0x270>
mov    -0x58(%rbp),%rdi
mov    -0x38(%rbp),%eax
sub    $0x1,%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x58(%rbp),%rsi
mov    -0x3c(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x1c(%rbp),%edx
call   1060 <sorter_grail_swap_n@plt>
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x3c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
call   1030 <sorter_grail_swap1@plt>
mov    -0x30(%rbp),%eax
mov    -0x38(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     13bc <sorter_grail_combine_blocks+0x25c>
mov    -0x30(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jne    13cb <sorter_grail_combine_blocks+0x26b>
mov    -0x38(%rbp),%eax
sub    $0x1,%eax
xor    -0x3c(%rbp),%eax
xor    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    13d0 <sorter_grail_combine_blocks+0x270>
jmp    13d5 <sorter_grail_combine_blocks+0x275>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1297 <sorter_grail_combine_blocks+0x137>
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    1407 <sorter_grail_combine_blocks+0x2a7>
mov    -0x34(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     147e <sorter_grail_combine_blocks+0x31e>
jmp    1416 <sorter_grail_combine_blocks+0x2b6>
mov    -0x48(%rbp),%ecx
xor    %eax,%eax
cmp    -0x2c(%rbp),%ecx
mov    %al,-0x5d(%rbp)
jge    145b <sorter_grail_combine_blocks+0x2fb>
mov    -0x58(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x58(%rbp),%rcx
mov    -0x2c(%rbp),%edx
sub    -0x48(%rbp),%edx
sub    $0x1,%edx
imul   -0x1c(%rbp),%edx
movslq %edx,%rdx
sub    (%rcx,%rdx,8),%rax
cmp    $0x0,%rax
setl   %al
mov    %al,-0x5d(%rbp)
mov    -0x5d(%rbp),%al
test   $0x1,%al
jne    146b <sorter_grail_combine_blocks+0x30b>
jmp    1479 <sorter_grail_combine_blocks+0x319>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1416 <sorter_grail_combine_blocks+0x2b6>
jmp    147e <sorter_grail_combine_blocks+0x31e>
cmpq   $0x0,0x10(%rbp)
je     14be <sorter_grail_combine_blocks+0x35e>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x30(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x58(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
sub    -0x48(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x48(%rbp),%r9d
mov    -0x4c(%rbp),%eax
mov    %eax,(%rsp)
call   1070 <sorter_grail_merge_buffers_left_with_x_buf@plt>
jmp    14f7 <sorter_grail_combine_blocks+0x397>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x30(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x58(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
sub    -0x48(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    -0x48(%rbp),%r10d
mov    -0x4c(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <sorter_grail_merge_buffers_left@plt>
jmp    14fc <sorter_grail_combine_blocks+0x39c>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11f7 <sorter_grail_combine_blocks+0x97>
cmpq   $0x0,0x10(%rbp)
je     157b <sorter_grail_combine_blocks+0x41b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
cmp    $0x0,%eax
jl     154f <sorter_grail_combine_blocks+0x3ef>
mov    -0x10(%rbp),%rax
mov    -0x3c(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    151b <sorter_grail_combine_blocks+0x3bb>
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    0x10(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
jmp    15de <sorter_grail_combine_blocks+0x47e>
cmpl   $0x0,-0x20(%rbp)
je     15d9 <sorter_grail_combine_blocks+0x479>
jmp    158a <sorter_grail_combine_blocks+0x42a>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jl     15d4 <sorter_grail_combine_blocks+0x474>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
movslq -0x1c(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
shl    $0x3,%rax
add    %rax,%rsi
call   1030 <sorter_grail_swap1@plt>
jmp    158a <sorter_grail_combine_blocks+0x42a>
jmp    15d9 <sorter_grail_combine_blocks+0x479>
jmp    15de <sorter_grail_combine_blocks+0x47e>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sorter_grail_combine_blocks>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r9d,0x18(%rsp)
mov    %r8d,%ebp
mov    %edx,%eax
mov    %rsi,%r15
mov    0xc0(%rsp),%r14
lea    (%rcx,%rcx,1),%ebx
mov    %edx,0x48(%rsp)
cltd
idiv   %ebx
mov    %eax,%r13d
xor    %eax,%eax
mov    %rcx,0x80(%rsp)
cmp    %ecx,%edx
mov    $0x0,%ecx
cmovg  %edx,%ecx
mov    %ecx,0x14(%rsp)
cmovle %edx,%eax
mov    %rax,0x68(%rsp)
movslq %r8d,%r12
test   %r14,%r14
mov    %rdi,0x8(%rsp)
je     11e3 <sorter_grail_combine_blocks+0x83>
lea    0x0(,%r12,8),%rax
mov    %r15,%rsi
sub    %rax,%rsi
lea    0x0(,%r12,8),%edx
mov    %r14,%rdi
call   1050 <memcpy@plt>
mov    0x8(%rsp),%rdi
mov    %r12,0x40(%rsp)
mov    %r14,0x50(%rsp)
test   %r13d,%r13d
js     14ac <sorter_grail_combine_blocks+0x34c>
mov    %r13d,%eax
mov    %rax,0x38(%rsp)
add    $0x1,%r13d
mov    %r13,0x78(%rsp)
mov    0x40(%rsp),%rax
lea    (%r15,%rax,8),%rcx
mov    %rcx,0x70(%rsp)
lea    0x0(,%rax,8),%r14
xor    %eax,%eax
mov    %rax,0x28(%rsp)
xor    %ecx,%ecx
mov    %r15,0x20(%rsp)
mov    %ebx,0x1c(%rsp)
jmp    1288 <sorter_grail_combine_blocks+0x128>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
sub    $0x8,%rsp
mov    0x10(%rsp),%rdi
mov    %r13,%rdx
mov    %r12d,%ecx
mov    %ebp,%r8d
mov    %ebx,%r9d
push   %rax
call   1070 <sorter_grail_merge_buffers_left_with_x_buf@plt>
mov    0x18(%rsp),%rdi
add    $0x10,%rsp
mov    0x1c(%rsp),%ebx
mov    0x30(%rsp),%rcx
add    $0x1,%rcx
mov    0x28(%rsp),%rax
add    %ebx,%eax
mov    %rax,0x28(%rsp)
cmp    0x78(%rsp),%rcx
je     14ac <sorter_grail_combine_blocks+0x34c>
cmp    0x38(%rsp),%rcx
jne    129a <sorter_grail_combine_blocks+0x13a>
cmpl   $0x0,0x14(%rsp)
je     14ac <sorter_grail_combine_blocks+0x34c>
mov    %ebx,%eax
imul   %ecx,%eax
xor    %esi,%esi
mov    %rcx,0x30(%rsp)
cmp    0x38(%rsp),%rcx
sete   %sil
movslq %eax,%rcx
mov    %ebx,%eax
cmove  0x14(%rsp),%eax
lea    (%r15,%rcx,8),%r13
cltd
idiv   %ebp
mov    %eax,%r12d
add    %eax,%esi
call   1080 <sorter_binary_insertion_sort@plt>
mov    0x80(%rsp),%rax
cltd
idiv   %ebp
mov    %eax,%r8d
cmp    $0x2,%r12d
jl     1400 <sorter_grail_combine_blocks+0x2a0>
movslq 0x28(%rsp),%rax
mov    0x70(%rsp),%rcx
lea    (%rcx,%rax,8),%rsi
mov    $0x1,%r15d
mov    0x8(%rsp),%rdi
jmp    1320 <sorter_grail_combine_blocks+0x1c0>
nopl   (%rax)
xor    %ecx,%r8d
xor    %ebx,%r8d
mov    0x8(%rsp),%rdi
mov    0x58(%rsp),%rsi
add    $0x1,%r15
add    %r14,%rsi
cmp    %r12,%r15
je     1405 <sorter_grail_combine_blocks+0x2a5>
lea    -0x1(%r15),%r9
mov    %rsi,%rax
mov    %r15,%rcx
mov    %r9d,%ebx
jmp    133e <sorter_grail_combine_blocks+0x1de>
nop
mov    %ecx,%ebx
add    $0x1,%rcx
add    %r14,%rax
cmp    %rcx,%r12
je     1370 <sorter_grail_combine_blocks+0x210>
mov    %ebx,%edx
imul   %ebp,%edx
movslq %edx,%rdx
mov    0x0(%r13,%rdx,8),%edx
sub    (%rax),%edx
test   %edx,%edx
jg     1330 <sorter_grail_combine_blocks+0x1d0>
jne    1332 <sorter_grail_combine_blocks+0x1d2>
movslq %ebx,%rdx
mov    (%rdi,%rdx,8),%rdx
cmp    (%rdi,%rcx,8),%rdx
jg     1330 <sorter_grail_combine_blocks+0x1d0>
jmp    1332 <sorter_grail_combine_blocks+0x1d2>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%eax
cmp    %rax,%r9
je     1310 <sorter_grail_combine_blocks+0x1b0>
mov    %rsi,0x58(%rsp)
mov    %r9,%rax
imul   0x40(%rsp),%rax
lea    0x0(,%rax,8),%rdi
add    %r13,%rdi
mov    %ebx,%eax
imul   %ebp,%eax
cltq
lea    0x0(,%rax,8),%rsi
add    %r13,%rsi
mov    %ebp,%edx
mov    %r8d,0x4c(%rsp)
mov    %r9,0x60(%rsp)
call   1060 <sorter_grail_swap_n@plt>
mov    0x60(%rsp),%rax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
movslq %ebx,%rax
lea    (%rcx,%rax,8),%rsi
call   1030 <sorter_grail_swap1@plt>
mov    0x60(%rsp),%rcx
mov    0x4c(%rsp),%r8d
mov    %r8d,%eax
cmp    %rax,%rcx
je     1300 <sorter_grail_combine_blocks+0x1a0>
cmp    %ebx,%r8d
jne    1306 <sorter_grail_combine_blocks+0x1a6>
jmp    1300 <sorter_grail_combine_blocks+0x1a0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rdi
xor    %ebx,%ebx
mov    0x30(%rsp),%rax
cmp    0x38(%rsp),%rax
jne    1470 <sorter_grail_combine_blocks+0x310>
mov    0x14(%rsp),%eax
cltd
idiv   %ebp
test   %edx,%edx
je     1470 <sorter_grail_combine_blocks+0x310>
mov    %edx,%eax
test   %r12d,%r12d
mov    0x20(%rsp),%r15
jle    1477 <sorter_grail_combine_blocks+0x317>
mov    %r12d,%ecx
imul   %ebp,%ecx
movslq %ecx,%rcx
mov    0x0(%r13,%rcx,8),%rcx
lea    -0x1(%r12),%edx
imul   %ebp,%edx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %edx,%rsi
cmp    0x0(%r13,%rsi,8),%rcx
jge    1477 <sorter_grail_combine_blocks+0x317>
add    $0x1,%rbx
sub    %ebp,%edx
cmp    %rbx,%r12
jne    1450 <sorter_grail_combine_blocks+0x2f0>
mov    %r12d,%ebx
jmp    1477 <sorter_grail_combine_blocks+0x317>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
mov    0x20(%rsp),%r15
sub    %ebx,%r12d
movslq %r8d,%rcx
lea    (%rdi,%rcx,8),%rsi
cmpq   $0x0,0x50(%rsp)
jne    1240 <sorter_grail_combine_blocks+0xe0>
mov    0x8(%rsp),%rdi
mov    %r13,%rdx
mov    %r12d,%ecx
mov    %ebp,%r8d
mov    0x18(%rsp),%r9d
push   %rax
push   %rbx
call   1040 <sorter_grail_merge_buffers_left@plt>
jmp    125b <sorter_grail_combine_blocks+0xfb>
mov    0x48(%rsp),%edx
mov    %edx,%eax
mov    0x68(%rsp),%r8
sub    %r8d,%eax
mov    0x50(%rsp),%rsi
test   %rsi,%rsi
je     150d <sorter_grail_combine_blocks+0x3ad>
test   %eax,%eax
jle    155d <sorter_grail_combine_blocks+0x3fd>
mov    %eax,%ebx
movslq %ebp,%r11
cmp    $0x4,%eax
jae    1587 <sorter_grail_combine_blocks+0x427>
add    $0xffffffffffffffff,%rbx
lea    0x0(,%r11,8),%rcx
mov    %r15,%rax
sub    %rcx,%rax
nopl   0x0(%rax)
mov    (%rax,%rbx,8),%rcx
mov    %ebx,%edx
mov    %rcx,(%r15,%rdx,8)
lea    -0x1(%rbx),%rcx
add    $0x1,%rbx
cmp    $0x1,%rbx
mov    %rcx,%rbx
ja     14f0 <sorter_grail_combine_blocks+0x390>
jmp    1562 <sorter_grail_combine_blocks+0x402>
cmpl   $0x0,0x18(%rsp)
je     154b <sorter_grail_combine_blocks+0x3eb>
test   %eax,%eax
jle    154b <sorter_grail_combine_blocks+0x3eb>
movslq %ebp,%rbx
neg    %rbx
mov    %eax,%ebp
add    $0xffffffffffffffff,%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%eax
lea    (%r15,%rax,8),%rdi
lea    (%rdi,%rbx,8),%rsi
call   1030 <sorter_grail_swap1@plt>
add    $0xffffffffffffffff,%rbp
lea    0x2(%rbp),%eax
cmp    $0x1,%eax
jg     1530 <sorter_grail_combine_blocks+0x3d0>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x40(%rsp),%r11
shl    $0x3,%r11
sub    %r11,%r15
shl    $0x3,%ebp
mov    %r15,%rdi
mov    %ebp,%edx
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <memcpy@plt>
lea    -0x1(%rbx),%rcx
not    %r8d
add    %edx,%r8d
mov    $0x8,%edx
mov    %rcx,%rax
mul    %rdx
seto   %dl
cmp    %ecx,%r8d
jb     14da <sorter_grail_combine_blocks+0x37a>
shr    $0x20,%rcx
jne    14da <sorter_grail_combine_blocks+0x37a>
lea    (%r15,%r8,8),%rcx
mov    %rcx,%rdi
sub    %rax,%rdi
cmp    %rcx,%rdi
ja     14da <sorter_grail_combine_blocks+0x37a>
test   %dl,%dl
jne    14da <sorter_grail_combine_blocks+0x37a>
mov    %r11,%rcx
not    %rcx
add    %rbx,%rcx
lea    (%r15,%rcx,8),%rcx
mov    %rcx,%rdi
sub    %rax,%rdi
cmp    %rcx,%rdi
ja     14da <sorter_grail_combine_blocks+0x37a>
test   %dl,%dl
jne    14da <sorter_grail_combine_blocks+0x37a>
lea    0x1(%r8),%rax
sub    %rbx,%rax
lea    (%r15,%rax,8),%rax
mov    %rbx,%rcx
sub    %r11,%rcx
lea    (%r15,%rcx,8),%rcx
cmp    %rcx,%rax
jae    162a <sorter_grail_combine_blocks+0x4ca>
lea    (%r15,%r8,8),%rax
add    $0x8,%rax
lea    0x0(,%r11,8),%rcx
mov    %r15,%rdx
sub    %rcx,%rdx
cmp    %rax,%rdx
jb     14da <sorter_grail_combine_blocks+0x37a>
mov    %ebx,%r8d
and    $0xfffffffc,%r8d
lea    -0x4(%r8),%rax
mov    %rax,%r9
shr    $0x2,%r9
add    $0x1,%r9
test   %rax,%rax
je     16ed <sorter_grail_combine_blocks+0x58d>
mov    %r9,%rdi
and    $0xfffffffffffffffe,%rdi
mov    $0xfffffffffffffffe,%rax
sub    %r11,%rax
lea    (%r15,%rax,8),%r10
mov    $0xffffffffffffffff,%rdx
mov    %rbx,%rax
nopl   0x0(%rax,%rax,1)
lea    -0x1(%rax),%ecx
movups -0x10(%r10,%rax,8),%xmm0
movups (%r10,%rax,8),%xmm1
movups %xmm1,-0x8(%r15,%rcx,8)
movups %xmm0,-0x18(%r15,%rcx,8)
lea    -0x5(%rax),%ecx
movups -0x30(%r10,%rax,8),%xmm0
movups -0x20(%r10,%rax,8),%xmm1
movups %xmm1,-0x8(%r15,%rcx,8)
movups %xmm0,-0x18(%r15,%rcx,8)
add    $0xfffffffffffffff8,%rdx
add    $0xfffffffffffffff8,%rax
add    $0xfffffffffffffffe,%rdi
jne    1670 <sorter_grail_combine_blocks+0x510>
test   $0x1,%r9b
je     16dc <sorter_grail_combine_blocks+0x57c>
add    %rbx,%rdx
mov    %rdx,%rax
sub    %r11,%rax
movups -0x18(%r15,%rax,8),%xmm0
movups -0x8(%r15,%rax,8),%xmm1
mov    %edx,%eax
movups %xmm1,-0x8(%r15,%rax,8)
movups %xmm0,-0x18(%r15,%rax,8)
cmp    %rbx,%r8
je     1562 <sorter_grail_combine_blocks+0x402>
and    $0x3,%ebx
jmp    14da <sorter_grail_combine_blocks+0x37a>
mov    $0xffffffffffffffff,%rdx
test   $0x1,%r9b
jne    16b9 <sorter_grail_combine_blocks+0x559>
jmp    16dc <sorter_grail_combine_blocks+0x57c>

LLVM IR (-O0):
define void @sorter_grail_combine_blocks(i64* %0, i64* %1, i32 %2, i32 %3, i32 %4, i32 %5, i64* %6) {
%8 = alloca i64*
%9 = alloca i64*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i64*
store i64* %0, i64** %8
store i64* %1, i64** %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i64* %6, i64** %14
%27 = load i32, i32* %10
%28 = load i32, i32* %11
%29 = mul nsw i32 2, %28
%30 = sdiv i32 %27, %29
store i32 %30, i32* %15
%31 = load i32, i32* %10
%32 = load i32, i32* %11
%33 = mul nsw i32 2, %32
%34 = srem i32 %31, %33
store i32 %34, i32* %19
%35 = load i32, i32* %19
%36 = load i32, i32* %11
%37 = icmp sle i32 %35, %36
br i1 %37, label %38, label %42
38: ; preds = %7
%39 = load i32, i32* %19
%40 = load i32, i32* %10
%41 = sub nsw i32 %40, %39
store i32 %41, i32* %10
store i32 0, i32* %19
br label %42
42: ; preds = %38, %7
%43 = load i64*, i64** %14
%44 = icmp ne i64* %43, null
br i1 %44, label %45, label %57
45: ; preds = %42
%46 = load i64*, i64** %14
%47 = load i64*, i64** %9
%48 = load i32, i32* %12
%49 = sext i32 %48 to i64
%50 = sub i64 0, %49
%51 = getelementptr inbounds i64, i64* %47, i64 %50
%52 = load i32, i32* %12
%53 = sext i32 %52 to i64
%54 = mul i64 %53, 8
%55 = trunc i64 %54 to i32
%56 = call i32 @memcpy(i64* %46, i64* %51, i32 %55)
br label %57
57: ; preds = %45, %42
store i32 0, i32* %16
br label %58
58: ; preds = %281, %57
%59 = load i32, i32* %16
%60 = load i32, i32* %15
%61 = icmp sle i32 %59, %60
br i1 %61, label %62, label %284
62: ; preds = %58
%63 = load i32, i32* %16
%64 = load i32, i32* %15
%65 = icmp eq i32 %63, %64
br i1 %65, label %66, label %70
66: ; preds = %62
%67 = load i32, i32* %19
%68 = icmp eq i32 %67, 0
br i1 %68, label %69, label %70
69: ; preds = %66
br label %284
70: ; preds = %66, %62
%71 = load i64*, i64** %9
%72 = load i32, i32* %16
%73 = mul nsw i32 %72, 2
%74 = load i32, i32* %11
%75 = mul nsw i32 %73, %74
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i64, i64* %71, i64 %76
store i64* %77, i64** %26
%78 = load i32, i32* %16
%79 = load i32, i32* %15
%80 = icmp eq i32 %78, %79
br i1 %80, label %81, label %83
81: ; preds = %70
%82 = load i32, i32* %19
br label %86
83: ; preds = %70
%84 = load i32, i32* %11
%85 = mul nsw i32 2, %84
br label %86
86: ; preds = %83, %81
%87 = phi i32 [ %82, %81 ], [ %85, %83 ]
%88 = load i32, i32* %12
%89 = sdiv i32 %87, %88
store i32 %89, i32* %17
%90 = load i64*, i64** %8
%91 = load i32, i32* %17
%92 = load i32, i32* %16
%93 = load i32, i32* %15
%94 = icmp eq i32 %92, %93
%95 = zext i1 %94 to i64
%96 = select i1 %94, i32 1, i32 0
%97 = add nsw i32 %91, %96
%98 = call i32 @sorter_binary_insertion_sort(i64* %90, i32 %97)
%99 = load i32, i32* %11
%100 = load i32, i32* %12
%101 = sdiv i32 %99, %100
store i32 %101, i32* %18
store i32 1, i32* %20
br label %102
102: ; preds = %203, %86
%103 = load i32, i32* %20
%104 = load i32, i32* %17
%105 = icmp slt i32 %103, %104
br i1 %105, label %106, label %206
106: ; preds = %102
%107 = load i32, i32* %20
%108 = sub nsw i32 %107, 1
store i32 %108, i32* %21
%109 = load i32, i32* %20
store i32 %109, i32* %22
br label %110
110: ; preds = %152, %106
%111 = load i32, i32* %22
%112 = load i32, i32* %17
%113 = icmp slt i32 %111, %112
br i1 %113, label %114, label %155
114: ; preds = %110
%115 = load i64*, i64** %26
%116 = load i32, i32* %21
%117 = load i32, i32* %12
%118 = mul nsw i32 %116, %117
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds i64, i64* %115, i64 %119
%121 = load i64, i64* %120
%122 = load i64*, i64** %26
%123 = load i32, i32* %22
%124 = load i32, i32* %12
%125 = mul nsw i32 %123, %124
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds i64, i64* %122, i64 %126
%128 = load i64, i64* %127
%129 = sub nsw i64 %121, %128
%130 = trunc i64 %129 to i32
store i32 %130, i32* %23
%131 = load i32, i32* %23
%132 = icmp sgt i32 %131, 0
br i1 %132, label %149, label %133
133: ; preds = %114
%134 = load i32, i32* %23
%135 = icmp eq i32 %134, 0
br i1 %135, label %136, label %151
136: ; preds = %133
%137 = load i64*, i64** %8
%138 = load i32, i32* %21
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds i64, i64* %137, i64 %139
%141 = load i64, i64* %140
%142 = load i64*, i64** %8
%143 = load i32, i32* %22
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds i64, i64* %142, i64 %144
%146 = load i64, i64* %145
%147 = sub nsw i64 %141, %146
%148 = icmp sgt i64 %147, 0
br i1 %148, label %149, label %151
149: ; preds = %136, %114
%150 = load i32, i32* %22
store i32 %150, i32* %21
br label %151
151: ; preds = %149, %136, %133
br label %152
152: ; preds = %151
%153 = load i32, i32* %22
%154 = add nsw i32 %153, 1
store i32 %154, i32* %22
br label %110
155: ; preds = %110
%156 = load i32, i32* %21
%157 = load i32, i32* %20
%158 = sub nsw i32 %157, 1
%159 = icmp ne i32 %156, %158
br i1 %159, label %160, label %202
160: ; preds = %155
%161 = load i64*, i64** %26
%162 = load i32, i32* %20
%163 = sub nsw i32 %162, 1
%164 = load i32, i32* %12
%165 = mul nsw i32 %163, %164
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds i64, i64* %161, i64 %166
%168 = load i64*, i64** %26
%169 = load i32, i32* %21
%170 = load i32, i32* %12
%171 = mul nsw i32 %169, %170
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds i64, i64* %168, i64 %172
%174 = load i32, i32* %12
%175 = call i32 @sorter_grail_swap_n(i64* %167, i64* %173, i32 %174)
%176 = load i64*, i64** %8
%177 = load i32, i32* %20
%178 = sub nsw i32 %177, 1
%179 = sext i32 %178 to i64
%180 = getelementptr inbounds i64, i64* %176, i64 %179
%181 = load i64*, i64** %8
%182 = load i32, i32* %21
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds i64, i64* %181, i64 %183
%185 = call i32 @sorter_grail_swap1(i64* %180, i64* %184)
%186 = load i32, i32* %18
%187 = load i32, i32* %20
%188 = sub nsw i32 %187, 1
%189 = icmp eq i32 %186, %188
br i1 %189, label %194, label %190
190: ; preds = %160
%191 = load i32, i32* %18
%192 = load i32, i32* %21
%193 = icmp eq i32 %191, %192
br i1 %193, label %194, label %201
194: ; preds = %190, %160
%195 = load i32, i32* %20
%196 = sub nsw i32 %195, 1
%197 = load i32, i32* %21
%198 = xor i32 %196, %197
%199 = load i32, i32* %18
%200 = xor i32 %199, %198
store i32 %200, i32* %18
br label %201
201: ; preds = %194, %190
br label %202
202: ; preds = %201, %155
br label %203
203: ; preds = %202
%204 = load i32, i32* %20
%205 = add nsw i32 %204, 1
store i32 %205, i32* %20
br label %102
206: ; preds = %102
store i32 0, i32* %25
store i32 0, i32* %24
%207 = load i32, i32* %16
%208 = load i32, i32* %15
%209 = icmp eq i32 %207, %208
br i1 %209, label %210, label %214
210: ; preds = %206
%211 = load i32, i32* %19
%212 = load i32, i32* %12
%213 = srem i32 %211, %212
store i32 %213, i32* %25
br label %214
214: ; preds = %210, %206
%215 = load i32, i32* %25
%216 = icmp ne i32 %215, 0
br i1 %216, label %217, label %248
217: ; preds = %214
br label %218
218: ; preds = %244, %217
%219 = load i32, i32* %24
%220 = load i32, i32* %17
%221 = icmp slt i32 %219, %220
br i1 %221, label %222, label %242
222: ; preds = %218
%223 = load i64*, i64** %26
%224 = load i32, i32* %17
%225 = load i32, i32* %12
%226 = mul nsw i32 %224, %225
%227 = sext i32 %226 to i64
%228 = getelementptr inbounds i64, i64* %223, i64 %227
%229 = load i64, i64* %228
%230 = load i64*, i64** %26
%231 = load i32, i32* %17
%232 = load i32, i32* %24
%233 = sub nsw i32 %231, %232
%234 = sub nsw i32 %233, 1
%235 = load i32, i32* %12
%236 = mul nsw i32 %234, %235
%237 = sext i32 %236 to i64
%238 = getelementptr inbounds i64, i64* %230, i64 %237
%239 = load i64, i64* %238
%240 = sub nsw i64 %229, %239
%241 = icmp slt i64 %240, 0
br label %242
242: ; preds = %222, %218
%243 = phi i1 [ false, %218 ], [ %241, %222 ]
br i1 %243, label %244, label %247
244: ; preds = %242
%245 = load i32, i32* %24
%246 = add nsw i32 %245, 1
store i32 %246, i32* %24
br label %218
247: ; preds = %242
br label %248
248: ; preds = %247, %214
%249 = load i64*, i64** %14
%250 = icmp ne i64* %249, null
br i1 %250, label %251, label %265
251: ; preds = %248
%252 = load i64*, i64** %8
%253 = load i64*, i64** %8
%254 = load i32, i32* %18
%255 = sext i32 %254 to i64
%256 = getelementptr inbounds i64, i64* %253, i64 %255
%257 = load i64*, i64** %26
%258 = load i32, i32* %17
%259 = load i32, i32* %24
%260 = sub nsw i32 %258, %259
%261 = load i32, i32* %12
%262 = load i32, i32* %24
%263 = load i32, i32* %25
%264 = call i32 @sorter_grail_merge_buffers_left_with_x_buf(i64* %252, i64* %256, i64* %257, i32 %260, i32 %261, i32 %262, i32 %263)
br label %280
265: ; preds = %248
%266 = load i64*, i64** %8
%267 = load i64*, i64** %8
%268 = load i32, i32* %18
%269 = sext i32 %268 to i64
%270 = getelementptr inbounds i64, i64* %267, i64 %269
%271 = load i64*, i64** %26
%272 = load i32, i32* %17
%273 = load i32, i32* %24
%274 = sub nsw i32 %272, %273
%275 = load i32, i32* %12
%276 = load i32, i32* %13
%277 = load i32, i32* %24
%278 = load i32, i32* %25
%279 = call i32 @sorter_grail_merge_buffers_left(i64* %266, i64* %270, i64* %271, i32 %274, i32 %275, i32 %276, i32 %277, i32 %278)
br label %280
280: ; preds = %265, %251
br label %281
281: ; preds = %280
%282 = load i32, i32* %16
%283 = add nsw i32 %282, 1
store i32 %283, i32* %16
br label %58
284: ; preds = %69, %58
%285 = load i64*, i64** %14
%286 = icmp ne i64* %285, null
br i1 %286, label %287, label %317
287: ; preds = %284
%288 = load i32, i32* %10
store i32 %288, i32* %21
br label %289
289: ; preds = %293, %287
%290 = load i32, i32* %21
%291 = add nsw i32 %290, -1
store i32 %291, i32* %21
%292 = icmp sge i32 %291, 0
br i1 %292, label %293, label %305
293: ; preds = %289
%294 = load i64*, i64** %9
%295 = load i32, i32* %21
%296 = load i32, i32* %12
%297 = sub nsw i32 %295, %296
%298 = sext i32 %297 to i64
%299 = getelementptr inbounds i64, i64* %294, i64 %298
%300 = load i64, i64* %299
%301 = load i64*, i64** %9
%302 = load i32, i32* %21
%303 = sext i32 %302 to i64
%304 = getelementptr inbounds i64, i64* %301, i64 %303
store i64 %300, i64* %304
br label %289
305: ; preds = %289
%306 = load i64*, i64** %9
%307 = load i32, i32* %12
%308 = sext i32 %307 to i64
%309 = sub i64 0, %308
%310 = getelementptr inbounds i64, i64* %306, i64 %309
%311 = load i64*, i64** %14
%312 = load i32, i32* %12
%313 = sext i32 %312 to i64
%314 = mul i64 %313, 8
%315 = trunc i64 %314 to i32
%316 = call i32 @memcpy(i64* %310, i64* %311, i32 %315)
br label %341
317: ; preds = %284
%318 = load i32, i32* %13
%319 = icmp ne i32 %318, 0
br i1 %319, label %320, label %340
320: ; preds = %317
br label %321
321: ; preds = %325, %320
%322 = load i32, i32* %10
%323 = add nsw i32 %322, -1
store i32 %323, i32* %10
%324 = icmp sge i32 %323, 0
br i1 %324, label %325, label %339
325: ; preds = %321
%326 = load i64*, i64** %9
%327 = load i32, i32* %10
%328 = sext i32 %327 to i64
%329 = getelementptr inbounds i64, i64* %326, i64 %328
%330 = load i64*, i64** %9
%331 = load i32, i32* %10
%332 = sext i32 %331 to i64
%333 = getelementptr inbounds i64, i64* %330, i64 %332
%334 = load i32, i32* %12
%335 = sext i32 %334 to i64
%336 = sub i64 0, %335
%337 = getelementptr inbounds i64, i64* %333, i64 %336
%338 = call i32 @sorter_grail_swap1(i64* %329, i64* %337)
br label %321
339: ; preds = %321
br label %340
340: ; preds = %339, %317
br label %341
341: ; preds = %340, %305
ret void
}

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