// File: ostafen[P]Fast-Insertion-Sort/src/algo.cpp
// Function: ChainedBlockInsertionSort<int>::sort(int*, int)
virtual void sort(T *A, int n)
    {
        int k = pow(n, exp);
        if (n < k)
        {
            algo->sort(A, n);
            return;
        }

        algo->sort(A, k);
        for (int i = k; i < n; i += k)
        {
            if (n - i < k)
                k = n - i;

            T b[k];
            for (int h = 0; h < k; h++)
                b[h] = A[i + h];

            algo->sort(b, k);
            int j = i - 1;
            int s = k - 1;
            while (s >= 0)
            {
                while (j >= 0 && A[j] > b[s])
                {
                    A[j + s + 1] = A[j];
                    j--;
                }
                A[j + s + 1] = b[s];
                s--;
            }
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x14(%rbp), %edi
movss 0x8(%rax), %xmm0
callq 0x8870
cvttsd2si %xmm0, %eax
movl %eax, -0x18(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x8680
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movq (%rdi), %rax
callq *(%rax)
jmp 0x87e2
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rsi
movl -0x18(%rbp), %edx
movq (%rdi), %rax
callq *(%rax)
movl -0x18(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x87e2
movl -0x14(%rbp), %eax
subl -0x1c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x86ba
movl -0x14(%rbp), %eax
subl -0x1c(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x28(%rbp)
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x50(%rbp)
movq %rcx, %rsp
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x8716
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movl -0x1c(%rbp), %edx
addl -0x34(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %edx
movslq -0x34(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x86e8
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x18(%rbp), %edx
movq (%rdi), %rax
callq *(%rax)
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x18(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jl 0x87cd
jmp 0x8748
xorl %eax, %eax
cmpl $0x0, -0x38(%rbp)
movb %al, -0x51(%rbp)
jl 0x876f
movq -0x50(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rdx
movl (%rax,%rdx,4), %eax
movslq -0x3c(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
setg %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x8778
jmp 0x87a1
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
addl -0x3c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x8748
movq -0x50(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
addl -0x3c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x873c
movq -0x28(%rbp), %rax
movq %rax, %rsp
movl -0x18(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x869a
movq %rbp, %rsp
popq %rbp
retq
nopw (%rax,%rax)