// File: /workspace/github_cpp_makefile_star2_O3/kulpreet[P]lightning-network-graph-analysis/src/include/algos.hpp
// Function: lncentrality::get_centrality(boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, lncentrality::LitVertex, lncentrality::LitEdge, boost::no_property, boost::listS>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
void get_centrality(LitGraph &g, string &stem, string &outdir) {
  std::ofstream out;
  std::vector<double> centrality(num_vertices(g));
  graph_traits<LitGraph>::vertex_iterator i, end;

  std::vector<centrality_s> centrality_vector(num_vertices(g));

  brandes_betweenness_centrality(
      g, centrality_map(make_iterator_property_map(
                            centrality.begin(), get(vertex_index, g), double()))
             .vertex_index_map(get(vertex_index, g)));

  relative_betweenness_centrality(
      g, make_iterator_property_map(centrality.begin(), get(vertex_index, g),
                                    double()));

  for (boost::tie(i, end) = vertices(g); i != end; ++i) {
    centrality_s c = {g[*i].name, g[*i].pub_key, centrality[*i]};
    centrality_vector.push_back(c);
    // std::cout << g[*i].name << " :: "
    //           << g[*i].pub_key << " :: "
    //           << centrality[*i] << endl;
  }

  // sort centrality vector
  std::sort(centrality_vector.begin(), centrality_vector.end(),
            compare_by_centrality<centrality_s>());

  out.open(outdir + "/" + stem + ".centrality.csv",
           std::fstream::out | std::fstream::trunc);

  out << "alias,centrality,pub_key" << std::endl;
  for (std::vector<centrality_s>::iterator centrality_iter =
           centrality_vector.begin();
       centrality_iter != centrality_vector.begin() + 50; centrality_iter++) {
    out << "\"" << centrality_iter->name << "\""
        << "," << centrality_iter->centrality << "," << centrality_iter->pub_key
        << std::endl;
  }
  out.close();

  double dominance = central_point_dominance(
      g, make_iterator_property_map(centrality.begin(), get(vertex_index, g),
                                    double()));
  out.open(outdir + "/cpd.csv", std::fstream::out | std::fstream::app);
  out << stem << "," << dominance << std::endl;
  out.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2d8, %rsp            # imm = 0x2D8
movq %rdx, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdi, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x7500
movq 0x20(%rbx), %rsi
subq 0x18(%rbx), %rsi
sarq $0x3, %rsi
movabsq $-0x2c8590b21642c859, %r14 # imm = 0xD37A6F4DE9BD37A7
imulq %r14, %rsi
leaq 0x68(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x9c8e
movq 0x20(%rbx), %rsi
subq 0x18(%rbx), %rsi
sarq $0x3, %rsi
imulq %r14, %rsi
leaq 0x80(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x9d1c
movq 0x68(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movl $0x0, (%rdx)
movq %rbx, %rdi
callq 0xad9b
movq 0x18(%rbx), %rax
movq %rbx, 0x8(%rsp)
movq 0x20(%rbx), %rcx
movq %rcx, %rbx
subq %rax, %rbx
je 0x7b72
sarq $0x3, %rbx
imulq %r14, %rbx
leaq -0x3(%rbx), %rsi
imulq %rbx, %rsi
addq $0x2, %rsi
movq 0x68(%rsp), %rdx
movq %rsi, %xmm0
punpckldq 0x1559c(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x155a4(%rip), %xmm0    # 0x1d020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x15620(%rip), %xmm0    # 0x1d0b0
divsd %xmm1, %xmm0
xorl %esi, %esi
movsd (%rdx,%rsi,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rbx
jne 0x7a96
cmpq %rax, %rcx
je 0x7b72
leaq 0x40(%rsp), %r15
xorl %r12d, %r12d
leaq 0x10(%rsp), %r13
xorl %ebp, %ebp
movq 0x8(%rsp), %r14
movq 0x18(%r14), %rax
leaq 0x20(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movq 0x58(%rax,%r12), %rsi
movq 0x60(%rax,%r12), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0xabd6
movq 0x18(%r14), %rax
movq %r15, 0x30(%rsp)
movq 0x38(%rax,%r12), %rsi
movq 0x40(%rax,%r12), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %rdi
callq 0xabd6
movq 0x68(%rsp), %rax
movsd (%rax,%rbp,8), %xmm0
movsd %xmm0, 0x50(%rsp)
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
callq 0x9dc0
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x7b43
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x7300
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x7b5f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7300
incq %rbp
addq $0xb8, %r12
cmpq %rbp, %rbx
jne 0x7ac9
movq 0x80(%rsp), %r12
movq 0x88(%rsp), %r13
cmpq %r13, %r12
je 0x7bc2
movq %r13, %rax
subq %r12, %rax
sarq $0x3, %rax
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %rax, %rcx
bsrq %rcx, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0xc202
movq %r12, %rdi
movq %r13, %rsi
callq 0xc337
leaq 0xa8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x60(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0xabd6
leaq 0x154f1(%rip), %rsi     # 0x1d0e3
leaq 0x98(%rsp), %rdi
callq 0x75c0
movq 0x58(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq 0x98(%rsp), %rdi
callq 0x7100
leaq 0xc8(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7c48
movq %rdx, 0xb8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xc8(%rsp)
jmp 0x7c51
movupd (%rcx), %xmm0
movupd %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq 0xb8(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x1546e(%rip), %rsi     # 0x1d0e5
callq 0x75c0
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7ca3
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x7cac
movupd (%rcx), %xmm0
movupd %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq 0x10(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xd8(%rsp), %rdi
movl $0x30, %edx
callq 0x7170
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x7cf1
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7300
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x7d0e
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x7300
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x7d2b
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x7300
leaq 0x153c3(%rip), %rsi     # 0x1d0f5
leaq 0xd8(%rsp), %rbx
movl $0x18, %edx
movq %rbx, %rdi
callq 0x7350
movq 0xd8(%rsp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x72e0
movsbl %al, %esi
leaq 0xd8(%rsp), %rdi
callq 0x7040
movq %rax, %rdi
callq 0x7240
movq 0x80(%rsp), %r14
leaq 0x165e9(%rip), %r12     # 0x1e370
leaq 0xd8(%rsp), %r13
leaq 0x15378(%rip), %rbp     # 0x1d10e
movl $0xe10, %r15d           # imm = 0xE10
movl $0x1, %edx
movq %r13, %rdi
movq %r12, %rsi
callq 0x7350
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %r13, %rdi
callq 0x7350
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x7350
movl $0x1, %edx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x7350
movsd 0x40(%r14), %xmm0
movq %rbx, %rdi
callq 0x74a0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x7350
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
movq %rbx, %rdi
callq 0x7350
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x72e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x7240
addq $0x48, %r14
movq 0x80(%rsp), %rax
addq %r15, %rax
cmpq %rax, %r14
jne 0x7d9c
leaq 0xd8(%rsp), %rdi
callq 0x7430
movq 0x68(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x9e20
movsd %xmm0, 0x8(%rsp)
leaq 0x20(%rsp), %r14
leaq 0x10(%rsp), %rdi
movq %r14, (%rdi)
movq 0x60(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
callq 0xabd6
leaq 0x15275(%rip), %rsi     # 0x1d110
leaq 0x10(%rsp), %rdi
callq 0x75c0
leaq 0xd8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl $0x11, %edx
callq 0x7170
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x7ed3
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7300
movq 0x58(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq 0xd8(%rsp), %rdi
callq 0x7350
movq %rax, %rbx
leaq 0x15218(%rip), %rsi     # 0x1d10e
movl $0x1, %edx
movq %rax, %rdi
callq 0x7350
movq %rbx, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x74a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x72e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x7240
leaq 0xd8(%rsp), %rdi
callq 0x7430
leaq 0x80(%rsp), %rdi
callq 0x9eb0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x7f6c
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x7300
movq 0x2300d(%rip), %rax     # 0x2af80
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0xe0(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0xd8(%rsp,%rcx)
callq 0x72a0
leaq 0x1d0(%rsp), %rdi
callq 0x7110
addq $0x2d8, %rsp            # imm = 0x2D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7fb8
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
jne 0x8053
jmp 0x8074
jmp 0x8071
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x7ff2
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7300
jmp 0x7ff2
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x8016
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x7300
jmp 0x8016
jmp 0x8013
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x8074
movq 0xa8(%rsp), %rsi
jmp 0x8058
jmp 0x8071
jmp 0x8071
movq %rax, %rbx
jmp 0x8081
movq %rax, %rbx
jmp 0x8098
jmp 0x8071
jmp 0x8071
jmp 0x8071
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x8074
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7300
jmp 0x8074
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x9dea
jmp 0x8074
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x9eb0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x8098
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x7300
leaq 0xd8(%rsp), %rdi
callq 0x7450
movq %rbx, %rdi
callq 0x7550