// File: fjamour[P]icentral/src/bc.cc
// Function: brandes_betweenness_centrality(graph_t&)
vector<double> brandes_betweenness_centrality(graph_t& graph_in)
{
    vector<double> bc_vec;
    bc_vec.resize(graph_in.size());
    fill(bc_vec.begin(), bc_vec.end(), 0.0);
    
    for(node_id_t s = 0; s < graph_in.size(); ++s) {
        stack<node_id_t>                  S;
        vector<vector<node_id_t> >        P;
        vector<int>                     path_cnt_vec;
        vector<int>                     dist_vec;
        queue<node_id_t>                  Q;
        
        P.resize(graph_in.size());
        path_cnt_vec.resize(graph_in.size());
        fill(path_cnt_vec.begin(), path_cnt_vec.end(), 0);
        path_cnt_vec[s] = 1;
        dist_vec.resize(graph_in.size());
        fill(dist_vec.begin(), dist_vec.end(), -1);
        dist_vec[s] = 0;
        
        Q.push(s);
        
        while(!Q.empty()) {
            node_id_t v = Q.front(); Q.pop();
            S.push(v);
            vector<node_id_t> nbr_vec = graph_in.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_vec[w] < 0) {
                    Q.push(w);
                    dist_vec[w] = dist_vec[v] + 1;
                }
                if(dist_vec[w] == dist_vec[v] + 1) {
                    path_cnt_vec[w] += path_cnt_vec[v];
                    P[w].push_back(v);
                }
            }
        }
        vector<double> pair_dep_vec;
        pair_dep_vec.resize(graph_in.size());
        fill(pair_dep_vec.begin(), pair_dep_vec.end(), 0.0);
        while(!S.empty()) {
            node_id_t w = S.top(); S.pop();
            for(int idx = 0; idx < P[w].size(); ++idx) {
                node_id_t v = P[w][idx];
                pair_dep_vec[v] += (((double)path_cnt_vec[v]/path_cnt_vec[w]) * (1+pair_dep_vec[w]));
            }
            if (w != s) {
                bc_vec[w] += pair_dep_vec[w];
            }
        }
    }
    for(node_id_t i = 0; i < bc_vec.size(); ++i) {
        bc_vec[i] = bc_vec[i]/2;
    }
    return bc_vec;
}

// Assembly:
subq $0x2a8, %rsp            # imm = 0x2A8
movq %rdi, 0xd0(%rsp)
movq %rdi, %rax
movq %rax, 0xd8(%rsp)
movq %rdi, 0x2a0(%rsp)
movq %rsi, 0x298(%rsp)
movb $0x0, 0x297(%rsp)
callq 0xfa00
movq 0x298(%rsp), %rdi
callq 0x56b40
movq %rax, 0xe0(%rsp)
jmp 0x27dbe
movq 0xe0(%rsp), %rsi
movq 0xd0(%rsp), %rdi
callq 0xf680
jmp 0x27dd5
movq 0xd0(%rsp), %rdi
callq 0xf760
movq 0xd0(%rsp), %rdi
movq %rax, 0x278(%rsp)
callq 0xf790
movq %rax, 0x270(%rsp)
movq $0x0, 0x268(%rsp)
movq 0x278(%rsp), %rdi
movq 0x270(%rsp), %rsi
leaq 0x268(%rsp), %rdx
callq 0xf720
jmp 0x27e2a
movl $0x0, 0x264(%rsp)
movl 0x264(%rsp), %eax
movq %rax, 0xc0(%rsp)
movq 0x298(%rsp), %rdi
callq 0x56b40
movq %rax, 0xc8(%rsp)
jmp 0x27e5b
movq 0xc0(%rsp), %rax
movq 0xc8(%rsp), %rcx
cmpq %rcx, %rax
jae 0x2863d
leaq 0x210(%rsp), %rdi
callq 0x21da0
jmp 0x27e83
leaq 0x1f8(%rsp), %rdi
callq 0x10030
leaq 0x1e0(%rsp), %rdi
callq 0xfc40
leaq 0x1c8(%rsp), %rdi
callq 0xfc40
leaq 0x178(%rsp), %rdi
callq 0x10580
jmp 0x27eb9
movq 0x298(%rsp), %rdi
callq 0x56b40
movq %rax, 0xb8(%rsp)
jmp 0x27ed0
movq 0xb8(%rsp), %rsi
leaq 0x1f8(%rsp), %rdi
callq 0x10040
jmp 0x27ee7
movq 0x298(%rsp), %rdi
callq 0x56b40
movq %rax, 0xb0(%rsp)
jmp 0x27efe
movq 0xb0(%rsp), %rsi
leaq 0x1e0(%rsp), %rdi
callq 0x2cfc0
jmp 0x27f15
leaq 0x1e0(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x109f0
movq 0xa8(%rsp), %rdi
movq %rax, 0x170(%rsp)
callq 0x10a20
movq %rax, 0x168(%rsp)
movl $0x0, 0x164(%rsp)
movq 0x170(%rsp), %rdi
movq 0x168(%rsp), %rsi
leaq 0x164(%rsp), %rdx
callq 0x21f20
jmp 0x27f71
movl 0x264(%rsp), %eax
movl %eax, %esi
leaq 0x1e0(%rsp), %rdi
callq 0xfc50
movl $0x1, (%rax)
movq 0x298(%rsp), %rdi
callq 0x56b40
movq %rax, 0xa0(%rsp)
jmp 0x27fa4
movq 0xa0(%rsp), %rsi
leaq 0x1c8(%rsp), %rdi
callq 0x2cfc0
jmp 0x27fbb
leaq 0x1c8(%rsp), %rdi
movq %rdi, 0x98(%rsp)
callq 0x109f0
movq 0x98(%rsp), %rdi
movq %rax, 0x158(%rsp)
callq 0x10a20
movq %rax, 0x150(%rsp)
movl $0xffffffff, 0x14c(%rsp) # imm = 0xFFFFFFFF
movq 0x158(%rsp), %rdi
movq 0x150(%rsp), %rsi
leaq 0x14c(%rsp), %rdx
callq 0x21f20
jmp 0x28017
movl 0x264(%rsp), %eax
movl %eax, %esi
leaq 0x1c8(%rsp), %rdi
callq 0xfc50
movl $0x0, (%rax)
leaq 0x178(%rsp), %rdi
leaq 0x264(%rsp), %rsi
callq 0x105b0
jmp 0x2804a
jmp 0x2804c
leaq 0x178(%rsp), %rdi
callq 0x105e0
movb %al, 0x97(%rsp)
jmp 0x28062
movb 0x97(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x28074
jmp 0x28303
leaq 0x178(%rsp), %rdi
callq 0x10600
movq %rax, 0x88(%rsp)
jmp 0x2808b
movq 0x88(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x148(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x10610
jmp 0x280ab
leaq 0x210(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x21d50
jmp 0x280c2
movq 0x298(%rsp), %rdi
movl 0x148(%rsp), %esi
callq 0x566f0
movq %rax, 0x80(%rsp)
jmp 0x280e0
movq 0x80(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0x10b20
jmp 0x280f7
movl $0x0, 0x12c(%rsp)
movslq 0x12c(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x130(%rsp), %rdi
callq 0xfd50
movq %rax, %rcx
movq 0x78(%rsp), %rax
cmpq %rcx, %rax
jae 0x282f1
movslq 0x12c(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0xfbc0
movl (%rax), %eax
movl %eax, 0x128(%rsp)
movl 0x128(%rsp), %eax
movl %eax, %esi
leaq 0x1c8(%rsp), %rdi
callq 0xfc50
cmpl $0x0, (%rax)
jge 0x2822f
leaq 0x178(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x105b0
jmp 0x28181
movl 0x148(%rsp), %eax
movl %eax, %esi
leaq 0x1c8(%rsp), %rdi
callq 0xfc50
movl (%rax), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
movl 0x128(%rsp), %eax
movl %eax, %esi
leaq 0x1c8(%rsp), %rdi
callq 0xfc50
movl 0x74(%rsp), %ecx
movl %ecx, (%rax)
jmp 0x2822f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
jmp 0x286ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
jmp 0x28604
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
jmp 0x285f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x10520
jmp 0x285f7
movl 0x128(%rsp), %eax
movl %eax, %esi
leaq 0x1c8(%rsp), %rdi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0x70(%rsp)
movl 0x148(%rsp), %eax
movl %eax, %esi
leaq 0x1c8(%rsp), %rdi
callq 0xfc50
movq %rax, %rcx
movl 0x70(%rsp), %eax
movl (%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x282d9
movl 0x148(%rsp), %eax
movl %eax, %esi
leaq 0x1e0(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0xfc50
movq 0x60(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x6c(%rsp)
movl 0x128(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movl 0x6c(%rsp), %edx
movl (%rax), %ecx
addl %edx, %ecx
movl %ecx, (%rax)
movl 0x128(%rsp), %eax
movl %eax, %esi
leaq 0x1f8(%rsp), %rdi
callq 0x100e0
movq %rax, %rdi
leaq 0x148(%rsp), %rsi
callq 0xfce0
jmp 0x282d7
jmp 0x282d9
jmp 0x282db
movl 0x12c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x12c(%rsp)
jmp 0x28102
leaq 0x130(%rsp), %rdi
callq 0x10520
jmp 0x2804c
leaq 0x110(%rsp), %rdi
callq 0xfa00
movq 0x298(%rsp), %rdi
callq 0x56b40
movq %rax, 0x58(%rsp)
jmp 0x28324
movq 0x58(%rsp), %rsi
leaq 0x110(%rsp), %rdi
callq 0xf680
jmp 0x28338
leaq 0x110(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0xf760
movq 0x50(%rsp), %rdi
movq %rax, 0x108(%rsp)
callq 0xf790
movq %rax, 0x100(%rsp)
movq $0x0, 0xf8(%rsp)
movq 0x108(%rsp), %rdi
movq 0x100(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
callq 0xf720
jmp 0x2838f
jmp 0x28391
leaq 0x210(%rsp), %rdi
callq 0x21ee0
movb %al, 0x4f(%rsp)
jmp 0x283a4
movb 0x4f(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x283b3
jmp 0x28593
leaq 0x210(%rsp), %rdi
callq 0x21f00
movq %rax, 0x40(%rsp)
jmp 0x283c7
movq 0x40(%rsp), %rax
movl (%rax), %eax
movl %eax, 0xf4(%rsp)
leaq 0x210(%rsp), %rdi
callq 0x21f10
jmp 0x283e4
movl $0x0, 0xf0(%rsp)
movslq 0xf0(%rsp), %rax
movq %rax, 0x38(%rsp)
movl 0xf4(%rsp), %eax
movl %eax, %esi
leaq 0x1f8(%rsp), %rdi
callq 0x100e0
movq %rax, %rdi
callq 0xfd50
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
jae 0x2853a
movl 0xf4(%rsp), %eax
movl %eax, %esi
leaq 0x1f8(%rsp), %rdi
callq 0x100e0
movq %rax, %rdi
movslq 0xf0(%rsp), %rsi
callq 0xfbc0
movl (%rax), %eax
movl %eax, 0xec(%rsp)
movl 0xec(%rsp), %eax
movl %eax, %esi
leaq 0x1e0(%rsp), %rdi
callq 0xfc50
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movl 0xf4(%rsp), %eax
movl %eax, %esi
leaq 0x1e0(%rsp), %rdi
callq 0xfc50
movsd 0x20(%rsp), %xmm0
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movl 0xf4(%rsp), %eax
movl %eax, %esi
leaq 0x110(%rsp), %rdi
callq 0xfa30
movsd 0x52b4e(%rip), %xmm0    # 0x7b010
addsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movl 0xec(%rsp), %eax
movl %eax, %esi
leaq 0x110(%rsp), %rdi
callq 0xfa30
movsd 0x28(%rsp), %xmm0
movsd 0x30(%rsp), %xmm2
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl 0xf0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf0(%rsp)
jmp 0x283ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x110(%rsp), %rdi
callq 0xfa50
jmp 0x285f7
movl 0xf4(%rsp), %eax
cmpl 0x264(%rsp), %eax
je 0x2858e
movl 0xf4(%rsp), %eax
movl %eax, %esi
leaq 0x110(%rsp), %rdi
callq 0xfa30
movq 0xd0(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movl 0xf4(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x18(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
jmp 0x28391
leaq 0x110(%rsp), %rdi
callq 0xfa50
leaq 0x178(%rsp), %rdi
callq 0x10620
leaq 0x1c8(%rsp), %rdi
callq 0xfc70
leaq 0x1e0(%rsp), %rdi
callq 0xfc70
leaq 0x1f8(%rsp), %rdi
callq 0x104c0
leaq 0x210(%rsp), %rdi
callq 0x21e40
movl 0x264(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x264(%rsp)
jmp 0x27e35
leaq 0x178(%rsp), %rdi
callq 0x10620
leaq 0x1c8(%rsp), %rdi
callq 0xfc70
leaq 0x1e0(%rsp), %rdi
callq 0xfc70
leaq 0x1f8(%rsp), %rdi
callq 0x104c0
leaq 0x210(%rsp), %rdi
callq 0x21e40
jmp 0x286ff
movl $0x0, 0xe8(%rsp)
movq 0xd0(%rsp), %rdi
movl 0xe8(%rsp), %eax
movq %rax, 0x10(%rsp)
callq 0xfa10
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
jae 0x286d0
movq 0xd0(%rsp), %rdi
movl 0xe8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movq 0xd0(%rsp), %rdi
movsd (%rax), %xmm0
movsd 0x52970(%rip), %xmm1    # 0x7b008
divsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movl 0xe8(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0xe8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe8(%rsp)
jmp 0x28648
movb $0x1, 0x297(%rsp)
testb $0x1, 0x297(%rsp)
jne 0x286ef
movq 0xd0(%rsp), %rdi
callq 0xfa50
movq 0xd8(%rsp), %rax
addq $0x2a8, %rsp            # imm = 0x2A8
retq
movq 0xd0(%rsp), %rdi
callq 0xfa50
movq 0x288(%rsp), %rdi
callq 0x9cf0
nopl (%rax)