// File: /workspace/github_cpp_makefile_star2_O1/Cell-veto[P]postlhc/./marsaglia.hpp
// Function: MtwDiscreteSampler<std::array<double, 2ul>>::init_table()
void init_table ()
    {
        // convert to scaled representation
        std::vector <index_t> scaled_ws;
        for (double w : weights)
            // + .5 would be fair rounding
            // + 1. to over-allocate a bit (compensates for rounding)
            scaled_ws.push_back (P_SCALE / weights_total * w + 1.);

        // set up lookup tables
        index_t entry_weight = P_SCALE;
        index_t total_alloc = 0;
        for (unsigned n = 0; n != NUM_LEVELS; ++n)
        {
            table[n].clear ();
            tbase[n] = total_alloc;
            entry_weight /= 64;
            for (index_t i = 0; i != weights.size (); ++i)
            {
                while (scaled_ws[i] >= entry_weight)
                {
                    scaled_ws[i] -= entry_weight;
                    table[n].push_back (i);
                    total_alloc += entry_weight;
                }
            }
        }
        tbase[NUM_LEVELS] = total_alloc;

        std::cerr << "mtw_init alloci " << total_alloc << ' ' << P_SCALE
            << "\nmtw_init rawrate " << weights_total << '\n';

        if (total_alloc < P_SCALE)
            std::cerr << "Initializing MtwDiscreteSampler: rounding error" << ABORT;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq (%rdi), %r12
movq 0x8(%rdi), %r13
cmpq %r13, %r12
je 0x41d1a3
leaq 0x10(%rsp), %r14
leaq 0x8(%rsp), %r15
movsd 0x1b073a(%rip), %xmm0   # 0x5cd878
divsd 0x18(%rbx), %xmm0
mulsd (%r12), %xmm0
addsd 0x1acec7(%rip), %xmm0   # 0x5ca018
cvttsd2si %xmm0, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
subsd 0x1ade73(%rip), %xmm0   # 0x5cafd8
cvttsd2si %xmm0, %rax
andq %rdx, %rax
orq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x41d18f
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x41d19a
movq %r14, %rdi
movq %r15, %rdx
callq 0x41d38c
addq $0x8, %r12
cmpq %r13, %r12
jne 0x41d136
leaq 0x38(%rbx), %rax
movq %rax, 0x30(%rsp)
movl $0x40000000, %ebp       # imm = 0x40000000
xorl %r13d, %r13d
leaq 0x8(%rsp), %r15
xorl %r14d, %r14d
leaq (,%r13,2), %rax
addq %r13, %rax
movq 0x30(%rsp), %rcx
leaq (%rcx,%rax,8), %r12
movq (%r12), %rax
cmpq %rax, 0x8(%r12)
je 0x41d1e0
movq %rax, 0x8(%r12)
movq %r14, 0xb0(%rbx,%r13,8)
shrq $0x6, %rbp
movq $0x0, 0x8(%rsp)
movq 0x8(%rbx), %rax
cmpq (%rbx), %rax
je 0x41d276
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rdx
movq (%rdx,%rax,8), %rcx
cmpq %rbp, %rcx
jb 0x41d25e
leaq (%rdx,%rax,8), %rdx
subq %rbp, %rcx
movq %rcx, (%rdx)
movq 0x8(%r12), %rsi
cmpq 0x10(%r12), %rsi
je 0x41d23a
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%r12)
jmp 0x41d245
movq %r12, %rdi
movq %r15, %rdx
callq 0x41d4ac
addq %rbp, %r14
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
leaq (%rcx,%rax,8), %rdx
movq (%rdx), %rcx
cmpq %rbp, %rcx
jae 0x41d215
incq %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rbx), %rcx
subq (%rbx), %rcx
sarq $0x3, %rcx
cmpq %rcx, %rax
jne 0x41d1fe
incq %r13
cmpq $0x5, %r13
jne 0x41d1bc
movq %r14, 0xd8(%rbx)
movq $0x656aa0, %rdi         # imm = 0x656AA0
leaq 0x1b0746(%rip), %rsi    # 0x5cd9de
movl $0x10, %edx
callq 0x4b14d0
movq $0x656aa0, %rdi         # imm = 0x656AA0
movq %r14, %rsi
callq 0x4b1dd0
leaq 0x8(%rsp), %rsi
movb $0x20, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x4b14d0
movl $0x40000000, %esi       # imm = 0x40000000
movq %rax, %rdi
callq 0x4b1dd0
movq %rax, %r15
leaq 0x1b0712(%rip), %rsi    # 0x5cd9ef
movl $0x12, %edx
movq %rax, %rdi
callq 0x4b14d0
movsd 0x18(%rbx), %xmm0
movq %r15, %rdi
callq 0x4b2730
leaq 0x8(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x4b14d0
cmpq $0x3fffffff, %r14       # imm = 0x3FFFFFFF
jbe 0x41d33b
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x41d32c
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4440d0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x656aa0, %rdi         # imm = 0x656AA0
leaq 0x1b06b9(%rip), %rsi    # 0x5cda02
movl $0x2f, %edx
callq 0x4b14d0
movq $0x656aa0, %rdi         # imm = 0x656AA0
leaq 0x2382f8(%rip), %rsi    # 0x655659
callq 0x440cc2
jmp 0x41d36a
jmp 0x41d36a
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x41d384
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4440d0
movq %rbx, %rdi
callq 0x4f77a0