// File: /workspace/github_cpp_makefile_star2_O2/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, 0x50(%rsp)
movq %rdi, %r12
movl %esi, 0x14(%rsp)
leaq 0x90(%rdi), %r14
leaq 0xf0(%rdi), %rbx
leaq 0x258(%rdi), %rax
movq %rax, 0x8(%rsp)
callq 0x173d2
movq 0x240(%r12), %rax
cmpq %rax, 0x248(%r12)
je 0xaca6
movq %rax, 0x248(%r12)
leaq 0x60(%r12), %r15
leaq 0x120(%r12), %rax
movq %rax, 0x30(%rsp)
leaq 0x240(%r12), %rax
movq %rax, 0x28(%rsp)
leaq 0x14(%rsp), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0xb180
movl $0x1, (%rax)
movq %rbx, %rdi
movq %r13, %rsi
callq 0xb180
andl $0x0, (%rax)
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x62da
leaq 0x24(%rsp), %r13
movq %r12, 0x18(%rsp)
movq 0x268(%r12), %rax
cmpq %rax, 0x288(%r12)
je 0xae20
movl (%rax), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rdi
callq 0x650e
movq 0x28(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x478c
movl 0x4(%rsp), %esi
movq %r12, %rdi
callq 0x173c0
leaq 0x38(%rsp), %rdi
movq %rax, %rsi
callq 0x4ba0
xorl %r12d, %r12d
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r12, %rcx
jbe 0xae0c
movl (%rax,%r12,4), %eax
movl %eax, 0x24(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0xb180
cmpl $0x0, (%rax)
jns 0xadae
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x62da
movq %rbx, %rdi
leaq 0x4(%rsp), %rsi
callq 0xb180
movl (%rax), %ebp
movq %rbx, %rdi
movq %r13, %rsi
callq 0xb180
incl %ebp
movl %ebp, (%rax)
movq %rbx, %rdi
movq %r13, %rsi
callq 0xb180
movl (%rax), %ebp
movq %rbx, %rdi
leaq 0x4(%rsp), %rsi
callq 0xb180
movl (%rax), %eax
incl %eax
cmpl %eax, %ebp
jne 0xae04
movq %r14, %rdi
leaq 0x4(%rsp), %rsi
callq 0xb180
movl (%rax), %ebp
movq %r14, %rdi
movq %r13, %rsi
callq 0xb180
addl %ebp, (%rax)
movq %r15, %rdi
movq %r13, %rsi
callq 0xb1de
movq %rax, %rdi
leaq 0x4(%rsp), %rsi
callq 0x478c
incq %r12
jmp 0xad51
leaq 0x38(%rsp), %rdi
callq 0x56ec
movq 0x18(%rsp), %r12
jmp 0xad00
movq 0x248(%r12), %rax
subq 0x240(%r12), %rax
shrq $0x2, %rax
movl %eax, %eax
leaq 0x38(%rsp), %rbx
leaq 0x4(%rsp), %r13
movq 0x30(%rsp), %r12
decq %rax
testl %eax, %eax
js 0xaf5d
movq %rax, 0x18(%rsp)
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq 0x28(%rsp), %rcx
movq (%rcx), %rcx
movl (%rcx,%rax,4), %eax
movl %eax, 0x38(%rsp)
xorl %ebp, %ebp
movq %r15, %rdi
movq %rbx, %rsi
callq 0xb1de
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x2, %rcx
cmpq %rbp, %rcx
jbe 0xaf17
movq %r15, %rdi
movq %rbx, %rsi
callq 0xb1de
movq (%rax), %rax
movl (%rax,%rbp,4), %eax
movl %eax, 0x4(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0xb180
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0xb180
cvtsi2sdl (%rax), %xmm0
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movq %r12, %rdi
movq %rbx, %rsi
callq 0xb00c
movsd (%rax), %xmm0
addsd 0x1d156(%rip), %xmm0    # 0x28040
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0xb00c
movsd 0x8(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
incq %rbp
jmp 0xae6b
movl 0x38(%rsp), %eax
cmpl 0x14(%rsp), %eax
je 0xaf53
movq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0xb00c
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0xb00c
movsd 0x8(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movq 0x18(%rsp), %rax
jmp 0xae45
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x56ec
movq %rbx, %rdi
callq 0x23d0
nop