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

    if( bcore_array_p_is_of_links( p ) )
    {
        vc_t* data = ( vc_t* )bcore_array_p_get_d_data( p, o ) + start;
        vc_t* buf = bcore_un_alloc( sizeof( vd_t ), NULL, 0, range >> 1, NULL );
        buf_sort_link( data, range, buf, cmp, direction );
        bcore_un_alloc( sizeof( vd_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;
        vd_t data = ( u0_t* )bcore_array_p_get_d_data( p, o ) + start * unit_size;

        uz_t range1 = range >> 1;
        vd_t buf = bcore_un_alloc( unit_size, NULL, 0, range1, NULL );
        for( uz_t i = 0; i < range1; i++ ) item_p->init( item_p, ( u0_t* )buf + i * unit_size );

        buf_sort_spect_empl( item_p, data, range, buf, cmp, direction );

        for( uz_t i = 0; i < range1; i++ ) item_p->down( item_p, ( u0_t* )buf + i * unit_size );
        bcore_un_alloc( unit_size, buf, range1, 0, NULL );
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %r13
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbp
movl 0x70(%rsp), %ecx
movq 0x18(%rdi), %rbx
testq %rbx, %rbx
jne 0x7d126
movq 0x20(%rbp), %rax
movq 0x8(%r14,%rax), %rbx
cmpq 0x10(%r14,%rax), %rbx
jbe 0x7d126
movq %rbp, %rdi
movq %r14, %rsi
movq %r8, 0x10(%rsp)
movl %ecx, 0xc(%rsp)
callq 0x7b108
movl 0xc(%rsp), %ecx
movq 0x10(%rsp), %r8
cmpq %r15, %rbx
cmovbq %rbx, %r15
subq %r12, %r15
jbe 0x7d191
cmpb $0x1, 0x42(%rbp)
movl %ecx, 0xc(%rsp)
jne 0x7d1a0
movq %rbp, %rdi
movq %r14, %rsi
movq %r8, %rbp
callq 0x7bf18
leaq (%rax,%r12,8), %rbx
movq %r15, %r14
shrq %r14
pushq $0x8
popq %r12
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x60263
movq %r13, %r8
movq %rax, %r13
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
movq %rbp, %rcx
movl 0xc(%rsp), %r9d
callq 0x7d29b
movq %r12, %rdi
movq %r13, %rsi
jmp 0x7d280
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r8, 0x10(%rsp)
movq %r13, 0x30(%rsp)
movq 0x10(%rbp), %rax
addq $-0x7, %rax
testq $-0x3, %rax
je 0x7d1c0
movq 0x28(%rbp), %r13
jmp 0x7d1d6
movq %rbp, %rdi
movq %r14, %rsi
callq 0x7ccc9
movq %rax, %rdi
callq 0x7b39a
movq %rax, %r13
movq 0x18(%r13), %rbx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x7bf18
movq %rax, 0x18(%rsp)
imulq %rbx, %r12
movq %r15, %r14
shrq %r14
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x60263
movq %rax, %rbp
movq %rax, 0x20(%rsp)
movq %r14, 0x28(%rsp)
subq $0x1, %r14
jb 0x7d22b
movq %r13, %rdi
movq %rbp, %rsi
callq *0x80(%r13)
addq %rbx, %rbp
jmp 0x7d213
movq 0x18(%rsp), %rsi
addq %r12, %rsi
movl 0xc(%rsp), %eax
movl %eax, (%rsp)
movq %r13, %rdi
movq %r15, %rdx
movq 0x20(%rsp), %rbp
movq %rbp, %rcx
movq 0x10(%rsp), %r8
movq 0x30(%rsp), %r9
callq 0x7d38f
movq %rbp, %r15
movq 0x28(%rsp), %r14
movq %r14, %r12
subq $0x1, %r12
jb 0x7d27a
movq %r13, %rdi
movq %r15, %rsi
callq *0x88(%r13)
addq %rbx, %r15
jmp 0x7d262
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x60263