// File: /workspace/github_cpp_makefile_star2_O3/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 0x68c1
sqrtsd %xmm0, %xmm0
jmp 0x68c9
callq 0x3130
movl -0x2c(%rbp), %edx
cvttsd2si %xmm0, %r12d
cmpl %edx, %r12d
jle 0x691f
cmpl $0x2, %edx
jl 0x6a96
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 0x690c
movl %r8d, (%rbx,%rsi,4)
leaq 0x1(%rdi), %r8
movq %rdi, %rsi
cmpq $0x1, %r8
jg 0x68e9
xorl %esi, %esi
movslq %esi, %rsi
movl %edx, (%rbx,%rsi,4)
incq %rcx
cmpq %rax, %rcx
jne 0x68e3
jmp 0x6a96
cmpl $0x2, %r12d
jl 0x6966
movl %r12d, %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 0x6957
movl %r8d, (%rbx,%rsi,4)
leaq 0x1(%rdi), %r8
movq %rdi, %rsi
cmpq $0x1, %r8
jg 0x6934
xorl %esi, %esi
movslq %esi, %rsi
movl %r9d, (%rbx,%rsi,4)
incq %rcx
cmpq %rax, %rcx
jne 0x692d
cmpl %edx, %r12d
jge 0x6a96
movabsq $-0x100000000, %r13     # imm = 0xFFFFFFFF00000000
movl %r12d, %r10d
movq %rsp, %r11
movl %r12d, %ecx
movl %edx, %r14d
subl %r10d, %r14d
cmpl %r12d, %r14d
cmovll %r14d, %r12d
leaq 0xf(,%r12,4), %rax
andq $-0x10, %rax
movq %rsp, %r15
subq %rax, %r15
movq %r15, %rsp
testl %r12d, %r12d
jle 0x6a87
movslq %r10d, %rax
leaq (%rbx,%rax,4), %rsi
leaq (,%r12,4), %rdx
movq %r15, %rdi
movq %r10, -0x40(%rbp)
movq %r11, -0x38(%rbp)
movl %ecx, -0x30(%rbp)
callq 0x3140
movl -0x30(%rbp), %r9d
movq -0x38(%rbp), %r11
movq -0x40(%rbp), %r10
movl -0x2c(%rbp), %edx
cmpq $0x1, %r12
je 0x6a26
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 0x6a12
movl %edi, (%r15,%r8,4)
leaq 0x1(%rsi), %rdi
movq %rsi, %r8
cmpq $0x1, %rdi
jg 0x69f0
xorl %r8d, %r8d
movslq %r8d, %rsi
movl %ecx, (%r15,%rsi,4)
incq %rax
cmpq %r12, %rax
jne 0x69e9
testl %r12d, %r12d
jle 0x6a87
leal -0x1(%r10), %eax
cmpl %r14d, %r9d
cmovll %r9d, %r14d
movslq %r14d, %rcx
movl -0x4(%r15,%rcx,4), %r9d
testl %eax, %eax
js 0x6a70
movl %eax, %esi
addl %ecx, %eax
shlq $0x20, %rax
movl (%rbx,%rsi,4), %edi
cmpl %r9d, %edi
jle 0x6a6e
movq %rax, %r8
sarq $0x1e, %r8
movl %edi, (%rbx,%r8)
leaq -0x1(%rsi), %rdi
addq %r13, %rax
testq %rsi, %rsi
movq %rdi, %rsi
jg 0x6a45
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x6a70
movl %esi, %eax
leal (%rcx,%rax), %esi
leaq -0x1(%rcx), %rdi
movslq %esi, %rsi
movl %r9d, (%rbx,%rsi,4)
cmpq $0x1, %rcx
movq %rdi, %rcx
jg 0x6a34
movq %r11, %rsp
addl %r12d, %r10d
cmpl %edx, %r10d
jl 0x697c
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop