// File: /workspace/github_cpp_makefile_star2_O3/ekg[P]sgd2/src/sgd2.hpp
// Function: sgd2::maxmin_bfs_weighted(std::vector<std::vector<sgd2::edge, std::allocator<sgd2::edge>>, std::allocator<std::vector<sgd2::edge, std::allocator<sgd2::edge>>>> const&, unsigned long, std::vector<double, std::allocator<double>>&, std::vector<unsigned long, std::allocator<unsigned long>>&)
void maxmin_bfs_weighted(const std::vector<std::vector<edge>>& graph, const uint64_t p, std::vector<double>& mins, std::vector<uint64_t>& argmins)
{
    uint64_t n = graph.size();
    std::vector<bool> visited(n, false);
    std::vector<double> d(n, std::numeric_limits<double>::max()); // init 'tentative' distances to infinity

    // I am not using a fibonacci heap. I AM NOT USING A FIBONACCI HEAP
    // edges are used 'invisibly' here
    std::priority_queue<edge, std::vector<edge>, edge_comp> pq;

    d[p] = 0;
    pq.push(edge(p,0));

    while (!pq.empty())
    {
        uint64_t current = pq.top().target;
        double d_pi = pq.top().weight;
        pq.pop();
        
        if (!visited[current]) // ignore redundant elements in queue
        {
            visited[current] = true;

            if (d_pi < mins[current])
            {
                mins[current] = d_pi;
                argmins[current] = p;
            }
            for (edge e : graph[current])
            {
                // here the edge is not 'invisible'
                uint64_t next = e.target;
                double weight = e.weight;

                if (d_pi + weight < d[next]) // update tentative value of d 
                {
                    d[next] = d_pi + weight;
                    pq.push(edge(next, d[next]));
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rcx, -0x88(%rbp)
movq %rdx, -0x98(%rbp)
movq %rsi, %r14
movq 0x8(%rdi), %rax
movq %rdi, -0x90(%rbp)
subq (%rdi), %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rbx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rbx
leaq -0x50(%rbp), %r15
movb $0x0, (%r15)
leaq -0xc0(%rbp), %rdi
leaq -0x68(%rbp), %rcx
movq %rbx, %rsi
movq %r15, %rdx
callq 0x7766
movabsq $0x7fefffffffffffff, %rax # imm = 0x7FEFFFFFFFFFFFFF
movq %rax, (%r15)
leaq -0x68(%rbp), %rdi
leaq -0x50(%rbp), %rdx
leaq -0x78(%rbp), %rcx
movq %rbx, %rsi
callq 0x77cc
xorl %eax, %eax
leaq -0x50(%rbp), %rdi
movq %rax, 0x10(%rdi)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movq -0x68(%rbp), %rcx
movq %rax, (%rcx,%r14,8)
leaq -0x78(%rbp), %rsi
movq %r14, (%rsi)
movq %rax, 0x8(%rsi)
callq 0x7858
movq -0x50(%rbp), %rdi
cmpq -0x48(%rbp), %rdi
je 0x56c2
movq %r14, -0x80(%rbp)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
leaq -0x50(%rbp), %r13
leaq 0x3f(%rax), %r12
leaq -0x78(%rbp), %rbx
movq (%rdi), %r15
movsd 0x8(%rdi), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %r13, %rdi
callq 0x78f8
leaq 0x3f(%r15), %rax
testq %r15, %r15
cmovnsq %r15, %rax
sarq $0x6, %rax
shlq $0x3, %rax
addq -0xc0(%rbp), %rax
movq %r15, %rcx
andq %r12, %rcx
xorl %edx, %edx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
cmpq %rsi, %rcx
setbe %dl
movl $0x1, %esi
movl %r15d, %ecx
shlq %cl, %rsi
movq -0x8(%rax,%rdx,8), %rcx
btq %r15, %rcx
jae 0x5627
movq -0x50(%rbp), %rdi
cmpq -0x48(%rbp), %rdi
jne 0x55bb
jmp 0x56c2
leaq -0x8(,%rdx,8), %rdx
orq %rsi, %rcx
movq %rcx, (%rax,%rdx)
movq -0x98(%rbp), %rax
movq (%rax), %rax
movsd (%rax,%r15,8), %xmm0
ucomisd -0x30(%rbp), %xmm0
jbe 0x566a
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax,%r15,8)
movq -0x88(%rbp), %rax
movq (%rax), %rax
movq -0x80(%rbp), %rcx
movq %rcx, (%rax,%r15,8)
movq -0x90(%rbp), %rax
movq (%rax), %rax
leaq (%r15,%r15,2), %rcx
movq (%rax,%rcx,8), %r15
movq 0x8(%rax,%rcx,8), %r14
cmpq %r14, %r15
je 0x5618
movq (%r15), %rax
movsd 0x8(%r15), %xmm0
addsd -0x30(%rbp), %xmm0
movq -0x68(%rbp), %rcx
movsd (%rcx,%rax,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x56bc
movsd %xmm0, (%rcx,%rax,8)
movq %rax, -0x78(%rbp)
movsd %xmm0, -0x70(%rbp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x7858
addq $0x10, %r15
jmp 0x5681
testq %rdi, %rdi
je 0x56d3
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x56e8
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x5703
movq -0xa0(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x571e
movq %rax, %rbx
jmp 0x574b
jmp 0x571e
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x5736
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x574b
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x5766
movq -0xa0(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
movq %rbx, %rdi
callq 0x2230