// File: /workspace/github_cpp_makefile_star2_O3/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, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movq %rdi, 0x18(%rsp)
movq (%rsi), %rax
cmpq 0x8(%rsi), %rax
je 0x94a1
movq %rcx, %r14
movq %rsi, %r12
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
addq $0x3f, %rcx
movq %rcx, 0x20(%rsp)
movl 0x4(%rax), %ecx
movq %rcx, 0x8(%rsp)
movslq (%rax), %rbp
movq %r12, %rdi
callq 0x833a
leal 0x3f(%rbp), %eax
testq %rbp, %rbp
cmovnsl %ebp, %eax
sarl $0x6, %eax
cltq
shlq $0x3, %rax
movq 0x28(%rsp), %rcx
addq (%rcx), %rax
movq %rbp, %rcx
andq 0x20(%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 0x9469
leaq -0x8(,%rdx,8), %rdx
orq %rsi, %rcx
movq %rcx, (%rax,%rdx)
movq (%r14), %rax
movl (%rax,%rbp,4), %r9d
cmpl %r9d, 0x8(%rsp)
jne 0x947a
movq 0x18(%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 0x9469
movq 0x8(%rsp), %rax
leal 0x1(%rax), %r15d
movslq (%r13), %rax
movl %eax, 0x4(%rsp)
movq (%r14), %rcx
movl (%rcx,%rax,4), %esi
movq 0x30(%rsp), %rdx
movq (%rdx), %rdx
cmpl $-0x1, %esi
je 0x943a
cmpl %esi, %r15d
jl 0x943a
cmpl 0x8(%rsp), %esi
jle 0x9460
movl (%rdx,%rax,4), %esi
cmpl %esi, (%rdx,%rbp,4)
jge 0x9460
movl %r15d, (%rcx,%rax,4)
movl (%rdx,%rbp,4), %eax
movslq 0x4(%rsp), %rcx
movl %eax, (%rdx,%rcx,4)
movl %r15d, 0x14(%rsp)
movq %r12, %rdi
leaq 0x14(%rsp), %rsi
leaq 0x4(%rsp), %rdx
callq 0x8390
addq $0x4, %r13
cmpq %rbx, %r13
jne 0x940c
movq (%r12), %rax
cmpq 0x8(%r12), %rax
jne 0x9361
jmp 0x94a1
movq 0x7b4f(%rip), %rax      # 0x10fd0
movq (%rax), %rdi
leaq 0x31d7(%rip), %rsi      # 0xc662
movl %ebp, %edx
movq 0x8(%rsp), %rcx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x21b0
jmp 0x93e2
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq