// File: /workspace/github_c_makefile_star2_O0/johsteffens[P]beth/lib/bcore/bcore.xo.c
// Function: bcore_huffman_selftest
void bcore_huffman_selftest( void )
{
    // bcore_huffman.x:567:1
    BLM_INIT_LEVEL(0);
    bcore_prsg_lcg_u3_00_s prsg;BLM_T_INIT_SPUSH(bcore_prsg_lcg_u3_00_s, &prsg);;
    
    sz_t n = 100000;
    
    bcore_arr_s3_s arr_s3;BLM_T_INIT_SPUSH(bcore_arr_s3_s, &arr_s3);;
    for(sz_t i = 0; i < n; i++ )
    {
        f3_t v = bcore_prsg_lcg_u3_00_s_gen_f3(&(prsg),0.0, 1.0 );
        s3_t x = pow( sin( v * 3.141 * 2.0 ), 10 + 1 ) * 1000;
        bcore_arr_s3_s_push(&(arr_s3),x );
    }
    
    
    /// huffman codec
    {BLM_INIT_LEVEL(1);
        bcore_huffman_codec_s codec;BLM_T_INIT_SPUSH(bcore_huffman_codec_s, &codec);;
        bcore_huffman_codec_s_scan_start(&(codec));
        for(sz_t i = 0; i < n; i++ ) bcore_huffman_codec_s_scan_s3(&(codec),arr_s3.data[ i ] );
        bcore_huffman_codec_s_scan_end(&(codec));
    
        bcore_huffman_bit_buffer_s bit_buffer;BLM_T_INIT_SPUSH(bcore_huffman_bit_buffer_s, &bit_buffer);;
    
        bcore_huffman_codec_s_encode(&(codec),&(bit_buffer ));
        for(sz_t i = 0; i < n; i++ ) bcore_huffman_codec_s_encode_s3(&(codec),arr_s3.data[ i ],&( bit_buffer ));
    
        bcore_huffman_bit_buffer_iterator_s iterator;BLM_T_INIT_SPUSH(bcore_huffman_bit_buffer_iterator_s, &iterator);bcore_huffman_bit_buffer_iterator_s_setup(&(iterator),&(bit_buffer ));
    
        bcore_huffman_codec_s codec2;BLM_T_INIT_SPUSH(bcore_huffman_codec_s, &codec2);bcore_huffman_codec_s_decode(&(codec2),&(iterator ));
        for(sz_t i = 0; i < n; i++ ) ASSERT( bcore_huffman_codec_s_decode_s3(&(codec2),&(iterator )) == arr_s3.data[ i ] );
    BLM_DOWN();}
    
    /// direct s3 codec
    {BLM_INIT_LEVEL(1);
        s3_t max = bcore_arr_s3_s_max(&(arr_s3));
        s3_t min = bcore_arr_s3_s_min(&(arr_s3));
        sz_t bits = 0;
        while( ( max >> bits ) > 0 || ( min >> bits ) < -1 ) bits++;
        bits++;
    
        bcore_huffman_bit_buffer_s bit_buffer;BLM_T_INIT_SPUSH(bcore_huffman_bit_buffer_s, &bit_buffer);;
        for(sz_t i = 0; i < n; i++ ) bcore_huffman_bit_buffer_s_push_s3(&(bit_buffer),arr_s3.data[ i ], bits );
    
        bcore_huffman_bit_buffer_iterator_s iterator;BLM_T_INIT_SPUSH(bcore_huffman_bit_buffer_iterator_s, &iterator);bcore_huffman_bit_buffer_iterator_s_setup(&(iterator),&(bit_buffer ));
        for(sz_t i = 0; i < n; i++ ) ASSERT( bcore_huffman_bit_buffer_iterator_s_read_s3(&(iterator),bits ) == arr_s3.data[ i ] );
    BLM_DOWN();}
    
    BLM_DOWN();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
leaq 0x1619ae(%rip), %rax    # 0x1b2330
movq (%rax), %rax
movq %rax, -0x8(%rbp)
leaq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0xbfe80
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq $0x0, 0x10(%rax)
leaq -0x50(%rbp), %rdi
callq 0x46780
movq -0x8(%rbp), %rdi
movabsq $-0x1804b258fae5f3f6, %rsi # imm = 0xE7FB4DA7051A0C0A
leaq -0x50(%rbp), %rdx
callq 0xc0220
movq $0x186a0, -0x58(%rbp)   # imm = 0x186A0
leaq -0x78(%rbp), %rdi
callq 0x92310
movq -0x8(%rbp), %rdi
movabsq $0x2cabd5fd9af9a7b7, %rsi # imm = 0x2CABD5FD9AF9A7B7
leaq -0x78(%rbp), %rdx
callq 0xc0220
movq $0x0, -0x80(%rbp)
movq -0x80(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x50a93
leaq -0x50(%rbp), %rdi
xorps %xmm0, %xmm0
movsd 0xee409(%rip), %xmm1    # 0x13ee28
callq 0x50f20
movsd %xmm0, -0x88(%rbp)
movsd 0xee40c(%rip), %xmm0    # 0x13ee40
mulsd -0x88(%rbp), %xmm0
movsd 0xee3dc(%rip), %xmm1    # 0x13ee20
mulsd %xmm1, %xmm0
callq 0x4460
movsd 0xee3e3(%rip), %xmm1    # 0x13ee38
callq 0x4420
movsd 0xee3ce(%rip), %xmm1    # 0x13ee30
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x927f0
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x50a02
movq -0x40(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0xc8(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0xbfe80
movq -0xd0(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq $0x1, 0x10(%rax)
leaq -0xf8(%rbp), %rdi
callq 0x4e080
movq -0x98(%rbp), %rdi
movabsq $0x7dbd1c5e923a8433, %rsi # imm = 0x7DBD1C5E923A8433
leaq -0xf8(%rbp), %rdx
callq 0xc0220
leaq -0xf8(%rbp), %rdi
callq 0x4e350
movq $0x0, -0x100(%rbp)
movq -0x100(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x50b58
movq -0x70(%rbp), %rax
movq -0x100(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0xf8(%rbp), %rdi
callq 0x50f60
movq -0x100(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x100(%rbp)
jmp 0x50b1c
leaq -0xf8(%rbp), %rdi
callq 0x4e4f0
leaq -0x128(%rbp), %rdi
callq 0x4f4c0
movq -0x98(%rbp), %rdi
movabsq $-0x20f7792dc858395f, %rsi # imm = 0xDF0886D237A7C6A1
leaq -0x128(%rbp), %rdx
callq 0xc0220
leaq -0xf8(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x4ef20
movq $0x0, -0x130(%rbp)
movq -0x130(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x50bee
movq -0x70(%rbp), %rax
movq -0x130(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0xf8(%rbp), %rdi
leaq -0x128(%rbp), %rdx
callq 0x50fa0
movq -0x130(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x130(%rbp)
jmp 0x50bab
leaq -0x148(%rbp), %rdi
callq 0x4fcf0
movq -0x98(%rbp), %rdi
movabsq $0x93943e0ef30024c, %rsi # imm = 0x93943E0EF30024C
leaq -0x148(%rbp), %rdx
callq 0xc0220
leaq -0x148(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x50fe0
leaq -0x170(%rbp), %rdi
callq 0x4e080
movq -0x98(%rbp), %rdi
movabsq $0x7dbd1c5e923a8433, %rsi # imm = 0x7DBD1C5E923A8433
leaq -0x170(%rbp), %rdx
callq 0xc0220
leaq -0x170(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x4f220
movq $0x0, -0x178(%rbp)
movq -0x178(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x50ce1
leaq -0x170(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x51010
movq -0x70(%rbp), %rcx
movq -0x178(%rbp), %rdx
cmpq (%rcx,%rdx,8), %rax
je 0x50ccb
leaq 0xe2cf6(%rip), %rdi     # 0x13399f
leaq 0xeeb93(%rip), %rsi     # 0x13f843
leaq 0xeebd8(%rip), %rdx     # 0x13f88f
leaq 0xee350(%rip), %rcx     # 0x13f00e
movl $0xbdb, %r8d            # imm = 0xBDB
movb $0x0, %al
callq 0x9cea0
jmp 0x50ccd
movq -0x178(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x178(%rbp)
jmp 0x50c71
leaq -0xd0(%rbp), %rdi
callq 0xc06e0
movq -0x40(%rbp), %rax
movq %rax, -0x180(%rbp)
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movq -0x1b8(%rbp), %rdi
movq -0x180(%rbp), %rsi
callq 0xbfe80
movq -0x1b8(%rbp), %rax
movq %rax, -0x180(%rbp)
movq -0x180(%rbp), %rax
movq $0x1, 0x10(%rax)
leaq -0x78(%rbp), %rdi
callq 0x930f0
movq %rax, -0x1c0(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x93190
movq %rax, -0x1c8(%rbp)
movq $0x0, -0x1d0(%rbp)
movq -0x1c0(%rbp), %rax
movq -0x1d0(%rbp), %rcx
sarq %cl, %rax
movq %rax, %rcx
movb $0x1, %al
cmpq $0x0, %rcx
movb %al, -0x221(%rbp)
jg 0x50da1
movq -0x1c8(%rbp), %rax
movq -0x1d0(%rbp), %rcx
sarq %cl, %rax
cmpq $-0x1, %rax
setl %al
movb %al, -0x221(%rbp)
movb -0x221(%rbp), %al
testb $0x1, %al
jne 0x50dad
jmp 0x50dc1
movq -0x1d0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1d0(%rbp)
jmp 0x50d61
movq -0x1d0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1d0(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x4f4c0
movq -0x180(%rbp), %rdi
movabsq $-0x20f7792dc858395f, %rsi # imm = 0xDF0886D237A7C6A1
leaq -0x1f8(%rbp), %rdx
callq 0xc0220
movq $0x0, -0x200(%rbp)
movq -0x200(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x50e4a
movq -0x70(%rbp), %rax
movq -0x200(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x1d0(%rbp), %rdx
leaq -0x1f8(%rbp), %rdi
callq 0x4f7f0
movq -0x200(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x200(%rbp)
jmp 0x50e07
leaq -0x218(%rbp), %rdi
callq 0x4fcf0
movq -0x180(%rbp), %rdi
movabsq $0x93943e0ef30024c, %rsi # imm = 0x93943E0EF30024C
leaq -0x218(%rbp), %rdx
callq 0xc0220
leaq -0x218(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x50fe0
movq $0x0, -0x220(%rbp)
movq -0x220(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x50f01
movq -0x1d0(%rbp), %rsi
leaq -0x218(%rbp), %rdi
callq 0x4fee0
movq -0x70(%rbp), %rcx
movq -0x220(%rbp), %rdx
cmpq (%rcx,%rdx,8), %rax
je 0x50eeb
leaq 0xe2ad6(%rip), %rdi     # 0x13399f
leaq 0xee9d6(%rip), %rsi     # 0x13f8a6
leaq 0xee9b8(%rip), %rdx     # 0x13f88f
leaq 0xee130(%rip), %rcx     # 0x13f00e
movl $0xbea, %r8d            # imm = 0xBEA
movb $0x0, %al
callq 0x9cea0
jmp 0x50eed
movq -0x220(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x220(%rbp)
jmp 0x50e91
leaq -0x1b8(%rbp), %rdi
callq 0xc06e0
leaq -0x40(%rbp), %rdi
callq 0xc06e0
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
nop