// File: /workspace/github_c_makefile_star2_O3/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, %rbp
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
movl 0x70(%rsp), %ecx
movq 0x18(%rdi), %r14
testq %r14, %r14
jne 0xee724
movq 0x20(%rbx), %rax
movq 0x8(%r13,%rax), %r14
cmpq 0x10(%r13,%rax), %r14
jbe 0xee724
movq %rbx, %rdi
movq %r13, %rsi
movq %r8, 0x10(%rsp)
movl %ecx, 0xc(%rsp)
callq 0xeba34
movl 0xc(%rsp), %ecx
movq 0x10(%rsp), %r8
cmpq %r15, %r14
cmovbq %r14, %r15
subq %r12, %r15
jbe 0xee792
cmpb $0x1, 0x42(%rbx)
movl %ecx, 0xc(%rsp)
jne 0xee7a1
movq %rbx, %rdi
movq %r13, %rsi
movq %r8, %r13
callq 0xece27
leaq (%rax,%r12,8), %rbx
movq %r15, %r14
shrq %r14
movl $0x8, %edi
xorl %esi, %esi
xorl %edx, %edx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0xbe7da
movq %rax, %r12
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
movq %r13, %rcx
movq %rbp, %r8
movl 0xc(%rsp), %r9d
callq 0xee964
movl $0x8, %edi
movq %r12, %rsi
movq %r14, %rdx
jmp 0xee94c
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r8, 0x10(%rsp)
movq %rbp, 0x18(%rsp)
movq 0x10(%rbx), %rax
addq $-0x7, %rax
testq $-0x3, %rax
je 0xee7c4
movq 0x28(%rbx), %r14
jmp 0xee85f
movq %rbx, %rdi
movq %r13, %rsi
callq 0xee1d0
movq %rax, %rbp
leaq 0xadc8f(%rip), %rax     # 0x19c468
movl (%rax), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %rbp, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %rbp, %rdx
je 0xee82f
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbp, %rdx
je 0xee82f
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbp, %rdx
je 0xee82f
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbp, %rdx
jne 0xee838
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0xee85f
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %rbp, %rsi
callq 0xe9bc5
movq %rax, %r14
leaq 0xadc14(%rip), %rdi     # 0x19c468
movq %rbp, %rsi
movq %rax, %rdx
callq 0x115fac
movq 0x18(%r14), %rbp
movq %rbx, %rdi
movq %r13, %rsi
callq 0xece27
imulq %rbp, %r12
addq %rax, %r12
movq %r15, %r13
shrq %r13
movq %rbp, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0xbe7da
movq %r12, %rsi
movq %rax, %r12
cmpq $0x1, %r15
ja 0xee8bd
movl 0xc(%rsp), %eax
movl %eax, (%rsp)
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r9
callq 0xeea57
jmp 0xee943
movq %rsi, 0x20(%rsp)
cmpq $0x1, %r13
movq %r13, 0x30(%rsp)
movq %r13, %rbx
adcq $0x0, %rbx
movq %r12, 0x28(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq *0x80(%r14)
addq %rbp, %r12
decq %rbx
jne 0xee8d7
movl 0xc(%rsp), %eax
movl %eax, (%rsp)
movq %r14, %rdi
movq 0x20(%rsp), %rsi
movq %r15, %rdx
movq 0x28(%rsp), %r12
movq %r12, %rcx
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r9
callq 0xeea57
cmpq $0x2, %r15
movq 0x30(%rsp), %r13
jb 0xee943
cmpq $0x1, %r13
movq %r13, %rbx
adcq $0x0, %rbx
movq %r12, %r15
movq %r14, %rdi
movq %r15, %rsi
callq *0x88(%r14)
addq %rbp, %r15
decq %rbx
jne 0xee92e
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xbe7da