// File: /workspace/github_cpp_makefile_star2_O2/Baobaobear[P]sort/./sortlib.hpp
// Function: void baobao::internal::merge_2_part_force<true, baobao::TestClass*, baobao::TestClass*, std::less<baobao::TestClass>>(baobao::TestClass*, baobao::TestClass*, baobao::TestClass*, baobao::TestClass*, std::less<baobao::TestClass>)
void merge_2_part_force(RandomAccessBufferIterator buf, RandomAccessIterator beg, RandomAccessIterator mid, RandomAccessIterator end, Comp compare)
{
    if (mid - beg <= end - mid)
    {
        if (safecopy)
        {
            RandomAccessBufferIterator t = buf;
            for (RandomAccessIterator s = beg; s != mid; ++s, ++t)
            {
                *t = *s;
            }
        }
        else
            memcpy((char*)buf, (char*)&*beg, (char*)&*mid - (char*)&*beg);

        RandomAccessBufferIterator start1 = buf, start1_end = buf + (mid - beg);
        RandomAccessIterator start2 = mid, k = beg;
        if (start1 < start1_end && start2 < end)
        {
            while (true)
            {
                if (compare(*start2, *start1))
                {
                    *k++ = *start2++;
                    if (start2 >= end)
                        break;
                }
                else
                {
                    *k++ = *start1++;
                    if (start1 >= start1_end)
                        break;
                }
            }
        }
        while (start1 < start1_end)
        {
            *k++ = *start1++;
        }
    }
    else
    {
        if (safecopy)
        {
            RandomAccessBufferIterator t = buf;
            for (RandomAccessIterator s = mid; s != end; ++s, ++t)
            {
                *t = *s;
            }
        }
        else
            memcpy((char*)buf, (char*)&*mid, (char*)&*end - (char*)&*mid);

        RandomAccessBufferIterator start1 = buf + (end - mid) - 1, start1_end = buf;
        RandomAccessIterator start2 = mid - 1, k = end;
        if (start1 >= start1_end && start2 >= beg)
        {
            while (true)
            {
                if (compare(*start1, *start2))
                {
                    *--k = *start2--;
                    if (start2 < beg)
                        break;
                }
                else
                {
                    *--k = *start1--;
                    if (start1 < start1_end)
                        break;
                }
            }
        }
        while (start1 >= start1_end)
        {
            *--k = *start1--;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdx, %rax
subq %rsi, %rax
movq %rcx, %r12
subq %rdx, %r12
cmpq %r12, %rax
movq %rdi, 0x8(%rsp)
jle 0x61d8
movq %rdi, %r13
movq %r14, %rbp
cmpq %rbx, %rbp
je 0x61fb
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4164
addq $0x20, %rbp
addq $0x20, %r13
jmp 0x61be
movq %rax, %r12
movq %rdi, %rbp
movq %r15, %r13
cmpq %r14, %r13
je 0x624d
movq %rbp, %rdi
movq %r13, %rsi
callq 0x4164
addq $0x20, %r13
addq $0x20, %rbp
jmp 0x61e1
movq 0x8(%rsp), %rax
leaq (%rax,%r12), %r13
addq $-0x20, %r13
cmpq %rax, %r13
setb %al
addq $-0x20, %r14
cmpq %r15, %r14
setb %cl
orb %al, %cl
je 0x62ee
movq %r13, %rbp
addq $-0x20, %rbx
movq 0x8(%rsp), %r15
cmpq %r15, %rbp
jb 0x62df
leaq -0x20(%rbp), %r14
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x4164
addq $-0x20, %rbx
movq %r14, %rbp
jmp 0x622c
movq 0x8(%rsp), %r13
movq %r12, %rax
addq %r13, %r12
testq %rax, %rax
setle %al
cmpq %rbx, %r14
setae %cl
orb %al, %cl
jne 0x62da
movq %r12, 0x10(%rsp)
movq %r15, %rbp
movl (%r14), %eax
cmpl (%r13), %eax
jge 0x6296
leaq 0x20(%rbp), %r15
leaq 0x20(%r14), %r12
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4164
movq %r12, %r14
cmpq %rbx, %r12
jb 0x626d
jmp 0x62b3
leaq 0x20(%r13), %rax
movq %rbp, %rdi
movq %r13, %rsi
movq %rax, %r13
callq 0x4164
leaq 0x20(%rbp), %r15
cmpq 0x10(%rsp), %r13
jb 0x626d
addq $0x20, %rbp
movq %rbp, %r15
movq 0x10(%rsp), %r12
jmp 0x62da
leaq 0x20(%r13), %rbx
leaq 0x20(%r15), %r14
movq %r15, %rdi
movq %r13, %rsi
callq 0x4164
movq %rbx, %r13
movq %r14, %r15
cmpq %r12, %r13
jb 0x62c1
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $-0x20, %rbx
movq %rbx, %rax
movq %rax, %rbx
movl (%r13), %eax
cmpl (%r14), %eax
jge 0x6321
leaq -0x20(%r14), %r12
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4164
leaq -0x20(%rbx), %rax
movq %r12, %r14
cmpq %r15, %r12
jae 0x62f5
jmp 0x6220
leaq -0x20(%r13), %rbp
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4164
movq %rbp, %r13
cmpq 0x8(%rsp), %rbp
jae 0x62ee
jmp 0x6223