#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;
typedef int /*<<< orphan*/ dst1;

/* Variables and functions */
size_t rbnd(size_t const);
int /*<<< orphan*/ sorter_binary_insertion_sort(scalar_t__ *, size_t const);
int /*<<< orphan*/ sorter_merge_sort_in_place_aswap(scalar_t__ *, scalar_t__ *,
                                                    size_t);
scalar_t__ sorter_merge_sort_in_place_backmerge(scalar_t__ *, size_t,
                                                scalar_t__ *, size_t);
int /*<<< orphan*/ sorter_merge_sort_in_place_frontmerge(scalar_t__ *, size_t,
                                                         scalar_t__ *, size_t);
int /*<<< orphan*/ sorter_merge_sort_in_place_rmerge(scalar_t__ *, size_t,
                                                     size_t, size_t);
void sorter_merge_sort_in_place(int64_t *dst, const size_t len) {
  if (len <= 1) {
    return;
  }
  size_t r = rbnd(len);
  size_t lr = (len / r - 1) * r, p, m, q, q1, p0;
  int64_t *dst1 = dst - 1;
  if (len < 16) {
    sorter_binary_insertion_sort(dst, len);
    return;
  }
  for (p = 2; p <= lr; p += 2) {
    dst1 += 2;
    if (((dst1[0]) - (dst1[-1])) < 0) {
      {
        int64_t _sort_swap_temp = (dst1[0]);
        (dst1[0]) = (dst1[-1]);
        (dst1[-1]) = _sort_swap_temp;
      };
    }
    if (p & 2) {
      continue;
    }
    m = len - p;
    q = 2;
    while ((p & q) == 0) {
      if (((dst1[1 - q]) - (dst1[-q])) < 0) {
        break;
      }
      q *= 2;
    }
    if (p & q) {
      continue;
    }
    if (q < m) {
      p0 = len - q;
      sorter_merge_sort_in_place_aswap(dst + p - q, dst + p0, q);
      for (;;) {
        q1 = 2 * q;
        if ((q1 > m) || (p & q1)) {
          break;
        }
        p0 = len - q1;
        sorter_merge_sort_in_place_frontmerge(dst + (p - q1), q, dst + p0 + q,
                                              q);
        q = q1;
      }
      sorter_merge_sort_in_place_backmerge(dst + (len - 1), q, dst1 - q, q);
      q *= 2;
    }
    q1 = q;
    while (q1 > m) {
      q1 /= 2;
    }
    while ((q & p) == 0) {
      q *= 2;
      sorter_merge_sort_in_place_rmerge(dst + (p - q), q, q / 2, q1);
    }
  }
  q1 = 0;
  for (q = r; q < lr; q *= 2) {
    if ((lr & q) != 0) {
      q1 += q;
      if (q1 != q) {
        sorter_merge_sort_in_place_rmerge(dst + (lr - q1), q1, q, r);
      }
    }
  }
  m = len - lr;
  sorter_merge_sort_in_place(dst + lr, m);
  sorter_merge_sort_in_place_aswap(dst, dst + lr, m);
  m += sorter_merge_sort_in_place_backmerge(dst + (m - 1), m, dst + (lr - 1),
                                            lr - m);
  sorter_merge_sort_in_place(dst, m);
}


x86 assembly (clang, -O0):
<sorter_merge_sort_in_place>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x1,-0x10(%rbp)
ja     1190 <sorter_merge_sort_in_place+0x20>
jmp    1584 <sorter_merge_sort_in_place+0x414>
mov    -0x10(%rbp),%rdi
call   1080 <rbnd@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
sub    $0x1,%rax
imul   -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x10,-0x10(%rbp)
jae    11df <sorter_merge_sort_in_place+0x6f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <sorter_binary_insertion_sort@plt>
jmp    1584 <sorter_merge_sort_in_place+0x414>
movq   $0x2,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
ja     146f <sorter_merge_sort_in_place+0x2ff>
mov    -0x50(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    (%rax),%rax
mov    -0x50(%rbp),%rcx
sub    -0x8(%rcx),%rax
cmp    $0x0,%rax
jge    1240 <sorter_merge_sort_in_place+0xd0>
mov    -0x50(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rax
mov    -0x8(%rax),%rcx
mov    -0x50(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x58(%rbp),%rcx
mov    -0x50(%rbp),%rax
mov    %rcx,-0x8(%rax)
mov    -0x28(%rbp),%rax
and    $0x2,%rax
cmp    $0x0,%rax
je     1257 <sorter_merge_sort_in_place+0xe7>
jmp    145e <sorter_merge_sort_in_place+0x2ee>
mov    -0x10(%rbp),%rax
sub    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
movq   $0x2,-0x38(%rbp)
mov    -0x28(%rbp),%rax
and    -0x38(%rbp),%rax
cmp    $0x0,%rax
jne    12bc <sorter_merge_sort_in_place+0x14c>
mov    -0x50(%rbp),%rax
mov    $0x1,%ecx
sub    -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x50(%rbp),%rcx
xor    %edx,%edx
sub    -0x38(%rbp),%rdx
sub    (%rcx,%rdx,8),%rax
cmp    $0x0,%rax
jge    12ab <sorter_merge_sort_in_place+0x13b>
jmp    12bc <sorter_merge_sort_in_place+0x14c>
mov    -0x38(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    126b <sorter_merge_sort_in_place+0xfb>
mov    -0x28(%rbp),%rax
and    -0x38(%rbp),%rax
cmp    $0x0,%rax
je     12d3 <sorter_merge_sort_in_place+0x163>
jmp    145e <sorter_merge_sort_in_place+0x2ee>
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    13e2 <sorter_merge_sort_in_place+0x272>
mov    -0x10(%rbp),%rax
sub    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
xor    %eax,%eax
sub    -0x38(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x48(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x38(%rbp),%rdx
call   1030 <sorter_merge_sort_in_place_aswap@plt>
mov    -0x38(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
ja     134d <sorter_merge_sort_in_place+0x1dd>
mov    -0x28(%rbp),%rax
and    -0x40(%rbp),%rax
cmp    $0x0,%rax
je     1352 <sorter_merge_sort_in_place+0x1e2>
jmp    13a5 <sorter_merge_sort_in_place+0x235>
mov    -0x10(%rbp),%rax
sub    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rax
sub    -0x40(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x38(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x48(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x38(%rbp),%rcx
call   1060 <sorter_merge_sort_in_place_frontmerge@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1321 <sorter_merge_sort_in_place+0x1b1>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x38(%rbp),%rsi
mov    -0x50(%rbp),%rdx
xor    %eax,%eax
sub    -0x38(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x38(%rbp),%rcx
call   1050 <sorter_merge_sort_in_place_backmerge@plt>
mov    -0x38(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
jbe    1409 <sorter_merge_sort_in_place+0x299>
mov    -0x40(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    13ea <sorter_merge_sort_in_place+0x27a>
jmp    140e <sorter_merge_sort_in_place+0x29e>
mov    -0x38(%rbp),%rax
and    -0x28(%rbp),%rax
cmp    $0x0,%rax
jne    1459 <sorter_merge_sort_in_place+0x2e9>
mov    -0x38(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rax
sub    -0x38(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x38(%rbp),%rsi
mov    -0x38(%rbp),%rdx
shr    $0x1,%rdx
mov    -0x40(%rbp),%rcx
call   1070 <sorter_merge_sort_in_place_rmerge@plt>
jmp    140e <sorter_merge_sort_in_place+0x29e>
jmp    145e <sorter_merge_sort_in_place+0x2ee>
mov    -0x28(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x28(%rbp)
jmp    11e7 <sorter_merge_sort_in_place+0x77>
movq   $0x0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    14f8 <sorter_merge_sort_in_place+0x388>
mov    -0x20(%rbp),%rax
and    -0x38(%rbp),%rax
cmp    $0x0,%rax
je     14e2 <sorter_merge_sort_in_place+0x372>
mov    -0x38(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x38(%rbp),%rax
je     14dd <sorter_merge_sort_in_place+0x36d>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
sub    -0x40(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1070 <sorter_merge_sort_in_place_rmerge@plt>
jmp    14e2 <sorter_merge_sort_in_place+0x372>
jmp    14e7 <sorter_merge_sort_in_place+0x377>
mov    -0x38(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    147f <sorter_merge_sort_in_place+0x30f>
mov    -0x10(%rbp),%rax
sub    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x30(%rbp),%rsi
call   1040 <sorter_merge_sort_in_place@plt>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x30(%rbp),%rdx
call   1030 <sorter_merge_sort_in_place_aswap@plt>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rax
sub    $0x1,%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x30(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x20(%rbp),%rax
sub    $0x1,%rax
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x20(%rbp),%rcx
sub    -0x30(%rbp),%rcx
call   1050 <sorter_merge_sort_in_place_backmerge@plt>
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <sorter_merge_sort_in_place@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sorter_merge_sort_in_place>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,0x8(%rsp)
cmp    $0x2,%rsi
jae    1198 <sorter_merge_sort_in_place+0x28>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%r14
mov    0x8(%rsp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,0x18(%rsp)
jmp    1209 <sorter_merge_sort_in_place+0x99>
nopl   0x0(%rax,%rax,1)
sub    %rbx,%r14
mov    0x8(%rsp),%rbp
lea    0x0(,%rbx,8),%r15
add    %rbp,%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <sorter_merge_sort_in_place@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <sorter_merge_sort_in_place_aswap@plt>
lea    -0x8(,%r14,8),%rdi
ff
add    %rbp,%rdi
lea    -0x8(,%rbx,8),%rdx
ff
add    %rbp,%rdx
sub    %r14,%rbx
mov    %r14,%rsi
mov    %rbx,%rcx
call   1050 <sorter_merge_sort_in_place_backmerge@plt>
add    %rax,%r14
cmp    $0x1,%r14
jbe    1189 <sorter_merge_sort_in_place+0x19>
mov    %r14,%rdi
call   1080 <rbnd@plt>
mov    %rax,%rcx
mov    %r14,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     1240 <sorter_merge_sort_in_place+0xd0>
mov    %r14,%rax
xor    %edx,%edx
div    %rcx
mov    %rax,%rbx
cmp    $0xf,%r14
ja     1253 <sorter_merge_sort_in_place+0xe3>
jmp    147d <sorter_merge_sort_in_place+0x30d>
cs nopw 0x0(%rax,%rax,1)
mov    %r14d,%eax
xor    %edx,%edx
div    %ecx
mov    %eax,%ebx
cmp    $0xf,%r14
jbe    147d <sorter_merge_sort_in_place+0x30d>
mov    %r14,0x10(%rsp)
add    $0xffffffffffffffff,%rbx
mov    %rcx,0x20(%rsp)
imul   %rcx,%rbx
cmp    $0x2,%rbx
jae    12d0 <sorter_merge_sort_in_place+0x160>
mov    0x20(%rsp),%r12
cmp    %rbx,%r12
mov    0x10(%rsp),%r14
jae    11b0 <sorter_merge_sort_in_place+0x40>
xor    %eax,%eax
mov    %r12,%rbp
jmp    12a2 <sorter_merge_sort_in_place+0x132>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rax,%r15
add    %rbp,%rbp
mov    %r15,%rax
cmp    %rbx,%rbp
jae    11b0 <sorter_merge_sort_in_place+0x40>
test   %rbx,%rbp
je     1290 <sorter_merge_sort_in_place+0x120>
lea    (%rax,%rbp,1),%r15
test   %rax,%rax
je     1293 <sorter_merge_sort_in_place+0x123>
mov    %rbx,%rax
sub    %r15,%rax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
mov    %r12,%rcx
call   1070 <sorter_merge_sort_in_place_rmerge@plt>
jmp    1293 <sorter_merge_sort_in_place+0x123>
nop
mov    0x10(%rsp),%rax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,8),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,0x28(%rsp)
mov    $0x2,%r14d
mov    0x18(%rsp),%r15
mov    %rbx,0x30(%rsp)
jmp    1312 <sorter_merge_sort_in_place+0x1a2>
nopl   0x0(%rax)
add    $0x2,%r14
mov    0x30(%rsp),%rbx
cmp    %rbx,%r14
ja     126b <sorter_merge_sort_in_place+0xfb>
mov    0x8(%r15),%rcx
mov    0x10(%r15),%rax
cmp    %rcx,%rax
jge    1327 <sorter_merge_sort_in_place+0x1b7>
mov    %rcx,0x10(%r15)
mov    %rax,0x8(%r15)
add    $0x10,%r15
test   $0x2,%r14b
jne    1300 <sorter_merge_sort_in_place+0x190>
mov    0x10(%rsp),%r12
sub    %r14,%r12
mov    $0x2,%ebp
xchg   %ax,%ax
mov    $0x1,%eax
sub    %rbp,%rax
mov    (%r15,%rax,8),%rax
lea    0x0(,%rbp,8),%rcx
neg    %rcx
cmp    (%r15,%rcx,1),%rax
jl     1370 <sorter_merge_sort_in_place+0x200>
add    %rbp,%rbp
test   %r14,%rbp
je     1340 <sorter_merge_sort_in_place+0x1d0>
jmp    1300 <sorter_merge_sort_in_place+0x190>
nopw   0x0(%rax,%rax,1)
cmp    %r12,%rbp
jae    1418 <sorter_merge_sort_in_place+0x2a8>
mov    %rbp,%r13
neg    %r13
mov    0x10(%rsp),%rax
sub    %rbp,%rax
mov    0x8(%rsp),%rdx
lea    (%rdx,%r14,8),%rcx
lea    (%rcx,%r13,8),%rdi
lea    (%rdx,%rax,8),%rsi
mov    %rbp,%rdx
call   1030 <sorter_merge_sort_in_place_aswap@plt>
mov    %rbp,%rbx
add    %rbp,%rbx
cmp    %r12,%rbx
ja     1401 <sorter_merge_sort_in_place+0x291>
mov    %rbx,%rax
and    %r14,%rax
jne    1401 <sorter_merge_sort_in_place+0x291>
mov    0x10(%rsp),%r13
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rcx
mov    %rbx,%rbp
mov    %r13,%rax
sub    %rbx,%rax
mov    %r14,%rdx
sub    %rbx,%rdx
mov    0x8(%rsp),%rsi
lea    (%rsi,%rdx,8),%rdi
lea    (%rsi,%rax,8),%rax
lea    (%rax,%rcx,8),%rdx
mov    %rcx,%rsi
call   1060 <sorter_merge_sort_in_place_frontmerge@plt>
add    %rbx,%rbx
cmp    %r12,%rbx
ja     13fb <sorter_merge_sort_in_place+0x28b>
mov    %rbx,%rax
and    %r14,%rax
je     13c0 <sorter_merge_sort_in_place+0x250>
mov    %rbp,%r13
neg    %r13
lea    (%r15,%r13,8),%rdx
mov    0x28(%rsp),%rdi
mov    %rbp,%rsi
mov    %rbp,%rcx
call   1050 <sorter_merge_sort_in_place_backmerge@plt>
mov    %rbx,%rbp
mov    %rbp,%rax
nopl   0x0(%rax,%rax,1)
mov    %rax,%r13
shr    %rax
cmp    %r12,%r13
ja     1420 <sorter_merge_sort_in_place+0x2b0>
test   %r14,%rbp
jne    1300 <sorter_merge_sort_in_place+0x190>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rbx
add    %rbp,%rbx
mov    %r14,%rax
sub    %rbx,%rax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
movabs $0x7ffffffffffffffe,%rax
ff ff 7f
and    %rax,%rbp
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %r13,%rcx
call   1070 <sorter_merge_sort_in_place_rmerge@plt>
mov    %rbx,%rbp
test   %r14,%rbx
je     1440 <sorter_merge_sort_in_place+0x2d0>
jmp    1300 <sorter_merge_sort_in_place+0x190>
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <sorter_binary_insertion_sort@plt>

LLVM IR (-O0):
define void @sorter_merge_sort_in_place(i64* %0, i64 %1) {
%3 = alloca i64*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64*
%13 = alloca i64
store i64* %0, i64** %3
store i64 %1, i64* %4
%14 = load i64, i64* %4
%15 = icmp ule i64 %14, 1
br i1 %15, label %16, label %17
16: ; preds = %2
br label %258
17: ; preds = %2
%18 = load i64, i64* %4
%19 = call i64 @rbnd(i64 %18)
store i64 %19, i64* %5
%20 = load i64, i64* %4
%21 = load i64, i64* %5
%22 = udiv i64 %20, %21
%23 = sub i64 %22, 1
%24 = load i64, i64* %5
%25 = mul i64 %23, %24
store i64 %25, i64* %6
%26 = load i64*, i64** %3
%27 = getelementptr inbounds i64, i64* %26, i64 -1
store i64* %27, i64** %12
%28 = load i64, i64* %4
%29 = icmp ult i64 %28, 16
br i1 %29, label %30, label %34
30: ; preds = %17
%31 = load i64*, i64** %3
%32 = load i64, i64* %4
%33 = call i32 @sorter_binary_insertion_sort(i64* %31, i64 %32)
br label %258
34: ; preds = %17
store i64 2, i64* %7
br label %35
35: ; preds = %191, %34
%36 = load i64, i64* %7
%37 = load i64, i64* %6
%38 = icmp ule i64 %36, %37
br i1 %38, label %39, label %194
39: ; preds = %35
%40 = load i64*, i64** %12
%41 = getelementptr inbounds i64, i64* %40, i64 2
store i64* %41, i64** %12
%42 = load i64*, i64** %12
%43 = getelementptr inbounds i64, i64* %42, i64 0
%44 = load i64, i64* %43
%45 = load i64*, i64** %12
%46 = getelementptr inbounds i64, i64* %45, i64 -1
%47 = load i64, i64* %46
%48 = sub nsw i64 %44, %47
%49 = icmp slt i64 %48, 0
br i1 %49, label %50, label %62
50: ; preds = %39
%51 = load i64*, i64** %12
%52 = getelementptr inbounds i64, i64* %51, i64 0
%53 = load i64, i64* %52
store i64 %53, i64* %13
%54 = load i64*, i64** %12
%55 = getelementptr inbounds i64, i64* %54, i64 -1
%56 = load i64, i64* %55
%57 = load i64*, i64** %12
%58 = getelementptr inbounds i64, i64* %57, i64 0
store i64 %56, i64* %58
%59 = load i64, i64* %13
%60 = load i64*, i64** %12
%61 = getelementptr inbounds i64, i64* %60, i64 -1
store i64 %59, i64* %61
br label %62
62: ; preds = %50, %39
%63 = load i64, i64* %7
%64 = and i64 %63, 2
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %62
br label %191
67: ; preds = %62
%68 = load i64, i64* %4
%69 = load i64, i64* %7
%70 = sub i64 %68, %69
store i64 %70, i64* %8
store i64 2, i64* %9
br label %71
71: ; preds = %90, %67
%72 = load i64, i64* %7
%73 = load i64, i64* %9
%74 = and i64 %72, %73
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %93
76: ; preds = %71
%77 = load i64*, i64** %12
%78 = load i64, i64* %9
%79 = sub i64 1, %78
%80 = getelementptr inbounds i64, i64* %77, i64 %79
%81 = load i64, i64* %80
%82 = load i64*, i64** %12
%83 = load i64, i64* %9
%84 = sub i64 0, %83
%85 = getelementptr inbounds i64, i64* %82, i64 %84
%86 = load i64, i64* %85
%87 = sub nsw i64 %81, %86
%88 = icmp slt i64 %87, 0
br i1 %88, label %89, label %90
89: ; preds = %76
br label %93
90: ; preds = %76
%91 = load i64, i64* %9
%92 = mul i64 %91, 2
store i64 %92, i64* %9
br label %71
93: ; preds = %89, %71
%94 = load i64, i64* %7
%95 = load i64, i64* %9
%96 = and i64 %94, %95
%97 = icmp ne i64 %96, 0
br i1 %97, label %98, label %99
98: ; preds = %93
br label %191
99: ; preds = %93
%100 = load i64, i64* %9
%101 = load i64, i64* %8
%102 = icmp ult i64 %100, %101
br i1 %102, label %103, label %162
103: ; preds = %99
%104 = load i64, i64* %4
%105 = load i64, i64* %9
%106 = sub i64 %104, %105
store i64 %106, i64* %11
%107 = load i64*, i64** %3
%108 = load i64, i64* %7
%109 = getelementptr inbounds i64, i64* %107, i64 %108
%110 = load i64, i64* %9
%111 = sub i64 0, %110
%112 = getelementptr inbounds i64, i64* %109, i64 %111
%113 = load i64*, i64** %3
%114 = load i64, i64* %11
%115 = getelementptr inbounds i64, i64* %113, i64 %114
%116 = load i64, i64* %9
%117 = call i32 @sorter_merge_sort_in_place_aswap(i64* %112, i64* %115, i64 %116)
br label %118
118: ; preds = %130, %103
%119 = load i64, i64* %9
%120 = mul i64 2, %119
store i64 %120, i64* %10
%121 = load i64, i64* %10
%122 = load i64, i64* %8
%123 = icmp ugt i64 %121, %122
br i1 %123, label %129, label %124
124: ; preds = %118
%125 = load i64, i64* %7
%126 = load i64, i64* %10
%127 = and i64 %125, %126
%128 = icmp ne i64 %127, 0
br i1 %128, label %129, label %130
129: ; preds = %124, %118
br label %148
130: ; preds = %124
%131 = load i64, i64* %4
%132 = load i64, i64* %10
%133 = sub i64 %131, %132
store i64 %133, i64* %11
%134 = load i64*, i64** %3
%135 = load i64, i64* %7
%136 = load i64, i64* %10
%137 = sub i64 %135, %136
%138 = getelementptr inbounds i64, i64* %134, i64 %137
%139 = load i64, i64* %9
%140 = load i64*, i64** %3
%141 = load i64, i64* %11
%142 = getelementptr inbounds i64, i64* %140, i64 %141
%143 = load i64, i64* %9
%144 = getelementptr inbounds i64, i64* %142, i64 %143
%145 = load i64, i64* %9
%146 = call i32 @sorter_merge_sort_in_place_frontmerge(i64* %138, i64 %139, i64* %144, i64 %145)
%147 = load i64, i64* %10
store i64 %147, i64* %9
br label %118
148: ; preds = %129
%149 = load i64*, i64** %3
%150 = load i64, i64* %4
%151 = sub i64 %150, 1
%152 = getelementptr inbounds i64, i64* %149, i64 %151
%153 = load i64, i64* %9
%154 = load i64*, i64** %12
%155 = load i64, i64* %9
%156 = sub i64 0, %155
%157 = getelementptr inbounds i64, i64* %154, i64 %156
%158 = load i64, i64* %9
%159 = call i64 @sorter_merge_sort_in_place_backmerge(i64* %152, i64 %153, i64* %157, i64 %158)
%160 = load i64, i64* %9
%161 = mul i64 %160, 2
store i64 %161, i64* %9
br label %162
162: ; preds = %148, %99
%163 = load i64, i64* %9
store i64 %163, i64* %10
br label %164
164: ; preds = %168, %162
%165 = load i64, i64* %10
%166 = load i64, i64* %8
%167 = icmp ugt i64 %165, %166
br i1 %167, label %168, label %171
168: ; preds = %164
%169 = load i64, i64* %10
%170 = udiv i64 %169, 2
store i64 %170, i64* %10
br label %164
171: ; preds = %164
br label %172
172: ; preds = %177, %171
%173 = load i64, i64* %9
%174 = load i64, i64* %7
%175 = and i64 %173, %174
%176 = icmp eq i64 %175, 0
br i1 %176, label %177, label %190
177: ; preds = %172
%178 = load i64, i64* %9
%179 = mul i64 %178, 2
store i64 %179, i64* %9
%180 = load i64*, i64** %3
%181 = load i64, i64* %7
%182 = load i64, i64* %9
%183 = sub i64 %181, %182
%184 = getelementptr inbounds i64, i64* %180, i64 %183
%185 = load i64, i64* %9
%186 = load i64, i64* %9
%187 = udiv i64 %186, 2
%188 = load i64, i64* %10
%189 = call i32 @sorter_merge_sort_in_place_rmerge(i64* %184, i64 %185, i64 %187, i64 %188)
br label %172
190: ; preds = %172
br label %191
191: ; preds = %190, %98, %66
%192 = load i64, i64* %7
%193 = add i64 %192, 2
store i64 %193, i64* %7
br label %35
194: ; preds = %35
store i64 0, i64* %10
%195 = load i64, i64* %5
store i64 %195, i64* %9
br label %196
196: ; preds = %224, %194
%197 = load i64, i64* %9
%198 = load i64, i64* %6
%199 = icmp ult i64 %197, %198
br i1 %199, label %200, label %227
200: ; preds = %196
%201 = load i64, i64* %6
%202 = load i64, i64* %9
%203 = and i64 %201, %202
%204 = icmp ne i64 %203, 0
br i1 %204, label %205, label %223
205: ; preds = %200
%206 = load i64, i64* %9
%207 = load i64, i64* %10
%208 = add i64 %207, %206
store i64 %208, i64* %10
%209 = load i64, i64* %10
%210 = load i64, i64* %9
%211 = icmp ne i64 %209, %210
br i1 %211, label %212, label %222
212: ; preds = %205
%213 = load i64*, i64** %3
%214 = load i64, i64* %6
%215 = load i64, i64* %10
%216 = sub i64 %214, %215
%217 = getelementptr inbounds i64, i64* %213, i64 %216
%218 = load i64, i64* %10
%219 = load i64, i64* %9
%220 = load i64, i64* %5
%221 = call i32 @sorter_merge_sort_in_place_rmerge(i64* %217, i64 %218, i64 %219, i64 %220)
br label %222
222: ; preds = %212, %205
br label %223
223: ; preds = %222, %200
br label %224
224: ; preds = %223
%225 = load i64, i64* %9
%226 = mul i64 %225, 2
store i64 %226, i64* %9
br label %196
227: ; preds = %196
%228 = load i64, i64* %4
%229 = load i64, i64* %6
%230 = sub i64 %228, %229
store i64 %230, i64* %8
%231 = load i64*, i64** %3
%232 = load i64, i64* %6
%233 = getelementptr inbounds i64, i64* %231, i64 %232
%234 = load i64, i64* %8
%235 = load i64*, i64** %3
%236 = load i64*, i64** %3
%237 = load i64, i64* %6
%238 = getelementptr inbounds i64, i64* %236, i64 %237
%239 = load i64, i64* %8
%240 = call i32 @sorter_merge_sort_in_place_aswap(i64* %235, i64* %238, i64 %239)
%241 = load i64*, i64** %3
%242 = load i64, i64* %8
%243 = sub i64 %242, 1
%244 = getelementptr inbounds i64, i64* %241, i64 %243
%245 = load i64, i64* %8
%246 = load i64*, i64** %3
%247 = load i64, i64* %6
%248 = sub i64 %247, 1
%249 = getelementptr inbounds i64, i64* %246, i64 %248
%250 = load i64, i64* %6
%251 = load i64, i64* %8
%252 = sub i64 %250, %251
%253 = call i64 @sorter_merge_sort_in_place_backmerge(i64* %244, i64 %245, i64* %249, i64 %252)
%254 = load i64, i64* %8
%255 = add i64 %254, %253
store i64 %255, i64* %8
%256 = load i64*, i64** %3
%257 = load i64, i64* %8
br label %258
258: ; preds = %227, %30, %16
ret void
}

LLVM IR (-O2):
define void @sorter_merge_sort_in_place(i64* %0, i64 %1) {
%3 = icmp ult i64 %1, 2
br i1 %3, label %133, label %4
4: ; preds = %2
%5 = getelementptr inbounds i64, i64* %0, i64 -1
br label %6
6: ; preds = %4, %121
%7 = phi i64 [ %1, %4 ], [ %131, %121 ]
%8 = tail call i64 @rbnd(i64 %7)
%9 = udiv i64 %7, %8
%10 = add i64 %9, -1
%11 = mul i64 %10, %8
%12 = icmp ult i64 %7, 16
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = tail call i32 @sorter_binary_insertion_sort(i64* %0, i64 %7)
br label %133
15: ; preds = %6
%16 = icmp ult i64 %11, 2
br i1 %16, label %20, label %17
17: ; preds = %15
%18 = add i64 %7, -1
%19 = getelementptr inbounds i64, i64* %0, i64 %18
br label %22
20: ; preds = %102, %15
%21 = icmp ult i64 %8, %11
br i1 %21, label %105, label %121
22: ; preds = %17, %102
%23 = phi i64 [ 2, %17 ], [ %103, %102 ]
%24 = phi i64* [ %5, %17 ], [ %25, %102 ]
%25 = getelementptr inbounds i64, i64* %24, i64 2
%26 = load i64, i64* %25
%27 = getelementptr inbounds i64, i64* %24, i64 1
%28 = load i64, i64* %27
%29 = icmp slt i64 %26, %28
br i1 %29, label %30, label %31
30: ; preds = %22
store i64 %28, i64* %25
store i64 %26, i64* %27
br label %31
31: ; preds = %30, %22
%32 = and i64 %23, 2
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %102
34: ; preds = %31
%35 = sub i64 %7, %23
br label %36
36: ; preds = %34, %45
%37 = phi i64 [ %46, %45 ], [ 2, %34 ]
%38 = sub i64 1, %37
%39 = getelementptr inbounds i64, i64* %25, i64 %38
%40 = load i64, i64* %39
%41 = sub i64 0, %37
%42 = getelementptr inbounds i64, i64* %25, i64 %41
%43 = load i64, i64* %42
%44 = icmp slt i64 %40, %43
br i1 %44, label %49, label %45
45: ; preds = %36
%46 = shl i64 %37, 1
%47 = and i64 %46, %23
%48 = icmp eq i64 %47, 0
br i1 %48, label %36, label %102
49: ; preds = %36
%50 = icmp ult i64 %37, %35
br i1 %50, label %51, label %84
51: ; preds = %49
%52 = sub i64 %7, %37
%53 = getelementptr inbounds i64, i64* %0, i64 %23
%54 = getelementptr inbounds i64, i64* %53, i64 %41
%55 = getelementptr inbounds i64, i64* %0, i64 %52
%56 = tail call i32 @sorter_merge_sort_in_place_aswap(i64* %54, i64* %55, i64 %37)
%57 = shl i64 %37, 1
%58 = icmp ule i64 %57, %35
%59 = and i64 %57, %23
%60 = icmp eq i64 %59, 0
%61 = and i1 %58, %60
br i1 %61, label %62, label %78
62: ; preds = %51, %62
%63 = phi i64 [ %71, %62 ], [ %57, %51 ]
%64 = phi i64 [ %63, %62 ], [ %37, %51 ]
%65 = sub i64 %7, %63
%66 = sub i64 %23, %63
%67 = getelementptr inbounds i64, i64* %0, i64 %66
%68 = getelementptr inbounds i64, i64* %0, i64 %65
%69 = getelementptr inbounds i64, i64* %68, i64 %64
%70 = tail call i32 @sorter_merge_sort_in_place_frontmerge(i64* %67, i64 %64, i64* %69, i64 %64)
%71 = shl i64 %63, 1
%72 = icmp ule i64 %71, %35
%73 = and i64 %71, %23
%74 = icmp eq i64 %73, 0
%75 = and i1 %72, %74
br i1 %75, label %62, label %76
76: ; preds = %62
%77 = sub i64 0, %63
br label %78
78: ; preds = %76, %51
%79 = phi i64 [ %77, %76 ], [ %41, %51 ]
%80 = phi i64 [ %63, %76 ], [ %37, %51 ]
%81 = phi i64 [ %71, %76 ], [ %57, %51 ]
%82 = getelementptr inbounds i64, i64* %25, i64 %79
%83 = tail call i64 @sorter_merge_sort_in_place_backmerge(i64* %19, i64 %80, i64* %82, i64 %80)
br label %84
84: ; preds = %78, %49
%85 = phi i64 [ %81, %78 ], [ %37, %49 ]
br label %86
86: ; preds = %86, %84
%87 = phi i64 [ %85, %84 ], [ %89, %86 ]
%88 = icmp ugt i64 %87, %35
%89 = lshr i64 %87, 1
br i1 %88, label %86, label %90
90: ; preds = %86
%91 = and i64 %85, %23
%92 = icmp eq i64 %91, 0
br i1 %92, label %93, label %102
93: ; preds = %90, %93
%94 = phi i64 [ %95, %93 ], [ %85, %90 ]
%95 = shl i64 %94, 1
%96 = sub i64 %23, %95
%97 = getelementptr inbounds i64, i64* %0, i64 %96
%98 = and i64 %94, 9223372036854775806
%99 = tail call i32 @sorter_merge_sort_in_place_rmerge(i64* %97, i64 %95, i64 %98, i64 %87)
%100 = and i64 %95, %23
%101 = icmp eq i64 %100, 0
br i1 %101, label %93, label %102
102: ; preds = %45, %93, %90, %31
%103 = add i64 %23, 2
%104 = icmp ugt i64 %103, %11
br i1 %104, label %20, label %22
105: ; preds = %20, %117
%106 = phi i64 [ %118, %117 ], [ 0, %20 ]
%107 = phi i64 [ %119, %117 ], [ %8, %20 ]
%108 = and i64 %107, %11
%109 = icmp eq i64 %108, 0
br i1 %109, label %117, label %110
110: ; preds = %105
%111 = add i64 %106, %107
%112 = icmp eq i64 %106, 0
br i1 %112, label %117, label %113
113: ; preds = %110
%114 = sub i64 %11, %111
%115 = getelementptr inbounds i64, i64* %0, i64 %114
%116 = tail call i32 @sorter_merge_sort_in_place_rmerge(i64* %115, i64 %111, i64 %107, i64 %8)
br label %117
117: ; preds = %105, %113, %110
%118 = phi i64 [ %111, %113 ], [ %111, %110 ], [ %106, %105 ]
%119 = shl i64 %107, 1
%120 = icmp ult i64 %119, %11
br i1 %120, label %105, label %121
121: ; preds = %117, %20
%122 = sub i64 %7, %11
%123 = getelementptr inbounds i64, i64* %0, i64 %11
tail call void @sorter_merge_sort_in_place(i64* %123, i64 %122)
%124 = tail call i32 @sorter_merge_sort_in_place_aswap(i64* %0, i64* %123, i64 %122)
%125 = add i64 %122, -1
%126 = getelementptr inbounds i64, i64* %0, i64 %125
%127 = add i64 %11, -1
%128 = getelementptr inbounds i64, i64* %0, i64 %127
%129 = sub i64 %11, %122
%130 = tail call i64 @sorter_merge_sort_in_place_backmerge(i64* %126, i64 %122, i64* %128, i64 %129)
%131 = add i64 %130, %122
%132 = icmp ult i64 %131, 2
br i1 %132, label %133, label %6
133: ; preds = %121, %2, %13
ret void
}