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

        is.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];

            is.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
callq 0x55b0
cvttsd2si %xmm0, %eax
movl %eax, -0x18(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x994b
movq -0x48(%rbp), %rdi
addq $0x10, %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x5c80
jmp 0x9aad
movq -0x48(%rbp), %rdi
addq $0x10, %rdi
movq -0x10(%rbp), %rsi
movl -0x18(%rbp), %edx
callq 0x5c80
movl -0x18(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x9aad
movl -0x14(%rbp), %eax
subl -0x1c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x9985
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 0x99e1
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 0x99b3
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdi
addq $0x10, %rdi
movl -0x18(%rbp), %edx
callq 0x5c80
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 0x9a98
jmp 0x9a13
xorl %eax, %eax
cmpl $0x0, -0x38(%rbp)
movb %al, -0x51(%rbp)
jl 0x9a3a
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 0x9a43
jmp 0x9a6c
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 0x9a13
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 0x9a07
movq -0x28(%rbp), %rax
movq %rax, %rsp
movl -0x18(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x9965
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)