// File: /workspace/github_cpp_makefile_star2_O3/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 %rcx, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
movq %rdi, 0x10(%rsp)
movl %r9d, 0xc(%rsp)
movq (%rsi), %rax
cmpq 0x8(%rsi), %rax
je 0x7c7f
movq %r8, %r14
movq %rsi, %r12
movabsq $-0x8000000000000000, %r15 # imm = 0x8000000000000000
leaq 0x3f(%r15), %rcx
movq %rcx, 0x50(%rsp)
leaq 0x8(%rsp), %r13
movq %r8, 0x48(%rsp)
movl 0x4(%rax), %ebx
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
addq (%r14), %rax
movq %rbp, %rcx
andq 0x50(%rsp), %rcx
xorl %edx, %edx
cmpq %r15, %rcx
setbe %dl
movl $0x1, %esi
movl %ebp, %ecx
shlq %cl, %rsi
movq -0x8(%rax,%rdx,8), %rcx
btq %rbp, %rcx
jb 0x7c4a
leaq -0x8(,%rdx,8), %rdx
orq %rsi, %rcx
movq %rcx, (%rax,%rdx)
movq 0x40(%rsp), %rax
movq (%rax), %rax
movl (%rax,%rbp,4), %r9d
cmpl %r9d, %ebx
jne 0x7c5b
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
leaq (,%rbp,8), %rax
leaq (%rax,%rax,2), %rax
movq 0x10(%rsp), %rdx
movq 0x48(%rdx), %rcx
movq 0x60(%rdx), %rdx
movq 0x8(%rcx,%rax), %rdi
subq (%rcx,%rax), %rdi
sarq $0x2, %rdi
movq 0x8(%rdx,%rax), %rsi
subq (%rdx,%rax), %rsi
sarq $0x2, %rsi
addq %rdi, %rsi
leaq 0x20(%rsp), %rdi
callq 0x6980
cmpl $-0x1, 0xc(%rsp)
je 0x7b62
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
leaq (,%rbp,2), %rcx
addq %rbp, %rcx
movq (%rax,%rcx,8), %r14
movq 0x8(%rax,%rcx,8), %r15
cmpq %r15, %r14
je 0x7b62
movl (%r14), %eax
movl %eax, 0x8(%rsp)
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
leaq 0xc(%rsp), %rdx
callq 0x6740
addq $0x4, %r14
jmp 0x7b3e
cmpl $-0x1, 0x90(%rsp)
je 0x7bb0
movq 0x10(%rsp), %rax
movq 0x60(%rax), %rax
leaq (,%rbp,2), %rcx
addq %rbp, %rcx
movq (%rax,%rcx,8), %r14
movq 0x8(%rax,%rcx,8), %r15
cmpq %r15, %r14
je 0x7bb0
movl (%r14), %eax
movl %eax, 0x8(%rsp)
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
leaq 0x90(%rsp), %rdx
callq 0x6740
addq $0x4, %r14
jmp 0x7b89
movq 0x20(%rsp), %r15
movq 0x28(%rsp), %r14
cmpq %r14, %r15
je 0x7c2e
movslq (%r15), %rcx
movl %ecx, 0x8(%rsp)
movl 0x4(%r15), %eax
movq 0x40(%rsp), %rdx
movq (%rdx), %rdx
movl (%rdx,%rcx,4), %edi
cmpl $-0x1, %edi
je 0x7bf4
addl %ebx, %eax
movq 0x38(%rsp), %rsi
movq (%rsi), %rsi
cmpl %edi, %eax
jl 0x7bfe
jg 0x7c20
movl (%rsi,%rcx,4), %edi
cmpl %edi, (%rsi,%rbp,4)
jl 0x7bfe
jmp 0x7c20
movq 0x38(%rsp), %rsi
movq (%rsi), %rsi
addl %ebx, %eax
movl %eax, (%rdx,%rcx,4)
movl (%rsi,%rbp,4), %ecx
movslq 0x8(%rsp), %rdx
movl %ecx, (%rsi,%rdx,4)
movl %eax, 0x1c(%rsp)
movq %r12, %rdi
leaq 0x1c(%rsp), %rsi
movq %r13, %rdx
callq 0x8390
addq $0x8, %r15
cmpq %r14, %r15
jne 0x7bbf
movq 0x20(%rsp), %r15
testq %r15, %r15
je 0x7c3b
movq %r15, %rdi
callq 0x2150
movq 0x48(%rsp), %r14
movabsq $-0x8000000000000000, %r15 # imm = 0x8000000000000000
movq (%r12), %rax
cmpq 0x8(%r12), %rax
jne 0x7a59
jmp 0x7c7f
movq 0x936e(%rip), %rax      # 0x10fd0
movq (%rax), %rdi
leaq 0x49f6(%rip), %rsi      # 0xc662
movl %ebp, %edx
movl %ebx, %ecx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x21b0
jmp 0x7ac9
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7c94
jmp 0x7c94
jmp 0x7c94
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x7ca6
callq 0x2150
movq %rbx, %rdi
callq 0x2220