// File: /workspace/github_cpp_makefile_star2_O2/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 $0x28, %rsp
movq %rdi, %rbx
leaq 0x10(%rsp), %r14
andq $0x0, 0x10(%r14)
xorpd %xmm0, %xmm0
movapd %xmm0, (%r14)
movq (%rdi), %r12
movq 0x8(%rdi), %r13
movq %rsp, %r15
cmpq %r13, %r12
je 0x418b48
movsd 0x1a9027(%rip), %xmm0   # 0x5c1b28
divsd 0x18(%rbx), %xmm0
mulsd (%r12), %xmm0
addsd 0x1a5504(%rip), %xmm0   # 0x5be018
cvttsd2si %xmm0, %rax
movq %rax, %rcx
subsd 0x1a66bc(%rip), %xmm0   # 0x5bf1e0
cvttsd2si %xmm0, %rdx
sarq $0x3f, %rcx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x418cb6
addq $0x8, %r12
jmp 0x418af4
leaq 0x38(%rbx), %rax
movq %rax, 0x8(%rsp)
movl $0x40000000, %ebp       # imm = 0x40000000
xorl %r13d, %r13d
movq %rsp, %r15
xorl %r14d, %r14d
cmpq $0x5, %r13
je 0x418bd4
imulq $0x18, %r13, %rcx
movq 0x8(%rsp), %rdx
leaq (%rdx,%rcx), %r12
movq (%rdx,%rcx), %rax
cmpq %rax, 0x8(%rdx,%rcx)
je 0x418b82
movq %rax, 0x8(%r12)
movq %r14, 0xb0(%rbx,%r13,8)
shrq $0x6, %rbp
xorl %eax, %eax
movq %rax, (%rsp)
movq 0x8(%rbx), %rcx
subq (%rbx), %rcx
sarq $0x3, %rcx
cmpq %rcx, %rax
je 0x418bcf
movq 0x10(%rsp), %rcx
movq (%rcx,%rax,8), %rdx
subq %rbp, %rdx
jb 0x418bca
movq %rdx, (%rcx,%rax,8)
movq %r12, %rdi
movq %r15, %rsi
callq 0x418c96
addq %rbp, %r14
movq (%rsp), %rax
jmp 0x418ba4
incq %rax
jmp 0x418b90
incq %r13
jmp 0x418b5f
movq %r14, 0xd8(%rbx)
movq $0x64eaa0, %rdi         # imm = 0x64EAA0
leaq 0x1a90a5(%rip), %rsi    # 0x5c1c8e
callq 0x4a4910
movq %rax, %rdi
movq %r14, %rsi
callq 0x4a4ce0
pushq $0x20
popq %rsi
movq %rax, %rdi
callq 0x4a4840
movl $0x40000000, %esi       # imm = 0x40000000
movq %rax, %rdi
callq 0x4a4ce0
leaq 0x1a9087(%rip), %rsi    # 0x5c1c9f
movq %rax, %rdi
callq 0x4a4910
movsd 0x18(%rbx), %xmm0
movq %rax, %rdi
callq 0x4a5640
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x4a4840
cmpq $0x3fffffff, %r14       # imm = 0x3FFFFFFF
jbe 0x418c5a
leaq 0x10(%rsp), %rdi
callq 0x417874
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x64eaa0, %rdi         # imm = 0x64EAA0
leaq 0x1a904a(%rip), %rsi    # 0x5c1cb2
callq 0x4a4910
leaq 0x2349e5(%rip), %rsi    # 0x64d659
movq %rax, %rdi
callq 0x434f95
jmp 0x418c80
jmp 0x418c80
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x417874
movq %rbx, %rdi
callq 0x4eb220
nop