// File: /workspace/github_cpp_makefile_star2_O3/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 0x15482
movq %r8, %rbp
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
movb $0x1, %al
movl $0x1, %ecx
movb $0x1, %dl
testb $0x1, %dl
je 0x1545a
movq 0x28(%r14), %rdx
movsd (%rdx,%rcx,8), %xmm0
ucomisd -0x8(%rdx,%rcx,8), %xmm0
setae %dl
jmp 0x1545c
xorl %edx, %edx
testb $0x1, %al
je 0x15474
movq 0x28(%r14), %rax
movsd -0x8(%rax,%rcx,8), %xmm0
ucomisd (%rax,%rcx,8), %xmm0
setae %al
jmp 0x15476
xorl %eax, %eax
incq %rcx
cmpq %rcx, %rbp
jne 0x15441
testb %dl, %dl
je 0x15491
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x1(%rbp), %r13
testb %al, %al
je 0x154e7
xorl %eax, %eax
cmpq %rax, %r13
jle 0x15482
movq 0x28(%r14), %rcx
movsd (%rcx,%rax,8), %xmm0
movsd (%rcx,%r13,8), %xmm1
movsd %xmm1, (%rcx,%rax,8)
movq 0x28(%r14), %rcx
movsd %xmm0, (%rcx,%r13,8)
movq 0x28(%rbx), %rcx
movsd (%rcx,%rax,8), %xmm0
movsd (%rcx,%r13,8), %xmm1
movsd %xmm1, (%rcx,%rax,8)
movq 0x28(%rbx), %rcx
movsd %xmm0, (%rcx,%r13,8)
incq %rax
addq $-0x1, %r13
jb 0x1549b
jmp 0x15482
cmpq %rbp, (%r12)
jge 0x15503
movq %r12, %rdi
movq %rbp, %rsi
movq %r9, %rdx
movq %r9, (%rsp)
callq 0x25326
movq (%rsp), %r9
cmpq %rbp, (%r15)
jge 0x15516
movq %r15, %rdi
movq %rbp, %rsi
movq %r9, %rdx
callq 0x25326
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
movq %r13, %r9
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x15538