// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
movl %edx, %r15d
movq %rsi, %rbx
movq %rdi, %r14
addq $0x30, %rdi
xorpd %xmm0, %xmm0
callq 0x1d472
movq 0x2d8(%r14), %rax
movq 0x2e0(%r14), %rcx
cmpl $-0x1, %r15d
je 0x13b0b
cmpq %rax, %rcx
je 0x13b49
leal -0x1(%r15), %r13d
xorl %r12d, %r12d
movabsq $-0x5555555555555555, %rbp # imm = 0xAAAAAAAAAAAAAAAB
movq %r14, %rdi
movl %r12d, %esi
movq %rbx, %rdx
callq 0x13cf0
cmpq %r12, %r13
je 0x13b49
movq 0x2e0(%r14), %rax
subq 0x2d8(%r14), %rax
incq %r12
sarq $0x3, %rax
imulq %rbp, %rax
cmpq %r12, %rax
ja 0x13ad8
jmp 0x13b49
cmpq %rax, %rcx
je 0x13b49
xorl %r12d, %r12d
movabsq $-0x5555555555555555, %r13 # imm = 0xAAAAAAAAAAAAAAAB
movq %r14, %rdi
movl %r12d, %esi
movq %rbx, %rdx
callq 0x13cf0
movq 0x2e0(%r14), %rax
subq 0x2d8(%r14), %rax
incq %r12
sarq $0x3, %rax
imulq %r13, %rax
cmpq %r12, %rax
ja 0x13b1d
cmpl $-0x1, %r15d
jne 0x13cbd
movq 0x8(%r14), %r13
movq (%r13), %r15
testq %r15, %r15
jne 0x13b6a
movq 0x8(%r13), %r15
addq $0x8, %r13
jmp 0x13b5b
movq 0x8(%r14), %rax
movq 0x10(%r14), %rcx
cmpq (%rax,%rcx,8), %r15
je 0x13c63
movq %rsp, %r12
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x8(%r15), %rsi
movq %r12, %rdi
callq 0x8c74
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq $0x2, %rcx
jb 0x13c28
xorl %edx, %edx
xorl %ebp, %ebp
movl (%rax,%rdx,4), %esi
imull %esi, %esi
addl %esi, %ebp
incq %rdx
cmpq %rdx, %rcx
jne 0x13bb7
movq 0x8(%r15), %rax
movq 0x10(%r15), %rcx
xorl %r12d, %r12d
cmpq %rcx, %rax
je 0x13be0
addl (%rax), %r12d
addq $0x4, %rax
jmp 0x13bd2
movq %rbx, %rdi
movq %r15, %rsi
callq 0xd85a
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xd85a
imull %r12d, %r12d
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movsd 0x20(%rsp), %xmm1
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, (%rax)
movq %rsp, %r12
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x13c3e
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq 0x20(%r15), %r15
testq %r15, %r15
jne 0x13c51
movq 0x8(%r13), %r15
addq $0x8, %r13
jmp 0x13c42
movq 0x8(%r14), %rax
movq 0x10(%r14), %rcx
cmpq (%rax,%rcx,8), %r15
jne 0x13b7f
movq 0x8(%rbx), %rdx
movq (%rdx), %rcx
movq %rdx, %rax
testq %rcx, %rcx
jne 0x13c82
movq %rdx, %rax
movq 0x8(%rax), %rcx
addq $0x8, %rax
testq %rcx, %rcx
je 0x13c75
movq 0x10(%rbx), %rsi
movq (%rdx,%rsi,8), %rdx
cmpq %rdx, %rcx
je 0x13cbd
movsd 0x1d3a1(%rip), %xmm0    # 0x31038
movsd 0x8(%rcx), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rcx)
movq 0x10(%rcx), %rcx
testq %rcx, %rcx
jne 0x13cb8
movq 0x8(%rax), %rcx
addq $0x8, %rax
jmp 0x13ca9
cmpq %rdx, %rcx
jne 0x13c97
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x13cce
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x13ce7
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq %rbx, %rdi
callq 0x23b0
nop