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

    typedef struct myclass
    {
        st_s  name1;
        st_s* name2;
        u3_t  v1;
        u3_t* v2;
    } myclass;

    tp_t t_myclass = bcore_flect_type_parse_sc( "{ st_s name1; st_s => name2; u3_t v1; u3_t => v2; }" );
    bcore_inst_t_discard( t_myclass, bcore_inst_t_create( t_myclass ) ); // cycle once to get all perspectives alive

    myclass* obj1 = bcore_inst_t_create( t_myclass );
    myclass* obj2 = bcore_inst_t_create( t_myclass );

    uz_t arr_size = 100000;
    myclass* obj_arr = bcore_tbman_malloc( sizeof( myclass ) * arr_size );
    for( uz_t i = 0; i < arr_size; i++ )
    {
        bcore_inst_t_init( t_myclass, (bcore_inst*)&obj_arr[ i ] );
        st_s_pushf( &obj_arr[ i ].name1, "Hi!" );
        obj_arr[ i ].name2 = st_s_createf( "Ho!" );
    }

    obj_arr = bcore_tbman_fork( obj_arr );
    bcore_tbman_release_arg_arr( ( fp_down_arg )bcore_inst_p_down, bcore_inst_s_get_typed( t_myclass ), obj_arr, arr_size, sizeof( myclass ) );

    vd_t* ref_arr1 = bcore_tbman_u_alloc( sizeof( vd_t ), NULL, arr_size, NULL );
    vd_t* ref_arr2 = bcore_tbman_u_alloc( sizeof( vd_t ), NULL, arr_size, NULL );

    {
        clock_t time = clock();
        for( uz_t i = 0; i < arr_size; i++ )
        {
            ref_arr1[ i ] = bcore_tbman_fork( &obj_arr[ i ].name1 );
        }
        time = clock() - time;
        st_s_pushf( log, "fork 1 ..... %zuns\n", ( uz_t )( ( ( double )time * 1E9 ) / ( CLOCKS_PER_SEC  * arr_size ) ) );
    }

    {
        clock_t time = clock();
        for( uz_t i = 0; i < arr_size; i++ )
        {
            ref_arr2[ i ] = bcore_tbman_fork( &obj_arr[ i ].name1 );
        }
        time = clock() - time;
        st_s_pushf( log, "fork 2 ..... %zuns\n", ( uz_t )( ( ( double )time * 1E9 ) / ( CLOCKS_PER_SEC  * arr_size ) ) );
    }

    st_s* obj2_name1 = bcore_tbman_fork( &obj2->name1 );

    st_s_pushf( obj2_name1, "Hi!" );

    bcore_tbman_release_arg( ( fp_down_arg )bcore_inst_p_down, bcore_inst_s_get_typed( t_myclass ), obj1 );
    bcore_tbman_release_arg( ( fp_down_arg )bcore_inst_p_down, bcore_inst_s_get_typed( t_myclass ), obj2 );

    bcore_tbman_release( obj2_name1 );

    st_s_pushf( log, "obj_arr references %zu\n", bcore_tbman_references( obj_arr ) );

    {
        clock_t time = clock();
        for( uz_t i = 0; i < arr_size; i++ )
        {
            bcore_tbman_release( ref_arr1[ i ] );
        }
        time = clock() - time;
        st_s_pushf( log, "release 1 .. %zuns\n", ( uz_t )( ( ( double )time * 1E9 ) / ( CLOCKS_PER_SEC  * arr_size ) ) );
    }

    {
        clock_t time = clock();
        for( uz_t i = 0; i < arr_size; i++ )
        {
            bcore_tbman_release( ref_arr2[ i ] );
        }
        time = clock() - time;
        st_s_pushf( log, "release 2 .. %zuns\n", ( uz_t )( ( ( double )time * 1E9 ) / ( CLOCKS_PER_SEC  * arr_size ) ) );
    }

    st_s_pushf( log, "obj_arr references %zu\n", bcore_tbman_references( obj_arr ) );

    bcore_tbman_release( obj_arr );

    st_s_pushf( log, "obj_arr references %zu\n", bcore_tbman_references( obj_arr ) );

    bcore_tbman_release( ref_arr1 );
    bcore_tbman_release( ref_arr2 );

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

    st_s_push_st_d( log, bcore_tbman_s_status( tbman_s_g, 1 ) );
    return log;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
leaq 0x4bec4(%rip), %rdi     # 0x1580d6
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
leaq 0x4be9c(%rip), %rdi     # 0x1580e9
callq 0xa7a50
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10f6a0
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x10f650
movq -0x10(%rbp), %rdi
callq 0x10f6a0
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10f6a0
movq %rax, -0x20(%rbp)
movq $0x186a0, -0x28(%rbp)   # imm = 0x186A0
imulq $0x38, -0x28(%rbp), %rdi
callq 0x10f6e0
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x10c319
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
imulq $0x38, -0x38(%rbp), %rax
addq %rax, %rsi
callq 0x10f710
movq -0x30(%rbp), %rdi
imulq $0x38, -0x38(%rbp), %rax
addq %rax, %rdi
leaq 0x4be3a(%rip), %rsi     # 0x15811d
movb $0x0, %al
callq 0x100120
leaq 0x4be30(%rip), %rdi     # 0x158121
movb $0x0, %al
callq 0xff350
movq %rax, %rcx
movq -0x30(%rbp), %rax
imulq $0x38, -0x38(%rbp), %rdx
addq %rdx, %rax
movq %rcx, 0x20(%rax)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x10c2b1
movq -0x30(%rbp), %rdi
callq 0x109300
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10f1f0
movq %rax, %rsi
movq -0x30(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq 0x33ff(%rip), %rdi      # 0x10f740
movl $0x38, %r8d
callq 0x109410
movq -0x28(%rbp), %rdx
movl $0x8, %edi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rsi
callq 0x109510
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rdx
movl $0x8, %edi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rsi
callq 0x109510
movq %rax, -0x48(%rbp)
callq 0x4300
movq %rax, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x10c3c7
movq -0x30(%rbp), %rdi
imulq $0x38, -0x58(%rbp), %rax
addq %rax, %rdi
callq 0x109300
movq %rax, %rdx
movq -0x40(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x10c38f
callq 0x4300
movq -0x50(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
cvtsi2sdq -0x50(%rbp), %xmm0
movsd 0x32a97(%rip), %xmm1    # 0x13ee80
mulsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
imulq $0xf4240, %rax, %rax    # imm = 0xF4240
movq %rax, %xmm1
movaps 0x32afc(%rip), %xmm2    # 0x13ef00
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x32b00(%rip), %xmm2    # 0x13ef10
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rdx
movq %rdx, %rcx
sarq $0x3f, %rcx
movsd 0x329de(%rip), %xmm1    # 0x13ee18
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
andq %rcx, %rax
orq %rax, %rdx
leaq 0x4bcd5(%rip), %rsi     # 0x158125
movb $0x0, %al
callq 0x100120
callq 0x4300
movq %rax, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x10c4a0
movq -0x30(%rbp), %rdi
imulq $0x38, -0x68(%rbp), %rax
addq %rax, %rdi
callq 0x109300
movq %rax, %rdx
movq -0x48(%rbp), %rax
movq -0x68(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x10c468
callq 0x4300
movq -0x60(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
cvtsi2sdq -0x60(%rbp), %xmm0
movsd 0x329be(%rip), %xmm1    # 0x13ee80
mulsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
imulq $0xf4240, %rax, %rax    # imm = 0xF4240
movq %rax, %xmm1
movaps 0x32a23(%rip), %xmm2    # 0x13ef00
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x32a27(%rip), %xmm2    # 0x13ef10
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rdx
movq %rdx, %rcx
sarq $0x3f, %rcx
movsd 0x32905(%rip), %xmm1    # 0x13ee18
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
andq %rcx, %rax
orq %rax, %rdx
leaq 0x4bc10(%rip), %rsi     # 0x158139
movb $0x0, %al
callq 0x100120
movq -0x20(%rbp), %rdi
callq 0x109300
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
leaq 0x4bbd5(%rip), %rsi     # 0x15811d
movb $0x0, %al
callq 0x100120
movq -0x10(%rbp), %rdi
callq 0x10f1f0
movq %rax, %rsi
movq -0x18(%rbp), %rdx
leaq 0x31da(%rip), %rdi      # 0x10f740
callq 0x109390
movq -0x10(%rbp), %rdi
callq 0x10f1f0
movq %rax, %rsi
movq -0x20(%rbp), %rdx
leaq 0x31be(%rip), %rdi      # 0x10f740
callq 0x109390
movq -0x70(%rbp), %rdi
callq 0x109330
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x30(%rbp), %rdi
callq 0x109460
movq -0xa0(%rbp), %rdi
movq %rax, %rdx
leaq 0x4bb98(%rip), %rsi     # 0x15814d
movb $0x0, %al
callq 0x100120
callq 0x4300
movq %rax, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x80(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x10c5f6
movq -0x40(%rbp), %rax
movq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x109330
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x10c5cd
callq 0x4300
movq -0x78(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rdi
cvtsi2sdq -0x78(%rbp), %xmm0
movsd 0x32868(%rip), %xmm1    # 0x13ee80
mulsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
imulq $0xf4240, %rax, %rax    # imm = 0xF4240
movq %rax, %xmm1
movaps 0x328cd(%rip), %xmm2    # 0x13ef00
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x328d1(%rip), %xmm2    # 0x13ef10
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rdx
movq %rdx, %rcx
sarq $0x3f, %rcx
movsd 0x327af(%rip), %xmm1    # 0x13ee18
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
andq %rcx, %rax
orq %rax, %rdx
leaq 0x4bae6(%rip), %rsi     # 0x158165
movb $0x0, %al
callq 0x100120
callq 0x4300
movq %rax, -0x88(%rbp)
movq $0x0, -0x90(%rbp)
movq -0x90(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x10c6d2
movq -0x48(%rbp), %rax
movq -0x90(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x109330
movq -0x90(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x90(%rbp)
jmp 0x10c69d
callq 0x4300
movq -0x88(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x8(%rbp), %rdi
cvtsi2sdq -0x88(%rbp), %xmm0
movsd 0x32783(%rip), %xmm1    # 0x13ee80
mulsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
imulq $0xf4240, %rax, %rax    # imm = 0xF4240
movq %rax, %xmm1
movaps 0x327e8(%rip), %xmm2    # 0x13ef00
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x327ec(%rip), %xmm2    # 0x13ef10
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rdx
movq %rdx, %rcx
sarq $0x3f, %rcx
movsd 0x326ca(%rip), %xmm1    # 0x13ee18
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
andq %rcx, %rax
orq %rax, %rdx
leaq 0x4ba15(%rip), %rsi     # 0x158179
movb $0x0, %al
callq 0x100120
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x30(%rbp), %rdi
callq 0x109460
movq -0xb8(%rbp), %rdi
movq %rax, %rdx
leaq 0x4b9bd(%rip), %rsi     # 0x15814d
movb $0x0, %al
callq 0x100120
movq -0x30(%rbp), %rdi
callq 0x109330
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x30(%rbp), %rdi
callq 0x109460
movq -0xb0(%rbp), %rdi
movq %rax, %rdx
leaq 0x4b988(%rip), %rsi     # 0x15814d
movb $0x0, %al
callq 0x100120
movq -0x40(%rbp), %rdi
callq 0x109330
movq -0x48(%rbp), %rdi
callq 0x109330
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
movq %rax, -0xa8(%rbp)
movq 0xa705f(%rip), %rdi     # 0x1b3870
movl $0x1, %esi
callq 0x109b10
movq -0xa8(%rbp), %rdi
movq %rax, %rsi
callq 0xfff40
movq -0x8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nopw (%rax,%rax)