// File: 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:
subq $0x238, %rsp            # imm = 0x238
movl %r8d, 0xcc(%rsp)
movq %rcx, %rax
movl 0xcc(%rsp), %ecx
movq %rax, 0xd0(%rsp)
movl %edx, %eax
movq 0xd0(%rsp), %rdx
movl %eax, 0xdc(%rsp)
movq %rsi, %rax
movl 0xdc(%rsp), %esi
movq %rax, 0xe0(%rsp)
movq %rdi, %r8
movq 0xe0(%rsp), %rdi
movb %r9b, %al
movq %r8, 0x230(%rsp)
movq %rdi, 0x228(%rsp)
movl %esi, 0x224(%rsp)
movq %rdx, 0x218(%rsp)
andb $0x1, %cl
movb %cl, 0x217(%rsp)
andb $0x1, %al
movb %al, 0x216(%rsp)
movq 0x218(%rsp), %rax
movq %rax, 0x208(%rsp)
movq 0x218(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x200(%rsp)
movq 0x218(%rsp), %rax
addq $0x48, %rax
movq %rax, 0x1f8(%rsp)
movq 0x218(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x1f0(%rsp)
movq 0x218(%rsp), %rax
addq $0x100, %rax            # imm = 0x100
movq %rax, 0x1e8(%rsp)
movq 0x1f8(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq 0x228(%rsp), %rdi
callq 0x77430
movq 0xe8(%rsp), %rdi
movq %rax, %rsi
xorps %xmm0, %xmm0
callq 0xfbe0
movq 0x228(%rsp), %rax
cmpl $0x2, 0x228(%rax)
jne 0xbe3e
movq 0x1e8(%rsp), %rdi
callq 0xfd50
subq $0x1, %rax
movl %eax, 0x1e4(%rsp)
cmpl $0x0, 0x1e4(%rsp)
jl 0xbe39
movq 0x1e8(%rsp), %rdi
movslq 0x1e4(%rsp), %rsi
callq 0xfbc0
movl (%rax), %eax
movl %eax, 0x1e0(%rsp)
movl $0x0, 0x1dc(%rsp)
movslq 0x1dc(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0x208(%rsp), %rdi
movl 0x1e0(%rsp), %eax
movl %eax, %esi
callq 0x100e0
movq %rax, %rdi
callq 0xfd50
movq %rax, %rcx
movq 0xc0(%rsp), %rax
cmpq %rcx, %rax
jae 0xbd47
movq 0x208(%rsp), %rdi
movl 0x1e0(%rsp), %eax
movl %eax, %esi
callq 0x100e0
movq %rax, %rdi
movslq 0x1dc(%rsp), %rsi
callq 0xfbc0
movl (%rax), %eax
movl %eax, 0x1d8(%rsp)
movq 0x200(%rsp), %rdi
movl 0x1d8(%rsp), %eax
movl %eax, %esi
callq 0xfc50
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, 0xa8(%rsp)
movq 0x200(%rsp), %rdi
movl 0x1e0(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movsd 0xa8(%rsp), %xmm0
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
movq 0x1f8(%rsp), %rdi
movl 0x1e0(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x6f324(%rip), %xmm0    # 0x7b010
addsd (%rax), %xmm0
movsd %xmm0, 0xb8(%rsp)
movq 0x1f8(%rsp), %rdi
movl 0x1d8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0xb0(%rsp), %xmm0
movsd 0xb8(%rsp), %xmm2
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl 0x1dc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1dc(%rsp)
jmp 0xbc0a
movl 0x1e0(%rsp), %eax
cmpl 0x224(%rsp), %eax
je 0xbe21
testb $0x1, 0x217(%rsp)
je 0xbdbb
movq 0x1f8(%rsp), %rdi
movl 0x1e0(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd (%rax), %xmm0
movsd 0x6f281(%rip), %xmm1    # 0x7b008
divsd %xmm1, %xmm0
movsd %xmm0, 0xa0(%rsp)
movq 0x230(%rsp), %rdi
movl 0x1e0(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0xa0(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
testb $0x1, 0x216(%rsp)
je 0xbe1f
movq 0x1f8(%rsp), %rdi
movl 0x1e0(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd (%rax), %xmm0
movsd 0x6f221(%rip), %xmm1    # 0x7b008
divsd %xmm1, %xmm0
movsd %xmm0, 0x98(%rsp)
movq 0x230(%rsp), %rdi
movl 0x1e0(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x98(%rsp), %xmm1
movsd (%rax), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%rax)
jmp 0xbe21
jmp 0xbe23
movl 0x1e4(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x1e4(%rsp)
jmp 0xbbd3
jmp 0xc674
movq 0x228(%rsp), %rax
cmpl $0x0, 0x228(%rax)
jne 0xc672
movq 0x1f0(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x228(%rsp), %rdi
callq 0x77430
movq 0x90(%rsp), %rdi
movq %rax, %rsi
xorps %xmm0, %xmm0
callq 0xfbe0
movq 0x228(%rsp), %rax
addq $0x1f8, %rax            # imm = 0x1F8
movq %rax, 0x1d0(%rsp)
movq 0x1e8(%rsp), %rdi
callq 0xfd50
subq $0x1, %rax
movl %eax, 0x1cc(%rsp)
cmpl $0x0, 0x1cc(%rsp)
jl 0xc670
movq 0x1e8(%rsp), %rdi
movslq 0x1cc(%rsp), %rsi
callq 0xfbc0
movl (%rax), %eax
movl %eax, 0x1c8(%rsp)
movq 0x1d0(%rsp), %rdi
leaq 0x224(%rsp), %rsi
callq 0x10650
movq %rax, 0x1b8(%rsp)
movq %rdx, 0x1c0(%rsp)
movq 0x1d0(%rsp), %rdi
callq 0x10710
movq %rax, 0x1a8(%rsp)
movq %rdx, 0x1b0(%rsp)
leaq 0x1b8(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x10630
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x8f(%rsp)
jne 0xbf46
jmp 0xbfa4
movq 0x1d0(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0x10650
movq %rax, 0x198(%rsp)
movq %rdx, 0x1a0(%rsp)
movq 0x1d0(%rsp), %rdi
callq 0x10710
movq %rax, 0x188(%rsp)
movq %rdx, 0x190(%rsp)
leaq 0x198(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0x10630
movb %al, 0x8f(%rsp)
movb 0x8f(%rsp), %al
testb $0x1, %al
jne 0xbfb4
jmp 0xc0ed
movq 0x1d0(%rsp), %rdi
leaq 0x224(%rsp), %rsi
callq 0x107b0
movq %rax, %rdi
callq 0x109f0
movq %rax, 0x178(%rsp)
movq 0x1d0(%rsp), %rdi
leaq 0x224(%rsp), %rsi
callq 0x107b0
movq %rax, %rdi
callq 0x10a20
movq %rax, 0x170(%rsp)
movq 0x178(%rsp), %rdi
movq 0x170(%rsp), %rsi
xorl %edx, %edx
callq 0x10750
movl %eax, 0x184(%rsp)
movq 0x1d0(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0x107b0
movq %rax, %rdi
callq 0x109f0
movq %rax, 0x168(%rsp)
movq 0x1d0(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0x107b0
movq %rax, %rdi
callq 0x10a20
movq %rax, 0x160(%rsp)
movq 0x168(%rsp), %rdi
movq 0x160(%rsp), %rsi
xorl %edx, %edx
callq 0x10750
movl %eax, 0x180(%rsp)
movl 0x184(%rsp), %eax
imull 0x180(%rsp), %eax
movl %eax, 0x15c(%rsp)
movq 0x1f0(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd (%rax), %xmm0
cvtsi2sdl 0x15c(%rsp), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x80(%rsp)
movq 0x1f0(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x80(%rsp), %xmm0
movsd %xmm0, (%rax)
movl $0x0, 0x158(%rsp)
movslq 0x158(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x208(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0x100e0
movq %rax, %rdi
callq 0xfd50
movq %rax, %rcx
movq 0x78(%rsp), %rax
cmpq %rcx, %rax
jae 0xc327
movq 0x208(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0x100e0
movq %rax, %rdi
movslq 0x158(%rsp), %rsi
callq 0xfbc0
movl (%rax), %eax
movl %eax, 0x154(%rsp)
movq 0x200(%rsp), %rdi
movl 0x154(%rsp), %eax
movl %eax, %esi
callq 0xfc50
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
movq 0x200(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movsd 0x58(%rsp), %xmm0
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x148(%rsp)
movq 0x1f8(%rsp), %rdi
movl 0x154(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd (%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x148(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0x1f8(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x60(%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
movsd 0x6ee07(%rip), %xmm2    # 0x7b010
addsd (%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x70(%rsp)
movq 0x1f8(%rsp), %rdi
movl 0x154(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x70(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x1d0(%rsp), %rdi
leaq 0x224(%rsp), %rsi
callq 0x10650
movq %rax, 0x138(%rsp)
movq %rdx, 0x140(%rsp)
movq 0x1d0(%rsp), %rdi
callq 0x10710
movq %rax, 0x128(%rsp)
movq %rdx, 0x130(%rsp)
leaq 0x138(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x10630
testb $0x1, %al
jne 0xc298
jmp 0xc30f
movq 0x1f0(%rsp), %rdi
movl 0x154(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd (%rax), %xmm0
movsd %xmm0, 0x48(%rsp)
movq 0x1f0(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x48(%rsp), %xmm1
movsd (%rax), %xmm0
movsd 0x148(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0x1f0(%rsp), %rdi
movl 0x154(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x50(%rsp), %xmm0
movsd %xmm0, (%rax)
jmp 0xc311
movl 0x158(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x158(%rsp)
jmp 0xc0f8
movl 0x224(%rsp), %eax
cmpl 0x1c8(%rsp), %eax
je 0xc3f5
testb $0x1, 0x217(%rsp)
je 0xc395
movq 0x1f8(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd (%rax), %xmm0
movsd 0x6eca1(%rip), %xmm1    # 0x7b008
divsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x230(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x40(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
testb $0x1, 0x216(%rsp)
je 0xc3f3
movq 0x1f8(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd (%rax), %xmm0
movsd 0x6ec47(%rip), %xmm1    # 0x7b008
divsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x230(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x38(%rsp), %xmm1
movsd (%rax), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%rax)
jmp 0xc3f5
movq 0x1d0(%rsp), %rdi
leaq 0x224(%rsp), %rsi
callq 0x10650
movq %rax, 0x118(%rsp)
movq %rdx, 0x120(%rsp)
movq 0x1d0(%rsp), %rdi
callq 0x10710
movq %rax, 0x108(%rsp)
movq %rdx, 0x110(%rsp)
leaq 0x118(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x10630
testb $0x1, %al
jne 0xc455
jmp 0xc658
movq 0x1d0(%rsp), %rdi
leaq 0x224(%rsp), %rsi
callq 0x107b0
movq %rax, %rdi
callq 0x109f0
movq %rax, 0xf8(%rsp)
movq 0x1d0(%rsp), %rdi
leaq 0x224(%rsp), %rsi
callq 0x107b0
movq %rax, %rdi
callq 0x10a20
movq %rax, 0xf0(%rsp)
movq 0xf8(%rsp), %rdi
movq 0xf0(%rsp), %rsi
xorl %edx, %edx
callq 0x10750
movl %eax, 0x104(%rsp)
testb $0x1, 0x217(%rsp)
je 0xc57c
movq 0x1f8(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
cvtsi2sdl 0x104(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x230(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm2
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movq 0x1f0(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd (%rax), %xmm0
movsd 0x6eaba(%rip), %xmm1    # 0x7b008
divsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x230(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x30(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
testb $0x1, 0x216(%rsp)
je 0xc656
movq 0x1f8(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
cvtsi2sdl 0x104(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x230(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x8(%rsp), %xmm0
movsd 0x10(%rsp), %xmm2
movsd (%rax), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movq 0x1f0(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd (%rax), %xmm0
movsd 0x6e9e4(%rip), %xmm1    # 0x7b008
divsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x230(%rsp), %rdi
movl 0x1c8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x18(%rsp), %xmm1
movsd (%rax), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%rax)
jmp 0xc658
jmp 0xc65a
movl 0x1cc(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x1cc(%rsp)
jmp 0xbeb1
jmp 0xc672
jmp 0xc674
addq $0x238, %rsp            # imm = 0x238
retq
nopl (%rax)