// File: /workspace/github_c_makefile_star2_O0/johsteffens[P]beth/lib/bcore/bcore_btree.c
// Function: btree_ps_s_selftest
static st_s* btree_ps_s_selftest( void )
{
    st_s* log = st_s_createf( "== btree_ps_s_selftest " );
    st_s_push_char_n( log, '=', 80 - log->size );
    st_s_push_char( log, '\n' );
    bcore_btree_ps_s* t = bcore_btree_ps_s_create( NULL );
    const uz_t cycles = 200000;

    bcore_btree_ps_kv_s* kvbuf = bcore_alloc( NULL, cycles * sizeof( bcore_btree_ps_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_xsg_u2( rval1 );
            rval2 = bcore_xsg_u2( rval2 );
            bcore_btree_ps_kv_s kv;
            kv.key = ( bcore_btree_ps_key_t )(intptr_t)rval1;
            kv.val = ( bcore_btree_ps_val_t )(intptr_t)rval2;
            kvbuf[ kvbuf_size++ ] = kv;

            // set
            bcore_btree_ps_s_set( t, kv.key, kv.val );

            // retrieve
            rval1 = bcore_xsg_u2( rval1 );
            kv = kvbuf[ rval1 % kvbuf_size ];
            bcore_btree_ps_val_t* val_ptr = bcore_btree_ps_s_val( t, kv.key );
            if( kv.val != *val_ptr ) ERR( "value mismatch (%lu vs %lu)", kv.val, *val_ptr );

            // delete
            rval1 = bcore_xsg_u2( rval1 );
            if( ( ( rval1 >> 10 ) & 1 ) == 1 )
            {
                rval1 = bcore_xsg_u2( rval1 );
                uz_t idx = rval1 % kvbuf_size;
                bcore_btree_ps_kv_s kv = kvbuf[ idx ];
                if( !bcore_btree_ps_s_val( t, kv.key ) )  ERR( "key (%lu) not found", kv.key );
                bcore_btree_ps_s_remove( t, kv.key );
                if( bcore_btree_ps_s_val( t, 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 );

    bcore_btree_node_ps_s_check_consistency( t->root );
    st_s_push_st_d( log, bcore_btree_ps_s_status( t ) );

    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_btree_ps_s_val( t, 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--;
        bcore_btree_ps_kv_s kv = kvbuf[ kvbuf_size ];
        if( !bcore_btree_ps_s_val( t, kv.key ) )  ERR( "key (%lu) not found", kv.key );
        bcore_btree_ps_s_remove( t, kv.key );
        if( bcore_btree_ps_s_val( t, 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 );

    if( t->root ) ERR( "root still exists" );

    st_s_push_st_d( log, bcore_btree_ps_s_status( t ) );

    bcore_btree_ps_s_discard( t );
    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 0x2fb18(%rip), %rdi     # 0x15931a
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
xorl %eax, %eax
movl %eax, %edi
callq 0x123510
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 0x17ce2(%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 0x129acf
movq -0x38(%rbp), %rax
movl %eax, %edi
callq 0x12af40
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
movl %eax, %edi
callq 0x12af40
movl %eax, %eax
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
callq 0x1241a0
movq -0x38(%rbp), %rax
movl %eax, %edi
callq 0x12af40
movl %eax, %eax
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 0x124100
movq %rax, -0x60(%rbp)
movq -0x50(%rbp), %rax
movq -0x60(%rbp), %rcx
cmpq (%rcx), %rax
je 0x1299a1
movq -0x50(%rbp), %r8
movq -0x60(%rbp), %rax
movq (%rax), %r9
leaq 0x2f9ab(%rip), %rdi     # 0x159332
leaq 0x2f66f(%rip), %rsi     # 0x158ffd
movl $0x5c3, %edx            # imm = 0x5C3
leaq 0x26d36(%rip), %rcx     # 0x1506d0
movb $0x0, %al
callq 0x9cf40
movq -0x38(%rbp), %rax
movl %eax, %edi
callq 0x12af40
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shrq $0xa, %rax
andq $0x1, %rax
cmpq $0x1, %rax
jne 0x129abc
movq -0x38(%rbp), %rax
movl %eax, %edi
callq 0x12af40
movl %eax, %eax
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 0x124100
cmpq $0x0, %rax
jne 0x129a3f
movq -0x78(%rbp), %r8
leaq 0x2f90d(%rip), %rdi     # 0x159332
leaq 0x2f5d1(%rip), %rsi     # 0x158ffd
movl $0x5cc, %edx            # imm = 0x5CC
leaq 0x26cb4(%rip), %rcx     # 0x1506ec
movb $0x0, %al
callq 0x9cf40
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x124330
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x124100
cmpq $0x0, %rax
je 0x129a84
movq -0x78(%rbp), %r8
leaq 0x2f8c8(%rip), %rdi     # 0x159332
leaq 0x2f58c(%rip), %rsi     # 0x158ffd
movl $0x5ce, %edx            # imm = 0x5CE
leaq 0x26c83(%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 0x129abe
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x129898
callq 0x4300
subq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
cvtsi2sdq -0x30(%rbp), %xmm0
movsd 0x98da(%rip), %xmm1     # 0x1333c8
divsd %xmm1, %xmm0
leaq 0x26c26(%rip), %rsi     # 0x15071f
movb $0x1, %al
callq 0x100120
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x122d80
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1247a0
movq -0xb0(%rbp), %rdi
movq %rax, %rsi
callq 0xfff40
callq 0x4300
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x26be2(%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 0x129c45
movq $0x0, -0x90(%rbp)
movq -0x90(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x129c2c
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq -0x90(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x124100
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movq -0x90(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
je 0x129c13
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 0x2f739(%rip), %rdi     # 0x159332
leaq 0x2f3fd(%rip), %rsi     # 0x158ffd
movl $0x5e2, %edx            # imm = 0x5E2
leaq 0x26ac4(%rip), %rcx     # 0x1506d0
movb $0x0, %al
callq 0x9cf40
jmp 0x129c15
movq -0x90(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x90(%rbp)
jmp 0x129b7d
jmp 0x129c2e
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x129b61
callq 0x4300
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
cvtsi2sdq -0x30(%rbp), %xmm0
movsd 0x9761(%rip), %xmm1     # 0x1333c8
divsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
movq -0x80(%rbp), %rcx
imulq %rcx, %rax
movq %rax, %xmm1
movaps 0x1527d(%rip), %xmm2    # 0x13ef00
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x15281(%rip), %xmm2    # 0x13ef10
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
leaq 0x26a9b(%rip), %rsi     # 0x150744
movb $0x1, %al
callq 0x100120
movq -0x8(%rbp), %rdi
leaq 0x28d66(%rip), %rsi     # 0x152a21
movb $0x0, %al
callq 0x100120
movq -0x8(%rbp), %rdi
leaq 0x17ae9(%rip), %rsi     # 0x1417b6
movb $0x0, %al
callq 0x100120
callq 0x4300
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x129da9
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 0x124100
cmpq $0x0, %rax
jne 0x129d56
movq -0xa0(%rbp), %r8
leaq 0x2f5f6(%rip), %rdi     # 0x159332
leaq 0x2f2ba(%rip), %rsi     # 0x158ffd
movl $0x5ef, %edx            # imm = 0x5EF
leaq 0x2699d(%rip), %rcx     # 0x1506ec
movb $0x0, %al
callq 0x9cf40
movq -0x10(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x124330
movq -0x10(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x124100
cmpq $0x0, %rax
je 0x129da4
movq -0xa0(%rbp), %r8
leaq 0x2f5a8(%rip), %rdi     # 0x159332
leaq 0x2f26c(%rip), %rsi     # 0x158ffd
movl $0x5f1, %edx            # imm = 0x5F1
leaq 0x26963(%rip), %rcx     # 0x150700
movb $0x0, %al
callq 0x9cf40
jmp 0x129cdd
callq 0x4300
subq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
cvtsi2sdq -0x30(%rbp), %xmm0
movsd 0x9600(%rip), %xmm1     # 0x1333c8
divsd %xmm1, %xmm0
leaq 0x2694c(%rip), %rsi     # 0x15071f
movb $0x1, %al
callq 0x100120
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x129e05
leaq 0x2f547(%rip), %rdi     # 0x159332
leaq 0x2f20b(%rip), %rsi     # 0x158ffd
movl $0x5f6, %edx            # imm = 0x5F6
leaq 0x2f50a(%rip), %rcx     # 0x159308
movb $0x0, %al
callq 0x9cf40
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1247a0
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0xfff40
movq -0x10(%rbp), %rdi
callq 0x1235c0
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
nopl (%rax)