// File: /workspace/github_cpp_makefile_star2_O1/sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/../qsort_parallel.h
// Function: unsigned int* _sort_parallel_partition<unsigned int, hdiff_private::TIndex_comp, 137ul>(unsigned int*, unsigned int*, 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 $0x2, %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 0x201c3
movq 0x8(%rsp), %rax
addq %rax, %r12
imulq $0x89, %rax, %rax
xorl %edx, %edx
divq %r12
movq %rax, %r12
cmpq $0x89, %rax
je 0x2022f
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 0x21ce0
movq 0x10(%rsp,%r12,8), %rax
movl (%rbx), %ecx
movl (%rbx,%rax,4), %edx
movl %edx, (%rbx)
movl %ecx, (%rbx,%rax,4)
cmpq $0x2, %r14
jb 0x202af
movl (%rbx), %r12d
leal 0x1(%r12), %ebp
movl $0x1, %r15d
xorl %r13d, %r13d
leaq 0x490(%rsp), %rsi
movl (%rbx,%r15,4), %edi
movq (%rsi), %r8
movq (%r8,%r12,8), %rax
cmpq %rax, (%r8,%rdi,8)
jne 0x20289
incl %edi
movq 0x8(%rsi), %rdx
movq 0x10(%rsi), %rcx
movl %ebp, %esi
callq 0x222d4
leaq 0x490(%rsp), %rsi
jmp 0x2028c
setb %al
testb %al, %al
je 0x202a5
movl 0x4(%rbx,%r13,4), %eax
movl (%rbx,%r15,4), %ecx
movl %ecx, 0x4(%rbx,%r13,4)
incq %r13
movl %eax, (%rbx,%r15,4)
incq %r15
cmpq %r15, %r14
jne 0x2025d
jmp 0x202b2
xorl %r13d, %r13d
leaq (%rbx,%r13,4), %rax
movl (%rbx), %ecx
movl (%rax), %edx
movl %edx, (%rbx)
movl %ecx, (%rax)
addq $0x458, %rsp            # imm = 0x458
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq