// File: /workspace/github_c_makefile_star2_O1/johsteffens[P]beth/lib/bcore/bcore_spect_array.c
// Function: bcore_array_default_create_sorted_order_f
bcore_arr_uz_s* bcore_array_default_create_sorted_order_f( const bcore_array_s* p, const bcore_array* o, uz_t start, uz_t end, bcore_cmp_f cmp, s2_t direction )
{
    bcore_arr_uz_s* order = bcore_arr_uz_s_create();
    uz_t size = get_size( p, o );
    uz_t end_l = end < size ? end : size;
    if( start >= end_l ) return order;
    uz_t range = end_l - start;

    bcore_arr_uz_s_step_fill( order, 0, 1, range );

    if( bcore_array_p_is_of_links( p ) )
    {
        vc_t* data = ( vc_t* )bcore_array_p_get_c_data( p, o ) + start;
        uz_t* buf = bcore_un_alloc( sizeof( uz_t ), NULL, 0, range >> 1, NULL );
        buf_order_sort( data, order->data, range, buf, cmp, direction );
        bcore_un_alloc( sizeof( uz_t ), buf, range >> 1, 0, NULL );
    }
    else
    {
        const bcore_inst_s* item_p = bcore_array_p_is_mutable_mono_typed( p ) ? bcore_inst_s_get_typed( bcore_array_p_get_mono_type( p, o ) ) : p->item_p;
        uz_t unit_size = item_p->size;
        vc_t src = ( u0_t* )bcore_array_p_get_c_data( p, o ) + start * unit_size;
        vc_t* data = bcore_un_alloc( sizeof( vc_t ), NULL, 0, range, NULL );
        for( uz_t i = 0; i < range; i++ ) data[ i ] = ( u0_t* )src + i * unit_size;

        uz_t* buf = bcore_un_alloc( sizeof( uz_t ), NULL, 0, range >> 1, NULL );
        buf_order_sort( data, order->data, range, buf, cmp, direction );
        bcore_un_alloc( sizeof( uz_t ), buf,  range >> 1, 0, NULL );
        bcore_un_alloc( sizeof( vc_t ), data, range,      0, NULL );
    }

    for( uz_t i = 0; i < order->size; i++ ) order->data[ i ] += start;

    return order;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r15
movq %r8, %rbp
movq %rcx, %r13
movq %rdx, %rbx
movq %rsi, 0x8(%rsp)
movq %rdi, %r12
xorl %eax, %eax
callq 0xbf532
movq %rax, %r14
movq 0x18(%r12), %rax
testq %rax, %rax
jne 0xf93f1
movq 0x20(%r12), %rax
movq 0x8(%rsp), %rcx
movq 0x8(%rcx,%rax), %rax
cmpq %r13, %rax
cmovbq %rax, %r13
movq %r13, 0x20(%rsp)
subq %rbx, %r13
jbe 0xf9616
movl $0x1, %edx
movq %r14, %rdi
xorl %esi, %esi
movq %r13, %rcx
callq 0xbf6a9
cmpb $0x1, 0x42(%r12)
movq %r15, 0x10(%rsp)
jne 0xf9484
movq %r12, %rdi
movq 0x8(%rsp), %rsi
callq 0xf80e2
leaq (%rax,%rbx,8), %r15
movq %r13, %r12
shrq %r12
movl $0x8, %edi
xorl %esi, %esi
xorl %edx, %edx
movq %r12, %rcx
xorl %r8d, %r8d
callq 0xc833e
movq %rbp, %r8
movq %rax, %rbp
movq 0x8(%r14), %rsi
movl 0x60(%rsp), %eax
movl %eax, (%rsp)
movq %r15, %rdi
movq %r13, %rdx
movq %rbp, %rcx
movq 0x10(%rsp), %r9
callq 0xf9630
movl $0x8, %edi
movq %rbp, %rsi
movq %r12, %rdx
jmp 0xf95f2
movq 0x10(%r12), %rax
addq $-0x7, %rax
testq $-0x3, %rax
movq %rbp, 0x18(%rsp)
je 0xf94a4
movq 0x28(%r12), %r15
jmp 0xf9545
movq %r12, %rdi
movq 0x8(%rsp), %rsi
callq 0xf86fe
leaq 0xaffb0(%rip), %rsi     # 0x1a9468
movl (%rsi), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rsi,%rcx,8), %rdx
movq 0x18(%rsi,%rcx,8), %rcx
andq %rax, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rsi
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %rax, %rdx
je 0xf9512
movq 0x10(%rsi), %rdx
movl $0x18, %ecx
cmpq %rax, %rdx
je 0xf9512
movq 0x20(%rsi), %rdx
movl $0x28, %ecx
cmpq %rax, %rdx
je 0xf9512
movq 0x30(%rsi), %rdx
movl $0x38, %ecx
cmpq %rax, %rdx
jne 0xf9628
movq (%rsi,%rcx), %r15
testq %r15, %r15
jne 0xf9545
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %rax, %rbp
movq %rax, %rsi
callq 0xf3f85
movq %rax, %r15
leaq 0xaff2e(%rip), %rdi     # 0x1a9468
movq %rbp, %rsi
movq %rax, %rdx
callq 0x12128c
movq 0x18(%r15), %rbp
movq %r12, %rdi
movq 0x8(%rsp), %rsi
callq 0xf80e2
movq %rax, %r12
movl $0x8, %edi
xorl %esi, %esi
xorl %edx, %edx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0xc833e
movq %rax, %r15
cmpq %rbx, 0x20(%rsp)
je 0xf9592
movq %rbp, %rax
imulq %rbx, %rax
addq %rax, %r12
xorl %eax, %eax
movq %r12, (%r15,%rax,8)
incq %rax
addq %rbp, %r12
cmpq %rax, %r13
jne 0xf9583
movq %r13, %r12
shrq %r12
movl $0x8, %edi
xorl %esi, %esi
xorl %edx, %edx
movq %r12, %rcx
xorl %r8d, %r8d
callq 0xc833e
movq %rax, %rbp
movq 0x8(%r14), %rsi
movl 0x60(%rsp), %eax
movl %eax, (%rsp)
movq %r15, %rdi
movq %r13, %rdx
movq %rbp, %rcx
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %r9
callq 0xf9630
movl $0x8, %edi
movq %rbp, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xc833e
movl $0x8, %edi
movq %r15, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xc833e
cmpq $0x0, 0x10(%r14)
je 0xf9616
xorl %eax, %eax
movq 0x8(%r14), %rcx
addq %rbx, (%rcx,%rax,8)
incq %rax
cmpq 0x10(%r14), %rax
jb 0xf9605
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
jmp 0xf9516