// File: /workspace/github_cpp_makefile_star2_O3/Baobaobear[P]sort/./sortlib.hpp
// Function: baobao::TestClass* baobao::internal::tim_sort_create_run<baobao::TestClass*, std::less<baobao::TestClass>>(baobao::TestClass*, baobao::TestClass*, std::less<baobao::TestClass>)
RandomAccessIterator tim_sort_create_run(RandomAccessIterator beg, RandomAccessIterator end, Comp compare)
{
    if (end - beg < timsort_last_run_threshold) // must bigger than timsort_min_run
    {
        insert_sort(beg, end, compare);
        return end;
    }

    bool ascending;
    RandomAccessIterator run_end = beg + 3;

    if (compare(*(beg + 1), *beg))
    {
        if (!compare(*(beg + 2), *beg))
        {
            std::swap(*beg, *(beg + 1));
            ascending = true;
        }
        else if (compare(*(beg + 2), *(beg + 1)))
        {
            ascending = false;
        }
        else
        {
            std::swap(*(beg + 2), *(beg + 1));
            ascending = false;
        }
    }
    else
    {
        if (compare(*(beg + 2), *beg))
        {
            std::swap(*beg, *(beg + 1));
            ascending = false;
        }
        else if (!compare(*(beg + 2), *(beg + 1)))
        {
            ascending = true;
        }
        else
        {
            std::swap(*(beg + 2), *(beg + 1));
            ascending = true;
        }
    }

    if (!ascending)
    {
        while (run_end < end && compare(*run_end, *(run_end - 1)))
        {
            ++run_end;
        }

        if (run_end - beg < timsort_min_run)
        {
            insert_sort_part_rev(beg, run_end, beg + timsort_min_run, compare);
            run_end = beg + timsort_min_run;
            while (run_end < end && compare(*run_end, *(run_end - timsort_insert_gap)))
            {
                unguarded_insert_single_rev(run_end, compare);
                ++run_end;
            }
        }

        // reverse
        typename std::iterator_traits<RandomAccessIterator>::value_type t;
        for (RandomAccessIterator b = beg, e = run_end - 1; b < e; ++b, --e)
        {
            t = *b; *b = *e; *e = t;
        }
    }
    else
    {
        while (run_end < end && !compare(*run_end, *(run_end - 1)))
        {
            ++run_end;
        }

        if (run_end - beg < timsort_min_run)
        {
            insert_sort_part(beg, run_end, beg + timsort_min_run, compare);
            run_end = beg + timsort_min_run;
            while (run_end < end && !compare(*run_end, *(run_end - timsort_insert_gap)))
            {
                unguarded_insert_single(run_end, compare);
                ++run_end;
            }
        }
    }

    return run_end;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rsi, %rax
subq %rdi, %rax
cmpq $0x7ff, %rax            # imm = 0x7FF
jg 0x9340
movq %rbx, %rsi
callq 0x65b3
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%rdi), %edx
movl 0x20(%rdi), %ecx
movl 0x40(%rdi), %eax
cmpl %edx, %ecx
jge 0x93b0
cmpl %edx, %eax
jge 0x9456
cmpl %ecx, %eax
jl 0x93fb
movl 0x44(%rdi), %edx
leaq 0x48(%rdi), %rsi
movq 0x58(%rdi), %r8
movq %r8, 0x10(%rsp)
movups 0x48(%rdi), %xmm0
movaps %xmm0, (%rsp)
movl %ecx, 0x40(%rdi)
movl 0x24(%rdi), %ecx
movl %ecx, 0x44(%rdi)
leaq 0x28(%rdi), %rcx
movq $-0x18, %r8
movl -0x8(%rsi,%r8), %r9d
movl %r9d, 0x18(%rsi,%r8)
addq $0x4, %r8
jne 0x9388
movl %eax, 0x20(%rdi)
movl %edx, 0x24(%rdi)
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rcx)
movaps (%rsp), %xmm0
movups %xmm0, (%rcx)
jmp 0x93fb
cmpl %edx, %eax
jge 0x949b
movl 0x4(%rdi), %eax
movq 0x18(%rdi), %rsi
movq %rsi, 0x10(%rsp)
movups 0x8(%rdi), %xmm0
movaps %xmm0, (%rsp)
movl %ecx, (%rdi)
movl 0x24(%rdi), %ecx
movl %ecx, 0x4(%rdi)
movups 0x28(%rdi), %xmm0
movups %xmm0, 0x8(%rdi)
movq 0x38(%rdi), %rcx
movq %rcx, 0x18(%rdi)
movl %edx, 0x20(%rdi)
movl %eax, 0x24(%rdi)
movaps (%rsp), %xmm0
movups %xmm0, 0x28(%rdi)
movq 0x10(%rsp), %rax
movq %rax, 0x38(%rdi)
leaq 0x60(%rdi), %rdx
cmpq %rbx, %rdx
jae 0x954c
movl $0x60, %ecx
movl (%rdi,%rcx), %eax
cmpl -0x20(%rdi,%rcx), %eax
jge 0x9427
leaq (%rdi,%rcx), %rax
addq $0x20, %rax
addq $0x20, %rcx
cmpq %rbx, %rax
jb 0x940d
leaq (%rdi,%rcx), %rdx
movq %rdx, %rax
subq %rdi, %rax
cmpq $0x400, %rax            # imm = 0x400
jge 0x98e9
leaq 0x400(%rdi), %rax
cmpq $0x3ff, %rcx            # imm = 0x3FF
jbe 0x9558
jmp 0x9641
movl 0x4(%rdi), %eax
movq 0x18(%rdi), %rsi
movq %rsi, 0x10(%rsp)
movups 0x8(%rdi), %xmm0
movaps %xmm0, (%rsp)
movl %ecx, (%rdi)
movl 0x24(%rdi), %ecx
movl %ecx, 0x4(%rdi)
movups 0x28(%rdi), %xmm0
movups %xmm0, 0x8(%rdi)
movq 0x38(%rdi), %rcx
movq %rcx, 0x18(%rdi)
movl %edx, 0x20(%rdi)
movl %eax, 0x24(%rdi)
movaps (%rsp), %xmm0
movups %xmm0, 0x28(%rdi)
movq 0x10(%rsp), %rax
movq %rax, 0x38(%rdi)
jmp 0x94f1
cmpl %ecx, %eax
jge 0x94f1
movl 0x44(%rdi), %edx
leaq 0x48(%rdi), %rsi
movq 0x58(%rdi), %r8
movq %r8, 0x10(%rsp)
movups 0x48(%rdi), %xmm0
movaps %xmm0, (%rsp)
movl %ecx, 0x40(%rdi)
movl 0x24(%rdi), %ecx
movl %ecx, 0x44(%rdi)
leaq 0x28(%rdi), %rcx
movq $-0x18, %r8
movl -0x8(%rsi,%r8), %r9d
movl %r9d, 0x18(%rsi,%r8)
addq $0x4, %r8
jne 0x94cb
movl %eax, 0x20(%rdi)
movl %edx, 0x24(%rdi)
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rcx)
movaps (%rsp), %xmm0
movups %xmm0, (%rcx)
leaq 0x60(%rdi), %rdx
cmpq %rbx, %rdx
jae 0x971d
movl $0x60, %ecx
movl (%rdi,%rcx), %eax
cmpl -0x20(%rdi,%rcx), %eax
jl 0x951d
leaq (%rdi,%rcx), %rax
addq $0x20, %rax
addq $0x20, %rcx
cmpq %rbx, %rax
jb 0x9503
leaq (%rdi,%rcx), %rdx
movq %rdx, %rax
subq %rdi, %rax
cmpq $0x400, %rax            # imm = 0x400
jge 0x9987
leaq 0x400(%rdi), %rax
cmpq $0x3ff, %rcx            # imm = 0x3FF
jbe 0x9729
jmp 0x9812
leaq 0x400(%rdi), %rax
movl $0x60, %ecx
leaq 0x8(%rsp), %rsi
leaq (%rdi,%rcx), %r8
xorl %r9d, %r9d
movl -0x20(%rdi,%rcx), %ebp
movl (%rdi,%rcx), %r10d
cmpl %ebp, %r10d
jl 0x9626
leaq (%rdi,%rcx), %r15
leaq (%rdi,%rcx), %r14
addq $-0x20, %r14
movq %r9, %r12
shlq $0x5, %r12
movl %r10d, (%rsp)
movl 0x4(%r15), %r11d
movl %r11d, 0x4(%rsp)
movq 0x18(%rdx,%r12), %r13
movq %r13, 0x10(%rsi)
movups 0x8(%rdx,%r12), %xmm0
movups %xmm0, (%rsi)
movl %ebp, (%r15)
movl -0x1c(%r15), %ebp
movl %ebp, 0x4(%r15)
movq $-0x18, %r15
movl (%r8,%r15), %ebp
movl %ebp, 0x20(%r8,%r15)
addq $0x4, %r15
jne 0x95b9
movq %r8, %r15
movl -0x20(%r14), %ebp
cmpl %ebp, %r10d
jl 0x9608
leaq -0x20(%r14), %r12
movl %ebp, (%r14)
movl -0x1c(%r14), %ebp
movl %ebp, 0x4(%r14)
movq $-0x18, %r14
movl -0x20(%r15,%r14), %ebp
movl %ebp, (%r15,%r14)
addq $0x4, %r14
jne 0x95ea
addq $-0x20, %r15
movq %r12, %r14
cmpq %rdi, %r12
jne 0x95cb
movq %rdi, %r14
movl %r10d, (%r14)
movl %r11d, 0x4(%r14)
movl $0x2, %r10d
movl (%rsp,%r10,4), %r11d
movl %r11d, (%r14,%r10,4)
incq %r10
cmpq $0x8, %r10
jne 0x9615
leaq 0x20(%rcx), %r10
incq %r9
addq $0x20, %r8
cmpq $0x3e0, %rcx            # imm = 0x3E0
movq %r10, %rcx
jb 0x9564
cmpq %rbx, %rax
jae 0x98ec
leaq 0x8(%rsp), %rcx
movl (%rax), %edx
cmpl -0x100(%rax), %edx
jge 0x98ec
movl -0x20(%rax), %r9d
cmpl %r9d, %edx
jl 0x970b
leaq -0x20(%rax), %rsi
movl %edx, (%rsp)
movl 0x4(%rax), %r8d
movl %r8d, 0x4(%rsp)
movq 0x18(%rax), %r10
movq %r10, 0x10(%rcx)
movups 0x8(%rax), %xmm0
movups %xmm0, (%rcx)
movl %r9d, (%rax)
movl -0x1c(%rax), %r9d
movl %r9d, 0x4(%rax)
movq $-0x18, %r9
movl (%rax,%r9), %r10d
movl %r10d, 0x20(%rax,%r9)
addq $0x4, %r9
jne 0x969b
movl -0x40(%rax), %r10d
cmpl %r10d, %edx
jl 0x96ef
leaq -0x40(%rax), %r11
movq %rax, %r9
movl %r10d, (%rsi)
movl -0x1c(%rsi), %r10d
movl %r10d, 0x4(%rsi)
movq %r11, %rsi
movq $-0x18, %r10
movl -0x20(%r9,%r10), %r11d
movl %r11d, (%r9,%r10)
addq $0x4, %r10
jne 0x96cf
leaq -0x20(%rsi), %r11
movl -0x20(%rsi), %r10d
addq $-0x20, %r9
cmpl %r10d, %edx
jge 0x96ba
movl %edx, (%rsi)
movl %r8d, 0x4(%rsi)
movl $0x2, %edx
movl (%rsp,%rdx,4), %r8d
movl %r8d, (%rsi,%rdx,4)
incq %rdx
cmpq $0x8, %rdx
jne 0x96fa
addq $0x20, %rax
cmpq %rbx, %rax
jb 0x964f
jmp 0x98ec
leaq 0x400(%rdi), %rax
movl $0x60, %ecx
leaq 0x8(%rsp), %rsi
leaq (%rdi,%rcx), %r8
xorl %r9d, %r9d
movl -0x20(%rdi,%rcx), %ebp
movl (%rdi,%rcx), %r10d
cmpl %ebp, %r10d
jge 0x97f7
leaq (%rdi,%rcx), %r15
leaq (%rdi,%rcx), %r14
addq $-0x20, %r14
movq %r9, %r12
shlq $0x5, %r12
movl %r10d, (%rsp)
movl 0x4(%r15), %r11d
movl %r11d, 0x4(%rsp)
movq 0x18(%rdx,%r12), %r13
movq %r13, 0x10(%rsi)
movups 0x8(%rdx,%r12), %xmm0
movups %xmm0, (%rsi)
movl %ebp, (%r15)
movl -0x1c(%r15), %ebp
movl %ebp, 0x4(%r15)
movq $-0x18, %r15
movl (%r8,%r15), %ebp
movl %ebp, 0x20(%r8,%r15)
addq $0x4, %r15
jne 0x978a
movq %r8, %r15
movl -0x20(%r14), %ebp
cmpl %ebp, %r10d
jge 0x97d9
leaq -0x20(%r14), %r12
movl %ebp, (%r14)
movl -0x1c(%r14), %ebp
movl %ebp, 0x4(%r14)
movq $-0x18, %r14
movl -0x20(%r15,%r14), %ebp
movl %ebp, (%r15,%r14)
addq $0x4, %r14
jne 0x97bb
addq $-0x20, %r15
movq %r12, %r14
cmpq %rdi, %r12
jne 0x979c
movq %rdi, %r14
movl %r10d, (%r14)
movl %r11d, 0x4(%r14)
movl $0x2, %r10d
movl (%rsp,%r10,4), %r11d
movl %r11d, (%r14,%r10,4)
incq %r10
cmpq $0x8, %r10
jne 0x97e6
leaq 0x20(%rcx), %r10
incq %r9
addq $0x20, %r8
cmpq $0x3e0, %rcx            # imm = 0x3E0
movq %r10, %rcx
jb 0x9735
cmpq %rbx, %rax
jae 0x9331
leaq 0x8(%rsp), %rcx
movl (%rax), %edx
cmpl -0x100(%rax), %edx
jl 0x9331
movl -0x20(%rax), %r8d
cmpl %r8d, %edx
jge 0x98d7
leaq -0x20(%rax), %rsi
movl %edx, (%rsp)
movl 0x4(%rax), %edi
movl %edi, 0x4(%rsp)
movq 0x18(%rax), %r9
movq %r9, 0x10(%rcx)
movups 0x8(%rax), %xmm0
movups %xmm0, (%rcx)
movl %r8d, (%rax)
movl -0x1c(%rax), %r8d
movl %r8d, 0x4(%rax)
movq $-0x18, %r8
movl (%rax,%r8), %r9d
movl %r9d, 0x20(%rax,%r8)
addq $0x4, %r8
jne 0x986a
movl -0x40(%rax), %r9d
cmpl %r9d, %edx
jge 0x98be
leaq -0x40(%rax), %r10
movq %rax, %r8
movl %r9d, (%rsi)
movl -0x1c(%rsi), %r9d
movl %r9d, 0x4(%rsi)
movq %r10, %rsi
movq $-0x18, %r9
movl -0x20(%r8,%r9), %r10d
movl %r10d, (%r8,%r9)
addq $0x4, %r9
jne 0x989e
leaq -0x20(%rsi), %r10
movl -0x20(%rsi), %r9d
addq $-0x20, %r8
cmpl %r9d, %edx
jl 0x9889
movl %edx, (%rsi)
movl %edi, 0x4(%rsi)
movl $0x2, %edx
movl (%rsp,%rdx,4), %edi
movl %edi, (%rsi,%rdx,4)
incq %rdx
cmpq $0x8, %rdx
jne 0x98c8
addq $0x20, %rax
cmpq %rbx, %rax
jb 0x9820
jmp 0x9331
movq %rdx, %rax
leaq -0x20(%rax), %rcx
cmpq %rdi, %rcx
jbe 0x9331
leaq 0x8(%rsp), %rdx
xorl %esi, %esi
movq %rax, %r8
movq %rdi, %r9
movq %rsi, %rbx
shlq $0x5, %rbx
movl (%r9), %r10d
movl %r10d, (%rsp)
movl 0x4(%r9), %r11d
movl %r11d, 0x4(%rsp)
movq 0x18(%rdi,%rbx), %r14
movq %r14, 0x10(%rdx)
movups 0x8(%rdi,%rbx), %xmm0
movups %xmm0, (%rdx)
movl (%rcx), %ebx
movl %ebx, (%r9)
movl -0x1c(%r8), %ebx
movl %ebx, 0x4(%r9)
movq $-0x18, %rbx
movl (%r8,%rbx), %ebp
movl %ebp, 0x20(%r9,%rbx)
addq $0x4, %rbx
jne 0x9942
movl %r10d, (%rcx)
movl %r11d, -0x1c(%r8)
movq $-0x18, %r10
movl 0x20(%rsp,%r10), %r11d
movl %r11d, (%r8,%r10)
addq $0x4, %r10
jne 0x995f
addq $0x20, %r9
addq $-0x20, %rcx
incq %rsi
addq $-0x20, %r8
cmpq %rcx, %r9
jb 0x9906
jmp 0x9331
movq %rdx, %rax
jmp 0x9331