// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cvtsi2sd %edx, %xmm0
movq %rsi, %rbx
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movl %edx, -0x2c(%rbp)
jb 0x6893
sqrtsd %xmm0, %xmm0
jmp 0x689b
callq 0x3130
movl -0x2c(%rbp), %edx
cvttsd2si %xmm0, %r10d
cmpl %edx, %r10d
jle 0x68f1
cmpl $0x2, %edx
jl 0x6a66
movl %edx, %eax
movl $0x1, %ecx
movl (%rbx,%rcx,4), %edx
movq %rcx, %rsi
leaq -0x1(%rsi), %rdi
movl %edi, %r8d
movl (%rbx,%r8,4), %r8d
cmpl %edx, %r8d
jle 0x68de
movl %r8d, (%rbx,%rsi,4)
leaq 0x1(%rdi), %r8
movq %rdi, %rsi
cmpq $0x1, %r8
jg 0x68bb
xorl %esi, %esi
movslq %esi, %rsi
movl %edx, (%rbx,%rsi,4)
incq %rcx
cmpq %rax, %rcx
jne 0x68b5
jmp 0x6a66
cmpl $0x2, %r10d
jl 0x6938
movl %r10d, %eax
movl $0x1, %ecx
movl (%rbx,%rcx,4), %r9d
movq %rcx, %rsi
leaq -0x1(%rsi), %rdi
movl %edi, %r8d
movl (%rbx,%r8,4), %r8d
cmpl %r9d, %r8d
jle 0x6929
movl %r8d, (%rbx,%rsi,4)
leaq 0x1(%rdi), %r8
movq %rdi, %rsi
cmpq $0x1, %r8
jg 0x6906
xorl %esi, %esi
movslq %esi, %rsi
movl %r9d, (%rbx,%rsi,4)
incq %rcx
cmpq %rax, %rcx
jne 0x68ff
cmpl %edx, %r10d
jge 0x6a66
movabsq $-0x100000000, %r12     # imm = 0xFFFFFFFF00000000
movl %r10d, %r11d
movl %r10d, %r14d
movq %rsp, -0x40(%rbp)
movl %edx, %r13d
subl %r11d, %r13d
cmpl %r10d, %r13d
cmovll %r13d, %r14d
leaq 0xf(,%r14,4), %rax
andq $-0x10, %rax
movq %rsp, %r15
subq %rax, %r15
movq %r15, %rsp
testl %r14d, %r14d
jle 0x69a6
movslq %r11d, %rax
leaq (%rbx,%rax,4), %rsi
leaq (,%r14,4), %rdx
movq %r15, %rdi
movq %r11, -0x38(%rbp)
movl %r10d, -0x30(%rbp)
callq 0x3140
movl -0x30(%rbp), %r10d
movq -0x38(%rbp), %r11
movl -0x2c(%rbp), %edx
cmpl $0x2, %r14d
jl 0x69e9
movl $0x1, %eax
movl (%r15,%rax,4), %ecx
movq %rax, %r8
leaq -0x1(%r8), %rsi
movl %esi, %edi
movl (%r15,%rdi,4), %edi
cmpl %ecx, %edi
jle 0x69da
movl %edi, (%r15,%r8,4)
leaq 0x1(%rsi), %rdi
movq %rsi, %r8
cmpq $0x1, %rdi
jg 0x69b8
xorl %r8d, %r8d
movslq %r8d, %rsi
movl %ecx, (%r15,%rsi,4)
incq %rax
cmpq %r14, %rax
jne 0x69b1
testl %r14d, %r14d
jle 0x6a53
leal -0x1(%r11), %eax
cmpl %r13d, %r10d
cmovll %r10d, %r13d
movslq %r13d, %rcx
movq %rcx, %r10
decq %rcx
testl %eax, %eax
js 0x6a3f
movl (%r15,%rcx,4), %esi
movl %eax, %edi
addl %r10d, %eax
shlq $0x20, %rax
movl (%rbx,%rdi,4), %r8d
cmpl %esi, %r8d
jle 0x6a3d
movq %rax, %r9
sarq $0x1e, %r9
movl %r8d, (%rbx,%r9)
leaq -0x1(%rdi), %r8
addq %r12, %rax
testq %rdi, %rdi
movq %r8, %rdi
jg 0x6a13
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x6a3f
movl %edi, %eax
movl (%r15,%rcx,4), %esi
leal (%r10,%rax), %edi
movslq %edi, %rdi
movl %esi, (%rbx,%rdi,4)
cmpq $0x1, %r10
jg 0x69fc
movq -0x40(%rbp), %rsp
addl %r14d, %r11d
movl %r14d, %r10d
cmpl %edx, %r11d
jl 0x6951
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop