// File: fjamour[P]icentral/src/bc.cc
// Function: naive_betweenness_centrality(graph_t&)
vector<double> naive_betweenness_centrality(graph_t& graph_in)
{
    vector<double> bc_vec;
    bc_vec.resize(graph_in.size());
    
    /*1. find all-pair shortest paths and store in a n^2 array*/
    /*2. find all-pair shortest paths count and store in a x^2 array*/
    /*3. do the three nested loops to find BC of each node*/
    
    vector<vector<int> > dst_2vec;      //all-pair distance array
    vector<vector<int> > cnt_2vec;      //all-pair shortest path count array
    dst_2vec.resize(graph_in.size());
    cnt_2vec.resize(graph_in.size());
    
    vector<int> tmp_vec;
    tmp_vec.resize(graph_in.size());
    
 
    /*Floyd-Warshall to compute all-pair shortest paths*/
    /*init distance with (infinity)*/
    fill(tmp_vec.begin(), tmp_vec.end(), INF);
    fill(dst_2vec.begin(), dst_2vec.end(), tmp_vec);
    /*update distance for immediate neighbors*/
    for(node_id_t i = 0; i < graph_in.size(); i++) {
        dst_2vec[i][i] = 0;
        for(int j = 0; j < graph_in.get_nbrs(i).size(); j++) {
            node_id_t nbr_id = graph_in.get_nbrs(i)[j];
            dst_2vec[i][nbr_id] = 1;
        }
    }
    for(int k = 0; k < graph_in.size(); ++k) {
        for(int i = 0; i < dst_2vec.size(); ++i) {
            for(int j = 0; j < dst_2vec.size(); ++j) {
                if(dst_2vec[i][j] > dst_2vec[i][k] + dst_2vec[k][j]) {
                    dst_2vec[i][j] = dst_2vec[i][k] + dst_2vec[k][j];
                }
            }
        }
    }
    
    /*Floyd-Warshall like algorithm to compute all-pair shortest paths counts*/
    /*init counts with 0*/
    fill(tmp_vec.begin(), tmp_vec.end(), 0);
    fill(cnt_2vec.begin(), cnt_2vec.end(), tmp_vec);
    /*update counts for immediate neighbors*/
    for(node_id_t i = 0; i < graph_in.size(); i++) {
        cnt_2vec[i][i] = 0;
        for(int j = 0; j < graph_in.get_nbrs(i).size(); j++) {
            node_id_t nbr_id = graph_in.get_nbrs(i)[j];
            cnt_2vec[i][nbr_id] = 1;
        }
    }
    for(int k = 0; k < graph_in.size(); ++k) {
        for(int i = 0; i < cnt_2vec.size(); ++i) {
            for(int j = 0; j < cnt_2vec.size(); ++j) {
                if(dst_2vec[i][j] == dst_2vec[i][k] + dst_2vec[k][j]) {
                    cnt_2vec[i][j] += cnt_2vec[i][k] * cnt_2vec[k][j];
                }
            }
        }
    }
    /*betweenness centrality computation*/
    for(node_id_t s = 0; s < graph_in.size(); ++s) {
        for(node_id_t t = 0; t < graph_in.size(); ++t) {
            for(node_id_t v = 0; v < bc_vec.size(); ++v) {
                if(s != v && v != t && s != t) {
                    if(dst_2vec[s][t] == dst_2vec[s][v] + dst_2vec[v][t]) {
                        bc_vec[v] += (cnt_2vec[s][v]*cnt_2vec[v][t]/(double)cnt_2vec[s][t]);
                    }
                }
            }
        }
    }
    
    for(node_id_t i = 0; i < bc_vec.size(); ++i) {
        bc_vec[i] = bc_vec[i]/2;
    }     
    return bc_vec;
}

// Assembly:
subq $0x258, %rsp            # imm = 0x258
movq %rdi, 0x140(%rsp)
movq %rdi, %rax
movq %rax, 0x148(%rsp)
movq %rdi, 0x250(%rsp)
movq %rsi, 0x248(%rsp)
movb $0x0, 0x247(%rsp)
callq 0xfa00
movq 0x248(%rsp), %rdi
callq 0x56b40
movq %rax, 0x150(%rsp)
jmp 0x2701e
movq 0x150(%rsp), %rsi
movq 0x140(%rsp), %rdi
callq 0xf680
jmp 0x27035
leaq 0x218(%rsp), %rdi
callq 0x2cf10
leaq 0x200(%rsp), %rdi
callq 0x2cf10
movq 0x248(%rsp), %rdi
callq 0x56b40
movq %rax, 0x138(%rsp)
jmp 0x27066
movq 0x138(%rsp), %rsi
leaq 0x218(%rsp), %rdi
callq 0x2cf20
jmp 0x2707d
movq 0x248(%rsp), %rdi
callq 0x56b40
movq %rax, 0x130(%rsp)
jmp 0x27094
movq 0x130(%rsp), %rsi
leaq 0x200(%rsp), %rdi
callq 0x2cf20
jmp 0x270ab
leaq 0x1e8(%rsp), %rdi
callq 0xfc40
movq 0x248(%rsp), %rdi
callq 0x56b40
movq %rax, 0x128(%rsp)
jmp 0x270cf
movq 0x128(%rsp), %rsi
leaq 0x1e8(%rsp), %rdi
callq 0x2cfc0
jmp 0x270e6
leaq 0x1e8(%rsp), %rdi
movq %rdi, 0x120(%rsp)
callq 0x109f0
movq 0x120(%rsp), %rdi
movq %rax, 0x1e0(%rsp)
callq 0x10a20
movq %rax, 0x1d8(%rsp)
movl $0x5f5e100, 0x1d4(%rsp) # imm = 0x5F5E100
movq 0x1e0(%rsp), %rdi
movq 0x1d8(%rsp), %rsi
leaq 0x1d4(%rsp), %rdx
callq 0x21f20
jmp 0x27142
leaq 0x218(%rsp), %rdi
movq %rdi, 0x118(%rsp)
callq 0x2d0a0
movq 0x118(%rsp), %rdi
movq %rax, 0x1c8(%rsp)
callq 0x2d0d0
movq %rax, 0x1c0(%rsp)
movq 0x1c8(%rsp), %rdi
movq 0x1c0(%rsp), %rsi
leaq 0x1e8(%rsp), %rdx
callq 0x2d060
jmp 0x27193
movl $0x0, 0x1bc(%rsp)
movl 0x1bc(%rsp), %eax
movq %rax, 0x108(%rsp)
movq 0x248(%rsp), %rdi
callq 0x56b40
movq %rax, 0x110(%rsp)
jmp 0x271c4
movq 0x108(%rsp), %rax
movq 0x110(%rsp), %rcx
cmpq %rcx, %rax
jae 0x27353
movl 0x1bc(%rsp), %eax
movl %eax, %esi
leaq 0x218(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movl 0x1bc(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movl $0x0, (%rax)
movl $0x0, 0x1b8(%rsp)
movslq 0x1b8(%rsp), %rax
movq %rax, 0xf8(%rsp)
movq 0x248(%rsp), %rdi
movl 0x1bc(%rsp), %esi
callq 0x566f0
movq %rax, 0x100(%rsp)
jmp 0x27243
movq 0x100(%rsp), %rdi
callq 0xfd50
movq %rax, %rcx
movq 0xf8(%rsp), %rax
cmpq %rcx, %rax
jae 0x2733b
movq 0x248(%rsp), %rdi
movl 0x1bc(%rsp), %esi
callq 0x566f0
movq %rax, 0xf0(%rsp)
jmp 0x27282
movq 0xf0(%rsp), %rdi
movslq 0x1b8(%rsp), %rsi
callq 0xfbc0
movl (%rax), %eax
movl %eax, 0x1b4(%rsp)
movl 0x1bc(%rsp), %eax
movl %eax, %esi
leaq 0x218(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movl 0x1b4(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movl $0x1, (%rax)
movl 0x1b8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1b8(%rsp)
jmp 0x27215
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x238(%rsp)
movl %eax, 0x234(%rsp)
jmp 0x27d4c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x238(%rsp)
movl %eax, 0x234(%rsp)
jmp 0x27d13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x238(%rsp)
movl %eax, 0x234(%rsp)
leaq 0x1e8(%rsp), %rdi
callq 0xfc70
jmp 0x27d13
jmp 0x2733d
movl 0x1bc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1bc(%rsp)
jmp 0x2719e
movl $0x0, 0x1b0(%rsp)
movslq 0x1b0(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0x248(%rsp), %rdi
callq 0x56b40
movq %rax, 0xe8(%rsp)
jmp 0x27385
movq 0xe0(%rsp), %rax
movq 0xe8(%rsp), %rcx
cmpq %rcx, %rax
jae 0x2758e
movl $0x0, 0x1ac(%rsp)
movslq 0x1ac(%rsp), %rax
movq %rax, 0xd8(%rsp)
leaq 0x218(%rsp), %rdi
callq 0x2d120
movq %rax, %rcx
movq 0xd8(%rsp), %rax
cmpq %rcx, %rax
jae 0x27576
movl $0x0, 0x1a8(%rsp)
movslq 0x1a8(%rsp), %rax
movq %rax, 0xd0(%rsp)
leaq 0x218(%rsp), %rdi
callq 0x2d120
movq %rax, %rcx
movq 0xd0(%rsp), %rax
cmpq %rcx, %rax
jae 0x2755e
movslq 0x1ac(%rsp), %rsi
leaq 0x218(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movslq 0x1a8(%rsp), %rsi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0xcc(%rsp)
movslq 0x1ac(%rsp), %rsi
leaq 0x218(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movslq 0x1b0(%rsp), %rsi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0xc8(%rsp)
movslq 0x1b0(%rsp), %rsi
leaq 0x218(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movslq 0x1a8(%rsp), %rsi
callq 0xfc50
movl 0xc8(%rsp), %ecx
movq %rax, %rdx
movl 0xcc(%rsp), %eax
addl (%rdx), %ecx
cmpl %ecx, %eax
jle 0x27546
movslq 0x1ac(%rsp), %rsi
leaq 0x218(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movslq 0x1b0(%rsp), %rsi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0xc0(%rsp)
movslq 0x1b0(%rsp), %rsi
leaq 0x218(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movslq 0x1a8(%rsp), %rsi
callq 0xfc50
movq %rax, %rcx
movl 0xc0(%rsp), %eax
addl (%rcx), %eax
movl %eax, 0xc4(%rsp)
movslq 0x1ac(%rsp), %rsi
leaq 0x218(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movslq 0x1a8(%rsp), %rsi
callq 0xfc50
movl 0xc4(%rsp), %ecx
movl %ecx, (%rax)
jmp 0x27548
movl 0x1a8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1a8(%rsp)
jmp 0x273e5
jmp 0x27560
movl 0x1ac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1ac(%rsp)
jmp 0x273a9
jmp 0x27578
movl 0x1b0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1b0(%rsp)
jmp 0x2735e
leaq 0x1e8(%rsp), %rdi
movq %rdi, 0xb8(%rsp)
callq 0x109f0
movq 0xb8(%rsp), %rdi
movq %rax, 0x1a0(%rsp)
callq 0x10a20
movq %rax, 0x198(%rsp)
movl $0x0, 0x194(%rsp)
movq 0x1a0(%rsp), %rdi
movq 0x198(%rsp), %rsi
leaq 0x194(%rsp), %rdx
callq 0x21f20
jmp 0x275ea
leaq 0x200(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0x2d0a0
movq 0xb0(%rsp), %rdi
movq %rax, 0x188(%rsp)
callq 0x2d0d0
movq %rax, 0x180(%rsp)
movq 0x188(%rsp), %rdi
movq 0x180(%rsp), %rsi
leaq 0x1e8(%rsp), %rdx
callq 0x2d060
jmp 0x2763b
movl $0x0, 0x17c(%rsp)
movl 0x17c(%rsp), %eax
movq %rax, 0xa0(%rsp)
movq 0x248(%rsp), %rdi
callq 0x56b40
movq %rax, 0xa8(%rsp)
jmp 0x2766c
movq 0xa0(%rsp), %rax
movq 0xa8(%rsp), %rcx
cmpq %rcx, %rax
jae 0x2779f
movl 0x17c(%rsp), %eax
movl %eax, %esi
leaq 0x200(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movl 0x17c(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movl $0x0, (%rax)
movl $0x0, 0x178(%rsp)
movslq 0x178(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x248(%rsp), %rdi
movl 0x17c(%rsp), %esi
callq 0x566f0
movq %rax, 0x98(%rsp)
jmp 0x276eb
movq 0x98(%rsp), %rdi
callq 0xfd50
movq %rax, %rcx
movq 0x90(%rsp), %rax
cmpq %rcx, %rax
jae 0x27787
movq 0x248(%rsp), %rdi
movl 0x17c(%rsp), %esi
callq 0x566f0
movq %rax, 0x88(%rsp)
jmp 0x27726
movq 0x88(%rsp), %rdi
movslq 0x178(%rsp), %rsi
callq 0xfbc0
movl (%rax), %eax
movl %eax, 0x174(%rsp)
movl 0x17c(%rsp), %eax
movl %eax, %esi
leaq 0x200(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movl 0x174(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movl $0x1, (%rax)
movl 0x178(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x178(%rsp)
jmp 0x276bd
jmp 0x27789
movl 0x17c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x17c(%rsp)
jmp 0x27646
movl $0x0, 0x170(%rsp)
movslq 0x170(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x248(%rsp), %rdi
callq 0x56b40
movq %rax, 0x80(%rsp)
jmp 0x277ce
movq 0x78(%rsp), %rax
movq 0x80(%rsp), %rcx
cmpq %rcx, %rax
jae 0x279b3
movl $0x0, 0x16c(%rsp)
movslq 0x16c(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x200(%rsp), %rdi
callq 0x2d120
movq %rax, %rcx
movq 0x70(%rsp), %rax
cmpq %rcx, %rax
jae 0x2799b
movl $0x0, 0x168(%rsp)
movslq 0x168(%rsp), %rax
movq %rax, 0x68(%rsp)
leaq 0x200(%rsp), %rdi
callq 0x2d120
movq %rax, %rcx
movq 0x68(%rsp), %rax
cmpq %rcx, %rax
jae 0x27983
movslq 0x16c(%rsp), %rsi
leaq 0x218(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movslq 0x168(%rsp), %rsi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0x64(%rsp)
movslq 0x16c(%rsp), %rsi
leaq 0x218(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movslq 0x170(%rsp), %rsi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0x60(%rsp)
movslq 0x170(%rsp), %rsi
leaq 0x218(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movslq 0x168(%rsp), %rsi
callq 0xfc50
movl 0x60(%rsp), %ecx
movq %rax, %rdx
movl 0x64(%rsp), %eax
addl (%rdx), %ecx
cmpl %ecx, %eax
jne 0x2796b
movslq 0x16c(%rsp), %rsi
leaq 0x200(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movslq 0x170(%rsp), %rsi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0x58(%rsp)
movslq 0x170(%rsp), %rsi
leaq 0x200(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movslq 0x168(%rsp), %rsi
callq 0xfc50
movq %rax, %rcx
movl 0x58(%rsp), %eax
imull (%rcx), %eax
movl %eax, 0x5c(%rsp)
movslq 0x16c(%rsp), %rsi
leaq 0x200(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movslq 0x168(%rsp), %rsi
callq 0xfc50
movl 0x5c(%rsp), %ecx
addl (%rax), %ecx
movl %ecx, (%rax)
jmp 0x2796d
movl 0x168(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x168(%rsp)
jmp 0x27825
jmp 0x27985
movl 0x16c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x16c(%rsp)
jmp 0x277ef
jmp 0x2799d
movl 0x170(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x170(%rsp)
jmp 0x277aa
movl $0x0, 0x164(%rsp)
movl 0x164(%rsp), %eax
movq %rax, 0x48(%rsp)
movq 0x248(%rsp), %rdi
callq 0x56b40
movq %rax, 0x50(%rsp)
jmp 0x279de
movq 0x48(%rsp), %rax
movq 0x50(%rsp), %rcx
cmpq %rcx, %rax
jae 0x27c47
movl $0x0, 0x160(%rsp)
movl 0x160(%rsp), %eax
movq %rax, 0x38(%rsp)
movq 0x248(%rsp), %rdi
callq 0x56b40
movq %rax, 0x40(%rsp)
jmp 0x27a1c
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rcx
cmpq %rcx, %rax
jae 0x27c2f
movl $0x0, 0x15c(%rsp)
movq 0x140(%rsp), %rdi
movl 0x15c(%rsp), %eax
movq %rax, 0x30(%rsp)
callq 0xfa10
movq %rax, %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
jae 0x27c17
movl 0x164(%rsp), %eax
cmpl 0x15c(%rsp), %eax
je 0x27bff
movl 0x15c(%rsp), %eax
cmpl 0x160(%rsp), %eax
je 0x27bff
movl 0x164(%rsp), %eax
cmpl 0x160(%rsp), %eax
je 0x27bff
movl 0x164(%rsp), %eax
movl %eax, %esi
leaq 0x218(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movl 0x160(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0x2c(%rsp)
movl 0x164(%rsp), %eax
movl %eax, %esi
leaq 0x218(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movl 0x15c(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0x28(%rsp)
movl 0x15c(%rsp), %eax
movl %eax, %esi
leaq 0x218(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movl 0x160(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movl 0x28(%rsp), %ecx
movq %rax, %rdx
movl 0x2c(%rsp), %eax
addl (%rdx), %ecx
cmpl %ecx, %eax
jne 0x27bfd
movl 0x164(%rsp), %eax
movl %eax, %esi
leaq 0x200(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movl 0x15c(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movl (%rax), %eax
movl %eax, 0x14(%rsp)
movl 0x15c(%rsp), %eax
movl %eax, %esi
leaq 0x200(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movl 0x160(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movq %rax, %rcx
movl 0x14(%rsp), %eax
imull (%rcx), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x18(%rsp)
movl 0x164(%rsp), %eax
movl %eax, %esi
leaq 0x200(%rsp), %rdi
callq 0x2d100
movq %rax, %rdi
movl 0x160(%rsp), %eax
movl %eax, %esi
callq 0xfc50
movsd 0x18(%rsp), %xmm0
movq 0x140(%rsp), %rdi
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movl 0x15c(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd 0x20(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
jmp 0x27bff
jmp 0x27c01
movl 0x15c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x15c(%rsp)
jmp 0x27a3a
jmp 0x27c19
movl 0x160(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x160(%rsp)
jmp 0x279fc
jmp 0x27c31
movl 0x164(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x164(%rsp)
jmp 0x279be
movl $0x0, 0x158(%rsp)
movq 0x140(%rsp), %rdi
movl 0x158(%rsp), %eax
movq %rax, 0x8(%rsp)
callq 0xfa10
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jae 0x27cd8
movq 0x140(%rsp), %rdi
movl 0x158(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movq 0x140(%rsp), %rdi
movsd (%rax), %xmm0
movsd 0x53366(%rip), %xmm1    # 0x7b008
divsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
movl 0x158(%rsp), %eax
movl %eax, %esi
callq 0xfa30
movsd (%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x158(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x158(%rsp)
jmp 0x27c52
movb $0x1, 0x247(%rsp)
leaq 0x1e8(%rsp), %rdi
callq 0xfc70
leaq 0x200(%rsp), %rdi
callq 0x2d140
leaq 0x218(%rsp), %rdi
callq 0x2d140
testb $0x1, 0x247(%rsp)
jne 0x27d3c
jmp 0x27d2f
leaq 0x200(%rsp), %rdi
callq 0x2d140
leaq 0x218(%rsp), %rdi
callq 0x2d140
jmp 0x27d4c
movq 0x140(%rsp), %rdi
callq 0xfa50
movq 0x148(%rsp), %rax
addq $0x258, %rsp            # imm = 0x258
retq
movq 0x140(%rsp), %rdi
callq 0xfa50
movq 0x238(%rsp), %rdi
callq 0x9cf0
nopw %cs:(%rax,%rax)