// File: /workspace/github_cpp_makefile_star2_O1/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 0x9237
movq 0x8(%rbx), %rax
cmpq 0x10(%rbx), %rax
je 0x93e7
movl %esi, (%rax)
addq $0x4, %rax
movq %rax, 0x8(%rbx)
jmp 0x93f7
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 0xa5ee
movl $0x0, (%rsp)
testl %r14d, %r14d
jle 0x9298
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 0xa68a
movl (%rsp), %eax
incl %eax
movl %eax, (%rsp)
cmpl %r14d, %eax
jl 0x9275
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %r15, %rdx
callq 0xa6b4
xorpd %xmm0, %xmm0
movq %rsp, %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq 0x28(%rsp), %rsi
callq 0x6a60
movq 0x30(%rsp), %r14
movq 0x38(%rsp), %rbp
cmpq %rbp, %r14
je 0x933a
movsd 0x4412(%rip), %xmm0     # 0xd6f0
leaq 0x20(%rsp), %r12
leaq 0x1c(%rsp), %r13
addsd (%r14), %xmm0
movl 0x8(%r14), %eax
movl %eax, 0x20(%rsp)
movsd %xmm0, 0x50(%rsp)
addsd 0x43f5(%rip), %xmm0     # 0xd6f8
cvttsd2si %xmm0, %r15d
movl %r15d, 0x1c(%rsp)
movq %rsp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xa8a8
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movsd 0x50(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addq $0x10, %r14
cmpq %rbp, %r14
jne 0x92e8
movq (%rsp), %r15
movq 0x8(%rsp), %r12
cmpq %r12, %r15
je 0x9375
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 0xaf33
movq %r15, %rdi
movq %r12, %rsi
callq 0xafe6
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0x58be
movq (%rsp), %r14
movq 0x8(%rsp), %r15
cmpq %r15, %r14
je 0x93c8
addq $0x4, %r14
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x93ad
movl (%r14), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x93b8
movq %rbx, %rdi
movq %r14, %rdx
callq 0x3e1c
leaq 0x8(%r14), %rax
addq $0x4, %r14
cmpq %r15, %r14
movq %rax, %r14
jne 0x9394
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x93d6
callq 0x2150
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x93f7
callq 0x2150
jmp 0x93f7
leaq 0x24(%rsp), %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3e1c
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x940e
jmp 0x9421
jmp 0x940e
jmp 0x940e
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x9424
callq 0x2150
jmp 0x9424
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x9433
callq 0x2150
movq %rbx, %rdi
callq 0x2220