// File: /workspace/github_cpp_makefile_star2_O2/fjamour[P]icentral/src/_bc.cc
// Function: RBFS(std::vector<double, std::allocator<double>>&, component_t&, unsigned int, iter_info_t&, bool, bool)
void RBFS(
        vector<double>& dBC_vec,    // delta BC of vertices
        component_t&    comp,       // component could be BCC, MUC, or just a graph
        node_id_t       s,          // source of the iteration
        iter_info_t&    iter_info,  //
        bool            add,
        bool            sub
        )
{
    vector<vector<node_id_t> >&  P = iter_info.P; 
    vector<int>&                 sigma_vec = iter_info.sigma_vec;
    vector<double>&              delta_vec = iter_info.delta_vec;
    vector<double>&              Delta_vec = iter_info.Delta_vec;
    vector<node_id_t>&           S = iter_info.S;
    
    fill_vec<double>(delta_vec, comp.subgraph.size(), 0);
    
   
    if(comp.comp_type == GRAPH) {
        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];
                delta_vec[v] += (((double) sigma_vec[v] / sigma_vec[w]) * (1 + delta_vec[w]));
            }
            if (w != s) {
                if(add) dBC_vec[w] += delta_vec[w]/2.0;
                if(sub) dBC_vec[w] -= delta_vec[w]/2.0;
            }
        }
    } else if(comp.comp_type == BCC) { //BCC or MUC case: involved case, with external pairs contribution
        fill_vec<double>(Delta_vec, comp.subgraph.size(), 0);
        component_t::art_pt_map_t& art_pt_map = comp.art_pt_map;
        for(int i = S.size()-1; i >= 0; --i) {
            node_id_t v_n = S[i];
            if(   art_pt_map.find(s) != art_pt_map.end()
               && art_pt_map.find(v_n) != art_pt_map.end()
               ){
                int VG_s, VG_n;
                VG_s = accumulate(art_pt_map[s].begin(), art_pt_map[s].end(), 0);
                VG_n = accumulate(art_pt_map[v_n].begin(), art_pt_map[v_n].end(), 0);
                int c_t = VG_s*VG_n;
                Delta_vec[v_n] =  Delta_vec[v_n] + c_t;
            }
            for(int i = 0; i < P[v_n].size(); ++i) {
                node_id_t v_p = P[v_n][i];
                double sp_sn = ((double)sigma_vec[v_p]/sigma_vec[v_n]);
                delta_vec[v_p] = delta_vec[v_p] + sp_sn*(1+delta_vec[v_n]);
                if(art_pt_map.find(s) != art_pt_map.end()) {
                    Delta_vec[v_p] = Delta_vec[v_p] + Delta_vec[v_n]*sp_sn;
                }
            }
            if(s != v_n) {
                if(add) dBC_vec[v_n] += delta_vec[v_n]/2.0;
                if(sub) dBC_vec[v_n] -= delta_vec[v_n]/2.0;
            }
            if(art_pt_map.find(s) != art_pt_map.end()) {
                int VG_s = accumulate(art_pt_map[s].begin(), art_pt_map[s].end(), 0);
                if(add) {
                    dBC_vec[v_n] += delta_vec[v_n]*VG_s;
                    dBC_vec[v_n] += Delta_vec[v_n]/2.0;
                }
                if(sub) {
                    dBC_vec[v_n] -= delta_vec[v_n]*VG_s;
                    dBC_vec[v_n] -= Delta_vec[v_n]/2.0;
                }
            }
        }
    }
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, 0x14(%rsp)
movl %r8d, 0x10(%rsp)
movq %rcx, %r14
movl %edx, %ebx
movq %rsi, %r12
movq %rdi, 0x18(%rsp)
movl %edx, 0xc(%rsp)
leaq 0x48(%rcx), %rbp
movq %rsi, %rdi
callq 0x2622a
xorpd %xmm0, %xmm0
movq %rbp, %rdi
movq %rax, %rsi
callq 0x4756
movl 0x228(%r12), %eax
testl %eax, %eax
je 0x3582
cmpl $0x2, %eax
jne 0x389b
movq 0x108(%r14), %rdi
movq 0x100(%r14), %rax
subq %rax, %rdi
shrq $0x2, %rdi
movq (%r14), %rcx
movq 0x48(%r14), %rdx
movq 0x18(%rsp), %rsi
movq (%rsi), %rsi
movl %edi, %edi
movsd 0x24b76(%rip), %xmm0    # 0x28030
movsd 0x24b76(%rip), %xmm1    # 0x28038
movsd 0x24b76(%rip), %xmm2    # 0x28040
decq %rdi
testl %edi, %edi
js 0x389b
movl %edi, %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movl (%rax,%r8,4), %r8d
imulq $0x18, %r8, %r10
movq (%rcx,%r10), %r9
movq 0x8(%rcx,%r10), %r10
subq %r9, %r10
sarq $0x2, %r10
movq 0x18(%r14), %r11
movq 0x48(%r14), %r15
xorl %r12d, %r12d
cmpq %r12, %r10
je 0x353a
movl (%r9,%r12,4), %r13d
cvtsi2sdl (%r11,%r13,4), %xmm3
cvtsi2sdl (%r11,%r8,4), %xmm4
divsd %xmm4, %xmm3
movsd (%r15,%r8,8), %xmm4
addsd %xmm2, %xmm4
mulsd %xmm3, %xmm4
addsd (%r15,%r13,8), %xmm4
movsd %xmm4, (%r15,%r13,8)
incq %r12
jmp 0x3502
cmpl %ebx, %r8d
je 0x34ca
cmpb $0x0, 0x10(%rsp)
je 0x355c
movsd (%rdx,%r8,8), %xmm3
mulsd %xmm0, %xmm3
addsd (%rsi,%r8,8), %xmm3
movsd %xmm3, (%rsi,%r8,8)
cmpb $0x0, 0x14(%rsp)
je 0x34ca
movsd (%rdx,%r8,8), %xmm3
mulsd %xmm1, %xmm3
addsd (%rsi,%r8,8), %xmm3
movsd %xmm3, (%rsi,%r8,8)
jmp 0x34ca
leaq 0x60(%r14), %r15
movq %r12, %rdi
callq 0x2622a
xorpd %xmm0, %xmm0
movq %r15, %rdi
movq %rax, %rsi
callq 0x4756
movq 0x108(%r14), %rax
subq 0x100(%r14), %rax
leaq 0x1f8(%r12), %r13
shrq $0x2, %rax
movl %eax, %eax
movq %rbp, 0x20(%rsp)
decq %rax
testl %eax, %eax
js 0x389b
movq %rax, 0x28(%rsp)
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq 0x100(%r14), %rcx
movl (%rcx,%rax,4), %eax
movl %eax, 0x8(%rsp)
movq %r13, %rdi
leaq 0xc(%rsp), %rsi
callq 0x4a5c
movq 0x200(%r12), %rcx
movq 0x208(%r12), %rdx
cmpq (%rcx,%rdx,8), %rax
je 0x36a4
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq 0x4a5c
movq 0x200(%r12), %rcx
movq 0x208(%r12), %rdx
cmpq (%rcx,%rdx,8), %rax
je 0x36a4
movq %r13, %rdi
leaq 0xc(%rsp), %rbp
movq %rbp, %rsi
callq 0x4aaa
movq (%rax), %rbx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4aaa
movq 0x8(%rax), %rax
xorl %ebp, %ebp
cmpq %rax, %rbx
je 0x365c
addl (%rbx), %ebp
addq $0x4, %rbx
jmp 0x364f
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq 0x4aaa
movq (%rax), %rbx
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq 0x4aaa
movq 0x8(%rax), %rcx
xorl %eax, %eax
cmpq %rcx, %rbx
je 0x368c
addl (%rbx), %eax
addq $0x4, %rbx
jmp 0x367f
imull %ebp, %eax
movl 0x8(%rsp), %ecx
cvtsi2sd %eax, %xmm0
movq (%r15), %rax
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
xorl %ebp, %ebp
movl 0x8(%rsp), %eax
movq (%r14), %rdx
imulq $0x18, %rax, %rsi
movq (%rdx,%rsi), %rcx
movq 0x8(%rdx,%rsi), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rbp, %rdx
jbe 0x374b
movl (%rcx,%rbp,4), %ebx
movq 0x18(%r14), %rcx
cvtsi2sdl (%rcx,%rbx,4), %xmm1
cvtsi2sdl (%rcx,%rax,4), %xmm0
movq 0x48(%r14), %rcx
divsd %xmm0, %xmm1
movsd (%rcx,%rax,8), %xmm0
addsd 0x24950(%rip), %xmm0    # 0x28040
movsd %xmm1, 0x30(%rsp)
mulsd %xmm1, %xmm0
addsd (%rcx,%rbx,8), %xmm0
movsd %xmm0, (%rcx,%rbx,8)
movq %r13, %rdi
leaq 0xc(%rsp), %rsi
callq 0x4a5c
movq 0x200(%r12), %rcx
movq 0x208(%r12), %rdx
cmpq (%rcx,%rdx,8), %rax
je 0x3743
movq (%r15), %rax
movl 0x8(%rsp), %ecx
movsd 0x30(%rsp), %xmm0
mulsd (%rax,%rcx,8), %xmm0
addsd (%rax,%rbx,8), %xmm0
movsd %xmm0, (%rax,%rbx,8)
incq %rbp
jmp 0x36a6
cmpl %eax, 0xc(%rsp)
movq 0x20(%rsp), %rbp
je 0x37aa
cmpb $0x0, 0x10(%rsp)
je 0x3780
movq (%rbp), %rcx
movsd (%rcx,%rax,8), %xmm0
mulsd 0x248c2(%rip), %xmm0    # 0x28030
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
addsd (%rcx,%rax,8), %xmm0
movsd %xmm0, (%rcx,%rax,8)
cmpb $0x0, 0x14(%rsp)
je 0x37aa
movq (%rbp), %rcx
movsd (%rcx,%rax,8), %xmm0
mulsd 0x248a0(%rip), %xmm0    # 0x28038
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
addsd (%rcx,%rax,8), %xmm0
movsd %xmm0, (%rcx,%rax,8)
movq %r13, %rdi
leaq 0xc(%rsp), %rsi
callq 0x4a5c
movq 0x200(%r12), %rcx
movq 0x208(%r12), %rdx
cmpq (%rcx,%rdx,8), %rax
je 0x3891
movq %r13, %rdi
leaq 0xc(%rsp), %rbp
movq %rbp, %rsi
callq 0x4aaa
movq (%rax), %rbx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4aaa
movq 0x8(%rax), %rcx
xorl %eax, %eax
cmpq %rcx, %rbx
je 0x3802
addl (%rbx), %eax
addq $0x4, %rbx
jmp 0x37f5
cvtsi2sd %eax, %xmm0
cmpb $0x0, 0x10(%rsp)
movq 0x20(%rsp), %rbp
je 0x384e
movl 0x8(%rsp), %eax
movq (%rbp), %rcx
movq 0x18(%rsp), %rdx
movq (%rdx), %rdx
movsd (%rcx,%rax,8), %xmm1
mulsd %xmm0, %xmm1
addsd (%rdx,%rax,8), %xmm1
movsd %xmm1, (%rdx,%rax,8)
movq (%r15), %rcx
movsd (%rcx,%rax,8), %xmm2
mulsd 0x247eb(%rip), %xmm2    # 0x28030
addsd %xmm1, %xmm2
movsd %xmm2, (%rdx,%rax,8)
cmpb $0x0, 0x14(%rsp)
je 0x3891
movl 0x8(%rsp), %eax
movq (%rbp), %rcx
movq 0x18(%rsp), %rdx
movq (%rdx), %rdx
mulsd (%rcx,%rax,8), %xmm0
movsd (%rdx,%rax,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%rdx,%rax,8)
movq (%r15), %rcx
movsd (%rcx,%rax,8), %xmm0
mulsd 0x247b0(%rip), %xmm0    # 0x28038
addsd %xmm1, %xmm0
movsd %xmm0, (%rdx,%rax,8)
movq 0x28(%rsp), %rax
jmp 0x35be
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq