// File: /workspace/github_cpp_makefile_star2_O1/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 $0xa8, %rsp
movq %rcx, -0xb8(%rbp)
movq %rdx, -0xc8(%rbp)
movq %rsi, %r14
movq 0x8(%rdi), %rax
movq %rdi, -0xc0(%rbp)
subq (%rdi), %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rbx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rbx
leaq -0x80(%rbp), %r15
movb $0x0, (%r15)
leaq -0x58(%rbp), %rdi
leaq -0x98(%rbp), %rcx
movq %rbx, %rsi
movq %r15, %rdx
callq 0x7e9e
movabsq $0x7fefffffffffffff, %rax # imm = 0x7FEFFFFFFFFFFFFF
movq %rax, (%r15)
leaq -0x98(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq -0xa8(%rbp), %rcx
movq %rbx, %rsi
callq 0x7f04
xorl %eax, %eax
leaq -0x80(%rbp), %rdi
movq %rax, 0x10(%rdi)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movq -0x98(%rbp), %rcx
movq %rax, (%rcx,%r14,8)
leaq -0xa8(%rbp), %rsi
movq %r14, (%rsi)
movq %rax, 0x8(%rsi)
callq 0x7f90
movq -0x80(%rbp), %rdi
cmpq -0x78(%rbp), %rdi
je 0x5af7
movq %r14, -0xb0(%rbp)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
leaq -0x80(%rbp), %r13
leaq 0x3f(%rax), %r12
leaq -0xa8(%rbp), %rbx
movq (%rdi), %r15
movsd 0x8(%rdi), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %r13, %rdi
callq 0x8036
leaq 0x3f(%r15), %rax
testq %r15, %r15
cmovnsq %r15, %rax
sarq $0x6, %rax
shlq $0x3, %rax
addq -0x58(%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 0x5a4b
movq -0x80(%rbp), %rdi
cmpq -0x78(%rbp), %rdi
jne 0x59e2
jmp 0x5af7
leaq -0x8(,%rdx,8), %rdx
orq %rsi, %rcx
movq %rcx, (%rax,%rdx)
movq -0xc8(%rbp), %rax
movq (%rax), %rax
movsd (%rax,%r15,8), %xmm0
ucomisd -0x30(%rbp), %xmm0
jbe 0x5a91
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax,%r15,8)
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movq -0xb0(%rbp), %rcx
movq %rcx, (%rax,%r15,8)
movq -0xc0(%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 0x5a3c
movq (%r15), %rax
movsd 0x8(%r15), %xmm0
addsd -0x30(%rbp), %xmm0
movq -0x98(%rbp), %rcx
movsd (%rcx,%rax,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x5af1
movsd %xmm0, (%rcx,%rax,8)
movsd (%rcx,%rax,8), %xmm0
movq %rax, -0xa8(%rbp)
movsd %xmm0, -0xa0(%rbp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x7f90
addq $0x10, %r15
jmp 0x5aa8
testq %rdi, %rdi
je 0x5b08
movq -0x70(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq -0x98(%rbp), %rdi
testq %rdi, %rdi
je 0x5b23
movq -0x88(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x5b4c
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
xorl %eax, %eax
movq %rax, -0x58(%rbp)
movl %eax, -0x50(%rbp)
movq %rax, -0x48(%rbp)
movl %eax, -0x40(%rbp)
movq %rax, -0x38(%rbp)
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5b67
movq %rax, %rbx
jmp 0x5b9a
jmp 0x5b67
movq %rax, %rbx
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x5b7f
movq -0x70(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq -0x98(%rbp), %rdi
testq %rdi, %rdi
je 0x5b9a
movq -0x88(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x5bc3
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
xorl %eax, %eax
movq %rax, -0x58(%rbp)
movl %eax, -0x50(%rbp)
movq %rax, -0x48(%rbp)
movl %eax, -0x40(%rbp)
movq %rax, -0x38(%rbp)
movq %rbx, %rdi
callq 0x2240