// File: /workspace/github_cpp_makefile_star2_O3/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 0x41cc7d
leaq 0x10(%rsp), %r14
leaq 0x8(%rsp), %r15
movsd 0x1afd50(%rip), %xmm0   # 0x5cc968
divsd 0x18(%rbx), %xmm0
mulsd (%r12), %xmm0
addsd 0x1ac3ed(%rip), %xmm0   # 0x5c9018
cvttsd2si %xmm0, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
subsd 0x1ad4d9(%rip), %xmm0   # 0x5ca118
cvttsd2si %xmm0, %rax
andq %rdx, %rax
orq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x41cc69
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x41cc74
movq %r14, %rdi
movq %r15, %rdx
callq 0x41ce6c
addq $0x8, %r12
cmpq %r13, %r12
jne 0x41cc10
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 0x41ccba
movq %rax, 0x8(%r12)
movq %r14, 0xb0(%rbx,%r13,8)
shrq $0x6, %rbp
movq $0x0, 0x8(%rsp)
movq (%rbx), %rdx
movq 0x8(%rbx), %rsi
cmpq %rdx, %rsi
je 0x41cd56
movq 0x10(%rsp), %rax
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdi
cmpq %rbp, %rdi
jb 0x41cd3f
leaq (%rax,%rcx,8), %rdx
subq %rbp, %rdi
movq %rdi, (%rdx)
movq 0x8(%r12), %rsi
cmpq 0x10(%r12), %rsi
je 0x41cd14
movq 0x8(%rsp), %rcx
movq %rcx, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%r12)
jmp 0x41cd29
movq %r12, %rdi
movq %r15, %rdx
callq 0x41cf8c
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rax
addq %rbp, %r14
leaq (%rax,%rcx,8), %rdx
movq (%rdx), %rdi
cmpq %rbp, %rdi
jae 0x41ccef
movq (%rbx), %rdx
movq 0x8(%rbx), %rsi
incq %rcx
movq %rcx, 0x8(%rsp)
movq %rsi, %rdi
subq %rdx, %rdi
sarq $0x3, %rdi
cmpq %rdi, %rcx
jne 0x41cce2
incq %r13
cmpq $0x5, %r13
jne 0x41cc96
movq %r14, 0xd8(%rbx)
movq $0x655aa0, %rdi         # imm = 0x655AA0
leaq 0x1afd56(%rip), %rsi    # 0x5ccace
movl $0x10, %edx
callq 0x4b0120
movq $0x655aa0, %rdi         # imm = 0x655AA0
movq %r14, %rsi
callq 0x4b0a20
leaq 0x8(%rsp), %rsi
movb $0x20, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x4b0120
movl $0x40000000, %esi       # imm = 0x40000000
movq %rax, %rdi
callq 0x4b0a20
movq %rax, %r15
leaq 0x1afd22(%rip), %rsi    # 0x5ccadf
movl $0x12, %edx
movq %rax, %rdi
callq 0x4b0120
movsd 0x18(%rbx), %xmm0
movq %r15, %rdi
callq 0x4b1380
leaq 0x8(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x4b0120
cmpq $0x3fffffff, %r14       # imm = 0x3FFFFFFF
jbe 0x41ce1b
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x41ce0c
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x442d20
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x655aa0, %rdi         # imm = 0x655AA0
leaq 0x1afcc9(%rip), %rsi    # 0x5ccaf2
movl $0x2f, %edx
callq 0x4b0120
movq $0x655aa0, %rdi         # imm = 0x655AA0
leaq 0x237818(%rip), %rsi    # 0x654659
callq 0x43f8ce
jmp 0x41ce4a
jmp 0x41ce4a
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x41ce64
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x442d20
movq %rbx, %rdi
callq 0x4f63f0