// File: /workspace/github_cpp_makefile_star2_O3/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 0x7444
cmpq %rcx, %rdx
je 0x7378
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 0x735a
addq $0x20, %rax
addq $0x20, %r9
cmpq %rcx, %rax
jne 0x7346
leaq (%rdi,%r8), %rax
addq $-0x20, %rax
cmpq %rdi, %rax
setb %r9b
addq $-0x20, %rdx
cmpq %rsi, %rdx
setb %r10b
orb %r9b, %r10b
jne 0x743a
addq %rdi, %r8
movq %rcx, %r9
movl (%rax), %r10d
movl (%rdx), %r11d
leaq -0x20(%r9), %rcx
cmpl %r11d, %r10d
jge 0x73df
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 0x73c3
addq $-0x20, %rdx
movq %rcx, %r9
cmpq %rsi, %rdx
jae 0x73a1
jmp 0x743a
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 0x73f2
addq $-0x20, %rax
addq $-0x20, %r8
cmpq %rdi, %rax
jae 0x739e
jmp 0x743a
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 0x7425
addq $-0x20, %rax
movq %rdx, %rcx
cmpq %rdi, %rax
jae 0x740f
jmp 0x7543
cmpq %rdx, %rsi
je 0x7481
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 0x7463
addq $0x20, %r8
addq $0x20, %rax
cmpq %rdx, %r8
jne 0x744f
leaq (%rdi,%r9), %rax
testq %r9, %r9
setle %r8b
cmpq %rcx, %rdx
setae %r9b
orb %r8b, %r9b
jne 0x750e
movq %rdi, %r8
movl (%rdx), %r9d
movl (%r8), %r10d
cmpl %r10d, %r9d
jge 0x74da
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 0x74bb
addq $0x20, %rsi
movq %rdi, %rdx
cmpq %rcx, %rdi
jb 0x749b
jmp 0x750b
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 0x74ef
addq $0x20, %rsi
cmpq %rax, %rdi
jb 0x7498
jmp 0x750e
movq %r8, %rdi
cmpq %rax, %rdi
jae 0x7543
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 0x7526
addq $0x20, %rsi
movq %rcx, %rdi
cmpq %rax, %rcx
jb 0x7513
retq