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

    bcore_hmap_u3vd_s* map = bcore_hmap_u3vd_s_create();
    const uz_t cycles = 200000;

    typedef struct
    {
        u3_t key;
        vd_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 = 1;
        u3_t rval2 = 12345;
        for( uz_t i = 0; i < cycles; i++ )
        {
            rval1 = bcore_lcg00_u3( rval1 );
            rval2 = bcore_lcg00_u3( rval2 );
            kv_s kv;
            kv.key = ( u3_t )rval1;
            kv.val = ( vd_t )(intptr_t)rval2;
            kvbuf[ kvbuf_size++ ] = kv;

            // set
            bcore_hmap_u3vd_s_set( map, kv.key, kv.val, false );

            // retrieve
            rval1 = bcore_lcg00_u3( rval1 );
            kv = kvbuf[ rval1 % kvbuf_size ];
            vd_t* val_ptr = bcore_hmap_u3vd_s_get( map, kv.key );
            if( kv.val != *val_ptr ) ERR( "value mismatch (%lu vs %lu)", kv.val, *val_ptr );

            // 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_u3vd_s_get( map, kv.key ) )  ERR( "key (%lu) not found", kv.key );
                bcore_hmap_u3vd_s_remove_d( map, kv.key );
                if( bcore_hmap_u3vd_s_get( map, kv.key ) )  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_u3vd_s_status( map ) );

    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_u3vd_s_get( map, kvbuf[ i ].key ) != kvbuf[ i ].val ) ERR( "value mismatch (%lu vs %lu)", kvbuf[ i ].key, 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_u3vd_s_get( map, kv.key ) )  ERR( "key (%lu) not found", kv.key );
        bcore_hmap_u3vd_s_remove_d( map, kv.key );
        if( bcore_hmap_u3vd_s_get( map, kv.key ) )  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_u3vd_s_status( map ) );

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

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
leaq 0x9cafe(%rip), %rdi     # 0x1506a0
movb $0x0, %al
callq 0xff350
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl $0x50, %edx
subq 0x10(%rax), %rdx
movl $0x3d, %esi
callq 0xffca0
movq -0x8(%rbp), %rdi
movl $0xa, %esi
callq 0xffba0
callq 0xab4f0
movq %rax, -0x10(%rbp)
movq $0x30d40, -0x18(%rbp)   # imm = 0x30D40
xorl %eax, %eax
movl %eax, %edi
movl $0x30d400, %esi         # imm = 0x30D400
callq 0x9d210
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
callq 0x4300
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x8d946(%rip), %rsi     # 0x14155b
movb $0x0, %al
callq 0x100120
movq $0x1, -0x38(%rbp)
movq $0x3039, -0x40(%rbp)    # imm = 0x3039
movq $0x0, -0x48(%rbp)
cmpq $0x30d40, -0x48(%rbp)   # imm = 0x30D40
jae 0xb3e59
movq -0x38(%rbp), %rdi
callq 0xac9a0
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rdi
callq 0xac9a0
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
shlq $0x4, %rcx
addq %rcx, %rax
movq -0x58(%rbp), %rcx
movq %rcx, (%rax)
movq -0x50(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
xorl %ecx, %ecx
callq 0xab870
movq -0x38(%rbp), %rdi
callq 0xac9a0
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x38(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0x28(%rbp)
movq -0xa8(%rbp), %rax
shlq $0x4, %rdx
addq %rdx, %rax
movq (%rax), %rcx
movq %rcx, -0x58(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0xab640
movq %rax, -0x60(%rbp)
movq -0x50(%rbp), %rax
movq -0x60(%rbp), %rcx
cmpq (%rcx), %rax
je 0xb3d33
movq -0x50(%rbp), %r8
movq -0x60(%rbp), %rax
movq (%rax), %r9
leaq 0x9c9a4(%rip), %rdi     # 0x1506bd
leaq 0x9ba83(%rip), %rsi     # 0x14f7a3
movl $0x2d8, %edx            # imm = 0x2D8
leaq 0x9c9a4(%rip), %rcx     # 0x1506d0
movb $0x0, %al
callq 0x9cf40
movq -0x38(%rbp), %rdi
callq 0xac9a0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shrq $0xa, %rax
andq $0x1, %rax
cmpq $0x1, %rax
jne 0xb3e46
movq -0x38(%rbp), %rdi
callq 0xac9a0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0x28(%rbp)
movq %rdx, -0x68(%rbp)
movq -0x20(%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 -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0xab640
cmpq $0x0, %rax
jne 0xb3dc9
movq -0x78(%rbp), %r8
leaq 0x9c90e(%rip), %rdi     # 0x1506bd
leaq 0x9b9ed(%rip), %rsi     # 0x14f7a3
movl $0x2e1, %edx            # imm = 0x2E1
leaq 0x9c92a(%rip), %rcx     # 0x1506ec
movb $0x0, %al
callq 0x9cf40
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0xac280
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0xab640
cmpq $0x0, %rax
je 0xb3e0e
movq -0x78(%rbp), %r8
leaq 0x9c8c9(%rip), %rdi     # 0x1506bd
leaq 0x9b9a8(%rip), %rsi     # 0x14f7a3
movl $0x2e3, %edx            # imm = 0x2E3
leaq 0x9c8f9(%rip), %rcx     # 0x150700
movb $0x0, %al
callq 0x9cf40
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq -0x68(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
jmp 0xb3e48
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0xb3c34
callq 0x4300
subq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
cvtsi2sdq -0x30(%rbp), %xmm0
movsd 0x7f550(%rip), %xmm1    # 0x1333c8
divsd %xmm1, %xmm0
leaq 0x9c89c(%rip), %rsi     # 0x15071f
movb $0x1, %al
callq 0x100120
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rdi
callq 0xac9c0
movq -0xb0(%rbp), %rdi
movq %rax, %rsi
callq 0xfff40
callq 0x4300
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x9c864(%rip), %rsi     # 0x150729
movb $0x0, %al
callq 0x100120
movq $0x14, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x80(%rbp), %rax
jae 0xb3fc3
movq $0x0, -0x90(%rbp)
movq -0x90(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0xb3faa
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq -0x90(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0xab640
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movq -0x90(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
je 0xb3f91
movq -0x20(%rbp), %rax
movq -0x90(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %r8
movq -0x20(%rbp), %rax
movq -0x90(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %r9
leaq 0x9c746(%rip), %rdi     # 0x1506bd
leaq 0x9b825(%rip), %rsi     # 0x14f7a3
movl $0x2f6, %edx            # imm = 0x2F6
leaq 0x9c746(%rip), %rcx     # 0x1506d0
movb $0x0, %al
callq 0x9cf40
jmp 0xb3f93
movq -0x90(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x90(%rbp)
jmp 0xb3efb
jmp 0xb3fac
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0xb3edf
callq 0x4300
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
cvtsi2sdq -0x30(%rbp), %xmm0
movsd 0x7f3e3(%rip), %xmm1    # 0x1333c8
divsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
movq -0x80(%rbp), %rcx
imulq %rcx, %rax
movq %rax, %xmm1
movaps 0x8aeff(%rip), %xmm2    # 0x13ef00
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x8af03(%rip), %xmm2    # 0x13ef10
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
leaq 0x9c71d(%rip), %rsi     # 0x150744
movb $0x1, %al
callq 0x100120
movq -0x8(%rbp), %rdi
leaq 0x9e9e8(%rip), %rsi     # 0x152a21
movb $0x0, %al
callq 0x100120
movq -0x8(%rbp), %rdi
leaq 0x8d76b(%rip), %rsi     # 0x1417b6
movb $0x0, %al
callq 0x100120
callq 0x4300
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xb4127
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0xa0(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0xab640
cmpq $0x0, %rax
jne 0xb40d4
movq -0xa0(%rbp), %r8
leaq 0x9c603(%rip), %rdi     # 0x1506bd
leaq 0x9b6e2(%rip), %rsi     # 0x14f7a3
movl $0x303, %edx            # imm = 0x303
leaq 0x9c61f(%rip), %rcx     # 0x1506ec
movb $0x0, %al
callq 0x9cf40
movq -0x10(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0xac280
movq -0x10(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0xab640
cmpq $0x0, %rax
je 0xb4122
movq -0xa0(%rbp), %r8
leaq 0x9c5b5(%rip), %rdi     # 0x1506bd
leaq 0x9b694(%rip), %rsi     # 0x14f7a3
movl $0x305, %edx            # imm = 0x305
leaq 0x9c5e5(%rip), %rcx     # 0x150700
movb $0x0, %al
callq 0x9cf40
jmp 0xb405b
callq 0x4300
subq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
cvtsi2sdq -0x30(%rbp), %xmm0
movsd 0x7f282(%rip), %xmm1    # 0x1333c8
divsd %xmm1, %xmm0
leaq 0x9c5ce(%rip), %rsi     # 0x15071f
movb $0x1, %al
callq 0x100120
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rdi
callq 0xac9c0
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0xfff40
movq -0x10(%rbp), %rdi
callq 0xab520
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x9d210
movq -0x8(%rbp), %rdi
movl $0x3d, %esi
movl $0x50, %edx
callq 0xffca0
movq -0x8(%rbp), %rdi
movl $0xa, %esi
callq 0xffba0
movq -0x8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nop