// File: /workspace/github_cpp_makefile_star2_O1/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 0x1c296
movq 0x240(%r14), %rax
cmpq %rax, 0x248(%r14)
je 0xd3de
movq %rax, 0x248(%r14)
leaq 0x258(%r14), %r13
leaq 0x18(%rsp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0xd8ec
movl $0x1, (%rax)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xd8ec
movl $0x0, (%rax)
movq 0x288(%r14), %rax
movq 0x298(%r14), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0xd436
movl 0x18(%rsp), %ecx
movl %ecx, (%rax)
addq $0x4, %rax
movq %rax, 0x288(%r14)
jmp 0xd443
leaq 0x18(%rsp), %rsi
movq %r13, %rdi
callq 0x7644
leaq 0x60(%r14), %r12
leaq 0x240(%r14), %rax
movq %rax, 0x38(%rsp)
movq 0x268(%r14), %rax
cmpq %rax, 0x288(%r14)
je 0xd615
leaq 0x1c(%rsp), %rbx
movq %r12, 0x40(%rsp)
movq %r13, 0x10(%rsp)
movl (%rax), %eax
movl %eax, 0xc(%rsp)
movq %r13, %rdi
callq 0xdd72
movq 0x248(%r14), %rsi
cmpq 0x250(%r14), %rsi
je 0xd4a7
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x248(%r14)
jmp 0xd4b6
movq 0x38(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x6f98
movl 0xc(%rsp), %esi
movq %r14, %rdi
callq 0x1c284
leaq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0x61a0
movq 0x20(%rsp), %rdi
cmpq %rdi, 0x28(%rsp)
je 0xd5ef
xorl %r13d, %r13d
movl (%rdi,%r13,4), %eax
movl %eax, 0x1c(%rsp)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xd8ec
cmpl $0x0, (%rax)
jns 0xd552
movq 0x288(%r14), %rax
movq 0x298(%r14), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0xd524
movl 0x1c(%rsp), %ecx
movl %ecx, (%rax)
addq $0x4, %rax
movq %rax, 0x288(%r14)
jmp 0xd531
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x7644
movq %rbp, %rdi
leaq 0xc(%rsp), %rsi
callq 0xd8ec
movl (%rax), %r12d
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xd8ec
incl %r12d
movl %r12d, (%rax)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xd8ec
movl (%rax), %r12d
movq %rbp, %rdi
leaq 0xc(%rsp), %rsi
callq 0xd8ec
movl (%rax), %eax
incl %eax
cmpl %eax, %r12d
jne 0xd5c8
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
callq 0xd8ec
movl (%rax), %r12d
movq %r15, %rdi
movq %rbx, %rsi
callq 0xd8ec
addl %r12d, (%rax)
movq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0xd93e
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0xd5bb
movl 0xc(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0xd5c8
movq %rax, %rdi
leaq 0xc(%rsp), %rdx
callq 0x6f98
incq %r13
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq %r13, %rax
ja 0xd4e2
movq 0x40(%rsp), %r12
movq 0x10(%rsp), %r13
testq %rdi, %rdi
je 0xd601
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq 0x268(%r14), %rax
cmpq %rax, 0x288(%r14)
jne 0xd476
movq 0x248(%r14), %rax
subq 0x240(%r14), %rax
shrq $0x2, %rax
decl %eax
js 0xd76c
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 0xd93e
movq 0x8(%rax), %rcx
cmpq (%rax), %rcx
je 0xd71d
xorl %ebp, %ebp
movq %r12, %rdi
movq %rbx, %rsi
callq 0xd93e
movq (%rax), %rax
movl (%rax,%rbp,4), %eax
movl %eax, 0xc(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0xd8ec
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0xd8ec
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0xd85a
movsd (%rax), %xmm0
addsd 0x2395a(%rip), %xmm0    # 0x31030
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0xd85a
movsd 0x10(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
incq %rbp
movq %r12, %rdi
movq %rbx, %rsi
callq 0xd93e
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x2, %rcx
cmpq %rbp, %rcx
ja 0xd670
movl 0x20(%rsp), %eax
cmpl 0x18(%rsp), %eax
je 0xd757
movq %r14, %rdi
movq %rbx, %rsi
callq 0xd85a
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x48(%rsp), %rdi
movq %rbx, %rsi
callq 0xd85a
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 0xd642
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 0xd795
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq %rbx, %rdi
callq 0x23b0
nop