// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xb0, %rsp
movl 0x10(%rbp), %eax
movq %r8, -0x10(%rbp)
movq %r9, -0x8(%rbp)
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xd5cd0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xd5d20
movq %rax, %rcx
movq -0x98(%rbp), %rax
cmpq %rcx, %rax
jbe 0xd8dfb
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xd5070
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0xd8e12
movq -0x30(%rbp), %rax
movq %rax, -0xa0(%rbp)
jmp 0xd8e1d
movq -0x38(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x40(%rbp), %rax
jb 0xd8e37
jmp 0xd9040
movq -0x40(%rbp), %rax
subq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
callq 0xd88b0
testb $0x1, %al
jne 0xd8e52
jmp 0xd8ecd
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xd5f80
movq -0x28(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rcx
shrq %rcx
movl $0x8, %edi
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rsi
movq %r8, %rdx
callq 0x9d370
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x58(%rbp), %rdx
movl 0x10(%rbp), %r9d
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %r8
callq 0xd9050
movq -0x58(%rbp), %rsi
movq -0x48(%rbp), %rdx
shrq %rdx
movl $0x8, %edi
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rcx
callq 0x9d370
jmp 0xd9040
movq -0x18(%rbp), %rdi
callq 0xd81d0
testb $0x1, %al
jne 0xd8edc
jmp 0xd8efa
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xd8410
movq %rax, %rdi
callq 0xd46d0
movq %rax, -0xa8(%rbp)
jmp 0xd8f09
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xd5f80
movq -0x28(%rbp), %rcx
imulq -0x68(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rax
shrq %rax
movq %rax, -0x78(%rbp)
movq -0x68(%rbp), %rdi
movq -0x78(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rsi
movq %r8, %rdx
callq 0x9d370
movq %rax, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x78(%rbp), %rax
jae 0xd8fb4
movq -0x60(%rbp), %rax
movq 0x80(%rax), %rax
movq -0x60(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0x88(%rbp), %rcx
imulq -0x68(%rbp), %rcx
addq %rcx, %rsi
callq *%rax
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0xd8f6f
movq -0x60(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x80(%rbp), %rcx
movl 0x10(%rbp), %eax
movq -0x10(%rbp), %r8
movq -0x8(%rbp), %r9
movl %eax, (%rsp)
callq 0xd91a0
movq $0x0, -0x90(%rbp)
movq -0x90(%rbp), %rax
cmpq -0x78(%rbp), %rax
jae 0xd9027
movq -0x60(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0x90(%rbp), %rcx
imulq -0x68(%rbp), %rcx
addq %rcx, %rsi
callq *%rax
movq -0x90(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x90(%rbp)
jmp 0xd8fe2
movq -0x68(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rcx
callq 0x9d370
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)