// File: /workspace/github_cpp_makefile_star2_O3/sharmaeklavya2[P]ddos-on-anycast/src/lib/place_victims.cpp
// Function: distribute(std::vector<double, std::allocator<double>>&, int, std::vector<int, std::allocator<int>>&, std::linear_congruential_engine<unsigned long, 48271ul, 0ul, 2147483647ul>&)
void distribute(vector<double>& weights, int x, ivec& xvec, rng_t& rng) {
    int n = weights.size();
    if(n == 1) {
        xvec.push_back(x);
        return;
    }

    typedef pair<double, int> dipair;
    vector<dipair> wvec;
    wvec.reserve(n);
    for(int i=0; i<n; ++i) {
        wvec.emplace_back(weights[i], i);
    }
    std::shuffle(wvec.begin(), wvec.end(), rng);

    vector<iipair> xvec2;
    xvec2.reserve(n);
    double acc = 0.000001;
    for(const dipair& p: wvec) {
        double w = p.first;
        int i = p.second;
        acc += w;
        xvec2.emplace_back(i, int(acc+0.4));
        acc -= int(acc+0.4);
    }
    std::sort(xvec2.begin(), xvec2.end());
    xvec.reserve(n);
    for(const iipair& p: xvec2) {
        xvec.push_back(p.second);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %rbx
movl %esi, 0x24(%rsp)
movq 0x8(%rdi), %r14
subq (%rdi), %r14
shrq $0x3, %r14
cmpl $0x1, %r14d
jne 0x9117
movq 0x8(%rbx), %rax
cmpq 0x10(%rbx), %rax
je 0x92ca
movl %esi, (%rax)
addq $0x4, %rax
movq %rax, 0x8(%rbx)
jmp 0x92da
movq %rcx, %r15
movq %rdi, %r12
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movslq %r14d, %rsi
movq %rsi, 0x28(%rsp)
callq 0xa428
movl $0x0, (%rsp)
testl %r14d, %r14d
jle 0x9178
xorl %eax, %eax
leaq 0x30(%rsp), %r13
movq %rsp, %rbp
movslq %eax, %rsi
shlq $0x3, %rsi
addq (%r12), %rsi
movq %r13, %rdi
movq %rbp, %rdx
callq 0xa4c4
movl (%rsp), %eax
incl %eax
movl %eax, (%rsp)
cmpl %r14d, %eax
jl 0x9155
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %r15, %rdx
callq 0xa4ee
xorpd %xmm0, %xmm0
movq %rsp, %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq 0x28(%rsp), %rsi
callq 0x6980
movq 0x30(%rsp), %r14
movq 0x38(%rsp), %rbp
cmpq %rbp, %r14
je 0x921a
movsd 0x3532(%rip), %xmm0     # 0xc6f0
leaq 0x20(%rsp), %r12
leaq 0x1c(%rsp), %r13
addsd (%r14), %xmm0
movl 0x8(%r14), %eax
movl %eax, 0x20(%rsp)
movsd %xmm0, 0x50(%rsp)
addsd 0x3515(%rip), %xmm0     # 0xc6f8
cvttsd2si %xmm0, %r15d
movl %r15d, 0x1c(%rsp)
movq %rsp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xa6e2
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movsd 0x50(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addq $0x10, %r14
cmpq %rbp, %r14
jne 0x91c8
movq (%rsp), %r15
movq 0x8(%rsp), %r12
cmpq %r12, %r15
je 0x9255
movq %r12, %rax
subq %r15, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0xad67
movq %r15, %rdi
movq %r12, %rsi
callq 0xae1a
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0x57a4
movq (%rsp), %r14
movq 0x8(%rsp), %r15
cmpq %r15, %r14
je 0x92ac
addq $0x4, %r14
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x928d
movl (%r14), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x9298
movq %rbx, %rdi
movq %r14, %rdx
callq 0x3d28
leaq 0x8(%r14), %rax
addq $0x4, %r14
cmpq %r15, %r14
movq %rax, %r14
jne 0x9274
movq (%rsp), %r14
testq %r14, %r14
je 0x92b9
movq %r14, %rdi
callq 0x2150
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x92da
callq 0x2150
jmp 0x92da
leaq 0x24(%rsp), %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3d28
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x92f1
jmp 0x9304
jmp 0x92f1
jmp 0x92f1
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x9307
callq 0x2150
jmp 0x9307
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x9316
callq 0x2150
movq %rbx, %rdi
callq 0x2220