// File: 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:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0x100(%rsp)
movl %esi, 0xfc(%rsp)
movq %rdx, 0xf0(%rsp)
movq %rcx, 0xe8(%rsp)
movq 0x100(%rsp), %rdi
callq 0x11850
movl %eax, 0xe4(%rsp)
cmpl $0x1, 0xe4(%rsp)
jne 0x1801e
movq 0xf0(%rsp), %rdi
leaq 0xfc(%rsp), %rsi
callq 0x46f0
jmp 0x18347
leaq 0xc8(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x1a380
movq 0x20(%rsp), %rdi
movslq 0xe4(%rsp), %rsi
callq 0x1a390
jmp 0x18044
movl $0x0, 0xb8(%rsp)
movl 0xb8(%rsp), %eax
cmpl 0xe4(%rsp), %eax
jge 0x180bc
movq 0x100(%rsp), %rdi
movslq 0xb8(%rsp), %rsi
callq 0xcfb0
movq %rax, %rsi
leaq 0xc8(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
callq 0x1a4a0
jmp 0x1808e
jmp 0x18090
movl 0xb8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb8(%rsp)
jmp 0x1804f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc0(%rsp)
movl %eax, 0xbc(%rsp)
jmp 0x1834f
leaq 0xc8(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x1a810
movq 0x18(%rsp), %rdi
movq %rax, 0xb0(%rsp)
callq 0x1a840
movq %rax, 0xa8(%rsp)
movq 0xe8(%rsp), %rdx
movq 0xb0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
callq 0x1a520
jmp 0x18107
leaq 0x90(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x4a50
movq 0x10(%rsp), %rdi
movslq 0xe4(%rsp), %rsi
callq 0xd2d0
jmp 0x1812d
movsd 0x954b(%rip), %xmm0     # 0x21680
movsd %xmm0, 0x88(%rsp)
leaq 0xc8(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rdi
callq 0x1a810
movq %rax, 0x78(%rsp)
movq 0x80(%rsp), %rdi
callq 0x1a840
movq %rax, 0x70(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x1a870
testb $0x1, %al
jne 0x1818a
jmp 0x1826a
leaq 0x78(%rsp), %rdi
callq 0x1a8b0
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0x68(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x5c(%rsp)
movsd 0x60(%rsp), %xmm1
movsd 0x88(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x88(%rsp)
movsd 0x88(%rsp), %xmm0
movsd 0x94a7(%rip), %xmm1     # 0x21688
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x58(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x5c(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x1a8c0
jmp 0x18206
movsd 0x947a(%rip), %xmm0     # 0x21688
addsd 0x88(%rsp), %xmm0
cvttsd2si %xmm0, %eax
cvtsi2sd %eax, %xmm1
movsd 0x88(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x88(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x1a940
jmp 0x18172
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc0(%rsp)
movl %eax, 0xbc(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x4ae0
jmp 0x1834f
leaq 0x90(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x7280
movq 0x8(%rsp), %rdi
movq %rax, 0x50(%rsp)
callq 0x7100
movq %rax, 0x48(%rsp)
movq 0x50(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x1a960
jmp 0x182a1
movq 0xf0(%rsp), %rdi
movslq 0xe4(%rsp), %rsi
callq 0xa200
jmp 0x182b8
leaq 0x90(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rdi
callq 0x7280
movq %rax, 0x38(%rsp)
movq 0x40(%rsp), %rdi
callq 0x7100
movq %rax, 0x30(%rsp)
leaq 0x38(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x9f70
testb $0x1, %al
jne 0x182f8
jmp 0x1832d
leaq 0x38(%rsp), %rdi
callq 0x9fb0
movq %rax, 0x28(%rsp)
movq 0xf0(%rsp), %rdi
movq 0x28(%rsp), %rsi
addq $0x4, %rsi
callq 0x46f0
jmp 0x1831f
jmp 0x18321
leaq 0x38(%rsp), %rdi
callq 0x9fc0
jmp 0x182e3
leaq 0x90(%rsp), %rdi
callq 0x4ae0
leaq 0xc8(%rsp), %rdi
callq 0x1a9a0
addq $0x108, %rsp            # imm = 0x108
retq
leaq 0xc8(%rsp), %rdi
callq 0x1a9a0
movq 0xc0(%rsp), %rdi
callq 0x21f0
nopl (%rax)