// File: /workspace/github_c_makefile_star2_O2/johsteffens[P]beth/lib/bcore/bcore_arr.c
// Function: bcore_arr_uz_selftest
st_s* bcore_arr_uz_selftest( void )
{
    st_s* log = st_s_createf( "== bcore_arr_uz_selftest " );
    st_s_push_char_n( log, '=', 80 - log->size );
    st_s_push_char( log, '\n' );

    bcore_arr_uz_s* sz_arr1 = bcore_arr_uz_s_create();
    bcore_arr_uz_s* sz_arr2 = bcore_arr_uz_s_create();
    uz_t size = 100000;
    {
        u2_t rval = 1;
        clock_t time = clock();
        for( uz_t i = 0; i < size; i++ )
        {
            rval = bcore_xsg_u2( rval );
            bcore_arr_uz_s_push( sz_arr1, rval );
        }
        time = clock() - time;
        st_s_push_fa( log, "#p28.{bcore_arr_uz_s_push } #<uz_t>ns\n", ( uz_t ) ( ( 1E9 * ( f3_t )time/CLOCKS_PER_SEC ) / size ) );
    }

    const bcore_array_s* array_p = bcore_array_s_get_typed( TYPEOF_bcore_arr_uz_s );
    const bcore_inst_s* u2_t_p = bcore_inst_s_get_typed( TYPEOF_u2_t );

    {
        u2_t rval = 1;
        clock_t time = clock();
        for( uz_t i = 0; i < size; i++ )
        {
            rval = bcore_xsg_u2( rval );
            bcore_array_p_push( array_p, (bcore_array*)sz_arr2, sr_pwc( u2_t_p, &rval ) );
        }
        time = clock() - time;
        st_s_push_fa( log, "#p28.{bcore_array_p_push } #<uz_t>ns\n", ( uz_t ) ( ( 1E9 * ( f3_t )time/CLOCKS_PER_SEC ) / size ) );
    }

    ASSERT( bcore_compare_aware( sz_arr1, sz_arr2 ) == 0 );

    {
        clock_t time = clock();
        bcore_arr_uz_s_sort( sz_arr1, 1 );
        time = clock() - time;
        st_s_push_fa( log, "#p28.{bcore_arr_uz_s_sort } #<uz_t>ns\n", ( uz_t ) ( ( 1E9 * ( f3_t )time/CLOCKS_PER_SEC ) / size ) );
    }

    {
        clock_t time = clock();
        bcore_array_a_sort( (bcore_array*)sz_arr2, 0, -1, 1 );
        time = clock() - time;
        st_s_push_fa( log, "#p28.{bcore_array_a_sort } #<uz_t>ns\n", ( uz_t ) ( ( 1E9 * ( f3_t )time/CLOCKS_PER_SEC ) / size ) );
    }

    bcore_arr_uz_s* permutation = bcore_arr_uz_s_create_random_permutation( bcore_xsg2_u2, 1, size );

    {
        clock_t time = clock();
        bcore_arr_uz_s_reorder( sz_arr1, permutation );
        time = clock() - time;
        st_s_push_fa( log, "#p28.{bcore_arr_uz_s_reorder } #<uz_t>ns\n", ( uz_t ) ( ( 1E9 * ( f3_t )time/CLOCKS_PER_SEC ) / size ) );
    }

    {
        clock_t time = clock();
        bcore_array_a_reorder( (bcore_array*)sz_arr2, permutation );
        time = clock() - time;
        st_s_push_fa( log, "#p28.{bcore_array_a_reorder } #<uz_t>ns\n", ( uz_t ) ( ( 1E9 * ( f3_t )time/CLOCKS_PER_SEC ) / size ) );
    }

    ASSERT( bcore_compare_aware( sz_arr1, sz_arr2 ) == 0 );

//    bcore_txt_ml_to_stdout( sr_awc( sz_arr1 ) );

    bcore_arr_uz_s_discard( permutation );
    bcore_arr_uz_s_discard( sz_arr1 );
    bcore_arr_uz_s_discard( sz_arr2 );

    st_s_push_char_n( log, '=', 80 );
    st_s_push_char( log, '\n' );
    return log;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
leaq 0x62b1f(%rip), %rdi     # 0xc046e
xorl %eax, %eax
callq 0x8ebc4
movq %rax, %r14
pushq $0x50
popq %rdx
subq 0x10(%rax), %rdx
pushq $0x3d
popq %rsi
movq %rax, %rdi
callq 0x8f175
pushq $0xa
popq %rsi
movq %r14, %rdi
callq 0x8f0ee
callq 0x588f8
movq %rax, %rbp
callq 0x588f8
movq %rax, %r15
pushq $0x1
popq %r13
movl $0x186a0, %ebx          # imm = 0x186A0
callq 0xd340
movq %rax, %r12
subq $0x1, %rbx
jb 0x5d9c4
movl %r13d, %eax
shrl $0x7, %eax
xorl %r13d, %eax
movl %eax, %ecx
shll $0x19, %ecx
xorl %eax, %ecx
movl %ecx, %r13d
shrl $0xc, %r13d
xorl %ecx, %r13d
movq %rbp, %rdi
movq %r13, %rsi
callq 0x58ab5
jmp 0x5d997
movq %rbp, 0x28(%rsp)
callq 0xd340
subq %r12, %rax
cvtsi2sd %rax, %xmm0
mulsd 0x62a72(%rip), %xmm0    # 0xc0450
divsd 0x4c68a(%rip), %xmm0    # 0xaa070
divsd 0x62a6a(%rip), %xmm0    # 0xc0458
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x56cde(%rip), %xmm0    # 0xb46e0
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
leaq 0x62a74(%rip), %rsi     # 0xc0488
movq %r14, 0x38(%rsp)
movq %r14, %rdi
xorl %eax, %eax
callq 0x8f4ef
movabsq $0x3cc9acead7f9ac2e, %rdi # imm = 0x3CC9ACEAD7F9AC2E
callq 0x5dd84
movq %rax, %r12
movabsq $-0x6119581ac7eacd63, %rdi # imm = 0x9EE6A7E53815329D
callq 0x5ddd4
movq %rax, %r13
leaq 0x24(%rsp), %rbx
movl $0x1, (%rbx)
movl $0x186a0, %ebp          # imm = 0x186A0
callq 0xd340
movq %rax, 0x30(%rsp)
pushq $0x1
popq %r14
subq $0x1, %rbp
jb 0x5dab4
movl 0x24(%rsp), %eax
movl %eax, %ecx
shrl $0x7, %ecx
xorl %eax, %ecx
movl %ecx, %eax
shll $0x19, %eax
xorl %ecx, %eax
movl %eax, %ecx
shrl $0xc, %ecx
xorl %eax, %ecx
movl %ecx, 0x24(%rsp)
movq %rbx, 0x40(%rsp)
movq %r13, 0x48(%rsp)
movq %r14, 0x50(%rsp)
movq %r14, 0x10(%rsp)
movupd 0x40(%rsp), %xmm0
movupd %xmm0, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x7c34a
jmp 0x5da65
callq 0xd340
subq 0x30(%rsp), %rax
cvtsi2sd %rax, %xmm0
mulsd 0x62985(%rip), %xmm0    # 0xc0450
divsd 0x4c59d(%rip), %xmm0    # 0xaa070
divsd 0x6297d(%rip), %xmm0    # 0xc0458
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x56bf1(%rip), %xmm0    # 0xb46e0
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
leaq 0x629ae(%rip), %rsi     # 0xc04af
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x8f4ef
movq 0x28(%rsp), %rdi
movq %r15, %rsi
callq 0x81306
testl %eax, %eax
je 0x5db4a
leaq 0x4cb1f(%rip), %rdi     # 0xaa647
leaq 0x629a6(%rip), %rsi     # 0xc04d5
leaq 0x629cc(%rip), %rdx     # 0xc0502
leaq 0x629db(%rip), %rcx     # 0xc0518
movl $0xd92, %r8d            # imm = 0xD92
xorl %eax, %eax
callq 0x5ffac
callq 0xd340
movq %rax, %r12
pushq $0x1
popq %rbp
movq 0x28(%rsp), %r14
movq %r14, %rdi
movl %ebp, %esi
callq 0x58c74
callq 0xd340
subq %r12, %rax
cvtsi2sd %rax, %xmm0
mulsd 0x628d7(%rip), %xmm0    # 0xc0450
divsd 0x4c4ef(%rip), %xmm0    # 0xaa070
divsd 0x628cf(%rip), %xmm0    # 0xc0458
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x56b43(%rip), %xmm0    # 0xb46e0
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
leaq 0x62975(%rip), %rsi     # 0xc0524
movq %rbx, %rdi
xorl %eax, %eax
callq 0x8f4ef
callq 0xd340
movq %rax, %r12
pushq $-0x1
popq %rsi
movq %r15, %rdi
movl %ebp, %edx
callq 0x5d560
callq 0xd340
subq %r12, %rax
cvtsi2sd %rax, %xmm0
mulsd 0x6286d(%rip), %xmm0    # 0xc0450
divsd 0x4c485(%rip), %xmm0    # 0xaa070
divsd 0x62865(%rip), %xmm0    # 0xc0458
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x56ad9(%rip), %xmm0    # 0xb46e0
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
leaq 0x62932(%rip), %rsi     # 0xc054b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x8f4ef
leaq 0x1fa(%rip), %rdi       # 0x5de24
movl $0x186a0, %edx          # imm = 0x186A0
movl %ebp, %esi
callq 0x58e1c
movq %rax, %r12
callq 0xd340
movq %rax, %r13
movq %r14, %rdi
movq %r12, %rsi
callq 0x58d80
callq 0xd340
subq %r13, %rax
cvtsi2sd %rax, %xmm0
mulsd 0x627ef(%rip), %xmm0    # 0xc0450
divsd 0x4c407(%rip), %xmm0    # 0xaa070
divsd 0x627e7(%rip), %xmm0    # 0xc0458
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x56a5b(%rip), %xmm0    # 0xb46e0
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
leaq 0x628da(%rip), %rsi     # 0xc0571
movq %rbx, %rdi
xorl %eax, %eax
callq 0x8f4ef
callq 0xd340
movq %rax, %r13
movq %r15, %rdi
movq %r12, %rsi
callq 0x5d59b
callq 0xd340
subq %r13, %rax
cvtsi2sd %rax, %xmm0
mulsd 0x62787(%rip), %xmm0    # 0xc0450
divsd 0x4c39f(%rip), %xmm0    # 0xaa070
divsd 0x6277f(%rip), %xmm0    # 0xc0458
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x569f3(%rip), %xmm0    # 0xb46e0
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
leaq 0x6289c(%rip), %rsi     # 0xc059b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x8f4ef
movq %r14, %rdi
movq %r15, %rsi
callq 0x81306
testl %eax, %eax
je 0x5dd41
leaq 0x4c928(%rip), %rdi     # 0xaa647
leaq 0x627af(%rip), %rsi     # 0xc04d5
leaq 0x627d5(%rip), %rdx     # 0xc0502
leaq 0x627e4(%rip), %rcx     # 0xc0518
movl $0xdb2, %r8d            # imm = 0xDB2
xorl %eax, %eax
callq 0x5ffac
movq %r12, %rdi
callq 0x58913
movq %r14, %rdi
callq 0x58913
movq %r15, %rdi
callq 0x58913
pushq $0x3d
popq %rsi
pushq $0x50
popq %rdx
movq %rbx, %rdi
callq 0x8f175
pushq $0xa
popq %rsi
movq %rbx, %rdi
callq 0x8f0ee
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq