// File: /workspace/github_cpp_makefile_star2_O2/sharmaeklavya2[P]ddos-on-anycast/src/lib/attack.cpp
// Function: dijkstra(Network const&, std::priority_queue<std::tuple<int, int>, std::vector<std::tuple<int, int>, std::allocator<std::tuple<int, int>>>, std::greater<std::tuple<int, int>>>&, std::vector<int, std::allocator<int>>&, std::vector<int, std::allocator<int>>&, std::vector<bool, std::allocator<bool>>&, int, int)
void dijkstra(const Network& network, PQ& pq, ivec& target, ivec& target_dist, vector<bool>& visited, int in_weight, int side_weight) {

    while(!pq.empty()) {
        int u, du;
        std::tie(du, u) = pq.top();
        pq.pop();
        if(visited[u]) {
            continue;
        }
        visited[u] = true;
        if(du != target_dist[u]) {
            fprintf(stderr, "u=%d, du=%d, target_dist[%d]=%d\n", u, du, u, target_dist[u]);
        }
        ipvec l;
        l.reserve(network.in_nbrs[u].size() + network.side_nbrs[u].size());
        if(in_weight != -1) {
            for(int v: network.in_nbrs[u]) {
                l.emplace_back(v, in_weight);
            }
        }
        if(side_weight != -1) {
            for(int v: network.side_nbrs[u]) {
                l.emplace_back(v, side_weight);
            }
        }
        for(const iipair& p: l) {
            int v = p.first, w = p.second;
            int dv = target_dist[v];
            if(dv == -1 || iipair(du+w, target[u]) < iipair(dv, target[v])) {
                target_dist[v] = du+w;
                target[v] = target[u];
                pq.emplace(du+w, v);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, %r14
movq %rcx, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movq %rsi, %r12
movq %rdi, 0x10(%rsp)
leaq 0xc(%rsp), %rax
movl %r9d, (%rax)
leaq 0x8(%rsp), %rbp
movq %r8, 0x50(%rsp)
movq (%r12), %rax
cmpq 0x8(%r12), %rax
je 0x6bca
movl 0x4(%rax), %ebx
movslq (%rax), %r13
movq %r12, %rdi
callq 0x71a2
movq %r14, %rdi
movq %r13, %rsi
callq 0x71ba
testq %rdx, (%rax)
jne 0x69f4
movq %r14, %rdi
movq %r13, %rsi
callq 0x71ba
orq %rdx, (%rax)
movq 0x48(%rsp), %rax
movq (%rax), %rax
movl (%rax,%r13,4), %r9d
cmpl %r9d, %ebx
jne 0x6ba5
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
imulq $0x18, %r13, %rdi
movq 0x10(%rsp), %rcx
movq 0x48(%rcx), %rax
movq 0x60(%rcx), %rcx
movq 0x8(%rax,%rdi), %rdx
subq (%rax,%rdi), %rdx
sarq $0x2, %rdx
movq 0x8(%rcx,%rdi), %rsi
movq %rdi, 0x38(%rsp)
subq (%rcx,%rdi), %rsi
sarq $0x2, %rsi
addq %rdx, %rsi
leaq 0x20(%rsp), %rdi
callq 0x589a
cmpl $-0x1, 0xc(%rsp)
je 0x6ad1
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x38(%rsp), %rcx
movq (%rax,%rcx), %r15
movq 0x8(%rax,%rcx), %r14
cmpq %r14, %r15
je 0x6ad1
movl (%r15), %eax
movl %eax, 0x8(%rsp)
leaq 0x20(%rsp), %rdi
movq %rbp, %rsi
leaq 0xc(%rsp), %rdx
callq 0x572e
addq $0x4, %r15
jmp 0x6aad
cmpl $-0x1, 0x90(%rsp)
je 0x6b19
movq 0x10(%rsp), %rax
movq 0x60(%rax), %rax
movq 0x38(%rsp), %rcx
movq (%rax,%rcx), %r15
movq 0x8(%rax,%rcx), %r14
cmpq %r14, %r15
je 0x6b19
movl (%r15), %eax
movl %eax, 0x8(%rsp)
leaq 0x20(%rsp), %rdi
movq %rbp, %rsi
leaq 0x90(%rsp), %rdx
callq 0x572e
addq $0x4, %r15
jmp 0x6af2
movq 0x20(%rsp), %r15
movq 0x28(%rsp), %r14
cmpq %r14, %r15
je 0x6b91
movslq (%r15), %rcx
movl %ecx, 0x8(%rsp)
movl 0x4(%r15), %eax
movq 0x48(%rsp), %rdx
movq (%rdx), %rdx
movl (%rdx,%rcx,4), %edi
cmpl $-0x1, %edi
je 0x6b5e
addl %ebx, %eax
movq 0x40(%rsp), %rsi
movq (%rsi), %rsi
cmpl %edi, %eax
jl 0x6b68
jg 0x6b8b
movl (%rsi,%rcx,4), %edi
cmpl %edi, (%rsi,%r13,4)
jl 0x6b68
jmp 0x6b8b
movq 0x40(%rsp), %rsi
movq (%rsi), %rsi
addl %ebx, %eax
movl %eax, (%rdx,%rcx,4)
movl (%rsi,%r13,4), %ecx
movslq 0x8(%rsp), %rdx
movl %ecx, (%rsi,%rdx,4)
movl %eax, 0x1c(%rsp)
movq %r12, %rdi
leaq 0x1c(%rsp), %rsi
movq %rbp, %rdx
callq 0x71f0
addq $0x8, %r15
jmp 0x6b23
leaq 0x20(%rsp), %rdi
callq 0x366e
movq 0x50(%rsp), %r14
jmp 0x69f4
movq 0xa424(%rip), %rax      # 0x10fd0
movq (%rax), %rdi
leaq 0x4a7c(%rip), %rsi      # 0xb632
movl %r13d, %edx
movl %ebx, %ecx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x2180
jmp 0x6a44
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6bdf
jmp 0x6bdf
jmp 0x6bdf
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x366e
movq %rbx, %rdi
callq 0x21f0