// File: /workspace/github_cpp_makefile_star2_O1/fjamour[P]icentral/src/_bc.cc
// Function: partial_BBFS_addition(iter_info_t&, component_t&, unsigned int, std::pair<unsigned int, unsigned int>)
void partial_BBFS_addition(
        iter_info_t&    iter_info,  // iteration info to be computed
        component_t&    comp,       // component
        node_id_t       s,          // source of the iteration
        edge_t          e           // inserted edge
        )
{
    subgraph_t& g = comp.subgraph;
    
    vector<vector<node_id_t> >&  P = iter_info.P; 
    vector<int>&                 path_cnt_vec = iter_info.sigma_vec;
    vector<int>&                 path_cnt_inc_map = iter_info.sigma_inc_vec;
    vector<int>&                 dist_map = iter_info.dist_vec;
    vector<bool>&                visited_vec = iter_info.visited_vec;
    vector<node_id_t>&           S = iter_info.S;
    
    queue<node_id_t>             Q;
    node_id_t src, dst;
    if(dist_map[e.first] > dist_map[e.second]) {
        src = e.second;
        dst = e.first;
    } else {
        src = e.first;
        dst = e.second;
    }
        
    //Compute new path counts and paths
    if(dist_map[dst] != dist_map[src]+1) {
        P[dst].clear();
        P[dst].push_back(src);
        path_cnt_vec[dst] = path_cnt_vec[src];
    } else {
        P[dst].push_back(src);
        path_cnt_vec[dst] += path_cnt_vec[src];
    }
        

    Q.push(dst);
    dist_map[dst] = dist_map[src] + 1;
    path_cnt_inc_map[dst] = path_cnt_vec[src];
    visited_vec[dst] = true;

    while (!Q.empty()) {
        node_id_t v = Q.front();
        Q.pop();
        vector<node_id_t> nbr_vec = g.get_nbrs(v);
        for (int nbr_idx = 0; nbr_idx < nbr_vec.size(); ++nbr_idx) {
            node_id_t w = nbr_vec[nbr_idx];
            if (dist_map[w] > (dist_map[v] + 1)) {
                dist_map[w] = dist_map[v] + 1;
                P[w].clear();
                P[w].push_back(v);
                path_cnt_vec[w] = 0;
                path_cnt_inc_map[w] = path_cnt_inc_map[v];
                path_cnt_vec[w] += path_cnt_inc_map[w];
                if (!visited_vec[w]) {
                    visited_vec[w] = true;
                    Q.push(w);
                }
            } else if (dist_map[w] == (dist_map[v] + 1)) {
                path_cnt_inc_map[w] += path_cnt_inc_map[v];
                path_cnt_vec[w] += path_cnt_inc_map[v];
                if (find(P[w].begin(), P[w].end(), v) == P[w].end()) {
                    P[w].push_back(v);
                }
                if (!visited_vec[w]) {
                    visited_vec[w] = true;
                    Q.push(w);
                }
            }
        }
    }


    //fix order of S
    //IMP::THIS CAN BE MADE MUCH BETTER!
    //HEAP FOR EXAMPLE
    //EVEN THE SWAPPING CAN BE DONE MORE EFFICIENTLY
    //for now it's not a bottleneck
    for (int i = 1; i < S.size(); ++i) {
        if (dist_map[S[i - 1]] > dist_map[S[i]]) {
            int j = i;
            while (dist_map[S[j - 1]] > dist_map[S[j]]) {
                node_id_t tmp = S[j - 1];
                S[j - 1] = S[j];
                S[j] = tmp;
                --j;
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rcx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq %rcx, %r12
shrq $0x20, %r12
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0x6b50
movl %r15d, %eax
movq 0x30(%rbx), %rcx
movl (%rcx,%rax,4), %eax
cmpl (%rcx,%r12,4), %eax
movl %r15d, %eax
cmovgl %r12d, %eax
cmovgl %r15d, %r12d
movl %eax, 0x14(%rsp)
movl %r12d, 0x10(%rsp)
movl (%rcx,%rax,4), %edx
incl %edx
leaq (%r12,%r12,2), %rdi
shlq $0x3, %rdi
addq (%rbx), %rdi
cmpl %edx, (%rcx,%r12,4)
jne 0x4a39
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x4a5c
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x4a66
movq (%rdi), %rcx
cmpq %rcx, 0x8(%rdi)
je 0x4a46
movq %rcx, 0x8(%rdi)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x4a7a
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x4a84
leaq 0x14(%rsp), %rdx
callq 0x6f98
movl 0x14(%rsp), %eax
movq 0x18(%rbx), %rcx
movl (%rcx,%rax,4), %eax
movl 0x10(%rsp), %edx
addl %eax, (%rcx,%rdx,4)
jmp 0x4a96
leaq 0x14(%rsp), %rdx
callq 0x6f98
movl 0x14(%rsp), %eax
movq 0x18(%rbx), %rcx
movl (%rcx,%rax,4), %eax
movl 0x10(%rsp), %edx
movl %eax, (%rcx,%rdx,4)
movq 0x60(%rsp), %rax
movq 0x70(%rsp), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x4aba
movl 0x10(%rsp), %ecx
movl %ecx, (%rax)
addq $0x4, %rax
movq %rax, 0x60(%rsp)
jmp 0x4ac9
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x7644
movl 0x14(%rsp), %eax
movq 0x30(%rbx), %rcx
movl (%rcx,%rax,4), %eax
incl %eax
movl 0x10(%rsp), %edx
movl %eax, (%rcx,%rdx,4)
movl 0x14(%rsp), %eax
movq 0x18(%rbx), %rcx
movq 0xc0(%rbx), %rdx
movl (%rcx,%rax,4), %eax
movl 0x10(%rsp), %ecx
movl %eax, (%rdx,%rcx,4)
movl 0x10(%rsp), %ecx
movq 0xd8(%rbx), %rax
movl %ecx, %edx
movl $0x1, %esi
shlq %cl, %rsi
shrl $0x6, %edx
orq %rsi, (%rax,%rdx,8)
movq 0x40(%rsp), %rax
cmpq %rax, 0x60(%rsp)
je 0x4d4e
leaq 0xc(%rsp), %r12
leaq 0x30(%rsp), %r13
leaq 0x8(%rsp), %rbp
movl (%rax), %ecx
movl %ecx, 0xc(%rsp)
movq 0x50(%rsp), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x4b4b
addq $0x4, %rax
jmp 0x4b7d
movq 0x48(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x2250
movq 0x58(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x58(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x48(%rsp)
leaq 0x200(%rax), %rcx
movq %rcx, 0x50(%rsp)
movq %rax, 0x40(%rsp)
movl 0xc(%rsp), %esi
movq %r14, %rdi
callq 0x2ea64
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x61a0
movq 0x18(%rsp), %rdi
cmpq %rdi, 0x20(%rsp)
je 0x4d2c
xorl %r15d, %r15d
movl (%rdi,%r15,4), %eax
movl %eax, 0x8(%rsp)
movq 0x30(%rbx), %rdx
movl 0xc(%rsp), %ecx
movl (%rdx,%rcx,4), %esi
incl %esi
cmpl %esi, (%rdx,%rax,4)
jle 0x4c05
movl %esi, (%rdx,%rax,4)
movl 0x8(%rsp), %eax
movq (%rbx), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rdi
movq (%rdi), %rax
cmpq %rax, 0x8(%rdi)
je 0x4be7
movq %rax, 0x8(%rdi)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x4c79
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x4c81
jne 0x4d03
movq 0xc0(%rbx), %rdx
movl (%rdx,%rcx,4), %ecx
addl %ecx, (%rdx,%rax,4)
movl 0xc(%rsp), %eax
movl (%rdx,%rax,4), %eax
movl 0x8(%rsp), %ecx
movq 0x18(%rbx), %rdx
addl %eax, (%rdx,%rcx,4)
movl 0x8(%rsp), %eax
movq (%rbx), %rcx
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %rdi
movq 0x8(%rcx,%rax,8), %rsi
movq %r12, %rdx
callq 0x7bff
movl 0x8(%rsp), %edx
movq (%rbx), %rcx
leaq (%rdx,%rdx,2), %rdx
movq 0x8(%rcx,%rdx,8), %rsi
cmpq %rsi, %rax
jne 0x4caf
leaq (%rcx,%rdx,8), %rdi
cmpq 0x10(%rdi), %rsi
je 0x4d22
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x4caf
movq %r12, %rdx
callq 0x6f98
movl 0x8(%rsp), %eax
movq 0x18(%rbx), %rcx
movl $0x0, (%rcx,%rax,4)
movl 0xc(%rsp), %eax
movq 0xc0(%rbx), %rdx
movl (%rdx,%rax,4), %eax
movl 0x8(%rsp), %esi
movl %eax, (%rdx,%rsi,4)
movl 0x8(%rsp), %eax
movl (%rdx,%rax,4), %edx
addl %edx, (%rcx,%rax,4)
movl 0x8(%rsp), %ecx
movq 0xd8(%rbx), %rax
movl $0x1, %edx
shlq %cl, %rdx
movl %ecx, %esi
shrl $0x6, %esi
movq (%rax,%rsi,8), %rdi
btq %rcx, %rdi
jb 0x4d03
orq %rdi, %rdx
movq %rdx, (%rax,%rsi,8)
movq 0x60(%rsp), %rax
movq 0x70(%rsp), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rax
je 0x4cf8
movl %ecx, (%rax)
addq $0x4, %rax
movq %rax, 0x60(%rsp)
jmp 0x4d03
movq %r13, %rdi
movq %rbp, %rsi
callq 0x7644
incq %r15
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq %r15, %rax
ja 0x4bae
jmp 0x4d2c
movq %r12, %rdx
callq 0x6f98
jmp 0x4caf
testq %rdi, %rdi
je 0x4d3e
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq 0x40(%rsp), %rax
cmpq %rax, 0x60(%rsp)
jne 0x4b31
movq 0x100(%rbx), %rax
movq 0x108(%rbx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq $0x2, %rcx
jb 0x4dd4
movq 0x30(%rbx), %rdx
addq $-0x2, %rcx
movl $0x1, %esi
xorl %r8d, %r8d
movq %rax, %rdi
movl -0x4(%rax,%rsi,4), %r9d
movl (%rax,%rsi,4), %r10d
movl (%rdx,%r9,4), %r9d
cmpl (%rdx,%r10,4), %r9d
jle 0x4dc1
movl -0x4(%rax,%rsi,4), %r10d
movl (%rax,%rsi,4), %r9d
movl (%rdx,%r10,4), %r11d
cmpl (%rdx,%r9,4), %r11d
jle 0x4dc1
movl %r9d, %r11d
movq %rdi, %rbx
movl %r9d, (%rbx)
movl %r10d, 0x4(%rbx)
movl -0x4(%rbx), %r10d
addq $-0x4, %rbx
movl (%rdx,%r10,4), %ebp
cmpl (%rdx,%r11,4), %ebp
jg 0x4da8
incq %rsi
leaq 0x1(%r8), %r9
addq $0x4, %rdi
cmpq %rcx, %r8
movq %r9, %r8
jne 0x4d7c
leaq 0x30(%rsp), %rdi
callq 0x6998
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4df2
movq %rax, %rbx
jmp 0x4e13
jmp 0x4df9
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x4e13
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
leaq 0x30(%rsp), %rdi
callq 0x6998
movq %rbx, %rdi
callq 0x23b0