// File: /workspace/github_cpp_makefile_star2_O1/sharmaeklavya2[P]ddos-on-anycast/src/lib/place_victims.cpp
// Function: dijkstra(std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>> 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>>&)
void dijkstra(const vector<ivec>& adj, PQ& pq, ivec& target, ivec& target_dist, vector<bool>& visited) {
    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]);
        }
        for(int v: adj[u]) {
            int dv = target_dist[v];
            if(dv == -1 || iipair(du+1, target[u]) < iipair(dv, target[v])) {
                target_dist[v] = du+1;
                target[v] = target[u];
                pq.emplace(du+1, v);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, 0x30(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdi, 0x20(%rsp)
movq (%rsi), %rax
cmpq 0x8(%rsi), %rax
je 0x95c7
movq %rdx, %r15
movq %rsi, %r12
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
addq $0x3f, %rcx
movq %rcx, 0x28(%rsp)
movl 0x4(%rax), %ecx
movq %rcx, 0x8(%rsp)
movslq (%rax), %rbp
movq %r12, %rdi
callq 0x845e
leaq 0x3f(%rbp), %rax
testq %rbp, %rbp
cmovnsq %rbp, %rax
sarq $0x6, %rax
shlq $0x3, %rax
movq 0x30(%rsp), %rcx
addq (%rcx), %rax
movq %rbp, %rcx
andq 0x28(%rsp), %rcx
xorl %edx, %edx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
cmpq %rsi, %rcx
setbe %dl
movl $0x1, %esi
movl %ebp, %ecx
shlq %cl, %rsi
movq -0x8(%rax,%rdx,8), %rcx
btq %rbp, %rcx
jb 0x958f
leaq -0x8(,%rdx,8), %rdx
orq %rsi, %rcx
movq %rcx, (%rax,%rdx)
movq 0x18(%rsp), %rax
movq (%rax), %rax
movl (%rax,%rbp,4), %r9d
cmpl %r9d, 0x8(%rsp)
jne 0x95a0
movq 0x20(%rsp), %rax
movq (%rax), %rax
leaq (,%rbp,2), %rcx
addq %rbp, %rcx
movq (%rax,%rcx,8), %r13
movq 0x8(%rax,%rcx,8), %rbx
cmpq %rbx, %r13
je 0x958f
movq 0x8(%rsp), %rax
leal 0x1(%rax), %r14d
movslq (%r13), %rax
movl %eax, 0x4(%rsp)
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
movl (%rcx,%rax,4), %edx
cmpl $-0x1, %edx
je 0x955d
cmpl %edx, %r14d
jl 0x955d
cmpl 0x8(%rsp), %edx
jle 0x9586
movq (%r15), %rdx
movl (%rdx,%rax,4), %esi
cmpl %esi, (%rdx,%rbp,4)
jge 0x9586
movl %r14d, (%rcx,%rax,4)
movq (%r15), %rax
movl (%rax,%rbp,4), %ecx
movslq 0x4(%rsp), %rdx
movl %ecx, (%rax,%rdx,4)
movl %r14d, 0x14(%rsp)
movq %r12, %rdi
leaq 0x14(%rsp), %rsi
leaq 0x4(%rsp), %rdx
callq 0x84ae
addq $0x4, %r13
cmpq %rbx, %r13
jne 0x952f
movq (%r12), %rax
cmpq 0x8(%r12), %rax
jne 0x947e
jmp 0x95c7
movq 0x8a29(%rip), %rax      # 0x11fd0
movq (%rax), %rdi
leaq 0x40b1(%rip), %rsi      # 0xd662
movl %ebp, %edx
movq 0x8(%rsp), %rcx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x21b0
jmp 0x9505
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq