// File: /workspace/github_cpp_makefile_star2_O1/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 0x9c86
movq 0x20(%rbx), %rsi
subq 0x18(%rbx), %rsi
sarq $0x3, %rsi
imulq %r14, %rsi
leaq 0x80(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x9d10
movq 0x68(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movl $0x0, (%rdx)
movq %rbx, %rdi
callq 0xad7f
movq 0x18(%rbx), %rax
movq %rbx, 0x8(%rsp)
movq 0x20(%rbx), %rcx
movq %rcx, %rbx
subq %rax, %rbx
sarq $0x3, %rbx
imulq %r14, %rbx
cmpq %rax, %rcx
je 0x7aab
leaq -0x3(%rbx), %rsi
imulq %rbx, %rsi
addq $0x2, %rsi
movq 0x68(%rsp), %rdx
movq %rsi, %xmm0
punpckldq 0x1459d(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x145a5(%rip), %xmm0    # 0x1c020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x145b1(%rip), %xmm0    # 0x1c040
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 0x7a95
cmpq %rax, %rcx
je 0x7b71
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 0xabc6
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 0xabc6
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 0x7b42
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x7300
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x7b5e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7300
incq %rbp
addq $0xb8, %r12
cmpq %rbp, %rbx
jne 0x7ac8
movq 0x80(%rsp), %r12
movq 0x88(%rsp), %r13
cmpq %r13, %r12
je 0x7bc1
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 0xc0f0
movq %r12, %rdi
movq %r13, %rsi
callq 0xc225
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 0xabc6
leaq 0x1447a(%rip), %rsi     # 0x1c06b
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 0x7c47
movq %rdx, 0xb8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xc8(%rsp)
jmp 0x7c50
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 0x143f7(%rip), %rsi     # 0x1c06d
callq 0x75c0
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7ca2
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x7cab
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 0x7cf0
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7300
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x7d0d
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x7300
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x7d2a
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x7300
leaq 0x1434c(%rip), %rsi     # 0x1c07d
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 0x1557a(%rip), %r12     # 0x1d300
leaq 0xd8(%rsp), %r13
leaq 0x14301(%rip), %rbp     # 0x1c096
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 0x7d9b
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 0xabc6
leaq 0x141fe(%rip), %rsi     # 0x1c098
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 0x7ed2
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 0x141a1(%rip), %rsi     # 0x1c096
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 0x9eb2
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x7f6b
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x7300
movq 0x2200e(%rip), %rax     # 0x29f80
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 0x7fb7
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
jne 0x8052
jmp 0x8073
jmp 0x8070
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x7ff1
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7300
jmp 0x7ff1
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x8015
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x7300
jmp 0x8015
jmp 0x8012
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x8073
movq 0xa8(%rsp), %rsi
jmp 0x8057
jmp 0x8070
jmp 0x8070
movq %rax, %rbx
jmp 0x8080
movq %rax, %rbx
jmp 0x8097
jmp 0x8070
jmp 0x8070
jmp 0x8070
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x8073
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7300
jmp 0x8073
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x9dea
jmp 0x8073
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x9eb2
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x8097
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x7300
leaq 0xd8(%rsp), %rdi
callq 0x7450
movq %rbx, %rdi
callq 0x7550