// File: /workspace/github_cpp_makefile_star2_O3/sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/../qsort_parallel.h
// Function: unsigned long* _sort_parallel_partition<unsigned long, hdiff_private::TIndex_comp, 137ul>(unsigned long*, unsigned long*, hdiff_private::TIndex_comp, unsigned long, unsigned long)
static TValue* _sort_parallel_partition(TValue* begin,TValue* end,TCmp cmp,
                                             size_t leftWeight=1,size_t rightWeight=1){
        const size_t size=end-begin;
        size_t samples[kSampleSize];
        const size_t _kIndexStep=size/kSampleSize+1;
        size_t curIndex=0;
        for(size_t i=0;i<kSampleSize;i++,curIndex+=_kIndexStep){
            size_t ri=(curIndex+(size_t)rand()) % size;  //multi thread safe
            samples[i]=ri;
        }
        const bool _kIsSortNotNth=false;
        if (_kIsSortNotNth) std::sort(samples,samples+kSampleSize,_sort_parallel_TCmpi<TValue,TCmp>(begin,cmp));
        size_t _pivot_i=__index_by_ratio(kSampleSize,leftWeight,(leftWeight+rightWeight));
        if (!_kIsSortNotNth) std::nth_element(samples,samples+_pivot_i,samples+kSampleSize,_sort_parallel_TCmpi<TValue,TCmp>(begin,cmp));
        size_t pivot=samples[_pivot_i];
        std::swap(begin[0],begin[pivot]);
        TValue x(begin[0]);
        size_t mid=0;
        for (size_t i=mid+1;i<size;++i){
            if (cmp(begin[i],x))
                std::swap(begin[++mid],begin[i]);
        }
        std::swap(begin[0],begin[mid]);
        return begin+mid;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x458, %rsp            # imm = 0x458
movq %rcx, %r12
movq %rdx, 0x8(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
subq %rdi, %r14
sarq $0x3, %r14
movabsq $-0x21a291c077975b8f, %rcx # imm = 0xDE5D6E3F8868A471
movq %r14, %rax
mulq %rcx
movq %r14, %r15
subq %rdx, %r15
shrq %r15
addq %rdx, %r15
shrq $0x7, %r15
incq %r15
xorl %ebp, %ebp
xorl %r13d, %r13d
callq 0x40a0
cltq
addq %rbp, %rax
xorl %edx, %edx
divq %r14
movq %rdx, 0x10(%rsp,%r13,8)
incq %r13
addq %r15, %rbp
cmpq $0x89, %r13
jne 0x1feca
movq 0x8(%rsp), %rax
addq %rax, %r12
imulq $0x89, %rax, %rax
xorl %edx, %edx
divq %r12
movq %rax, %r12
cmpq $0x89, %rax
je 0x1ff36
leaq 0x458(%rsp), %rdx
leaq (%rsp,%r12,8), %rsi
addq $0x10, %rsi
leaq 0x10(%rsp), %rdi
movl $0xe, %ecx
movq %rbx, %r8
leaq 0x490(%rsp), %r9
callq 0x20e50
movq 0x10(%rsp,%r12,8), %rax
movq (%rbx), %rcx
movq (%rbx,%rax,8), %rdx
movq %rdx, (%rbx)
movq %rcx, (%rbx,%rax,8)
movq (%rbx), %r13
cmpq $0x2, %r14
jb 0x1ffcd
leaq 0x1(%r13), %rax
movq %rax, 0x8(%rsp)
leaq 0x490(%rsp), %rax
movq (%rax), %r8
movl $0x1, %r15d
xorl %ebp, %ebp
movq (%rbx,%r15,8), %rdi
movq (%r8,%r13,8), %rax
cmpq %rax, (%r8,%rdi,8)
jne 0x1ffa9
incq %rdi
leaq 0x490(%rsp), %r12
movq 0x8(%r12), %rdx
movq 0x10(%r12), %rcx
movq 0x8(%rsp), %rsi
callq 0x21442
movq (%r12), %r8
testb %al, %al
je 0x1ffbc
movq (%rbx,%r15,8), %rdi
jmp 0x1ffab
jae 0x1ffbc
movq 0x8(%rbx,%rbp,8), %rax
movq %rdi, 0x8(%rbx,%rbp,8)
incq %rbp
movq %rax, (%rbx,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0x1ff6e
movq (%rbx), %rcx
movq (%rbx,%rbp,8), %r13
jmp 0x1ffd2
xorl %ebp, %ebp
movq %r13, %rcx
leaq (%rbx,%rbp,8), %rax
movq %r13, (%rbx)
movq %rcx, (%rax)
addq $0x458, %rsp            # imm = 0x458
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq