// File: /workspace/github_cpp_makefile_star2_O2/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, -0x70(%rbp)
movq %rdx, -0x80(%rbp)
movq 0x8(%rdi), %rax
movq %rdi, -0x78(%rbp)
subq (%rdi), %rax
movq %rsi, %r15
pushq $0x18
popq %rcx
cqto
idivq %rcx
movq %rax, %rbx
leaq -0x60(%rbp), %r14
movb $0x0, (%r14)
leaq -0xc0(%rbp), %rdi
leaq -0x98(%rbp), %rcx
movq %rax, %rsi
movq %r14, %rdx
callq 0x60c4
movabsq $0x7fefffffffffffff, %rax # imm = 0x7FEFFFFFFFFFFFFF
movq %rax, (%r14)
leaq -0x98(%rbp), %rdi
leaq -0x60(%rbp), %rdx
leaq -0x40(%rbp), %rcx
movq %rbx, %rsi
callq 0x6124
xorpd %xmm0, %xmm0
leaq -0x60(%rbp), %rdi
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movq -0x98(%rbp), %rax
andq $0x0, (%rax,%r15,8)
leaq -0x40(%rbp), %rsi
movq %r15, -0x68(%rbp)
movq %r15, (%rsi)
andq $0x0, 0x8(%rsi)
callq 0x6184
leaq -0x60(%rbp), %r13
leaq -0xc0(%rbp), %rbx
leaq -0x40(%rbp), %r12
movq -0x60(%rbp), %rax
cmpq -0x58(%rbp), %rax
je 0x484a
movq (%rax), %r14
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %r13, %rdi
callq 0x61a4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x61c6
testq %rdx, (%rax)
jne 0x477f
movq %rbx, %rdi
movq %r14, %rsi
callq 0x61c6
orq %rdx, (%rax)
movq -0x80(%rbp), %rax
movq (%rax), %rax
movsd (%rax,%r14,8), %xmm0
ucomisd -0x30(%rbp), %xmm0
jbe 0x47ee
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax,%r14,8)
movq -0x70(%rbp), %rax
movq (%rax), %rax
movq -0x68(%rbp), %rcx
movq %rcx, (%rax,%r14,8)
movq -0x78(%rbp), %rax
movq (%rax), %rax
imulq $0x18, %r14, %rcx
movq (%rax,%rcx), %r14
movq 0x8(%rax,%rcx), %r15
cmpq %r15, %r14
je 0x477f
movq (%r14), %rax
movsd 0x8(%r14), %xmm0
addsd -0x30(%rbp), %xmm0
movq -0x98(%rbp), %rcx
movsd (%rcx,%rax,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x4844
movsd %xmm0, (%rcx,%rax,8)
movq %rax, -0x40(%rbp)
movsd %xmm0, -0x38(%rbp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x6184
addq $0x10, %r14
jmp 0x4802
leaq -0x60(%rbp), %rdi
callq 0x6750
leaq -0x98(%rbp), %rdi
callq 0x89de
leaq -0xc0(%rbp), %rdi
callq 0x61e8
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x488a
movq %rax, %rbx
jmp 0x48a2
jmp 0x488a
jmp 0x488a
jmp 0x488a
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x6750
leaq -0x98(%rbp), %rdi
callq 0x89de
leaq -0xc0(%rbp), %rdi
callq 0x61e8
movq %rbx, %rdi
callq 0x2210