// File: 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
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x431e60
movq -0x80(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x420080
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x4200b0
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4209d0
testb $0x1, %al
jne 0x434e28
jmp 0x434eca
leaq -0x30(%rbp), %rdi
callq 0x421040
movq %rax, %rcx
movq -0x80(%rbp), %rax
movsd (%rcx), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd 0x18(%rax), %xmm1
movsd 0x1ca2b2(%rip), %xmm0   # 0x5ff100
divsd %xmm1, %xmm0
movsd -0x40(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x1c61b5(%rip), %xmm1   # 0x5fb018
addsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0x1c750a(%rip), %xmm1   # 0x5fc388
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x48(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x435100
jmp 0x434ea0
jmp 0x434ea2
leaq -0x30(%rbp), %rdi
callq 0x420fe0
jmp 0x434e12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x431fb0
jmp 0x4350ed
movq $0x40000000, -0x60(%rbp) # imm = 0x40000000
movq $0x0, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
cmpl $0x5, -0x6c(%rbp)
je 0x434fdb
movq -0x80(%rbp), %rdi
addq $0x38, %rdi
movl -0x6c(%rbp), %eax
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x435130
movq -0x80(%rbp), %rax
movq -0x68(%rbp), %rdx
movl -0x6c(%rbp), %ecx
movq %rdx, 0xb0(%rax,%rcx,8)
movq -0x60(%rbp), %rax
shrq $0x6, %rax
movq %rax, -0x60(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
callq 0x420670
movq %rax, %rcx
movq -0x88(%rbp), %rax
cmpq %rcx, %rax
je 0x434fcb
jmp 0x434f4e
movq -0x78(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x423c90
movq (%rax), %rax
cmpq -0x60(%rbp), %rax
jb 0x434fb8
movq -0x60(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x78(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x423c90
movq -0x90(%rbp), %rsi
movq %rax, %rcx
movq -0x80(%rbp), %rax
movq (%rcx), %rdx
subq %rsi, %rdx
movq %rdx, (%rcx)
movl -0x6c(%rbp), %ecx
leaq (%rcx,%rcx,2), %rcx
leaq 0x38(%rax,%rcx,8), %rdi
leaq -0x78(%rbp), %rsi
callq 0x435150
jmp 0x434faa
movq -0x60(%rbp), %rax
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x434f4e
jmp 0x434fba
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x434f29
jmp 0x434fcd
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x434ee1
movq -0x80(%rbp), %rax
movq -0x68(%rbp), %rcx
movq %rcx, 0xd8(%rax)
movq $0x698ac0, %rdi         # imm = 0x698AC0
leaq 0x1ca302(%rip), %rsi    # 0x5ff2fa
callq 0x4e1b60
movq %rax, -0x98(%rbp)
jmp 0x435006
movq -0x98(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x4e2170
movq %rax, -0xa0(%rbp)
jmp 0x43501f
movq -0xa0(%rbp), %rdi
movl $0x20, %esi
callq 0x4e1a90
movq %rax, -0xa8(%rbp)
jmp 0x435039
movq -0xa8(%rbp), %rdi
movl $0x40000000, %esi       # imm = 0x40000000
callq 0x4e2170
movq %rax, -0xb0(%rbp)
jmp 0x435053
movq -0xb0(%rbp), %rdi
leaq 0x1ca2aa(%rip), %rsi    # 0x5ff30b
callq 0x4e1b60
movq %rax, -0xb8(%rbp)
jmp 0x43506f
movq -0xb8(%rbp), %rdi
movq -0x80(%rbp), %rax
movsd 0x18(%rax), %xmm0
callq 0x4e2ad0
movq %rax, -0xc0(%rbp)
jmp 0x43508d
movq -0xc0(%rbp), %rdi
movl $0xa, %esi
callq 0x4e1a90
jmp 0x4350a0
cmpq $0x40000000, -0x68(%rbp) # imm = 0x40000000
jae 0x4350db
movq $0x698ac0, %rdi         # imm = 0x698AC0
leaq 0x1ca266(%rip), %rsi    # 0x5ff31e
callq 0x4e1b60
movq %rax, -0xc8(%rbp)
jmp 0x4350c6
movq -0xc8(%rbp), %rdi
leaq 0x2625a5(%rip), %rsi    # 0x697679
callq 0x46d700
jmp 0x4350db
leaq -0x20(%rbp), %rdi
callq 0x431fb0
addq $0xd0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x5283c0
nopw %cs:(%rax,%rax)