// File: /workspace/github_cpp_makefile_star2_O2/mouda[P]LTE_random_access-simulate/alglibinternal.cpp
// Function: alglib_impl::tagsortfastr(alglib_impl::ae_vector*, alglib_impl::ae_vector*, alglib_impl::ae_vector*, alglib_impl::ae_vector*, long, alglib_impl::ae_state*)
void tagsortfastr(/* Real    */ ae_vector* a,
     /* Real    */ ae_vector* b,
     /* Real    */ ae_vector* bufa,
     /* Real    */ ae_vector* bufb,
     ae_int_t n,
     ae_state *_state)
{
    ae_int_t i;
    ae_int_t j;
    ae_bool isascending;
    ae_bool isdescending;
    double tmpr;


    
    /*
     * Special case
     */
    if( n<=1 )
    {
        return;
    }
    
    /*
     * Test for already sorted set
     */
    isascending = ae_true;
    isdescending = ae_true;
    for(i=1; i<=n-1; i++)
    {
        isascending = isascending&&a->ptr.p_double[i]>=a->ptr.p_double[i-1];
        isdescending = isdescending&&a->ptr.p_double[i]<=a->ptr.p_double[i-1];
    }
    if( isascending )
    {
        return;
    }
    if( isdescending )
    {
        for(i=0; i<=n-1; i++)
        {
            j = n-1-i;
            if( j<=i )
            {
                break;
            }
            tmpr = a->ptr.p_double[i];
            a->ptr.p_double[i] = a->ptr.p_double[j];
            a->ptr.p_double[j] = tmpr;
            tmpr = b->ptr.p_double[i];
            b->ptr.p_double[i] = b->ptr.p_double[j];
            b->ptr.p_double[j] = tmpr;
        }
        return;
    }
    
    /*
     * General case
     */
    if( bufa->cnt<n )
    {
        ae_vector_set_length(bufa, n, _state);
    }
    if( bufb->cnt<n )
    {
        ae_vector_set_length(bufb, n, _state);
    }
    tsort_tagsortfastrrec(a, b, bufa, bufb, 0, n-1, _state);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpq $0x2, %r8
jl 0x14805
movq %r9, %rbp
movq %r8, %r15
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x1
popq %rax
movb $0x1, %dl
movb $0x1, %cl
cmpq %rax, %r15
je 0x14800
testb $0x1, %dl
je 0x147de
movq 0x28(%r14), %rdx
movsd (%rdx,%rax,8), %xmm0
ucomisd -0x8(%rdx,%rax,8), %xmm0
setae %dl
jmp 0x147e0
xorl %edx, %edx
testb $0x1, %cl
je 0x147f9
movq 0x28(%r14), %rcx
movsd -0x8(%rcx,%rax,8), %xmm0
ucomisd (%rcx,%rax,8), %xmm0
setae %cl
jmp 0x147fb
xorl %ecx, %ecx
incq %rax
jmp 0x147c0
testb $0x1, %dl
je 0x14814
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb $0x1, %cl
je 0x14871
xorl %eax, %eax
testq %r15, %r15
je 0x14805
leaq -0x1(%r15), %rcx
cmpq %rax, %rcx
jle 0x14805
movq 0x28(%r14), %rdx
movsd (%rdx,%rax,8), %xmm0
movsd -0x8(%rdx,%r15,8), %xmm1
movsd %xmm1, (%rdx,%rax,8)
movq 0x28(%r14), %rdx
movsd %xmm0, -0x8(%rdx,%r15,8)
movq 0x28(%rbx), %rdx
movsd (%rdx,%rax,8), %xmm0
movsd -0x8(%rdx,%r15,8), %xmm1
movsd %xmm1, (%rdx,%rax,8)
movq 0x28(%rbx), %rdx
movsd %xmm0, -0x8(%rdx,%r15,8)
incq %rax
movq %rcx, %r15
jmp 0x1481b
cmpq %r15, (%r13)
jge 0x14885
movq %r13, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x23add
leaq -0x1(%r15), %r9
cmpq %r15, (%r12)
jge 0x148a3
movq %r12, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movq %r9, %r15
callq 0x23add
movq %r15, %r9
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r12, %rcx
xorl %r8d, %r8d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x148c2