// File: /workspace/github_cpp_makefile_star2_O3/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 0x6ad0
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 0x4a42
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x4a67
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x4a71
movq (%rdi), %rcx
movq 0x8(%rdi), %rsi
cmpq %rcx, %rsi
je 0x4a55
movq %rcx, 0x8(%rdi)
movq %rcx, %rsi
cmpq 0x10(%rdi), %rsi
je 0x4a85
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x4a8f
leaq 0x14(%rsp), %rdx
callq 0x6f14
movl 0x14(%rsp), %eax
movq 0x18(%rbx), %rcx
movl (%rcx,%rax,4), %eax
movl 0x10(%rsp), %edx
addl %eax, (%rcx,%rdx,4)
jmp 0x4aa1
leaq 0x14(%rsp), %rdx
callq 0x6f14
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), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rax
je 0x4ac5
movl 0x10(%rsp), %edx
movl %edx, (%rax)
addq $0x4, %rax
movq %rax, 0x60(%rsp)
jmp 0x4ae1
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x75be
movl 0x10(%rsp), %edx
movq 0x18(%rbx), %rcx
movq 0x60(%rsp), %rax
movl 0x14(%rsp), %esi
movq 0x30(%rbx), %rdi
movl (%rdi,%rsi,4), %esi
incl %esi
movl %edx, %edx
movl %esi, (%rdi,%rdx,4)
movl 0x14(%rsp), %edx
movl (%rcx,%rdx,4), %ecx
movl 0x10(%rsp), %edx
movq 0xc0(%rbx), %rsi
movl %ecx, (%rsi,%rdx,4)
movl 0x10(%rsp), %ecx
movq 0xd8(%rbx), %rdx
movl %ecx, %esi
movl $0x1, %edi
shlq %cl, %rdi
shrl $0x6, %esi
orq %rdi, (%rdx,%rsi,8)
movq 0x40(%rsp), %rcx
cmpq %rcx, %rax
je 0x4d60
leaq 0xc(%rsp), %r12
leaq 0x30(%rsp), %r13
leaq 0x8(%rsp), %rbp
movl (%rcx), %esi
movl %esi, 0xc(%rsp)
movq 0x50(%rsp), %rax
addq $-0x4, %rax
cmpq %rax, %rcx
je 0x4b5b
addq $0x4, %rcx
jmp 0x4b91
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), %rcx
movq %rcx, 0x48(%rsp)
leaq 0x200(%rcx), %rax
movq %rax, 0x50(%rsp)
movl 0xc(%rsp), %esi
movq %rcx, 0x40(%rsp)
movq %r14, %rdi
callq 0x2e734
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x6112
movq 0x18(%rsp), %rdi
cmpq %rdi, 0x20(%rsp)
je 0x4d3e
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 0x4c17
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
movq 0x8(%rdi), %rsi
cmpq %rax, %rsi
je 0x4bfd
movq %rax, 0x8(%rdi)
movq %rax, %rsi
cmpq 0x10(%rdi), %rsi
je 0x4c8b
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x4c93
jne 0x4d15
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 0x7b97
movl 0x8(%rsp), %edx
movq (%rbx), %rcx
leaq (%rdx,%rdx,2), %rdx
movq 0x8(%rcx,%rdx,8), %rsi
cmpq %rsi, %rax
jne 0x4cc1
leaq (%rcx,%rdx,8), %rdi
cmpq 0x10(%rdi), %rax
je 0x4d34
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x4cc1
movq %r12, %rdx
callq 0x6f14
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 0x4d15
orq %rdi, %rdx
movq %rdx, (%rax,%rsi,8)
movq 0x60(%rsp), %rax
movq 0x70(%rsp), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rax
je 0x4d0a
movl %ecx, (%rax)
addq $0x4, %rax
movq %rax, 0x60(%rsp)
jmp 0x4d15
movq %r13, %rdi
movq %rbp, %rsi
callq 0x75be
incq %r15
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq %r15, %rax
ja 0x4bbe
jmp 0x4d3e
movq %r12, %rdx
callq 0x6f14
jmp 0x4cc1
testq %rdi, %rdi
je 0x4d50
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq 0x40(%rsp), %rcx
cmpq %rcx, 0x60(%rsp)
jne 0x4b41
movq 0x100(%rbx), %rax
movq 0x108(%rbx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq $0x2, %rcx
jb 0x4dd3
movq 0x30(%rbx), %rdx
addq $-0x2, %rcx
movl $0x1, %esi
xorl %r8d, %r8d
movq %rax, %rdi
movl -0x4(%rax,%rsi,4), %r10d
movl (%rax,%rsi,4), %r9d
movl (%rdx,%r10,4), %r11d
cmpl (%rdx,%r9,4), %r11d
jle 0x4dc0
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 0x4da7
incq %rsi
leaq 0x1(%r8), %r9
addq $0x4, %rdi
cmpq %rcx, %r8
movq %r9, %r8
jne 0x4d8e
leaq 0x30(%rsp), %rdi
callq 0x690a
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4df1
movq %rax, %rbx
jmp 0x4e12
jmp 0x4df8
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x4e12
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
leaq 0x30(%rsp), %rdi
callq 0x690a
movq %rbx, %rdi
callq 0x23b0