// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
movq %rsi, 0x18(%rsp)
movq %rdi, %rbx
movq %rcx, %r15
shrq $0x20, %r15
leaq 0x38(%rsp), %rdi
callq 0x4a40
movl %r14d, %eax
movq 0x30(%rbx), %rcx
movl (%rcx,%rax,4), %eax
cmpl (%rcx,%r15,4), %eax
movl %r14d, %eax
cmovgl %r15d, %eax
cmovgl %r14d, %r15d
movl %eax, 0x10(%rsp)
movl %r15d, 0xc(%rsp)
movl (%rcx,%rax,4), %eax
incl %eax
imulq $0x18, %r15, %rdi
addq (%rbx), %rdi
cmpl %eax, (%rcx,%r15,4)
jne 0x3929
leaq 0x10(%rsp), %rsi
callq 0x478c
movl 0x10(%rsp), %eax
movq 0x18(%rbx), %rcx
movl (%rcx,%rax,4), %eax
movl 0xc(%rsp), %edx
addl %eax, (%rcx,%rdx,4)
jmp 0x3952
movq (%rdi), %rax
cmpq %rax, 0x8(%rdi)
je 0x3936
movq %rax, 0x8(%rdi)
leaq 0x10(%rsp), %rsi
callq 0x478c
movl 0x10(%rsp), %eax
movq 0x18(%rbx), %rcx
movl (%rcx,%rax,4), %eax
movl 0xc(%rsp), %edx
movl %eax, (%rcx,%rdx,4)
leaq 0x38(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x62da
leaq 0xd8(%rbx), %r15
movl 0x10(%rsp), %eax
movq 0x30(%rbx), %rcx
movl (%rcx,%rax,4), %eax
incl %eax
movl 0xc(%rsp), %edx
movl %eax, (%rcx,%rdx,4)
movl 0x10(%rsp), %eax
movq 0x18(%rbx), %rcx
movq 0xc0(%rbx), %rdx
movl (%rcx,%rax,4), %eax
movl 0xc(%rsp), %ecx
movl %eax, (%rdx,%rcx,4)
movl 0xc(%rsp), %esi
movq %r15, %rdi
callq 0x4b82
orq %rdx, (%rax)
leaq 0x38(%rsp), %r12
leaq 0x20(%rsp), %r13
leaq 0x14(%rsp), %rbp
leaq 0x8(%rsp), %r14
movq 0x48(%rsp), %rax
cmpq %rax, 0x68(%rsp)
je 0x3b40
movl (%rax), %eax
movl %eax, 0x14(%rsp)
movq %r12, %rdi
callq 0x650e
movl 0x14(%rsp), %esi
movq 0x18(%rsp), %rdi
callq 0x25fe0
movq %r13, %rdi
movq %rax, %rsi
callq 0x4ba0
xorl %r13d, %r13d
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r13, %rcx
jbe 0x3b2e
movl (%rax,%r13,4), %eax
movl %eax, 0x8(%rsp)
movq 0x30(%rbx), %rdx
movl 0x14(%rsp), %ecx
movl (%rdx,%rcx,4), %esi
incl %esi
cmpl %esi, (%rdx,%rax,4)
jle 0x3a9d
movl %esi, (%rdx,%rax,4)
movl 0x8(%rsp), %eax
movq (%rbx), %rcx
imulq $0x18, %rax, %rdx
leaq (%rcx,%rdx), %rdi
movq (%rcx,%rdx), %rax
cmpq %rax, 0x8(%rcx,%rdx)
je 0x3a47
movq %rax, 0x8(%rdi)
movq %rbp, %rsi
callq 0x478c
movl 0x8(%rsp), %eax
movq 0x18(%rbx), %rcx
andl $0x0, (%rcx,%rax,4)
movl 0x14(%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), %esi
movq %r15, %rdi
callq 0x4b82
testq %rdx, (%rax)
jne 0x3b26
movl 0x8(%rsp), %esi
movq %r15, %rdi
callq 0x4b82
jmp 0x3b18
jne 0x3b26
movq 0xc0(%rbx), %rdx
movl (%rdx,%rcx,4), %ecx
addl %ecx, (%rdx,%rax,4)
movl 0x14(%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
imulq $0x18, %rax, %rax
movq (%rcx,%rax), %rdi
movq 0x8(%rcx,%rax), %rsi
movq %rbp, %rdx
callq 0x688c
movl 0x8(%rsp), %esi
movq (%rbx), %rdi
imulq $0x18, %rsi, %rcx
cmpq 0x8(%rdi,%rcx), %rax
jne 0x3aff
addq %rcx, %rdi
movq %rbp, %rsi
callq 0x478c
movl 0x8(%rsp), %esi
movq %r15, %rdi
callq 0x4b82
testq %rdx, (%rax)
jne 0x3b26
movl 0x8(%rsp), %esi
movq %r15, %rdi
callq 0x4b82
orq %rdx, (%rax)
movq %r12, %rdi
movq %r14, %rsi
callq 0x62da
incq %r13
jmp 0x39f2
leaq 0x20(%rsp), %r13
movq %r13, %rdi
callq 0x56ec
jmp 0x39b8
movq 0x108(%rbx), %rax
movq 0x30(%rbx), %rcx
movq 0x100(%rbx), %rdx
subq %rdx, %rax
sarq $0x2, %rax
pushq $0x1
popq %rsi
movq %rdx, %rdi
cmpq %rsi, %rax
jbe 0x3b9d
movl -0x4(%rdx,%rsi,4), %r9d
movl (%rdx,%rsi,4), %r8d
movl (%rcx,%r8,4), %r10d
cmpl %r10d, (%rcx,%r9,4)
jle 0x3b94
movq %rdi, %r9
movl (%r9), %r11d
cmpl %r10d, (%rcx,%r11,4)
jle 0x3b94
movl %r8d, (%r9)
movl %r11d, 0x4(%r9)
movl (%rcx,%r8,4), %r10d
addq $-0x4, %r9
jmp 0x3b7a
incq %rsi
addq $0x4, %rdi
jmp 0x3b5f
leaq 0x38(%rsp), %rdi
callq 0x5280
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3bbd
jmp 0x3bbd
movq %rax, %rbx
jmp 0x3bd9
jmp 0x3bcc
jmp 0x3bcc
jmp 0x3bcc
jmp 0x3bcc
jmp 0x3bcc
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x56ec
leaq 0x38(%rsp), %rdi
callq 0x5280
movq %rbx, %rdi
callq 0x23d0