// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
movl %r9d, 0x1c(%rsp)
movl %r8d, 0x18(%rsp)
movq %rcx, %rbx
movq %rsi, %r12
movq %rdi, 0x20(%rsp)
movl %edx, 0x8(%rsp)
leaq 0x48(%rcx), %r14
movq %rsi, %rdi
callq 0x2ed3a
movq %r14, 0x28(%rsp)
movq %r14, %rdi
movq %rax, %rsi
callq 0x5c58
movq 0x48(%rbx), %r15
movq %rbx, 0x10(%rsp)
movq 0x50(%rbx), %rdx
cmpq %rdx, %r15
je 0x4427
subq %r15, %rdx
addq $-0x8, %rdx
andq $-0x8, %rdx
addq $0x8, %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x2110
movl 0x228(%r12), %eax
testl %eax, %eax
je 0x454a
cmpl $0x2, %eax
jne 0x4999
movq 0x10(%rsp), %rcx
movq 0x100(%rcx), %rax
movq 0x108(%rcx), %r8
subq %rax, %r8
shrq $0x2, %r8
decl %r8d
js 0x4999
movq 0x10(%rsp), %rdx
movq (%rdx), %rcx
movq 0x18(%rdx), %rdx
movl 0x8(%rsp), %esi
movq 0x20(%rsp), %rdi
movq (%rdi), %rdi
movl %r8d, %r8d
movsd 0x2cbb2(%rip), %xmm0    # 0x31038
movsd 0x2cbb2(%rip), %xmm1    # 0x31040
movsd 0x2cb9a(%rip), %xmm2    # 0x31030
movl (%rax,%r8,4), %r9d
leaq (%r9,%r9,2), %r11
movq (%rcx,%r11,8), %r10
movq 0x8(%rcx,%r11,8), %r11
subq %r10, %r11
je 0x44f6
sarq $0x2, %r11
xorps %xmm3, %xmm3
cvtsi2sdl (%rdx,%r9,4), %xmm3
cmpq $0x1, %r11
adcq $0x0, %r11
xorl %ebx, %ebx
movl (%r10,%rbx,4), %r14d
xorps %xmm4, %xmm4
cvtsi2sdl (%rdx,%r14,4), %xmm4
divsd %xmm3, %xmm4
movsd (%r15,%r9,8), %xmm5
addsd %xmm2, %xmm5
mulsd %xmm4, %xmm5
addsd (%r15,%r14,8), %xmm5
movsd %xmm5, (%r15,%r14,8)
incq %rbx
cmpq %rbx, %r11
jne 0x44c3
cmpl %esi, %r9d
je 0x4535
cmpb $0x0, 0x18(%rsp)
je 0x4518
movsd (%r15,%r9,8), %xmm3
mulsd %xmm0, %xmm3
addsd (%rdi,%r9,8), %xmm3
movsd %xmm3, (%rdi,%r9,8)
cmpb $0x0, 0x1c(%rsp)
je 0x4535
movsd (%r15,%r9,8), %xmm3
mulsd %xmm1, %xmm3
addsd (%rdi,%r9,8), %xmm3
movsd %xmm3, (%rdi,%r9,8)
leaq -0x1(%r8), %r9
testq %r8, %r8
movq %r9, %r8
jg 0x4496
jmp 0x4999
movq 0x10(%rsp), %rbx
leaq 0x60(%rbx), %r14
movq %r12, %rdi
callq 0x2ed3a
movq %r14, 0x30(%rsp)
movq %r14, %rdi
movq %rax, %rsi
callq 0x5c58
movq 0x60(%rbx), %rdi
movq 0x68(%rbx), %rdx
cmpq %rdx, %rdi
je 0x458e
subq %rdi, %rdx
addq $-0x8, %rdx
andq $-0x8, %rdx
addq $0x8, %rdx
xorl %esi, %esi
callq 0x2110
movq 0x10(%rsp), %rcx
movq 0x108(%rcx), %rax
subq 0x100(%rcx), %rax
shrq $0x2, %rax
decl %eax
js 0x4999
leaq 0x1f8(%r12), %rcx
movq %rcx, 0x38(%rsp)
movl %eax, %ecx
movsd 0x2ca6c(%rip), %xmm3    # 0x31030
movq 0x10(%rsp), %rax
movq 0x100(%rax), %rax
movq %rcx, 0x40(%rsp)
movl (%rax,%rcx,4), %ecx
movl %ecx, 0xc(%rsp)
movl 0x8(%rsp), %esi
movq 0x200(%r12), %rdi
movq 0x208(%r12), %r8
movq %rsi, %rax
xorl %edx, %edx
divq %r8
movq (%rdi,%rdx,8), %rax
movl $0x0, %edx
testq %rax, %rax
je 0x461a
cmpl (%rax), %esi
je 0x4617
movq 0x20(%rax), %rax
testq %rax, %rax
jne 0x4606
xorl %edx, %edx
jmp 0x461a
movq %rax, %rdx
testq %rdx, %rdx
jne 0x4623
movq (%rdi,%r8,8), %rdx
movq (%rdi,%r8,8), %rsi
cmpq %rsi, %rdx
je 0x470e
movq %rcx, %rax
xorl %edx, %edx
divq %r8
movq (%rdi,%rdx,8), %rax
movl $0x0, %edx
testq %rax, %rax
je 0x465a
cmpl (%rax), %ecx
je 0x4657
movq 0x20(%rax), %rax
testq %rax, %rax
jne 0x4646
xorl %edx, %edx
jmp 0x465a
movq %rax, %rdx
testq %rdx, %rdx
sete %al
cmpq %rsi, %rdx
sete %cl
orb %al, %cl
jne 0x470e
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
leaq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0x6106
movq (%rax), %r14
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6106
movq 0x8(%rax), %rax
xorl %ebx, %ebx
movl $0x0, %ebp
cmpq %rax, %r14
je 0x46af
xorl %ebp, %ebp
addl (%r14), %ebp
addq $0x4, %r14
cmpq %rax, %r14
jne 0x46a3
movq 0x38(%rsp), %r15
movq %r15, %rdi
leaq 0xc(%rsp), %r13
movq %r13, %rsi
callq 0x6106
movq (%rax), %r14
movq %r15, %rdi
movq %r13, %rsi
callq 0x6106
movq 0x8(%rax), %rax
cmpq %rax, %r14
je 0x46e9
xorl %ebx, %ebx
addl (%r14), %ebx
addq $0x4, %r14
cmpq %rax, %r14
jne 0x46dd
imull %ebp, %ebx
movl 0xc(%rsp), %eax
cvtsi2sd %ebx, %xmm0
movq 0x30(%rsp), %rcx
movq (%rcx), %rcx
addsd (%rcx,%rax,8), %xmm0
movsd %xmm0, (%rcx,%rax,8)
movsd 0x2c922(%rip), %xmm3    # 0x31030
movq %r12, %r13
movl 0xc(%rsp), %esi
movq 0x10(%rsp), %rax
movq (%rax), %rax
leaq (%rsi,%rsi,2), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x8(%rax,%rcx,8), %r8
subq %rdi, %r8
je 0x47ea
sarq $0x2, %r8
movq 0x10(%rsp), %r14
movq 0x18(%r14), %r9
movq 0x48(%r14), %r10
xorps %xmm0, %xmm0
cvtsi2sdl (%r9,%rsi,4), %xmm0
movl 0x8(%rsp), %ecx
movq 0x200(%r13), %r11
movq 0x208(%r13), %rbx
movq %rcx, %rax
xorl %edx, %edx
divq %rbx
movq (%r11,%rdx,8), %r12
movq (%r11,%rbx,8), %rdx
movq 0x60(%r14), %rbp
cmpq $0x1, %r8
adcq $0x0, %r8
xorl %r15d, %r15d
movl (%rdi,%r15,4), %r14d
xorps %xmm1, %xmm1
cvtsi2sdl (%r9,%r14,4), %xmm1
divsd %xmm0, %xmm1
movsd (%r10,%rsi,8), %xmm2
addsd %xmm3, %xmm2
mulsd %xmm1, %xmm2
addsd (%r10,%r14,8), %xmm2
movsd %xmm2, (%r10,%r14,8)
testq %r12, %r12
je 0x47be
movq %r12, %rax
cmpl (%rax), %ecx
je 0x47c0
movq 0x20(%rax), %rax
testq %rax, %rax
jne 0x47b1
xorl %eax, %eax
testq %rax, %rax
jne 0x47c9
movq (%r11,%rbx,8), %rax
cmpq %rdx, %rax
je 0x47e2
mulsd (%rbp,%rsi,8), %xmm1
addsd (%rbp,%r14,8), %xmm1
movsd %xmm1, (%rbp,%r14,8)
incq %r15
cmpq %r8, %r15
jne 0x477e
movl 0x8(%rsp), %ecx
cmpl %esi, %ecx
movq %r13, %r12
je 0x4851
cmpb $0x0, 0x18(%rsp)
je 0x4823
movq 0x28(%rsp), %rax
movq (%rax), %rax
movsd (%rax,%rsi,8), %xmm0
mulsd 0x2c827(%rip), %xmm0    # 0x31038
movq 0x20(%rsp), %rax
movq (%rax), %rax
addsd (%rax,%rsi,8), %xmm0
movsd %xmm0, (%rax,%rsi,8)
cmpb $0x0, 0x1c(%rsp)
je 0x4851
movq 0x28(%rsp), %rax
movq (%rax), %rax
movsd (%rax,%rsi,8), %xmm0
mulsd 0x2c801(%rip), %xmm0    # 0x31040
movq 0x20(%rsp), %rax
movq (%rax), %rax
addsd (%rax,%rsi,8), %xmm0
movsd %xmm0, (%rax,%rsi,8)
movq 0x200(%r12), %rsi
movq 0x208(%r12), %rdi
movq %rcx, %rax
xorl %edx, %edx
divq %rdi
movq (%rsi,%rdx,8), %rax
movl $0x0, %edx
testq %rax, %rax
je 0x488b
cmpl (%rax), %ecx
je 0x4888
movq 0x20(%rax), %rax
testq %rax, %rax
jne 0x4877
xorl %edx, %edx
jmp 0x488b
movq %rax, %rdx
testq %rdx, %rdx
jne 0x4894
movq (%rsi,%rdi,8), %rdx
cmpq (%rsi,%rdi,8), %rdx
je 0x4984
movq 0x38(%rsp), %r14
movq %r14, %rdi
leaq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0x6106
movq (%rax), %rbx
movq %r14, %rdi
movq %r15, %rsi
callq 0x6106
movq 0x8(%rax), %rax
cmpq %rax, %rbx
je 0x48e0
xorl %ecx, %ecx
addl (%rbx), %ecx
addq $0x4, %rbx
cmpq %rax, %rbx
jne 0x48cc
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
jmp 0x48e4
xorpd %xmm0, %xmm0
movsd 0x2c744(%rip), %xmm3    # 0x31030
cmpb $0x0, 0x18(%rsp)
je 0x4938
movl 0xc(%rsp), %eax
movq 0x28(%rsp), %rcx
movq (%rcx), %rcx
movq 0x20(%rsp), %rdx
movq (%rdx), %rdx
movsd (%rcx,%rax,8), %xmm1
mulsd %xmm0, %xmm1
addsd (%rdx,%rax,8), %xmm1
movsd %xmm1, (%rdx,%rax,8)
movq 0x30(%rsp), %rcx
movq (%rcx), %rcx
movsd (%rcx,%rax,8), %xmm2
mulsd 0x2c709(%rip), %xmm2    # 0x31038
addsd %xmm1, %xmm2
movsd %xmm2, (%rdx,%rax,8)
cmpb $0x0, 0x1c(%rsp)
je 0x4984
movl 0xc(%rsp), %eax
movq 0x28(%rsp), %rcx
movq (%rcx), %rcx
movq 0x20(%rsp), %rdx
movq (%rdx), %rdx
mulsd (%rcx,%rax,8), %xmm0
movsd (%rdx,%rax,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%rdx,%rax,8)
movq 0x30(%rsp), %rcx
movq (%rcx), %rcx
movsd (%rcx,%rax,8), %xmm0
mulsd 0x2c6c5(%rip), %xmm0    # 0x31040
addsd %xmm1, %xmm0
movsd %xmm0, (%rdx,%rax,8)
movq 0x40(%rsp), %rcx
leaq -0x1(%rcx), %rax
testq %rcx, %rcx
movq %rax, %rcx
jg 0x45c4
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq