// File: fjamour[P]icentral/src/_bc.cc
// Function: BBFS(iter_info_t&, component_t&, unsigned int)
void BBFS(
        iter_info_t&    iter_info,  // iteration info to be computed
        component_t&    comp,       // component
        node_id_t       s          // source of the iteration
        )
{
    subgraph_t& g = comp.subgraph;
    
    vector<vector<node_id_t> >&  P = iter_info.P; 
    vector<int>&                 sigma_vec = iter_info.sigma_vec;
    vector<int>&                 dist_vec = iter_info.dist_vec;
    vector<node_id_t>&           S = iter_info.S;
    
    queue<node_id_t>             Q;
    
    // Assumes iter_info is initialized
    sigma_vec[s] = 1;
    dist_vec[s] = 0;
    Q.push(s);
    while(!Q.empty()) {
        node_id_t v_i = Q.front(); Q.pop();
        S.push_back(v_i);
        for(int i = 0; i < g.nodes_vec[v_i].size(); ++i) {
            node_id_t v_n = g.nodes_vec[v_i][i];
            if(dist_vec[v_n] < 0) {
                Q.push(v_n);
                dist_vec[v_n] = dist_vec[v_i] + 1;
            }
            if(dist_vec[v_n] == dist_vec[v_i] + 1) {
                sigma_vec[v_n] = sigma_vec[v_n] + sigma_vec[v_i];
                P[v_n].push_back(v_i);
            }
        }
    }
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0xd0(%rsp)
movq %rsi, 0xc8(%rsp)
movl %edx, 0xc4(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0xd0(%rsp), %rax
addq $0x18, %rax
movq %rax, 0xa8(%rsp)
movq 0xd0(%rsp), %rax
addq $0x30, %rax
movq %rax, 0xa0(%rsp)
movq 0xd0(%rsp), %rax
addq $0x100, %rax            # imm = 0x100
movq %rax, 0x98(%rsp)
leaq 0x48(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x10580
movq 0xa8(%rsp), %rdi
movl 0xc4(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movl $0x1, (%rax)
movq 0xa0(%rsp), %rdi
movl 0xc4(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movq 0x28(%rsp), %rdi
movl $0x0, (%rax)
leaq 0xc4(%rsp), %rsi
callq 0x105b0
jmp 0xb867
jmp 0xb869
leaq 0x48(%rsp), %rdi
callq 0x105e0
movb %al, 0x27(%rsp)
jmp 0xb879
movb 0x27(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xb888
jmp 0xba6e
leaq 0x48(%rsp), %rdi
callq 0x10600
movq %rax, 0x18(%rsp)
jmp 0xb899
movq 0x18(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x38(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x10610
jmp 0xb8b0
movq 0x98(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0xfce0
jmp 0xb8c4
movl $0x0, 0x34(%rsp)
movslq 0x34(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xb8(%rsp), %rdi
movl 0x38(%rsp), %eax
movl %eax, %esi
callq 0x100e0
movq %rax, %rdi
callq 0xfd50
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
jae 0xba69
movq 0xb8(%rsp), %rdi
movl 0x38(%rsp), %eax
movl %eax, %esi
callq 0x100e0
movq %rax, %rdi
movslq 0x34(%rsp), %rsi
callq 0xfbc0
movl (%rax), %eax
movl %eax, 0x30(%rsp)
movq 0xa0(%rsp), %rdi
movl 0x30(%rsp), %eax
movl %eax, %esi
callq 0xfc50
cmpl $0x0, (%rax)
jge 0xb9a5
leaq 0x48(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x105b0
jmp 0xb951
movq 0xa0(%rsp), %rdi
movl 0x38(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movl (%rax), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
movq 0xa0(%rsp), %rdi
movl 0x30(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movl 0xc(%rsp), %ecx
movl %ecx, (%rax)
jmp 0xb9a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x40(%rsp)
movl %eax, 0x3c(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x10620
jmp 0xba80
movq 0xa0(%rsp), %rdi
movl 0x30(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0x8(%rsp)
movq 0xa0(%rsp), %rdi
movl 0x38(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movq %rax, %rcx
movl 0x8(%rsp), %eax
movl (%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0xba57
movq 0xa8(%rsp), %rdi
movl 0x30(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movl (%rax), %eax
movl %eax, (%rsp)
movq 0xa8(%rsp), %rdi
movl 0x38(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movq %rax, %rcx
movl (%rsp), %eax
movl (%rcx), %ecx
addl %ecx, %eax
movl %eax, 0x4(%rsp)
movq 0xa8(%rsp), %rdi
movl 0x30(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movl 0x4(%rsp), %ecx
movl %ecx, (%rax)
movq 0xb0(%rsp), %rdi
movl 0x30(%rsp), %eax
movl %eax, %esi
callq 0x100e0
movq %rax, %rdi
leaq 0x38(%rsp), %rsi
callq 0xfce0
jmp 0xba55
jmp 0xba57
jmp 0xba59
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0xb8cc
jmp 0xb869
leaq 0x48(%rsp), %rdi
callq 0x10620
addq $0xd8, %rsp
retq
movq 0x40(%rsp), %rdi
callq 0x9cf0
nopw (%rax,%rax)