// File: /workspace/github_cpp_makefile_star2_O1/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:
movq %rdx, %r9
subq %rsi, %r9
movq %rcx, %r8
subq %rdx, %r8
cmpq %r8, %r9
jle 0x74e0
cmpq %rcx, %rdx
je 0x7414
movq %rdx, %rax
movq %rdi, %r9
movl (%rax), %r10d
movl %r10d, (%r9)
movl 0x4(%rax), %r10d
movl %r10d, 0x4(%r9)
movl $0x2, %r10d
movl (%rax,%r10,4), %r11d
movl %r11d, (%r9,%r10,4)
incq %r10
cmpq $0x8, %r10
jne 0x73f6
addq $0x20, %rax
addq $0x20, %r9
cmpq %rcx, %rax
jne 0x73e2
leaq (%rdi,%r8), %rax
addq $-0x20, %rax
cmpq %rdi, %rax
setb %r9b
addq $-0x20, %rdx
cmpq %rsi, %rdx
setb %r10b
orb %r9b, %r10b
jne 0x74d6
addq %rdi, %r8
movq %rcx, %r9
movl (%rax), %r10d
movl (%rdx), %r11d
leaq -0x20(%r9), %rcx
cmpl %r11d, %r10d
jge 0x747b
movl %r11d, -0x20(%r9)
movl 0x4(%rdx), %r10d
movl %r10d, -0x1c(%r9)
movq $-0x6, %r10
movl 0x20(%rdx,%r10,4), %r11d
movl %r11d, (%r9,%r10,4)
incq %r10
jne 0x745f
addq $-0x20, %rdx
movq %rcx, %r9
cmpq %rsi, %rdx
jae 0x743d
jmp 0x74d6
movl %r10d, -0x20(%r9)
movl 0x4(%rax), %r10d
movl %r10d, -0x1c(%r9)
movq $-0x18, %r10
movl (%r8,%r10), %r11d
movl %r11d, (%r9,%r10)
addq $0x4, %r10
jne 0x748e
addq $-0x20, %rax
addq $-0x20, %r8
cmpq %rdi, %rax
jae 0x743a
jmp 0x74d6
leaq -0x20(%rcx), %rdx
movl (%rax), %esi
movl %esi, -0x20(%rcx)
movl 0x4(%rax), %esi
movl %esi, -0x1c(%rcx)
movq $-0x6, %rsi
movl 0x20(%rax,%rsi,4), %r8d
movl %r8d, (%rcx,%rsi,4)
incq %rsi
jne 0x74c1
addq $-0x20, %rax
movq %rdx, %rcx
cmpq %rdi, %rax
jae 0x74ab
jmp 0x75df
cmpq %rdx, %rsi
je 0x751d
movq %rdi, %rax
movq %rsi, %r8
movl (%r8), %r10d
movl %r10d, (%rax)
movl 0x4(%r8), %r10d
movl %r10d, 0x4(%rax)
movl $0x2, %r10d
movl (%r8,%r10,4), %r11d
movl %r11d, (%rax,%r10,4)
incq %r10
cmpq $0x8, %r10
jne 0x74ff
addq $0x20, %r8
addq $0x20, %rax
cmpq %rdx, %r8
jne 0x74eb
leaq (%rdi,%r9), %rax
testq %r9, %r9
setle %r8b
cmpq %rcx, %rdx
setae %r9b
orb %r8b, %r9b
jne 0x75aa
movq %rdi, %r8
movl (%rdx), %r9d
movl (%r8), %r10d
cmpl %r10d, %r9d
jge 0x7576
leaq 0x20(%rdx), %rdi
movl %r9d, (%rsi)
movl 0x4(%rdx), %r9d
movl %r9d, 0x4(%rsi)
movl $0x2, %r9d
movl (%rdx,%r9,4), %r10d
movl %r10d, (%rsi,%r9,4)
incq %r9
cmpq $0x8, %r9
jne 0x7557
addq $0x20, %rsi
movq %rdi, %rdx
cmpq %rcx, %rdi
jb 0x7537
jmp 0x75a7
leaq 0x20(%r8), %rdi
movl %r10d, (%rsi)
movl 0x4(%r8), %r9d
movl %r9d, 0x4(%rsi)
movl $0x2, %r9d
movl (%r8,%r9,4), %r10d
movl %r10d, (%rsi,%r9,4)
incq %r9
cmpq $0x8, %r9
jne 0x758b
addq $0x20, %rsi
cmpq %rax, %rdi
jb 0x7534
jmp 0x75aa
movq %r8, %rdi
cmpq %rax, %rdi
jae 0x75df
leaq 0x20(%rdi), %rcx
movl (%rdi), %edx
movl %edx, (%rsi)
movl 0x4(%rdi), %edx
movl %edx, 0x4(%rsi)
movl $0x2, %edx
movl (%rdi,%rdx,4), %r8d
movl %r8d, (%rsi,%rdx,4)
incq %rdx
cmpq $0x8, %rdx
jne 0x75c2
addq $0x20, %rsi
movq %rcx, %rdi
cmpq %rax, %rcx
jb 0x75af
retq