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

    bcore_btree_ip_kv_s* kvbuf = bcore_alloc( NULL, cycles * sizeof( bcore_btree_ip_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_ip_kv_s kv;
            kv.key = ( bcore_btree_ip_key_t )rval1;
            kv.val = ( bcore_btree_ip_val_t )(intptr_t)rval2;
            kvbuf[ kvbuf_size++ ] = kv;

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

            // retrieve
            rval1 = bcore_xsg_u2( rval1 );
            kv = kvbuf[ rval1 % kvbuf_size ];
            bcore_btree_ip_val_t* val_ptr = bcore_btree_ip_s_val( t, kv.key );
            if( kv.val != *val_ptr ) ERR( "value mismatch (%lu vs %lu)", kv.val, (u3_t)(intptr_t)*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_ip_kv_s kv = kvbuf[ idx ];
                if( !bcore_btree_ip_s_val( t, kv.key ) )  ERR( "key (%lu) not found", kv.key );
                bcore_btree_ip_s_remove( t, kv.key );
                if( bcore_btree_ip_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_ip_s_check_consistency( t->root );
    st_s_push_st_d( log, bcore_btree_ip_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_ip_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_ip_kv_s kv = kvbuf[ kvbuf_size ];
        if( !bcore_btree_ip_s_val( t, kv.key ) )  ERR( "key (%lu) not found", kv.key );
        bcore_btree_ip_s_remove( t, kv.key );
        if( bcore_btree_ip_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_ip_s_status( t ) );

    bcore_btree_ip_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 0x3015a(%rip), %rdi     # 0x1592dc
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 0x121170
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 0x18366(%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 0x12944b
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 0x121da0
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 0x121d00
movq %rax, -0x60(%rbp)
movq -0x50(%rbp), %rax
movq -0x60(%rbp), %rcx
cmpq (%rcx), %rax
je 0x12931d
movq -0x50(%rbp), %r8
movq -0x60(%rbp), %rax
movq (%rax), %r9
leaq 0x2fff1(%rip), %rdi     # 0x1592f4
leaq 0x2fcf3(%rip), %rsi     # 0x158ffd
movl $0x2aa, %edx            # imm = 0x2AA
leaq 0x273ba(%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 0x129438
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 0x121d00
cmpq $0x0, %rax
jne 0x1293bb
movq -0x78(%rbp), %r8
leaq 0x2ff53(%rip), %rdi     # 0x1592f4
leaq 0x2fc55(%rip), %rsi     # 0x158ffd
movl $0x2b3, %edx            # imm = 0x2B3
leaq 0x27338(%rip), %rcx     # 0x1506ec
movb $0x0, %al
callq 0x9cf40
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x121f30
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x121d00
cmpq $0x0, %rax
je 0x129400
movq -0x78(%rbp), %r8
leaq 0x2ff0e(%rip), %rdi     # 0x1592f4
leaq 0x2fc10(%rip), %rsi     # 0x158ffd
movl $0x2b5, %edx            # imm = 0x2B5
leaq 0x27307(%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 0x12943a
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x129214
callq 0x4300
subq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
cvtsi2sdq -0x30(%rbp), %xmm0
movsd 0x9f5e(%rip), %xmm1     # 0x1333c8
divsd %xmm1, %xmm0
leaq 0x272aa(%rip), %rsi     # 0x15071f
movb $0x1, %al
callq 0x100120
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x1209e0
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x122320
movq -0xb0(%rbp), %rdi
movq %rax, %rsi
callq 0xfff40
callq 0x4300
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x27266(%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 0x1295c1
movq $0x0, -0x90(%rbp)
movq -0x90(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x1295a8
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq -0x90(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x121d00
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movq -0x90(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
je 0x12958f
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 0x2fd7f(%rip), %rdi     # 0x1592f4
leaq 0x2fa81(%rip), %rsi     # 0x158ffd
movl $0x2c9, %edx            # imm = 0x2C9
leaq 0x27148(%rip), %rcx     # 0x1506d0
movb $0x0, %al
callq 0x9cf40
jmp 0x129591
movq -0x90(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x90(%rbp)
jmp 0x1294f9
jmp 0x1295aa
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x1294dd
callq 0x4300
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
cvtsi2sdq -0x30(%rbp), %xmm0
movsd 0x9de5(%rip), %xmm1     # 0x1333c8
divsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
movq -0x80(%rbp), %rcx
imulq %rcx, %rax
movq %rax, %xmm1
movaps 0x15901(%rip), %xmm2    # 0x13ef00
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x15905(%rip), %xmm2    # 0x13ef10
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
leaq 0x2711f(%rip), %rsi     # 0x150744
movb $0x1, %al
callq 0x100120
movq -0x8(%rbp), %rdi
leaq 0x293ea(%rip), %rsi     # 0x152a21
movb $0x0, %al
callq 0x100120
movq -0x8(%rbp), %rdi
leaq 0x1816d(%rip), %rsi     # 0x1417b6
movb $0x0, %al
callq 0x100120
callq 0x4300
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x129725
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 0x121d00
cmpq $0x0, %rax
jne 0x1296d2
movq -0xa0(%rbp), %r8
leaq 0x2fc3c(%rip), %rdi     # 0x1592f4
leaq 0x2f93e(%rip), %rsi     # 0x158ffd
movl $0x2d6, %edx            # imm = 0x2D6
leaq 0x27021(%rip), %rcx     # 0x1506ec
movb $0x0, %al
callq 0x9cf40
movq -0x10(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x121f30
movq -0x10(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x121d00
cmpq $0x0, %rax
je 0x129720
movq -0xa0(%rbp), %r8
leaq 0x2fbee(%rip), %rdi     # 0x1592f4
leaq 0x2f8f0(%rip), %rsi     # 0x158ffd
movl $0x2d8, %edx            # imm = 0x2D8
leaq 0x26fe7(%rip), %rcx     # 0x150700
movb $0x0, %al
callq 0x9cf40
jmp 0x129659
callq 0x4300
subq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
cvtsi2sdq -0x30(%rbp), %xmm0
movsd 0x9c84(%rip), %xmm1     # 0x1333c8
divsd %xmm1, %xmm0
leaq 0x26fd0(%rip), %rsi     # 0x15071f
movb $0x1, %al
callq 0x100120
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x129781
leaq 0x2fb8d(%rip), %rdi     # 0x1592f4
leaq 0x2f88f(%rip), %rsi     # 0x158ffd
movl $0x2dd, %edx            # imm = 0x2DD
leaq 0x2fb8e(%rip), %rcx     # 0x159308
movb $0x0, %al
callq 0x9cf40
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x122320
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0xfff40
movq -0x10(%rbp), %rdi
callq 0x1211e0
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,%rax)