// File: 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
movq %rsp, %rbp
subq $0x560, %rsp            # imm = 0x560
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x218(%rbp), %rdi
callq 0xa760
movq -0x8(%rbp), %rdi
callq 0xe6e0
movq %rax, -0x438(%rbp)
jmp 0xada5
leaq -0x23d(%rbp), %rdi
movq %rdi, -0x440(%rbp)
callq 0xe720
movq -0x438(%rbp), %rsi
movq -0x440(%rbp), %rdx
leaq -0x230(%rbp), %rdi
callq 0xe740
jmp 0xadd4
leaq -0x23d(%rbp), %rdi
callq 0xe7b0
leaq -0x248(%rbp), %rdi
callq 0xe7d0
jmp 0xadee
leaq -0x250(%rbp), %rdi
callq 0xe7d0
jmp 0xadfc
movq -0x8(%rbp), %rdi
callq 0xe6e0
movq %rax, -0x448(%rbp)
jmp 0xae0e
leaq -0x269(%rbp), %rdi
movq %rdi, -0x450(%rbp)
callq 0xe7f0
movq -0x448(%rbp), %rsi
movq -0x450(%rbp), %rdx
leaq -0x268(%rbp), %rdi
callq 0xe810
jmp 0xae3d
leaq -0x269(%rbp), %rdi
callq 0xe880
movq -0x8(%rbp), %rax
movq %rax, -0x458(%rbp)
leaq -0x230(%rbp), %rdi
callq 0xe9d0
movq %rax, -0x2c0(%rbp)
movq -0x8(%rbp), %rsi
xorl %edi, %edi
callq 0xea00
jmp 0xae74
movq -0x2c0(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0xe990
movq %rax, -0x460(%rbp)
jmp 0xae8c
movq -0x460(%rbp), %rax
movq %rax, -0x2b8(%rbp)
leaq -0x2a8(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0xe950
jmp 0xaeaf
movq -0x8(%rbp), %rsi
xorl %edi, %edi
callq 0xea00
jmp 0xaebc
leaq -0x290(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
leaq -0x2c3(%rbp), %rdx
callq 0xea30
jmp 0xaed8
movq -0x458(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0xe8a0
jmp 0xaeed
movq -0x8(%rbp), %rax
movq %rax, -0x468(%rbp)
leaq -0x230(%rbp), %rdi
callq 0xe9d0
movq %rax, -0x2e0(%rbp)
movq -0x8(%rbp), %rsi
xorl %edi, %edi
callq 0xea00
jmp 0xaf18
movq -0x2e0(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0xe990
movq %rax, -0x470(%rbp)
jmp 0xaf30
movq -0x468(%rbp), %rdi
movq -0x470(%rbp), %rax
movq %rax, -0x2d8(%rbp)
movq -0x2d8(%rbp), %rsi
callq 0xea60
jmp 0xaf53
movq -0x8(%rbp), %rdi
callq 0xeb90
movq %rdx, -0x480(%rbp)
movq %rax, -0x478(%rbp)
jmp 0xaf6c
movq -0x480(%rbp), %rax
movq -0x478(%rbp), %rcx
movq %rcx, -0x2f8(%rbp)
movq %rax, -0x2f0(%rbp)
leaq -0x308(%rbp), %rdi
leaq -0x248(%rbp), %rsi
leaq -0x250(%rbp), %rdx
callq 0xec10
jmp 0xafa4
leaq -0x308(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0xec50
jmp 0xafb9
jmp 0xafbb
leaq -0x248(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0xec80
movb %al, -0x481(%rbp)
jmp 0xafd6
movb -0x481(%rbp), %al
testb $0x1, %al
jne 0xafe5
jmp 0xb218
leaq -0x350(%rbp), %rax
movq %rax, -0x4a0(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x498(%rbp)
leaq -0x248(%rbp), %rdi
callq 0xecc0
movq %rax, -0x490(%rbp)
jmp 0xb013
movq -0x490(%rbp), %rsi
movq -0x498(%rbp), %rdi
callq 0xe5f0
movq %rax, -0x4a8(%rbp)
jmp 0xb02f
movq -0x4a0(%rbp), %rdi
movq -0x4a8(%rbp), %rsi
addq $0x40, %rsi
callq 0xa1d0
jmp 0xb048
leaq -0x330(%rbp), %rax
movq %rax, -0x4c0(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x4b8(%rbp)
leaq -0x248(%rbp), %rdi
callq 0xecc0
movq %rax, -0x4b0(%rbp)
jmp 0xb076
movq -0x4b0(%rbp), %rsi
movq -0x4b8(%rbp), %rdi
callq 0xe5f0
movq %rax, -0x4c8(%rbp)
jmp 0xb092
movq -0x4c0(%rbp), %rdi
movq -0x4c8(%rbp), %rsi
addq $0x20, %rsi
callq 0xa1d0
jmp 0xb0ab
leaq -0x310(%rbp), %rax
movq %rax, -0x4d8(%rbp)
leaq -0x248(%rbp), %rdi
callq 0xecc0
movq %rax, -0x4d0(%rbp)
jmp 0xb0ce
movq -0x4d0(%rbp), %rsi
leaq -0x230(%rbp), %rdi
callq 0xecf0
movq %rax, %rcx
movq -0x4d8(%rbp), %rax
movsd (%rcx), %xmm0
movsd %xmm0, (%rax)
leaq -0x268(%rbp), %rdi
leaq -0x350(%rbp), %rsi
callq 0xed10
jmp 0xb108
leaq -0x350(%rbp), %rdi
callq 0xed80
leaq -0x248(%rbp), %rdi
callq 0xedb0
jmp 0xb122
jmp 0xafbb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0xb6ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
leaq -0x23d(%rbp), %rdi
callq 0xe7b0
jmp 0xb6ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0xb6ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
leaq -0x269(%rbp), %rdi
callq 0xe880
jmp 0xb6ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0xb6a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0xb1e4
movq -0x4c0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
callq 0xa2b0
movq -0x4a0(%rbp), %rdi
callq 0xa2b0
jmp 0xb6a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
leaq -0x350(%rbp), %rdi
callq 0xed80
jmp 0xb6a2
leaq -0x268(%rbp), %rdi
movq %rdi, -0x4e0(%rbp)
callq 0xee20
movq -0x4e0(%rbp), %rdi
movq %rax, -0x358(%rbp)
callq 0xee50
movq %rax, -0x360(%rbp)
movq -0x358(%rbp), %rdi
movq -0x360(%rbp), %rsi
callq 0xede0
jmp 0xb25a
movq -0x18(%rbp), %rsi
leaq 0x3fe13(%rip), %rdx     # 0x4b078
leaq -0x3c8(%rbp), %rdi
callq 0xef20
jmp 0xb273
movq -0x10(%rbp), %rdx
leaq -0x3a8(%rbp), %rdi
leaq -0x3c8(%rbp), %rsi
callq 0xeed0
jmp 0xb28c
leaq 0x3fde7(%rip), %rdx     # 0x4b07a
leaq -0x388(%rbp), %rdi
leaq -0x3a8(%rbp), %rsi
callq 0xee80
jmp 0xb2a8
movl $0x10, %edi
movl $0x20, %esi
callq 0xefa0
movl %eax, -0x4e4(%rbp)
jmp 0xb2bf
movl -0x4e4(%rbp), %edx
leaq -0x218(%rbp), %rdi
leaq -0x388(%rbp), %rsi
callq 0xa210
jmp 0xb2da
leaq -0x388(%rbp), %rdi
callq 0xa2b0
leaq -0x3a8(%rbp), %rdi
callq 0xa2b0
leaq -0x3c8(%rbp), %rdi
callq 0xa2b0
leaq 0x3fd85(%rip), %rsi     # 0x4b08a
leaq -0x218(%rbp), %rdi
callq 0xa410
movq %rax, -0x4f0(%rbp)
jmp 0xb31a
movq -0x4f0(%rbp), %rdi
movq 0x69c38(%rip), %rsi     # 0x74f60
callq 0xa460
jmp 0xb32f
leaq -0x268(%rbp), %rdi
callq 0xee20
movq %rax, -0x3d0(%rbp)
leaq -0x268(%rbp), %rdi
callq 0xee20
movq %rax, -0x3e0(%rbp)
leaq -0x3e0(%rbp), %rdi
movl $0x32, %esi
callq 0xf000
movq %rax, -0x3d8(%rbp)
leaq -0x3d0(%rbp), %rdi
leaq -0x3d8(%rbp), %rsi
callq 0xefc0
testb $0x1, %al
jne 0xb389
jmp 0xb4ff
leaq 0x41320(%rip), %rsi     # 0x4c6b0
leaq -0x218(%rbp), %rdi
callq 0xa410
movq %rax, -0x4f8(%rbp)
jmp 0xb3a5
leaq -0x3d0(%rbp), %rdi
callq 0xf040
movq -0x4f8(%rbp), %rdi
movq %rax, %rsi
callq 0xa3e0
movq %rax, -0x500(%rbp)
jmp 0xb3c9
movq -0x500(%rbp), %rdi
leaq 0x412d9(%rip), %rsi     # 0x4c6b0
callq 0xa410
movq %rax, -0x508(%rbp)
jmp 0xb3e5
movq -0x508(%rbp), %rdi
leaq 0x3fcb0(%rip), %rsi     # 0x4b0a3
callq 0xa410
movq %rax, -0x510(%rbp)
jmp 0xb401
leaq -0x3d0(%rbp), %rdi
callq 0xf040
movq -0x510(%rbp), %rdi
movsd 0x40(%rax), %xmm0
callq 0xa850
movq %rax, -0x518(%rbp)
jmp 0xb427
movq -0x518(%rbp), %rdi
leaq 0x3fc6e(%rip), %rsi     # 0x4b0a3
callq 0xa410
movq %rax, -0x520(%rbp)
jmp 0xb443
leaq -0x3d0(%rbp), %rdi
callq 0xf040
movq -0x520(%rbp), %rdi
movq %rax, %rsi
addq $0x20, %rsi
callq 0xa3e0
movq %rax, -0x528(%rbp)
jmp 0xb46b
movq -0x528(%rbp), %rdi
movq 0x69ae7(%rip), %rsi     # 0x74f60
callq 0xa460
jmp 0xb480
jmp 0xb482
leaq -0x3d0(%rbp), %rdi
xorl %esi, %esi
callq 0xf060
movq %rax, -0x3e8(%rbp)
jmp 0xb342
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0xb4ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0xb4e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
leaq -0x388(%rbp), %rdi
callq 0xa2b0
leaq -0x3a8(%rbp), %rdi
callq 0xa2b0
leaq -0x3c8(%rbp), %rdi
callq 0xa2b0
jmp 0xb6a2
leaq -0x218(%rbp), %rdi
callq 0xa640
jmp 0xb50d
movq -0x8(%rbp), %rax
movq %rax, -0x530(%rbp)
leaq -0x230(%rbp), %rdi
callq 0xe9d0
movq %rax, -0x408(%rbp)
movq -0x8(%rbp), %rsi
xorl %edi, %edi
callq 0xea00
jmp 0xb538
movq -0x408(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0xe990
movq %rax, -0x538(%rbp)
jmp 0xb550
movq -0x530(%rbp), %rdi
movq -0x538(%rbp), %rax
movq %rax, -0x400(%rbp)
movq -0x400(%rbp), %rsi
callq 0xf0a0
movsd %xmm0, -0x540(%rbp)
jmp 0xb57b
movsd -0x540(%rbp), %xmm0
movsd %xmm0, -0x3f0(%rbp)
movq -0x18(%rbp), %rsi
leaq 0x3fb0f(%rip), %rdx     # 0x4b0a5
leaq -0x430(%rbp), %rdi
callq 0xef20
jmp 0xb5a4
movl $0x10, %edi
movl $0x1, %esi
callq 0xefa0
movl %eax, -0x544(%rbp)
jmp 0xb5bb
movl -0x544(%rbp), %edx
leaq -0x218(%rbp), %rdi
leaq -0x430(%rbp), %rsi
callq 0xa210
jmp 0xb5d6
leaq -0x430(%rbp), %rdi
callq 0xa2b0
movq -0x10(%rbp), %rsi
leaq -0x218(%rbp), %rdi
callq 0xa3e0
movq %rax, -0x550(%rbp)
jmp 0xb5fb
movq -0x550(%rbp), %rdi
leaq 0x3fa9a(%rip), %rsi     # 0x4b0a3
callq 0xa410
movq %rax, -0x558(%rbp)
jmp 0xb617
movq -0x558(%rbp), %rdi
movsd -0x3f0(%rbp), %xmm0
callq 0xa850
movq %rax, -0x560(%rbp)
jmp 0xb634
movq -0x560(%rbp), %rdi
movq 0x6991e(%rip), %rsi     # 0x74f60
callq 0xa460
jmp 0xb649
leaq -0x218(%rbp), %rdi
callq 0xa640
jmp 0xb657
leaq -0x268(%rbp), %rdi
callq 0xf240
leaq -0x230(%rbp), %rdi
callq 0xf2a0
leaq -0x218(%rbp), %rdi
callq 0xa6a0
addq $0x560, %rsp            # imm = 0x560
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
leaq -0x430(%rbp), %rdi
callq 0xa2b0
leaq -0x268(%rbp), %rdi
callq 0xf240
leaq -0x230(%rbp), %rdi
callq 0xf2a0
leaq -0x218(%rbp), %rdi
callq 0xa6a0
movq -0x238(%rbp), %rdi
callq 0xa7d0
nopw %cs:(%rax,%rax)