// File: /workspace/github_cpp_makefile_star2_O3/fjamour[P]icentral/src/bc.cc
// Function: brandes_iter(graph_hash_t&, unsigned int, std::tr1::unordered_map<unsigned int, double, std::tr1::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, double>>>&)
void brandes_iter(graph_hash_t& graph_in,
        node_id_t s,
        tr1_map_t(double)& bc_vec)
{
    tr1_map_t(vector<node_id_t> )&      P = graph_in.P;
    tr1_map_t(int)&                     path_cnt_vec = graph_in.path_cnt_vec;
    tr1_map_t(int)&                     dist_vec = graph_in.dist_vec;
    tr1_map_t(double)&                  pair_dep_vec = graph_in.pair_dep_vec;
    vector<node_id_t>&                  S = graph_in.S;
    queue<node_id_t>&                   Q = graph_in.Q;
    
    graph_in.init_maps();
    
    S.clear();
    
    path_cnt_vec[s] = 1;
    dist_vec[s] = 0;

    Q.push(s);

    while (!Q.empty()) {
        node_id_t v = Q.front();
        Q.pop();
        S.push_back(v);
        vector<node_id_t> nbr_vec = graph_in.get_nbrs(v);
        for (int nbr_idx = 0; nbr_idx < nbr_vec.size(); ++nbr_idx) {
            node_id_t w = nbr_vec[nbr_idx];
            if (dist_vec[w] < 0) {
                Q.push(w);
                dist_vec[w] = dist_vec[v] + 1;
            }
            if (dist_vec[w] == dist_vec[v] + 1) {
                path_cnt_vec[w] += path_cnt_vec[v];
                P[w].push_back(v);
            }
        }
    }

    for(int i = S.size()-1; i >= 0; --i) {
        node_id_t w = S[i];
        for(int idx = 0; idx < P[w].size(); ++idx) {
            node_id_t v = P[w][idx];
            pair_dep_vec[v] += (((double) path_cnt_vec[v] / path_cnt_vec[w]) * (1 + pair_dep_vec[w]));
        }
        if (w != s) {
            bc_vec[w] += pair_dep_vec[w];
        }
    }    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, 0x48(%rsp)
movq %rdi, %r14
movl %esi, 0x18(%rsp)
leaq 0x90(%rdi), %r15
leaq 0xf0(%rdi), %rbp
callq 0x1c18e
movq 0x240(%r14), %rax
cmpq %rax, 0x248(%r14)
je 0xd447
movq %rax, 0x248(%r14)
leaq 0x258(%r14), %r13
leaq 0x18(%rsp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0xd94a
movl $0x1, (%rax)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xd94a
movl $0x0, (%rax)
movq 0x288(%r14), %rax
movq 0x298(%r14), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0xd49f
movl 0x18(%rsp), %ecx
movl %ecx, (%rax)
addq $0x4, %rax
movq %rax, 0x288(%r14)
jmp 0xd4b3
leaq 0x18(%rsp), %rsi
movq %r13, %rdi
callq 0x75be
movq 0x288(%r14), %rax
leaq 0x60(%r14), %r12
leaq 0x240(%r14), %rcx
movq %rcx, 0x38(%rsp)
movq 0x268(%r14), %rcx
cmpq %rcx, %rax
je 0xd684
leaq 0x1c(%rsp), %rbx
movq %r12, 0x40(%rsp)
movq %r13, 0x10(%rsp)
movl (%rcx), %eax
movl %eax, 0xc(%rsp)
movq %r13, %rdi
callq 0xddae
movq 0x248(%r14), %rax
cmpq 0x250(%r14), %rax
je 0xd513
movl 0xc(%rsp), %esi
movl %esi, (%rax)
addq $0x4, %rax
movq %rax, 0x248(%r14)
jmp 0xd529
movq 0x38(%rsp), %rdi
movq %rax, %rsi
leaq 0xc(%rsp), %rdx
callq 0x6f14
movl 0xc(%rsp), %esi
movq %r14, %rdi
callq 0x1c17c
leaq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0x6112
movq 0x20(%rsp), %rdi
cmpq %rdi, 0x28(%rsp)
je 0xd65e
xorl %r13d, %r13d
movl (%rdi,%r13,4), %eax
movl %eax, 0x1c(%rsp)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xd94a
cmpl $0x0, (%rax)
jns 0xd5c1
movq 0x288(%r14), %rax
movq 0x298(%r14), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0xd593
movl 0x1c(%rsp), %ecx
movl %ecx, (%rax)
addq $0x4, %rax
movq %rax, 0x288(%r14)
jmp 0xd5a0
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x75be
movq %rbp, %rdi
leaq 0xc(%rsp), %rsi
callq 0xd94a
movl (%rax), %r12d
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xd94a
incl %r12d
movl %r12d, (%rax)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xd94a
movl (%rax), %r12d
movq %rbp, %rdi
leaq 0xc(%rsp), %rsi
callq 0xd94a
movl (%rax), %eax
incl %eax
cmpl %eax, %r12d
jne 0xd637
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
callq 0xd94a
movl (%rax), %r12d
movq %r15, %rdi
movq %rbx, %rsi
callq 0xd94a
addl %r12d, (%rax)
movq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0xd984
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0xd62a
movl 0xc(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0xd637
movq %rax, %rdi
leaq 0xc(%rsp), %rdx
callq 0x6f14
incq %r13
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq %r13, %rax
ja 0xd551
movq 0x40(%rsp), %r12
movq 0x10(%rsp), %r13
testq %rdi, %rdi
je 0xd670
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq 0x268(%r14), %rcx
cmpq %rcx, 0x288(%r14)
jne 0xd4e2
movq 0x248(%r14), %rax
subq 0x240(%r14), %rax
shrq $0x2, %rax
decl %eax
js 0xd7db
addq $0x120, %r14            # imm = 0x120
movl %eax, %ecx
leaq 0x20(%rsp), %rbx
leaq 0xc(%rsp), %r13
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rcx, 0x50(%rsp)
movl (%rax,%rcx,4), %eax
movl %eax, 0x20(%rsp)
movq %r12, %rdi
movq %rbx, %rsi
callq 0xd984
movq 0x8(%rax), %rcx
cmpq (%rax), %rcx
je 0xd78c
xorl %ebp, %ebp
movq %r12, %rdi
movq %rbx, %rsi
callq 0xd984
movq (%rax), %rax
movl (%rax,%rbp,4), %eax
movl %eax, 0xc(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0xd94a
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0xd94a
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0xd8ce
movsd (%rax), %xmm0
addsd 0x228eb(%rip), %xmm0    # 0x30030
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0xd8ce
movsd 0x10(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
incq %rbp
movq %r12, %rdi
movq %rbx, %rsi
callq 0xd984
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x2, %rcx
cmpq %rbp, %rcx
ja 0xd6df
movl 0x20(%rsp), %eax
cmpl 0x18(%rsp), %eax
je 0xd7c6
movq %r14, %rdi
movq %rbx, %rsi
callq 0xd8ce
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x48(%rsp), %rdi
movq %rbx, %rsi
callq 0xd8ce
movsd 0x10(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movq 0x50(%rsp), %rcx
leaq -0x1(%rcx), %rax
testq %rcx, %rcx
movq %rax, %rcx
jg 0xd6b1
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xd804
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq %rbx, %rdi
callq 0x23b0