// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r14
movq %rdi, %rbx
xorpd %xmm0, %xmm0
movupd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movq %rsi, %rdi
callq 0x18d3c
movq %rbx, %rdi
movq %rax, %rsi
callq 0x45f0
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
movapd %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
movq %r14, %rdi
callq 0x18d3c
movq %rsp, %rdi
movq %rax, %rsi
callq 0xaf82
movq %r14, %rdi
callq 0x18d3c
leaq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0xaf82
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rsp)
andq $0x0, 0x50(%rsp)
movq %r14, %rdi
callq 0x18d3c
leaq 0x40(%rsp), %rdi
movq %rax, %rsi
callq 0xafb8
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
cmpq %rcx, %rax
je 0x87bb
movl $0x5f5e100, (%rax)      # imm = 0x5F5E100
addq $0x4, %rax
jmp 0x87aa
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0xb745
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x18d3c
movl %r15d, %r15d
cmpq %r15, %rax
jbe 0x883b
movq (%rsp), %rax
imulq $0x18, %r15, %r12
movq (%rax,%r12), %rax
andl $0x0, (%rax,%r15,4)
xorl %r13d, %r13d
movq %r14, %rdi
movl %r15d, %esi
callq 0x18b4c
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x2, %rcx
cmpq %r13, %rcx
jbe 0x8836
movq %r14, %rdi
movl %r15d, %esi
callq 0x18b4c
movq (%rax), %rax
movl (%rax,%r13,4), %eax
movq (%rsp), %rcx
movq (%rcx,%r12), %rcx
movl $0x1, (%rcx,%rax,4)
incq %r13
jmp 0x87f5
incl %r15d
jmp 0x87d1
xorl %r15d, %r15d
pushq $0x18
popq %r12
movq %r14, %rdi
callq 0x18d3c
cmpq %r15, %rax
jbe 0x88a4
movq (%rsp), %rcx
movq 0x8(%rsp), %rax
subq %rcx, %rax
cqto
idivq %r12
imulq $0x18, %r15, %rdx
addq %rcx, %rdx
xorl %esi, %esi
cmpq %rax, %rsi
je 0x889f
imulq $0x18, %rsi, %rdi
addq %rcx, %rdi
xorl %r8d, %r8d
cmpq %r8, %rax
je 0x889a
movq (%rdi), %r9
movq (%rdx), %r10
movl (%r10,%r8,4), %r10d
addl (%r9,%r15,4), %r10d
cmpl %r10d, (%r9,%r8,4)
jle 0x8895
movl %r10d, (%r9,%r8,4)
incq %r8
jmp 0x8878
incq %rsi
jmp 0x8869
incq %r15
jmp 0x8842
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
cmpq %rcx, %rax
je 0x88bc
andl $0x0, (%rax)
addq $0x4, %rax
jmp 0x88ae
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0xb745
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x18d3c
movl %r15d, %r15d
cmpq %r15, %rax
jbe 0x893d
movq 0x20(%rsp), %rax
imulq $0x18, %r15, %r13
movq (%rax,%r13), %rax
andl $0x0, (%rax,%r15,4)
xorl %ebp, %ebp
movq %r14, %rdi
movl %r15d, %esi
callq 0x18b4c
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x2, %rcx
cmpq %rbp, %rcx
jbe 0x8938
movq %r14, %rdi
movl %r15d, %esi
callq 0x18b4c
movq (%rax), %rax
movl (%rax,%rbp,4), %eax
movq 0x20(%rsp), %rcx
movq (%rcx,%r13), %rcx
movl $0x1, (%rcx,%rax,4)
incq %rbp
jmp 0x88f7
incl %r15d
jmp 0x88d3
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x18d3c
cmpq %r15, %rax
jbe 0x89c7
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rax
subq %rcx, %rax
cqto
idivq %r12
imulq $0x18, %r15, %rdx
leaq (%rcx,%rdx), %rsi
xorl %edi, %edi
cmpq %rax, %rdi
je 0x89bf
movq (%rsp), %r8
imulq $0x18, %rdi, %r9
leaq (%r8,%r9), %r10
addq %rdx, %r8
addq %rcx, %r9
xorl %r11d, %r11d
cmpq %r11, %rax
je 0x89ba
movq (%r10), %r13
movq (%r8), %rbp
movl (%rbp,%r11,4), %ebp
addl (%r13,%r15,4), %ebp
cmpl %ebp, (%r13,%r11,4)
jne 0x89b5
movq (%r9), %r13
movq (%rsi), %rbp
movl (%rbp,%r11,4), %ebp
imull (%r13,%r15,4), %ebp
addl %ebp, (%r13,%r11,4)
incq %r11
jmp 0x8983
incq %rdi
jmp 0x8969
incq %r15
jmp 0x8940
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x18d3c
movl %r15d, %r15d
cmpq %r15, %rax
jbe 0x8a8c
xorl %r12d, %r12d
imulq $0x18, %r15, %r13
movq %r14, %rdi
callq 0x18d3c
movl %r12d, %r12d
cmpq %r12, %rax
jbe 0x8a84
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movq (%rsp), %rdx
leaq (%rdx,%r13), %rsi
movq 0x20(%rsp), %rdi
leaq (%rdi,%r13), %r8
xorl %r9d, %r9d
movl %r9d, %r9d
cmpq %r9, %rcx
jbe 0x8a7c
cmpl %r9d, %r15d
je 0x8a77
cmpl %r9d, %r12d
je 0x8a77
cmpl %r12d, %r15d
je 0x8a77
movq (%rsi), %r11
imulq $0x18, %r9, %r10
movq (%rdx,%r10), %rbp
movl (%rbp,%r12,4), %ebp
addl (%r11,%r9,4), %ebp
cmpl %ebp, (%r11,%r12,4)
jne 0x8a77
movq (%r8), %r11
movq (%rdi,%r10), %r10
movl (%r10,%r12,4), %r10d
imull (%r11,%r9,4), %r10d
cvtsi2sd %r10d, %xmm0
cvtsi2sdl (%r11,%r12,4), %xmm1
divsd %xmm1, %xmm0
addsd (%rax,%r9,8), %xmm0
movsd %xmm0, (%rax,%r9,8)
incl %r9d
jmp 0x8a1b
incl %r12d
jmp 0x89e5
incl %r15d
jmp 0x89ca
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
xorl %edx, %edx
movsd 0x1f58c(%rip), %xmm0    # 0x28030
movl %edx, %edx
cmpq %rdx, %rcx
jbe 0x8abd
movsd (%rax,%rdx,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rdx,8)
incl %edx
jmp 0x8aa4
leaq 0x40(%rsp), %rdi
callq 0x5720
leaq 0x20(%rsp), %rdi
callq 0xafea
movq %rsp, %rdi
callq 0xafea
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x8b28
jmp 0x8b09
movq %rax, %r14
jmp 0x8b16
jmp 0x8b09
jmp 0x8b09
jmp 0x8b09
jmp 0x8b09
jmp 0x8b09
jmp 0x8b09
jmp 0x8b09
jmp 0x8b09
jmp 0x8b09
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0x5720
leaq 0x20(%rsp), %rdi
callq 0xafea
movq %rsp, %rdi
callq 0xafea
movq %rbx, %rdi
callq 0x5754
movq %r14, %rdi
callq 0x23d0