// File: /workspace/github_cpp_makefile_star2_O3/Baobaobear[P]sort/./sortlib.hpp
// Function: void baobao::internal::tim_sort_stack_merge_with_buffer_13<false, baobao::TestClass*, baobao::TestClass*, std::less<baobao::TestClass>>(baobao::TestClass*, unsigned long, baobao::TestClass**, baobao::TestClass**&, baobao::TestClass*, std::less<baobao::TestClass>)
void tim_sort_stack_merge_with_buffer_13(RandomAccessBufferIterator buf, size_t bufsize, 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_with_buffer<safecopy>(buf, bufsize, 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_with_buffer<safecopy>(buf, bufsize, 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_with_buffer<safecopy>(buf, bufsize, stack_top[-2], stack_top[-1], stack_top[0], compare);
            stack_top[-1] = stack_top[0];
            --stack_top;
        }
        else
        {
            break;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r13
movq (%rcx), %rdi
movq %rdi, %rax
subq %rdx, %rax
cmpq $0x9, %rax
jl 0x9d54
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movabsq $0x5555555555555556, %rbp # imm = 0x5555555555555556
movq -0x8(%rdi), %r9
movq (%rdi), %r8
movq %rbx, %rcx
subq %r8, %rcx
movq %r8, %rsi
subq %r9, %rsi
cmpq %rsi, %rcx
jle 0x9d54
movq -0x10(%rdi), %rcx
cmpq $0x10, %rax
je 0x9c4a
movq %r8, %rax
subq %rcx, %rax
sarq $0x3, %rax
imulq %rbp
movq %rdx, %rax
shrq $0x3f, %rax
addq %rdx, %rax
movq -0x18(%rdi), %rdx
movq %r9, %rdi
subq %rdx, %rdi
sarq $0x5, %rdi
cmpq %rdi, %rax
jge 0x9cab
sarq $0x3, %rsi
movq %rsi, %rax
imulq %rbp
movq %rdx, %rax
shrq $0x3f, %rax
addq %rdx, %rax
movq %r9, %rdx
subq %rcx, %rdx
sarq $0x5, %rdx
cmpq %rdx, %rax
jl 0x9d54
movq %r13, %rdi
movq %r12, %rsi
movq %rcx, %rdx
movq %r9, %rcx
callq 0x76e4
movq (%r14), %rax
movq (%rax), %rcx
movq %rcx, -0x8(%rax)
movq (%r14), %rdi
addq $-0x8, %rdi
movq %rdi, (%r14)
movq %rdi, %rax
subq %r15, %rax
cmpq $0x8, %rax
jg 0x9bfa
jmp 0x9d54
movq %r13, %rdi
movq %r12, %rsi
movq %r9, %r8
callq 0x76e4
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), %rdi
movq %rdi, (%r14)
movq %rdi, %rcx
subq %r15, %rcx
cmpq $0x11, %rcx
jl 0x9c96
movq -0x10(%rax), %r8
movq -0x20(%rax), %r9
movq -0x18(%rax), %rcx
movq %r8, %rax
subq %rcx, %rax
sarq $0x3, %rax
imulq %rbp
movq %rdx, %rax
shrq $0x3f, %rax
addq %rdx, %rax
movq %rcx, %rdx
subq %r9, %rdx
sarq $0x5, %rdx
cmpq %rdx, %rax
jl 0x9c96
movq %r13, %rdi
movq %r12, %rsi
movq %r9, %rdx
callq 0x76e4
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), %rdi
movq %rdi, (%r14)
movq %rdi, %rcx
subq %r15, %rcx
cmpq $0x10, %rcx
jg 0x9ce4
jmp 0x9c96
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq