// File: 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:
subq $0x88, %rsp
movq %rdi, 0x78(%rsp)
movq %rsi, 0x70(%rsp)
movq %rdx, 0x68(%rsp)
movq %rcx, 0x60(%rsp)
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
subq %rcx, %rax
sarq $0x5, %rax
movq 0x60(%rsp), %rcx
movq 0x68(%rsp), %rdx
subq %rdx, %rcx
sarq $0x5, %rcx
cmpq %rcx, %rax
jg 0xe183
movq 0x78(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
cmpq 0x68(%rsp), %rax
je 0xe053
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdi
callq 0x8710
movq 0x50(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x50(%rsp)
movq 0x58(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x58(%rsp)
jmp 0xe01a
movq 0x78(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x78(%rsp), %rax
movq 0x68(%rsp), %rcx
movq 0x70(%rsp), %rdx
subq %rdx, %rcx
sarq $0x5, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x48(%rsp), %rax
cmpq 0x40(%rsp), %rax
jae 0xe147
movq 0x38(%rsp), %rax
cmpq 0x60(%rsp), %rax
jae 0xe147
jmp 0xe0b5
movq 0x38(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x87(%rsp), %rdi
callq 0xcd80
testb $0x1, %al
jne 0xe0d2
jmp 0xe109
movq 0x38(%rsp), %rsi
movq %rsi, %rax
addq $0x20, %rax
movq %rax, 0x38(%rsp)
movq 0x30(%rsp), %rdi
movq %rdi, %rax
addq $0x20, %rax
movq %rax, 0x30(%rsp)
callq 0x8710
movq 0x38(%rsp), %rax
cmpq 0x60(%rsp), %rax
jb 0xe107
jmp 0xe145
jmp 0xe140
movq 0x48(%rsp), %rsi
movq %rsi, %rax
addq $0x20, %rax
movq %rax, 0x48(%rsp)
movq 0x30(%rsp), %rdi
movq %rdi, %rax
addq $0x20, %rax
movq %rax, 0x30(%rsp)
callq 0x8710
movq 0x48(%rsp), %rax
cmpq 0x40(%rsp), %rax
jb 0xe13e
jmp 0xe145
jmp 0xe140
jmp 0xe0b5
jmp 0xe147
jmp 0xe149
movq 0x48(%rsp), %rax
cmpq 0x40(%rsp), %rax
jae 0xe17e
movq 0x48(%rsp), %rsi
movq %rsi, %rax
addq $0x20, %rax
movq %rax, 0x48(%rsp)
movq 0x30(%rsp), %rdi
movq %rdi, %rax
addq $0x20, %rax
movq %rax, 0x30(%rsp)
callq 0x8710
jmp 0xe149
jmp 0xe2f5
movq 0x78(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
cmpq 0x60(%rsp), %rax
je 0xe1d0
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdi
callq 0x8710
movq 0x20(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x28(%rsp)
jmp 0xe197
movq 0x78(%rsp), %rax
movq 0x60(%rsp), %rcx
movq 0x68(%rsp), %rdx
subq %rdx, %rcx
sarq $0x5, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
addq $-0x20, %rax
movq %rax, 0x18(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x68(%rsp), %rax
addq $-0x20, %rax
movq %rax, 0x8(%rsp)
movq 0x60(%rsp), %rax
movq %rax, (%rsp)
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
jb 0xe2c1
movq 0x8(%rsp), %rax
cmpq 0x70(%rsp), %rax
jb 0xe2c1
jmp 0xe239
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x87(%rsp), %rdi
callq 0xcd80
testb $0x1, %al
jne 0xe256
jmp 0xe288
movq 0x8(%rsp), %rsi
movq %rsi, %rax
addq $-0x20, %rax
movq %rax, 0x8(%rsp)
movq (%rsp), %rdi
addq $-0x20, %rdi
movq %rdi, (%rsp)
callq 0x8710
movq 0x8(%rsp), %rax
cmpq 0x70(%rsp), %rax
jae 0xe286
jmp 0xe2bf
jmp 0xe2ba
movq 0x18(%rsp), %rsi
movq %rsi, %rax
addq $-0x20, %rax
movq %rax, 0x18(%rsp)
movq (%rsp), %rdi
addq $-0x20, %rdi
movq %rdi, (%rsp)
callq 0x8710
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
jae 0xe2b8
jmp 0xe2bf
jmp 0xe2ba
jmp 0xe239
jmp 0xe2c1
jmp 0xe2c3
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
jb 0xe2f3
movq 0x18(%rsp), %rsi
movq %rsi, %rax
addq $-0x20, %rax
movq %rax, 0x18(%rsp)
movq (%rsp), %rdi
addq $-0x20, %rdi
movq %rdi, (%rsp)
callq 0x8710
jmp 0xe2c3
jmp 0xe2f5
addq $0x88, %rsp
retq
nopl (%rax)