// File: 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:
subq $0xc8, %rsp
movq %rdi, 0xc0(%rsp)
movq %rsi, 0xb8(%rsp)
movq %rdx, 0xb0(%rsp)
movq %rcx, 0xa8(%rsp)
movq %r8, 0xa0(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x135a0
xorb $-0x1, %al
testb $0x1, %al
jne 0x183b7
jmp 0x1868c
movq 0xb8(%rsp), %rdi
callq 0x135c0
movq %rax, 0x28(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rsi
leaq 0x9c(%rsp), %rdx
callq 0x135d0
movq 0x28(%rsp), %rsi
leaq 0x88(%rsp), %rdi
callq 0x13610
movq 0xb8(%rsp), %rdi
callq 0x13650
movq 0xa0(%rsp), %rdi
movslq 0x9c(%rsp), %rsi
callq 0x136a0
movq %rax, 0x78(%rsp)
movq %rdx, 0x80(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x13700
testb $0x1, %al
jne 0x18437
jmp 0x1843c
jmp 0x1839f
movq 0xa0(%rsp), %rdi
movslq 0x9c(%rsp), %rsi
callq 0x136a0
movq %rax, 0x68(%rsp)
movq %rdx, 0x70(%rsp)
leaq 0x68(%rsp), %rdi
movl $0x1, %esi
callq 0x13730
movl 0x98(%rsp), %eax
movl %eax, 0x24(%rsp)
movq 0xa8(%rsp), %rdi
movslq 0x9c(%rsp), %rsi
callq 0x4860
movq %rax, %rcx
movl 0x24(%rsp), %eax
cmpl (%rcx), %eax
je 0x184fd
movq 0x14b2c(%rip), %rax     # 0x2cfc8
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movl 0x9c(%rsp), %eax
movl %eax, 0x18(%rsp)
movl 0x98(%rsp), %eax
movl %eax, 0x1c(%rsp)
movl 0x9c(%rsp), %eax
movl %eax, 0x20(%rsp)
movq 0xa8(%rsp), %rdi
movslq 0x9c(%rsp), %rsi
callq 0x4860
movq 0x10(%rsp), %rdi
movl 0x18(%rsp), %edx
movl 0x1c(%rsp), %ecx
movl 0x20(%rsp), %r8d
movl (%rax), %r9d
leaq 0x9114(%rip), %rsi      # 0x2160a
movb $0x0, %al
callq 0x2180
movq 0xc0(%rsp), %rdi
movslq 0x9c(%rsp), %rsi
callq 0x4a60
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdi
callq 0x4880
movq %rax, 0x58(%rsp)
movq 0x60(%rsp), %rdi
callq 0x48b0
movq %rax, 0x50(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x48e0
testb $0x1, %al
jne 0x1854d
jmp 0x18687
leaq 0x58(%rsp), %rdi
callq 0x4920
movl (%rax), %eax
movl %eax, 0x4c(%rsp)
movq 0xa8(%rsp), %rdi
movslq 0x4c(%rsp), %rsi
callq 0x4860
movl (%rax), %eax
movl %eax, 0x48(%rsp)
movb $0x1, %al
cmpl $-0x1, 0x48(%rsp)
movb %al, 0xf(%rsp)
je 0x185ee
movl 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
movq 0xb0(%rsp), %rdi
movslq 0x9c(%rsp), %rsi
callq 0x4860
movq %rax, %rdx
leaq 0x40(%rsp), %rdi
leaq 0x3c(%rsp), %rsi
callq 0xe870
movq 0xb0(%rsp), %rdi
movslq 0x4c(%rsp), %rsi
callq 0x4860
movq %rax, %rdx
leaq 0x34(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x4ab0
leaq 0x40(%rsp), %rdi
leaq 0x34(%rsp), %rsi
callq 0x13780
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x185f8
jmp 0x18676
movl 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
movq 0xa8(%rsp), %rdi
movslq 0x4c(%rsp), %rsi
callq 0x4860
movl 0x4(%rsp), %ecx
movl %ecx, (%rax)
movq 0xb0(%rsp), %rdi
movslq 0x9c(%rsp), %rsi
callq 0x4860
movl (%rax), %eax
movl %eax, 0x8(%rsp)
movq 0xb0(%rsp), %rdi
movslq 0x4c(%rsp), %rsi
callq 0x4860
movl 0x8(%rsp), %ecx
movl %ecx, (%rax)
movq 0xb8(%rsp), %rdi
movl 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
leaq 0x30(%rsp), %rsi
leaq 0x4c(%rsp), %rdx
callq 0x137e0
jmp 0x18678
leaq 0x58(%rsp), %rdi
callq 0x4930
jmp 0x18535
jmp 0x1839f
addq $0xc8, %rsp
retq
nopw %cs:(%rax,%rax)