void stable_sqrt_sort_common_sort(int **arr, int Len, int **extbuf, int *Tags) {
  int lblock, cbuf;
  if (Len < 16) {
    stable_sqrt_sort_sort_ins(arr, Len);
    return;
  }
  lblock = 1;
  while (lblock * lblock < Len) {
    lblock *= 2;
  }
  memcpy((extbuf), (arr), (lblock) * sizeof(int *));
  stable_sqrt_sort_common_sort(extbuf, lblock, arr, Tags);
  stable_sqrt_sort_build_blocks(arr + lblock, Len - lblock, lblock);
  cbuf = lblock;
  while (Len > (cbuf *= 2)) {
    stable_sqrt_sort_combine_blocks(arr + lblock, Len - lblock, cbuf, lblock,
                                    Tags);
  }
  stable_sqrt_sort_merge_down(arr + lblock, extbuf, Len - lblock, lblock);
}


x86 assembly (clang, -O0):
<stable_sqrt_sort_common_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    1194 <stable_sqrt_sort_common_sort+0x34>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x0,%al
call   1030 <stable_sqrt_sort_sort_ins@plt>
jmp    1269 <stable_sqrt_sort_common_sort+0x109>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
imul   -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b9 <stable_sqrt_sort_common_sort+0x59>
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119b <stable_sqrt_sort_common_sort+0x3b>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x24(%rbp),%rdx
shl    $0x3,%rdx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x8(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1060 <stable_sqrt_sort_common_sort@plt>
mov    -0x8(%rbp),%rdi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0xc(%rbp),%esi
sub    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    $0x0,%al
call   1080 <stable_sqrt_sort_build_blocks@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x28(%rbp),%ecx
shl    $0x1,%ecx
mov    %ecx,-0x28(%rbp)
cmp    %ecx,%eax
jle    1246 <stable_sqrt_sort_common_sort+0xe6>
mov    -0x8(%rbp),%rdi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0xc(%rbp),%esi
sub    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    $0x0,%al
call   1050 <stable_sqrt_sort_combine_blocks@plt>
jmp    1207 <stable_sqrt_sort_common_sort+0xa7>
mov    -0x8(%rbp),%rdi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
sub    -0x24(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    $0x0,%al
call   1070 <stable_sqrt_sort_merge_down@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stable_sqrt_sort_common_sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r12d
mov    %rdi,%r14
cmp    $0x10,%esi
jge    1194 <stable_sqrt_sort_common_sort+0x34>
mov    %r14,%rdi
mov    %r12d,%esi
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <stable_sqrt_sort_sort_ins@plt>
mov    %rcx,%r15
mov    %rdx,%r13
mov    $0x1,%ebp
nop
mov    %ebp,%ebx
mov    %ebp,%eax
imul   %ebp,%eax
lea    (%rbx,%rbx,1),%ebp
cmp    %r12d,%eax
jl     11a0 <stable_sqrt_sort_common_sort+0x40>
mov    %ebx,%eax
mov    %rax,0x8(%rsp)
lea    0x0(,%rax,8),%rdx
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <memcpy@plt>
mov    %r13,0x10(%rsp)
mov    %r13,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %r15,%rcx
call   1060 <stable_sqrt_sort_common_sort@plt>
mov    0x8(%rsp),%rax
lea    (%r14,%rax,8),%r14
mov    %r12d,%r13d
sub    %ebx,%r13d
mov    %r14,%rdi
mov    %r13d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <stable_sqrt_sort_build_blocks@plt>
cmp    %r12d,%ebp
jge    122b <stable_sqrt_sort_common_sort+0xcb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r13d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %r15,%r8
xor    %eax,%eax
call   1050 <stable_sqrt_sort_combine_blocks@plt>
add    %ebp,%ebp
cmp    %r12d,%ebp
jl     1210 <stable_sqrt_sort_common_sort+0xb0>
mov    %r14,%rdi
mov    0x10(%rsp),%rsi
mov    %r13d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <stable_sqrt_sort_merge_down@plt>

LLVM IR (-O0):
define void @stable_sqrt_sort_common_sort(i32** %0, i32 %1, i32** %2, i32* %3) {
%5 = alloca i32**
%6 = alloca i32
%7 = alloca i32**
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i32** %0, i32*** %5
store i32 %1, i32* %6
store i32** %2, i32*** %7
store i32* %3, i32** %8
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 16
br i1 %12, label %13, label %17
13: ; preds = %4
%14 = load i32**, i32*** %5
%15 = load i32, i32* %6
%16 = call i32 (i32**, i32, ...) bitcast (i32 (...)* @stable_sqrt_sort_sort_ins to i32 (i32**, i32, ...)*)(i32** %14, i32 %15)
br label %77
17: ; preds = %4
store i32 1, i32* %9
br label %18
18: ; preds = %24, %17
%19 = load i32, i32* %9
%20 = load i32, i32* %9
%21 = mul nsw i32 %19, %20
%22 = load i32, i32* %6
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i32, i32* %9
%26 = mul nsw i32 %25, 2
store i32 %26, i32* %9
br label %18
27: ; preds = %18
%28 = load i32**, i32*** %7
%29 = bitcast i32** %28 to i8*
%30 = load i32**, i32*** %5
%31 = bitcast i32** %30 to i8*
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = mul i64 %33, 8
%35 = load i32**, i32*** %7
%36 = load i32, i32* %9
%37 = load i32**, i32*** %5
%38 = load i32*, i32** %8
%39 = load i32**, i32*** %5
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32*, i32** %39, i64 %41
%43 = load i32, i32* %6
%44 = load i32, i32* %9
%45 = sub nsw i32 %43, %44
%46 = load i32, i32* %9
%47 = call i32 (i32**, i32, i32, ...) bitcast (i32 (...)* @stable_sqrt_sort_build_blocks to i32 (i32**, i32, i32, ...)*)(i32** %42, i32 %45, i32 %46)
%48 = load i32, i32* %9
store i32 %48, i32* %10
br label %49
49: ; preds = %54, %27
%50 = load i32, i32* %6
%51 = load i32, i32* %10
%52 = mul nsw i32 %51, 2
store i32 %52, i32* %10
%53 = icmp sgt i32 %50, %52
br i1 %53, label %54, label %66
54: ; preds = %49
%55 = load i32**, i32*** %5
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32*, i32** %55, i64 %57
%59 = load i32, i32* %6
%60 = load i32, i32* %9
%61 = sub nsw i32 %59, %60
%62 = load i32, i32* %10
%63 = load i32, i32* %9
%64 = load i32*, i32** %8
%65 = call i32 (i32**, i32, i32, i32, i32*, ...) bitcast (i32 (...)* @stable_sqrt_sort_combine_blocks to i32 (i32**, i32, i32, i32, i32*, ...)*)(i32** %58, i32 %61, i32 %62, i32 %63, i32* %64)
br label %49
66: ; preds = %49
%67 = load i32**, i32*** %5
%68 = load i32, i32* %9
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32*, i32** %67, i64 %69
%71 = load i32**, i32*** %7
%72 = load i32, i32* %6
%73 = load i32, i32* %9
%74 = sub nsw i32 %72, %73
%75 = load i32, i32* %9
%76 = call i32 (i32**, i32**, i32, i32, ...) bitcast (i32 (...)* @stable_sqrt_sort_merge_down to i32 (i32**, i32**, i32, i32, ...)*)(i32** %70, i32** %71, i32 %74, i32 %75)
br label %77
77: ; preds = %66, %13
ret void
}

LLVM IR (-O2):
define void @stable_sqrt_sort_common_sort(i32** %0, i32 %1, i32** %2, i32* %3) {
%5 = icmp slt i32 %1, 16
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 (i32**, i32, ...) bitcast (i32 (...)* @stable_sqrt_sort_sort_ins to i32 (i32**, i32, ...)*)(i32** %0, i32 %1)
br label %29
8: ; preds = %4, %8
%9 = phi i32 [ %12, %8 ], [ 1, %4 ]
%10 = mul nsw i32 %9, %9
%11 = icmp slt i32 %10, %1
%12 = shl nsw i32 %9, 1
br i1 %11, label %8, label %13
13: ; preds = %8
%14 = bitcast i32** %2 to i8*
%15 = bitcast i32** %0 to i8*
%16 = zext i32 %9 to i64
%17 = shl nuw nsw i64 %16, 3
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 dereferenceable(1) %14, i8* align 8 dereferenceable(1) %15, i64 %17, i1 false)
tail call void @stable_sqrt_sort_common_sort(i32** %2, i32 %9, i32** %0, i32* %3)
%18 = getelementptr inbounds i32*, i32** %0, i64 %16
%19 = sub nsw i32 %1, %9
%20 = tail call i32 (i32**, i32, i32, ...) bitcast (i32 (...)* @stable_sqrt_sort_build_blocks to i32 (i32**, i32, i32, ...)*)(i32** %18, i32 %19, i32 %9)
%21 = icmp slt i32 %12, %1
br i1 %21, label %22, label %27
22: ; preds = %13, %22
%23 = phi i32 [ %25, %22 ], [ %12, %13 ]
%24 = tail call i32 (i32**, i32, i32, i32, i32*, ...) bitcast (i32 (...)* @stable_sqrt_sort_combine_blocks to i32 (i32**, i32, i32, i32, i32*, ...)*)(i32** %18, i32 %19, i32 %23, i32 %9, i32* %3)
%25 = shl nsw i32 %23, 1
%26 = icmp slt i32 %25, %1
br i1 %26, label %22, label %27
27: ; preds = %22, %13
%28 = tail call i32 (i32**, i32**, i32, i32, ...) bitcast (i32 (...)* @stable_sqrt_sort_merge_down to i32 (i32**, i32**, i32, i32, ...)*)(i32** %18, i32** %2, i32 %19, i32 %9)
br label %29
29: ; preds = %27, %6
ret void
}