// File: ostafen[P]Fast-Insertion-Sort/src/algo.cpp
// Function: FastInsertionSort<int>::_sort(int*, int, int, int*)
void _sort(T *A, int n, int l, T *b)
    {
        float exp = (float)(l - 1) / l;
        int k = pow(n, exp);
        if (n <= k || k <= 5 || l <= 1)
        {
            is.sort(A, n);
            return;
        }

        _sort(A, k, l - 1, b);
        for (int i = k; i < n; i += k)
        {
            if (n - i < k)
                k = n - i;

            _sort(A + i, k, l - 1, b);

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

            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 $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movl -0x18(%rbp), %eax
subl $0x1, %eax
cvtsi2ss %eax, %xmm0
cvtsi2ssl -0x18(%rbp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x24(%rbp)
movl -0x14(%rbp), %edi
movss -0x24(%rbp), %xmm0
callq 0x8870
cvttsd2si %xmm0, %eax
movl %eax, -0x28(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x28(%rbp), %eax
jle 0x9642
cmpl $0x5, -0x28(%rbp)
jle 0x9642
cmpl $0x1, -0x18(%rbp)
jg 0x965b
movq -0x40(%rbp), %rdi
addq $0x10, %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x5c80
jmp 0x97a8
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x28(%rbp), %edx
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
movq -0x20(%rbp), %r8
callq 0x95e0
movl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x97a8
movl -0x14(%rbp), %eax
subl -0x2c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x969b
movl -0x14(%rbp), %eax
subl -0x2c(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
movslq -0x2c(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rsi
movl -0x28(%rbp), %edx
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
movq -0x20(%rbp), %r8
callq 0x95e0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x96f5
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl -0x30(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x96c7
movl -0x2c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x28(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jl 0x9798
jmp 0x9713
xorl %eax, %eax
cmpl $0x0, -0x34(%rbp)
movb %al, -0x41(%rbp)
jl 0x973a
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movslq -0x38(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
setg %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x9743
jmp 0x976c
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
addl -0x38(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x9713
movq -0x20(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
addl -0x38(%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 0x9707
jmp 0x979a
movl -0x28(%rbp), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x967b
addq $0x50, %rsp
popq %rbp
retq
nop