// File: /workspace/github_c_makefile_star2_O0/johsteffens[P]beth/lib/bcore/bcore_hmap.c
// Function: hmap_tp_selftest
static st_s* hmap_tp_selftest( void )
{
    bcore_life_s* l = bcore_life_s_create();
    st_s* log = st_s_createf( "== bcore_hmap_tp_selftest " );
    st_s_push_char_n( log, '=', 80 - log->size );
    st_s_push_char( log, '\n' );

    bcore_hmap_tp_s* map = bcore_hmap_tp_s_create();
    const uz_t cycles = 200000;

    typedef struct
    {
        tp_t key;
        uz_t val;
    } kv_s;

    kv_s* kvbuf = bcore_alloc( NULL, cycles * sizeof( kv_s ) );
    uz_t kvbuf_size = 0;

    clock_t time = clock();
    st_s_pushf( log, "Mixed access: " );

    {
        u3_t rval1 = 13478;
        for( uz_t i = 0; i < cycles; i++ )
        {
            rval1 = bcore_lcg00_u3( rval1 );
            kv_s kv;
            kv.key = ( tp_t )rval1;
            kv.val = bcore_hmap_tp_s_set( map, kv.key );
            kvbuf[ kvbuf_size++ ] = kv;

            // retrieve
            rval1 = bcore_lcg00_u3( rval1 );
            kv = kvbuf[ rval1 % kvbuf_size ];
            uz_t val = bcore_hmap_tp_s_get( map, kv.key );
            if( val == map->size ) ERR( "index error (%lu)", val );

            // delete
            rval1 = bcore_lcg00_u3( rval1 );
            if( ( ( rval1 >> 10 ) & 1 ) == 1 )
            {
                rval1 = bcore_lcg00_u3( rval1 );
                uz_t idx = rval1 % kvbuf_size;
                kv_s kv = kvbuf[ idx ];
                if( bcore_hmap_tp_s_get( map, kv.key ) == map->size )  ERR( "key (%lu) not found", kv.key );
                bcore_hmap_tp_s_remove( map, kv.key );
                if( bcore_hmap_tp_s_get( map, kv.key ) <  map->size )  ERR( "deleted key still exists (%lu)", kv.key );
                kvbuf_size--;
                kvbuf[ idx ] = kvbuf[ kvbuf_size ];
            }
        }
    }

    time = clock() - time;
    st_s_pushf( log, "(%5.3fs)\n", ( double )time/CLOCKS_PER_SEC );

    st_s_push_st_d( log, hmap_tp_s_status( map ) );

    time = clock();
    bcore_hmap_tp_s* map2 = bcore_life_s_push_aware( l, bcore_hmap_tp_s_clone( map ) );
    time = clock() - time;
    st_s_pushf( log, "Clone .......... %5.3fs\n", ( double )time/CLOCKS_PER_SEC );
    ASSERT( bcore_compare_aware( map, map2 ) == 0 );

    time = clock();
    ASSERT( bcore_compare_aware( map, map2 ) == 0 );
    time = clock() - time;
    st_s_pushf( log, "Comparison ..... %5.3fs\n", ( double )time/CLOCKS_PER_SEC );

    time = clock();
    bcore_hmap_tp_s* map3 = bcore_life_s_push_aware( l, bcore_hmap_tp_s_create() );
    bcore_via_a_nset( (bcore_via*)map3, typeof( "data" ), bcore_via_a_nget( (bcore_via*)map, typeof( "data" ) ) );
    time = clock() - time;
    st_s_pushf( log, "Via-assign ..... %5.3fs\n", ( double )time/CLOCKS_PER_SEC );

    time = clock();
    for( uz_t i = 0; i < map->size; i++ )
    {
        tp_t key = bcore_hmap_tp_s_idx_key( map, i );
        ASSERT( ( key == 0 ) || bcore_hmap_tp_s_exists( map3, key ) );
    }
    time = clock() - time;
    st_s_pushf( log, "verify assign .. %5.3fs\n", ( double )time/CLOCKS_PER_SEC );

    time = clock();
    st_s_pushf( log, "\nRead-access of %lu keys: ", kvbuf_size );
    uz_t read_cycles = 20;
    for( uz_t j = 0; j < read_cycles; j++ )
    {
        for( uz_t i = 0; i < kvbuf_size; i++ )
        {
            if( bcore_hmap_tp_s_get( map, kvbuf[ i ].key ) == map->size ) ERR( "index error (%lu)", kvbuf[ i ].val );
        }
    }
    time = clock() - time;
    st_s_pushf( log, "(%gs per access)\n", ( ( double )time/CLOCKS_PER_SEC ) / ( kvbuf_size * read_cycles ) );

    st_s_pushf( log, "\n" );
    st_s_pushf( log, "Removal: " );
    time = clock();
    while( kvbuf_size )
    {
        kvbuf_size--;
        kv_s kv = kvbuf[ kvbuf_size ];
        if( bcore_hmap_tp_s_get( map, kv.key ) == map->size )  ERR( "key (%lu) not found", kv.key );
        bcore_hmap_tp_s_remove( map, kv.key );
        if( bcore_hmap_tp_s_get( map, kv.key )  < map->size )  ERR( "deleted key still exists (%lu)", kv.key );
    }
    time = clock() - time;
    st_s_pushf( log, "(%5.3fs)\n", ( double )time/CLOCKS_PER_SEC );

    st_s_push_st_d( log, hmap_tp_s_status( map ) );

    bcore_hmap_tp_s_discard( map );
    bcore_alloc( kvbuf, 0 );

    bcore_life_s_discard( l );

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movb $0x0, %al
callq 0xbfdd0
movq %rax, -0x8(%rbp)
leaq 0x9922f(%rip), %rdi     # 0x150b1c
movb $0x0, %al
callq 0xff350
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl $0x50, %edx
subq 0x10(%rax), %rdx
movl $0x3d, %esi
callq 0xffca0
movq -0x10(%rbp), %rdi
movl $0xa, %esi
callq 0xffba0
callq 0xb28f0
movq %rax, -0x18(%rbp)
movq $0x30d40, -0x20(%rbp)   # imm = 0x30D40
xorl %eax, %eax
movl %eax, %edi
movl $0x30d400, %esi         # imm = 0x30D400
callq 0x9d210
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
callq 0x4300
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x89bfb(%rip), %rsi     # 0x14155b
movb $0x0, %al
callq 0x100120
movq $0x34a6, -0x40(%rbp)    # imm = 0x34A6
movq $0x0, -0x48(%rbp)
cmpq $0x30d40, -0x48(%rbp)   # imm = 0x30D40
jae 0xb7b87
movq -0x40(%rbp), %rdi
callq 0xac9a0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0xb2b20
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
shlq $0x4, %rcx
addq %rcx, %rax
movq -0x58(%rbp), %rcx
movq %rcx, (%rax)
movq -0x50(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rdi
callq 0xac9a0
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x40(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0x30(%rbp)
movq -0xe0(%rbp), %rax
shlq $0x4, %rdx
addq %rdx, %rax
movq (%rax), %rcx
movq %rcx, -0x58(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0xb29a0
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jne 0xb7a59
movq -0x60(%rbp), %r8
leaq 0x990f8(%rip), %rdi     # 0x150b37
leaq 0x97d5d(%rip), %rsi     # 0x14f7a3
movl $0x103a, %edx           # imm = 0x103A
leaq 0x990f6(%rip), %rcx     # 0x150b48
movb $0x0, %al
callq 0x9cf40
movq -0x40(%rbp), %rdi
callq 0xac9a0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
shrq $0xa, %rax
andq $0x1, %rax
cmpq $0x1, %rax
jne 0xb7b74
movq -0x40(%rbp), %rdi
callq 0xac9a0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0x30(%rbp)
movq %rdx, -0x68(%rbp)
movq -0x28(%rbp), %rax
movq -0x68(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x78(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0xb29a0
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jne 0xb7af3
movq -0x78(%rbp), %r8
leaq 0x9905e(%rip), %rdi     # 0x150b37
leaq 0x97cc3(%rip), %rsi     # 0x14f7a3
movl $0x1043, %edx           # imm = 0x1043
leaq 0x98c00(%rip), %rcx     # 0x1506ec
movb $0x0, %al
callq 0x9cf40
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0xb2f30
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0xb29a0
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0xb7b3c
movq -0x78(%rbp), %r8
leaq 0x99015(%rip), %rdi     # 0x150b37
leaq 0x97c7a(%rip), %rsi     # 0x14f7a3
movl $0x1045, %edx           # imm = 0x1045
leaq 0x98bcb(%rip), %rcx     # 0x150700
movb $0x0, %al
callq 0x9cf40
movq -0x30(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq -0x68(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
jmp 0xb7b76
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0xb7977
callq 0x4300
subq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
cvtsi2sdq -0x38(%rbp), %xmm0
movsd 0x7b822(%rip), %xmm1    # 0x1333c8
divsd %xmm1, %xmm0
leaq 0x98b6e(%rip), %rsi     # 0x15071f
movb $0x1, %al
callq 0x100120
movq -0x10(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x18(%rbp), %rdi
callq 0xba230
movq -0xf0(%rbp), %rdi
movq %rax, %rsi
callq 0xfff40
callq 0x4300
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x18(%rbp), %rdi
callq 0xb2950
movq -0xe8(%rbp), %rdi
movq %rax, %rsi
callq 0xc0460
movq %rax, -0x80(%rbp)
callq 0x4300
subq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
cvtsi2sdq -0x38(%rbp), %xmm0
movsd 0x7b79e(%rip), %xmm1    # 0x1333c8
divsd %xmm1, %xmm0
leaq 0x98b51(%rip), %rsi     # 0x150786
movb $0x1, %al
callq 0x100120
movq -0x18(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0xe0090
cmpl $0x0, %eax
je 0xb7c77
leaq 0x7bd4a(%rip), %rdi     # 0x13399f
leaq 0x98b43(%rip), %rsi     # 0x15079f
leaq 0x98ed4(%rip), %rdx     # 0x150b37
leaq 0x97b39(%rip), %rcx     # 0x14f7a3
movl $0x1055, %r8d           # imm = 0x1055
movb $0x0, %al
callq 0x9cea0
callq 0x4300
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0xe0090
cmpl $0x0, %eax
je 0xb7cbb
leaq 0x7bd06(%rip), %rdi     # 0x13399f
leaq 0x98aff(%rip), %rsi     # 0x15079f
leaq 0x98e90(%rip), %rdx     # 0x150b37
leaq 0x97af5(%rip), %rcx     # 0x14f7a3
movl $0x1058, %r8d           # imm = 0x1058
movb $0x0, %al
callq 0x9cea0
callq 0x4300
subq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
cvtsi2sdq -0x38(%rbp), %xmm0
movsd 0x7b6ee(%rip), %xmm1    # 0x1333c8
divsd %xmm1, %xmm0
leaq 0x98ae0(%rip), %rsi     # 0x1507c5
movb $0x1, %al
callq 0x100120
callq 0x4300
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x110(%rbp)
callq 0xb28f0
movq -0x110(%rbp), %rdi
movq %rax, %rsi
callq 0xc0460
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq 0x9b58f(%rip), %rdi     # 0x1532bf
callq 0xb3380
movq %rax, -0xf8(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq 0x9b571(%rip), %rdi     # 0x1532bf
callq 0xb3380
movq -0x108(%rbp), %rsi
movq %rax, %rdx
leaq -0xa0(%rbp), %rdi
callq 0xb9d50
movq -0x100(%rbp), %rdi
movq -0xf8(%rbp), %rsi
leaq -0xa0(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xb9cf0
callq 0x4300
subq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
cvtsi2sdq -0x38(%rbp), %xmm0
movsd 0x7b60d(%rip), %xmm1    # 0x1333c8
divsd %xmm1, %xmm0
leaq 0x98a18(%rip), %rsi     # 0x1507de
movb $0x1, %al
callq 0x100120
callq 0x4300
movq %rax, -0x38(%rbp)
movq $0x0, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0xb7e6c
movq -0x18(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0xb30e0
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
je 0xb7e53
movq -0x88(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0xb2fa0
testb $0x1, %al
jne 0xb7e53
leaq 0x7bb6e(%rip), %rdi     # 0x13399f
leaq 0x98d22(%rip), %rsi     # 0x150b5a
leaq 0x98cf8(%rip), %rdx     # 0x150b37
leaq 0x9795d(%rip), %rcx     # 0x14f7a3
movl $0x1066, %r8d           # imm = 0x1066
movb $0x0, %al
callq 0x9cea0
jmp 0xb7e55
movq -0xa8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
jmp 0xb7de1
callq 0x4300
subq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
cvtsi2sdq -0x38(%rbp), %xmm0
movsd 0x7b53d(%rip), %xmm1    # 0x1333c8
divsd %xmm1, %xmm0
leaq 0x989b2(%rip), %rsi     # 0x150848
movb $0x1, %al
callq 0x100120
callq 0x4300
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0x98874(%rip), %rsi     # 0x150729
movb $0x0, %al
callq 0x100120
movq $0x14, -0xb8(%rbp)
movq $0x0, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
cmpq -0xb8(%rbp), %rax
jae 0xb7f8f
movq $0x0, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0xb7f76
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movq -0xc8(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0xb29a0
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jne 0xb7f5d
movq -0x28(%rbp), %rax
movq -0xc8(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %r8
leaq 0x98bf4(%rip), %rdi     # 0x150b37
leaq 0x97859(%rip), %rsi     # 0x14f7a3
movl $0x1072, %edx           # imm = 0x1072
leaq 0x98bf2(%rip), %rcx     # 0x150b48
movb $0x0, %al
callq 0x9cf40
jmp 0xb7f5f
movq -0xc8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc8(%rbp)
jmp 0xb7ef1
jmp 0xb7f78
movq -0xc0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc0(%rbp)
jmp 0xb7ed2
callq 0x4300
movq -0x38(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
cvtsi2sdq -0x38(%rbp), %xmm0
movsd 0x7b417(%rip), %xmm1    # 0x1333c8
divsd %xmm1, %xmm0
movq -0x30(%rbp), %rax
movq -0xb8(%rbp), %rcx
imulq %rcx, %rax
movq %rax, %xmm1
movaps 0x86f30(%rip), %xmm2    # 0x13ef00
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x86f34(%rip), %xmm2    # 0x13ef10
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
leaq 0x9874e(%rip), %rsi     # 0x150744
movb $0x1, %al
callq 0x100120
movq -0x10(%rbp), %rdi
leaq 0x9aa19(%rip), %rsi     # 0x152a21
movb $0x0, %al
callq 0x100120
movq -0x10(%rbp), %rdi
leaq 0x8979c(%rip), %rsi     # 0x1417b6
movb $0x0, %al
callq 0x100120
callq 0x4300
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xb80fe
movq -0x30(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0xd8(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0x18(%rbp), %rdi
movq -0xd8(%rbp), %rsi
callq 0xb29a0
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jne 0xb80a7
movq -0xd8(%rbp), %r8
leaq 0x98aaa(%rip), %rdi     # 0x150b37
leaq 0x9770f(%rip), %rsi     # 0x14f7a3
movl $0x107f, %edx           # imm = 0x107F
leaq 0x9864c(%rip), %rcx     # 0x1506ec
movb $0x0, %al
callq 0x9cf40
movq -0x18(%rbp), %rdi
movq -0xd8(%rbp), %rsi
callq 0xb2f30
movq -0x18(%rbp), %rdi
movq -0xd8(%rbp), %rsi
callq 0xb29a0
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0xb80f9
movq -0xd8(%rbp), %r8
leaq 0x98a58(%rip), %rdi     # 0x150b37
leaq 0x976bd(%rip), %rsi     # 0x14f7a3
movl $0x1081, %edx           # imm = 0x1081
leaq 0x9860e(%rip), %rcx     # 0x150700
movb $0x0, %al
callq 0x9cf40
jmp 0xb802a
callq 0x4300
subq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
cvtsi2sdq -0x38(%rbp), %xmm0
movsd 0x7b2ab(%rip), %xmm1    # 0x1333c8
divsd %xmm1, %xmm0
leaq 0x985f7(%rip), %rsi     # 0x15071f
movb $0x1, %al
callq 0x100120
movq -0x10(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x18(%rbp), %rdi
callq 0xba230
movq -0x118(%rbp), %rdi
movq %rax, %rsi
callq 0xfff40
movq -0x18(%rbp), %rdi
callq 0xb2920
movq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x9d210
movq -0x8(%rbp), %rdi
callq 0xbfe00
movq -0x10(%rbp), %rdi
movl $0x3d, %esi
movl $0x50, %edx
callq 0xffca0
movq -0x10(%rbp), %rdi
movl $0xa, %esi
callq 0xffba0
movq -0x10(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nop