// File: /workspace/github_cpp_makefile_star2_O1/Baobaobear[P]sort/./sortlib.hpp
// Function: void baobao::internal::merge_2_part_with_buffer<false, baobao::TestClass*, baobao::TestClass*, std::less<baobao::TestClass>>(baobao::TestClass*, unsigned long, baobao::TestClass*, baobao::TestClass*, baobao::TestClass*, std::less<baobao::TestClass>)
void merge_2_part_with_buffer(RandomAccessBufferIterator buf, size_t bufsize, RandomAccessIterator beg, RandomAccessIterator mid, RandomAccessIterator end, Comp compare)
{
    if (!compare(*mid, *(mid - 1)))
    {
        return;
    }
    while (beg < mid && !compare(*mid, *beg))
    {
        ++beg;
    }
    if (beg < mid)
    {
        RandomAccessIterator mid_last = mid - 1, last = end - 1;
        while (mid_last < last && !compare(*last, *mid_last))
        {
            --last;
        }
        if (mid_last < last)
        {
            end = last + 1;
        }
        else
        {
            return;
        }
    }
    else
    {
        return;
    }

    if (end - beg < merge_2_part_insertion_sort_threshold || end - mid < 3 || mid - beg < 3)
    {
        insert_sort_part(beg, mid, end, compare);
        return;
    }

    if ((size_t)(end - mid) <= bufsize || (size_t)(mid - beg) <= bufsize)
    {
        merge_2_part_force<safecopy>(buf, beg, mid, end, compare);
        return;
    }

    std::pair<RandomAccessIterator, RandomAccessIterator> pair = find_swap_bound(beg, mid, end, compare);

    RandomAccessIterator swap_mid = swap_2_part_with_buffer<safecopy>(buf, bufsize, pair.first, mid, pair.second);
    if (beg < pair.first)
        merge_2_part_with_buffer<safecopy>(buf, bufsize, beg, pair.first, swap_mid, compare);
    if (pair.second < end)
        merge_2_part_with_buffer<safecopy>(buf, bufsize, swap_mid, pair.second, end, compare);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %rbp
movq %rsi, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
movl -0x20(%r14), %eax
movl (%r14), %ecx
cmpl %eax, %ecx
jge 0x798b
cmpq %r14, %rbp
jae 0x798b
movq %rbp, %r15
cmpl (%r15), %ecx
jl 0x77d7
addq $0x20, %r15
addq $0x20, %rbp
cmpq %r14, %r15
jb 0x77c0
jmp 0x798b
movq %rbx, %rdx
movq %rdx, %rcx
cmpq %r14, %rdx
jbe 0x77f2
leaq -0x20(%rcx), %rdx
cmpl %eax, -0x20(%rcx)
jge 0x77da
addq $0x20, %rdx
movq %rdx, %rbx
cmpq %r14, %rcx
jbe 0x798b
movq %rbx, %rax
subq %rbp, %rax
cmpq $0x400, %rax            # imm = 0x400
jl 0x78a3
movq %rbx, %rax
subq %r14, %rax
sarq $0x5, %rax
cmpq $0x3, %rax
jl 0x78a3
movq %r14, %rcx
subq %rbp, %rcx
sarq $0x5, %rcx
cmpq $0x2, %rcx
jle 0x78a3
movq 0x10(%rsp), %rbp
cmpq %rbp, %rcx
jbe 0x799a
cmpq %rbp, %rax
jbe 0x799a
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x79bb
movq %rax, %r13
movq %rdx, %r12
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq %rax, %rdx
movq %r14, %rcx
movq %r12, %r8
callq 0x7d05
movq %rax, %rbp
cmpq %r13, %r15
jae 0x7892
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
movq %r13, %rcx
movq %rbp, %r8
callq 0x7784
movq %r12, %r14
cmpq %rbx, %r12
jb 0x77a5
jmp 0x798b
cmpq %r14, %rbx
jbe 0x798b
leaq 0x20(%rsp), %rax
xorl %ecx, %ecx
movq %r14, %rdx
movl -0x20(%rdx), %edi
movl (%rdx), %r8d
cmpl %edi, %r8d
jge 0x797b
leaq -0x20(%rdx), %rsi
movq %rcx, %r9
shlq $0x5, %r9
movl %r8d, 0x18(%rsp)
movl 0x4(%rdx), %r8d
movl %r8d, 0x1c(%rsp)
movq 0x18(%r14,%r9), %r8
movq %r8, 0x10(%rax)
movups 0x8(%r14,%r9), %xmm0
movups %xmm0, (%rax)
movl %edi, (%rdx)
movl -0x1c(%rdx), %edi
movl %edi, 0x4(%rdx)
movq $-0x18, %rdi
movl (%rdx,%rdi), %r8d
movl %r8d, 0x20(%rdx,%rdi)
addq $0x4, %rdi
jne 0x78ff
cmpq %rsi, %r15
je 0x7954
movq %rdx, %r8
movl -0x20(%rsi), %r9d
cmpl %r9d, 0x18(%rsp)
jge 0x7954
leaq -0x20(%rsi), %rdi
movl %r9d, (%rsi)
movl -0x1c(%rsi), %r9d
movl %r9d, 0x4(%rsi)
movq $-0x18, %rsi
movl -0x20(%r8,%rsi), %r9d
movl %r9d, (%r8,%rsi)
addq $0x4, %rsi
jne 0x7937
addq $-0x20, %r8
movq %rdi, %rsi
cmpq %rdi, %r15
jne 0x7916
jmp 0x7957
movq %rsi, %rdi
movl 0x18(%rsp), %esi
movl %esi, (%rdi)
movl 0x1c(%rsp), %esi
movl %esi, 0x4(%rdi)
movl $0x2, %esi
movl 0x18(%rsp,%rsi,4), %r8d
movl %r8d, (%rdi,%rsi,4)
incq %rsi
cmpq $0x8, %rsi
jne 0x7969
addq $0x20, %rdx
incq %rcx
cmpq %rbx, %rdx
jb 0x78b6
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6fb5