// File: /workspace/github_cpp_makefile_star2_O2/fjamour[P]icentral/src/bcc_scratch.cc
// Function: bcc_scratch_t::compute_bc(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>>>&, int)
void bcc_scratch_t::compute_bc(tr1::unordered_map<node_id_t, double>& bc_map, int max_iter)
{
    //bc_map will have for each vertex in the muc it's betweenness centrality
    //init bc of all nodes to zero
    //XXX why fill this bc_map? Should have all vertices in the graph, here we increment/decrement
    bcc_subgraph.i_fill_map<double>(bc_map, 0);
    
    //do BFS's from the nodes in the bcc
    if(max_iter == -1) {
        for(int i = 0; i < bcc_fast_subgraph.nodes_vec.size(); ++i) {
            node_id_t s = i;
            bc_iter(s, bc_map);
        }  
    } else {
        int cnt = 0;
        for(int i = 0; i < bcc_fast_subgraph.nodes_vec.size(); ++i) {
            node_id_t s = i;
            ++cnt;
            bc_iter(s, bc_map);
            if(cnt == max_iter)
                break;
        }  
    }

    if(max_iter == -1) {
        for(art_pt_map_t::iterator
            it =  art_pt_map.begin();
            it != art_pt_map.end();
            ++it) {
            vector<int> size_vec;
            size_vec = it->second;
            if(size_vec.size() > 1) {
                int sub = 0;
                for(int i = 0; i < size_vec.size(); ++i) {
                    sub += size_vec[i]*size_vec[i];
                }
                int VG_i = accumulate(it->second.begin(), it->second.end(), 0);
                bc_map[it->first] = bc_map[it->first] + VG_i*VG_i - sub;
            }
        }
        for (tr1::unordered_map<node_id_t, double>::iterator
            it = bc_map.begin();
                it != bc_map.end();
                ++it) {
            it->second = it->second / 2;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
addq $0x30, %rdi
xorpd %xmm0, %xmm0
callq 0x18120
cmpl $-0x1, %ebp
je 0x10182
movl %ebp, %r15d
xorl %esi, %esi
pushq $0x18
popq %r12
movq 0x2e0(%r14), %rax
subq 0x2d8(%r14), %rax
cqto
idivq %r12
cmpq %rsi, %rax
jbe 0x1016e
leaq 0x1(%rsi), %r13
movq %r14, %rdi
movq %rbx, %rdx
callq 0x102f6
movq %r13, %rsi
cmpq %r13, %r15
jne 0x1013f
cmpl $-0x1, %ebp
je 0x101b4
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
pushq $0x18
popq %r12
movq 0x2e0(%r14), %rax
subq 0x2d8(%r14), %rax
cqto
idivq %r12
cmpq %r15, %rax
jbe 0x1016e
movq %r14, %rdi
movl %r15d, %esi
movq %rbx, %rdx
callq 0x102f6
incq %r15
jmp 0x10189
movq %r14, %rdi
callq 0xf10e
movq %rax, %rsi
leaq 0x28(%rsp), %r15
movq %rax, (%r15)
movq %rdx, 0x8(%r15)
movq %rsp, %r12
movq 0x8(%r14), %rax
movq 0x10(%r14), %rcx
cmpq (%rax,%rcx,8), %rsi
je 0x1029d
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
addq $0x8, %rsi
movq %r12, %rdi
callq 0x752c
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq $0x2, %rcx
jb 0x10283
xorl %edx, %edx
xorl %ebp, %ebp
cmpq %rdx, %rcx
je 0x10227
movl (%rax,%rdx,4), %esi
imull %esi, %esi
addl %esi, %ebp
incq %rdx
jmp 0x10215
movq 0x28(%rsp), %rsi
movq 0x8(%rsi), %rax
movq 0x10(%rsi), %rcx
xorl %r13d, %r13d
cmpq %rcx, %rax
je 0x10245
addl (%rax), %r13d
addq $0x4, %rax
jmp 0x10237
movq %rbx, %rdi
callq 0xb00c
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0xb00c
imull %r13d, %r13d
cvtsi2sd %r13d, %xmm0
movsd 0x20(%rsp), %xmm1
addsd %xmm0, %xmm1
cvtsi2sd %ebp, %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, (%rax)
movq %r12, %rdi
callq 0x5720
movq %r15, %rdi
callq 0xf43c
movq 0x28(%rsp), %rsi
jmp 0x101ce
movq %rbx, %rdi
callq 0xb14e
movq %rsp, %r14
movq %rax, (%r14)
movq %rdx, 0x8(%r14)
movq 0x8(%rbx), %rcx
movq 0x10(%rbx), %rdx
cmpq (%rcx,%rdx,8), %rax
je 0x10173
movsd 0x8(%rax), %xmm0
mulsd 0x17d62(%rip), %xmm0    # 0x28030
movsd %xmm0, 0x8(%rax)
movq %r14, %rdi
callq 0xbe06
movq (%rsp), %rax
jmp 0x102af
jmp 0x102e3
movq %rax, %rbx
movq %rsp, %rdi
callq 0x5720
movq %rbx, %rdi
callq 0x23d0