// File: /workspace/github_cpp_makefile_star2_O1/Baobaobear[P]sort/./sortlib.hpp
// Function: void baobao::internal::tim_sort_stack_merge_13<false, baobao::TestClass*, baobao::TestClass*, std::less<baobao::TestClass>>(baobao::TestClass*, baobao::TestClass**, baobao::TestClass**&, baobao::TestClass*, std::less<baobao::TestClass>)
void tim_sort_stack_merge_13(RandomAccessBufferIterator buf, RandomAccessIterator* run_stack, RandomAccessIterator* &stack_top, RandomAccessIterator end, Comp compare)
{
    while (stack_top - run_stack >= 2 && end - stack_top[0] > stack_top[0] - stack_top[-1])
    {
        if (stack_top - run_stack > 2 && (stack_top[0] - stack_top[-2]) * 4 / 3 >= stack_top[-1] - stack_top[-3]) // a >= c
        {
            merge_2_part<safecopy>(buf, stack_top[-3], stack_top[-2], stack_top[-1], compare);
            stack_top[-2] = stack_top[-1];
            stack_top[-1] = stack_top[0];
            --stack_top;
            while (stack_top - run_stack > 2 && (stack_top[-1] - stack_top[-2]) * 4 / 3 >= (stack_top[-2] - stack_top[-3]))
            {
                merge_2_part<safecopy>(buf, stack_top[-3], stack_top[-2], stack_top[-1], compare);
                stack_top[-2] = stack_top[-1];
                stack_top[-1] = stack_top[0];
                --stack_top;
            }
        }
        else if ((stack_top[0] - stack_top[-1]) * 4 / 3 >= (stack_top[-1] - stack_top[-2])) // 1.333 * a > b
        {
            merge_2_part<safecopy>(buf, stack_top[-2], stack_top[-1], stack_top[0], compare);
            stack_top[-1] = stack_top[0];
            --stack_top;
        }
        else
        {
            break;
        }
    }
}

// Assembly:
movq (%rdx), %r10
movq %r10, %rax
subq %rsi, %rax
cmpq $0x9, %rax
jl 0x9c6b
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movabsq $0x5555555555555556, %r13 # imm = 0x5555555555555556
movq -0x8(%r10), %r8
movq (%r10), %rcx
movq %rbx, %rdx
subq %rcx, %rdx
movq %rcx, %rdi
subq %r8, %rdi
cmpq %rdi, %rdx
jle 0x9c62
cmpq $0x10, %rax
je 0x9b66
movq -0x18(%r10), %rsi
movq -0x10(%r10), %r9
movq %rcx, %rax
subq %r9, %rax
sarq $0x3, %rax
imulq %r13
movq %rdx, %rax
shrq $0x3f, %rax
addq %rdx, %rax
movq %r8, %rdx
subq %rsi, %rdx
sarq $0x5, %rdx
cmpq %rdx, %rax
jge 0x9bc2
sarq $0x3, %rdi
movq %rdi, %rax
imulq %r13
movq %rdx, %rax
shrq $0x3f, %rax
addq %rdx, %rax
movq -0x10(%r10), %rsi
movq %r8, %rdx
subq %rsi, %rdx
sarq $0x5, %rdx
cmpq %rdx, %rax
jl 0x9c62
movq %r12, %rdi
movq %r8, %rdx
callq 0x6e52
movq (%r14), %rax
movq (%rax), %rcx
movq %rcx, -0x8(%rax)
addq $-0x8, (%r14)
movq (%r14), %r10
movq %r10, %rax
subq %r15, %rax
cmpq $0x8, %rax
jg 0x9b16
jmp 0x9c62
movq %r12, %rdi
movq %r9, %rdx
movq %r8, %rcx
callq 0x6e52
movq (%r14), %rax
movq -0x8(%rax), %rcx
movq %rcx, -0x10(%rax)
movq (%r14), %rax
movq (%rax), %rcx
movq %rcx, -0x8(%rax)
movq (%r14), %rax
leaq -0x8(%rax), %rcx
movq %rcx, (%r14)
subq %r15, %rcx
cmpq $0x11, %rcx
jl 0x9baa
movq -0x10(%rax), %rcx
movq -0x20(%rax), %rsi
movq -0x18(%rax), %r8
movq %rcx, %rax
subq %r8, %rax
sarq $0x3, %rax
imulq %r13
movq %rdx, %rax
shrq $0x3f, %rax
addq %rdx, %rax
movq %r8, %rdx
subq %rsi, %rdx
sarq $0x5, %rdx
cmpq %rdx, %rax
jl 0x9baa
movq %r12, %rdi
movq %r8, %rdx
callq 0x6e52
movq (%r14), %rax
movq -0x8(%rax), %rcx
movq %rcx, -0x10(%rax)
movq (%r14), %rax
movq (%rax), %rcx
movq %rcx, -0x8(%rax)
movq (%r14), %rax
leaq -0x8(%rax), %rcx
movq %rcx, (%r14)
subq %r15, %rcx
cmpq $0x10, %rcx
jg 0x9bf8
jmp 0x9baa
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq