// File: /workspace/github_cpp_makefile_star2_O1/Baobaobear[P]sort/./sortlib.hpp
// Function: void baobao::internal::quick_sort_loop<baobao::internal::indirect_sort_iter_warp<baobao::TestClass*>*, baobao::internal::indirect_sort_comp_warp<baobao::TestClass*, std::less<baobao::TestClass>>>(baobao::internal::indirect_sort_iter_warp<baobao::TestClass*>*, baobao::internal::indirect_sort_iter_warp<baobao::TestClass*>*, int, baobao::internal::indirect_sort_comp_warp<baobao::TestClass*, std::less<baobao::TestClass>>, bool)
void quick_sort_loop(RandomAccessIterator beg, RandomAccessIterator end, int deep, Comp compare, bool leftmost)
{
    if (end - beg <= qsort_insertion_sort_threshold)
    {
        if (leftmost)
        {
            q_insert_sort(beg, end, compare);
        }
        else
        {
            unguarded_q_insert_sort(beg, end, compare);
        }
        return;
    }
    if (deep <= 0)
    {
        shell_sort(beg, end, compare);
        return;
    }

    bool swaped = false;
    RandomAccessIterator l = quick_sort_partition(beg, end, compare, swaped), r = l + 1;
    if (!swaped && !compare(*(l - 1), *beg))
    {
        RandomAccessIterator i = leftmost ? insert_sort_limit(beg, l, compare, 1)
            : unguarded_insert_sort_limit(beg, l, compare, 1);
        if (i == l)
        {
            i = unguarded_insert_sort_limit(r, end, compare, 1);
        }
        if (i == end)
        {
            return;
        }
        if (i >= l)
        {
            while (r < end && util::object_equal(*r, *l, compare)) ++r;
            return quick_sort_loop(r, end, deep - 1, compare, false);
        }
    }
    while (r < end && util::object_equal(*r, *l, compare)) ++r;

    quick_sort_loop(beg, l, deep - 1, compare, leftmost);
    quick_sort_loop(r, end, deep - 1, compare, false);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rax
subq %rdi, %rax
cmpq $0x28f, %rax            # imm = 0x28F
jg 0xa808
testb %r8b, %r8b
je 0xa886
leaq 0x13(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa9e5
jmp 0xa9d6
movl %edx, %r15d
testl %edx, %edx
jle 0xa89b
movl %r8d, 0x14(%rsp)
leaq 0x10(%rsp), %rbp
movb $0x0, (%rbp)
leaq 0xf(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
movq %rbp, %rcx
callq 0xae4e
movq %rax, %r13
leaq 0x10(%rax), %r12
cmpb $0x0, (%rbp)
jne 0xa959
movq -0x8(%r13), %rax
movq 0x8(%r14), %rcx
movl (%rax), %eax
movl (%rcx), %ecx
cmpl %ecx, %eax
jl 0xa959
jg 0xa868
movq -0x10(%r13), %rax
cmpq (%r14), %rax
jb 0xa959
cmpb $0x0, 0x14(%rsp)
je 0xa8b0
leaq 0xe(%rsp), %rdx
movq %r14, %rdi
movq %r13, %rsi
movl $0x1, %ecx
callq 0xb45a
jmp 0xa8c5
leaq 0x12(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xaae9
jmp 0xa9d6
leaq 0x11(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xaba3
jmp 0xa9d6
leaq 0xd(%rsp), %rdx
movq %r14, %rdi
movq %r13, %rsi
movl $0x1, %ecx
callq 0xb54b
cmpq %r13, %rax
jne 0xa8df
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
movq %rbx, %rsi
movl $0x1, %ecx
callq 0xb54b
cmpq %rbx, %rax
je 0xa952
movb $0x1, %bpl
cmpq %r13, %rax
jb 0xa954
cmpq %rbx, %r12
jae 0xa937
movq 0x8(%r13), %rax
movl (%rax), %eax
movq 0x8(%r12), %rcx
movl (%rcx), %ecx
cmpl %eax, %ecx
jl 0xa937
jg 0xa90e
movq (%r12), %rdx
cmpq (%r13), %rdx
jb 0xa937
xorl %edx, %edx
cmpl %ecx, %eax
setge %dl
movq (%r13), %rsi
xorl %edi, %edi
cmpq (%r12), %rsi
setae %dil
cmpl %eax, %ecx
cmovnel %edx, %edi
cmpb $0x1, %dil
jne 0xa937
addq $0x10, %r12
cmpq %rbx, %r12
jb 0xa8f7
leal -0x1(%r15), %edx
leaq 0xb(%rsp), %rcx
xorl %ebp, %ebp
movq %r12, %rdi
movq %rbx, %rsi
xorl %r8d, %r8d
callq 0xa7c8
jmp 0xa954
xorl %ebp, %ebp
testb %bpl, %bpl
je 0xa9d6
cmpq %rbx, %r12
jae 0xa9a4
movq 0x8(%r13), %rax
movl (%rax), %eax
movq 0x8(%r12), %rcx
movl (%rcx), %ecx
cmpl %eax, %ecx
jl 0xa9a4
jg 0xa97b
movq (%r12), %rdx
cmpq (%r13), %rdx
jb 0xa9a4
xorl %edx, %edx
cmpl %ecx, %eax
setge %dl
movq (%r13), %rsi
xorl %edi, %edi
cmpq (%r12), %rsi
setae %dil
cmpl %eax, %ecx
cmovnel %edx, %edi
cmpb $0x1, %dil
jne 0xa9a4
addq $0x10, %r12
cmpq %rbx, %r12
jb 0xa964
decl %r15d
movzbl 0x14(%rsp), %r8d
leaq 0xa(%rsp), %rcx
movq %r14, %rdi
movq %r13, %rsi
movl %r15d, %edx
callq 0xa7c8
leaq 0x9(%rsp), %rcx
movq %r12, %rdi
movq %rbx, %rsi
movl %r15d, %edx
xorl %r8d, %r8d
callq 0xa7c8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq