// File: kulpreet[P]lightning-network-graph-analysis/src/run.cpp
// Function: main
int main(int ac, char **av) {
  LitGraph g;
  string filename, stem, outdir;
  namespace po = boost::program_options;
  po::options_description desc("Allowed options");
  desc.add_options()("help", "produce help message")(
      "input", po::value<string>(), "filename for the graphml file to process")(
      "outdir", po::value<string>(), "directory to save output files in");

  po::variables_map vm;
  po::store(po::parse_command_line(ac, av, desc), vm);
  po::notify(vm);

  if (vm.count("help")) {
    cout << desc << "\n";
    return 0;
  }

  if (vm.count("outdir")) {
    outdir = vm["outdir"].as<string>();
  } else {
    cout << "No output directory specified"
         << "\n";
    return 1;
  }

  if (vm.count("input")) {
    filename = vm["input"].as<string>();
    boost::filesystem::path p(filename);
    stem = p.stem().string();
    cout << "Reading graph from " << filename << std::endl;
  } else {
    cout << "No input file provided" << std::endl;
    return 1;
  }

  try {
    std::ifstream fstream(filename);
    readgraph(g, fstream);
  } catch (std::exception &e) {
    cout << "Error reading file " << filename << endl;
    return 1;
  }

  // // boost::print_graph(g, get(&LitVertex::name, g), std::cout);

  // // std::for_each(vertices(g).first, vertices(g).second,
  // //                   exercise_vertex<LitGraph>(g));

  // //boost::write_graphml(std::cout, g, dp);
  // // std::for_each(vertices(g).first, vertices(g).second,
  // //               degrees<LitGraph>(g));

  // // vector<Degree> in_degrees, out_degrees, degrees;
  // // get_degrees(in_degrees, out_degrees, degrees, g);
  // // for (vector<Degree>::const_iterator i = in_degrees.begin(); i !=
  // in_degrees.end(); ++i) {
  // //   std::cout << *i << ' ';
  // // }
  // // std::cout << endl;
  // // for (vector<Degree>::const_iterator i = out_degrees.begin(); i !=
  // out_degrees.end(); ++i) {
  // //   std::cout << *i << ' ';
  // // }
  // // std::cout << endl;
  // // for (vector<Degree>::const_iterator i = degrees.begin(); i !=
  // degrees.end(); ++i) {
  // //   std::cout << *i << ' ';
  // // }
  // // std::cout << endl;

  // std::cout << "Number of vertices: " << num_vertices(g) << endl;

  // // map<string, double> stats = get_degrees_stats(g);

  // // for (map<string, double>::const_iterator i = stats.begin(); i !=
  // stats.end(); ++i) {
  // //   std::cout << i->first << ' ' << i->second << endl;
  // // }

  get_articulation_points(g, stem, outdir);

  get_centrality(g, stem, outdir);

  // return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x670, %rsp            # imm = 0x670
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x49(%rbp), %rsi
callq 0x10100
leaq -0x70(%rbp), %rdi
callq 0xa610
leaq -0x90(%rbp), %rdi
callq 0xa610
leaq -0xb0(%rbp), %rdi
callq 0xa610
leaq -0x151(%rbp), %rdi
movq %rdi, -0x580(%rbp)
callq 0xa7e0
movq -0x580(%rbp), %rdx
leaq 0x3e165(%rip), %rsi     # 0x4b16d
leaq -0x150(%rbp), %rdi
callq 0x10010
jmp 0xd016
movq 0x67f4b(%rip), %rax     # 0x74f68
movl (%rax), %edx
movl %edx, %ecx
shrl %ecx
leaq -0x130(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0xa600
jmp 0xd038
leaq -0x150(%rbp), %rdi
callq 0xa2b0
leaq -0x151(%rbp), %rdi
callq 0xa480
leaq -0x130(%rbp), %rdi
callq 0xa500
movq %rax, -0x588(%rbp)
jmp 0xd065
movq -0x588(%rbp), %rax
movq %rax, -0x170(%rbp)
leaq 0x3e103(%rip), %rsi     # 0x4b17d
leaq 0x3e101(%rip), %rdx     # 0x4b182
leaq -0x170(%rbp), %rdi
callq 0xa810
movq %rax, -0x590(%rbp)
jmp 0xd096
callq 0x10170
movq %rax, -0x598(%rbp)
jmp 0xd0a4
movq -0x598(%rbp), %rdx
movq -0x590(%rbp), %rdi
leaq 0x3e0de(%rip), %rsi     # 0x4b197
leaq 0x3e0dd(%rip), %rcx     # 0x4b19d
callq 0xa870
movq %rax, -0x5a0(%rbp)
jmp 0xd0ce
callq 0x10170
movq %rax, -0x5a8(%rbp)
jmp 0xd0dc
movq -0x5a8(%rbp), %rdx
movq -0x5a0(%rbp), %rdi
leaq 0x3e0d5(%rip), %rsi     # 0x4b1c6
leaq 0x3e0d5(%rip), %rcx     # 0x4b1cd
callq 0xa870
jmp 0xd0ff
leaq -0x210(%rbp), %rdi
callq 0xa1c0
jmp 0xd10d
movl -0x8(%rbp), %eax
movl %eax, -0x5b4(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x5b0(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x250(%rbp)
movaps %xmm0, -0x260(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x102c0
jmp 0xd140
movq -0x5b0(%rbp), %rdx
movl -0x5b4(%rbp), %esi
leaq -0x238(%rbp), %rdi
leaq -0x130(%rbp), %rcx
xorl %r8d, %r8d
leaq -0x260(%rbp), %r9
callq 0x10180
jmp 0xd16c
leaq -0x238(%rbp), %rdi
leaq -0x210(%rbp), %rsi
xorl %edx, %edx
callq 0xa7c0
jmp 0xd183
leaq -0x238(%rbp), %rdi
callq 0x102e0
leaq -0x260(%rbp), %rdi
callq 0x10300
leaq -0x210(%rbp), %rdi
callq 0xa280
jmp 0xd1a9
leaq -0x200(%rbp), %rax
movq %rax, -0x5c8(%rbp)
leaq -0x281(%rbp), %rdi
movq %rdi, -0x5c0(%rbp)
callq 0xa7e0
movq -0x5c0(%rbp), %rdx
leaq 0x3dfa5(%rip), %rsi     # 0x4b17d
leaq -0x280(%rbp), %rdi
callq 0x10010
jmp 0xd1e6
movq -0x5c8(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x10330
movq %rax, -0x5d0(%rbp)
jmp 0xd202
leaq -0x280(%rbp), %rdi
callq 0xa2b0
leaq -0x281(%rbp), %rdi
callq 0xa480
movq -0x5d0(%rbp), %rax
cmpq $0x0, %rax
je 0xd369
movq 0x67d7e(%rip), %rdi     # 0x74fb0
leaq -0x130(%rbp), %rsi
callq 0xa0b0
movq %rax, -0x5d8(%rbp)
jmp 0xd247
movq -0x5d8(%rbp), %rdi
leaq 0x3de21(%rip), %rsi     # 0x4b076
callq 0xa410
jmp 0xd25c
movl $0x0, -0x4(%rbp)
movl $0x1, -0x288(%rbp)
jmp 0xd96e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0xd2a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x150(%rbp), %rdi
callq 0xa2b0
leaq -0x151(%rbp), %rdi
callq 0xa480
jmp 0xd9d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0xd9c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0xd9bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0xd315
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x102e0
leaq -0x260(%rbp), %rdi
callq 0x10300
jmp 0xd9bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0xd358
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x280(%rbp), %rdi
callq 0xa2b0
leaq -0x281(%rbp), %rdi
callq 0xa480
jmp 0xd9bc
leaq -0x200(%rbp), %rax
movq %rax, -0x5e8(%rbp)
leaq -0x2a9(%rbp), %rdi
movq %rdi, -0x5e0(%rbp)
callq 0xa7e0
movq -0x5e0(%rbp), %rdx
leaq 0x3de2e(%rip), %rsi     # 0x4b1c6
leaq -0x2a8(%rbp), %rdi
callq 0x10010
jmp 0xd3a6
movq -0x5e8(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
callq 0x10330
movq %rax, -0x5f0(%rbp)
jmp 0xd3c2
leaq -0x2a8(%rbp), %rdi
callq 0xa2b0
leaq -0x2a9(%rbp), %rdi
callq 0xa480
movq -0x5f0(%rbp), %rax
cmpq $0x0, %rax
je 0xd503
leaq -0x2d1(%rbp), %rdi
movq %rdi, -0x5f8(%rbp)
callq 0xa7e0
movq -0x5f8(%rbp), %rdx
leaq 0x3ddba(%rip), %rsi     # 0x4b1c6
leaq -0x2d0(%rbp), %rdi
callq 0x10010
jmp 0xd41a
leaq -0x210(%rbp), %rdi
leaq -0x2d0(%rbp), %rsi
callq 0x10390
movq %rax, -0x600(%rbp)
jmp 0xd436
movq -0x600(%rbp), %rdi
callq 0x103c0
movq %rax, -0x608(%rbp)
jmp 0xd44b
movq -0x608(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0xa050
jmp 0xd460
leaq -0x2d0(%rbp), %rdi
callq 0xa2b0
leaq -0x2d1(%rbp), %rdi
callq 0xa480
jmp 0xd54a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0xd4af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0xa2b0
leaq -0x2a9(%rbp), %rdi
callq 0xa480
jmp 0xd9bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0xd4f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x2d0(%rbp), %rdi
callq 0xa2b0
leaq -0x2d1(%rbp), %rdi
callq 0xa480
jmp 0xd9bc
movq 0x67aa6(%rip), %rdi     # 0x74fb0
leaq 0x3dcde(%rip), %rsi     # 0x4b1ef
callq 0xa410
movq %rax, -0x610(%rbp)
jmp 0xd51f
movq -0x610(%rbp), %rdi
leaq 0x3db49(%rip), %rsi     # 0x4b076
callq 0xa410
jmp 0xd534
movl $0x1, -0x4(%rbp)
movl $0x1, -0x288(%rbp)
jmp 0xd96e
leaq -0x200(%rbp), %rax
movq %rax, -0x620(%rbp)
leaq -0x2f9(%rbp), %rdi
movq %rdi, -0x618(%rbp)
callq 0xa7e0
movq -0x618(%rbp), %rdx
leaq 0x3dc1e(%rip), %rsi     # 0x4b197
leaq -0x2f8(%rbp), %rdi
callq 0x10010
jmp 0xd587
movq -0x620(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x10330
movq %rax, -0x628(%rbp)
jmp 0xd5a3
leaq -0x2f8(%rbp), %rdi
callq 0xa2b0
leaq -0x2f9(%rbp), %rdi
callq 0xa480
movq -0x628(%rbp), %rax
cmpq $0x0, %rax
je 0xd7d7
leaq -0x321(%rbp), %rdi
movq %rdi, -0x630(%rbp)
callq 0xa7e0
movq -0x630(%rbp), %rdx
leaq 0x3dbaa(%rip), %rsi     # 0x4b197
leaq -0x320(%rbp), %rdi
callq 0x10010
jmp 0xd5fb
leaq -0x210(%rbp), %rdi
leaq -0x320(%rbp), %rsi
callq 0x10390
movq %rax, -0x638(%rbp)
jmp 0xd617
movq -0x638(%rbp), %rdi
callq 0x103c0
movq %rax, -0x640(%rbp)
jmp 0xd62c
movq -0x640(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0xa050
jmp 0xd63e
leaq -0x320(%rbp), %rdi
callq 0xa2b0
leaq -0x321(%rbp), %rdi
callq 0xa480
leaq -0x348(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x103e0
jmp 0xd668
leaq -0x368(%rbp), %rdi
leaq -0x348(%rbp), %rsi
callq 0xa0e0
jmp 0xd67d
leaq -0x368(%rbp), %rdi
callq 0x10410
movq %rax, -0x648(%rbp)
jmp 0xd692
movq -0x648(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0xa050
jmp 0xd6a7
leaq -0x368(%rbp), %rdi
callq 0x10420
movq 0x678f6(%rip), %rdi     # 0x74fb0
leaq 0x3db4c(%rip), %rsi     # 0x4b20d
callq 0xa410
movq %rax, -0x650(%rbp)
jmp 0xd6cf
movq -0x650(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0xa3e0
movq %rax, -0x658(%rbp)
jmp 0xd6e8
movq -0x658(%rbp), %rdi
movq 0x6786a(%rip), %rsi     # 0x74f60
callq 0xa460
jmp 0xd6fd
leaq -0x348(%rbp), %rdi
callq 0x10420
jmp 0xd81e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0xd740
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x2f8(%rbp), %rdi
callq 0xa2b0
leaq -0x2f9(%rbp), %rdi
callq 0xa480
jmp 0xd9bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0xd783
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x320(%rbp), %rdi
callq 0xa2b0
leaq -0x321(%rbp), %rdi
callq 0xa480
jmp 0xd9bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0xd7c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x368(%rbp), %rdi
callq 0x10420
leaq -0x348(%rbp), %rdi
callq 0x10420
jmp 0xd9bc
movq 0x677d2(%rip), %rdi     # 0x74fb0
leaq 0x3da3c(%rip), %rsi     # 0x4b221
callq 0xa410
movq %rax, -0x660(%rbp)
jmp 0xd7f3
movq -0x660(%rbp), %rdi
movq 0x6775f(%rip), %rsi     # 0x74f60
callq 0xa460
jmp 0xd808
movl $0x1, -0x4(%rbp)
movl $0x1, -0x288(%rbp)
jmp 0xd96e
leaq -0x570(%rbp), %rdi
leaq -0x70(%rbp), %rsi
movl $0x8, %edx
callq 0xa700
jmp 0xd835
leaq -0x48(%rbp), %rdi
leaq -0x570(%rbp), %rsi
callq 0x36400
jmp 0xd847
leaq -0x570(%rbp), %rdi
callq 0xa110
jmp 0xd932
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0xd88a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x570(%rbp), %rdi
callq 0xa110
movl -0x164(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0xd9bc
movq -0x160(%rbp), %rdi
callq 0xa1a0
movq %rax, -0x578(%rbp)
movq 0x676f9(%rip), %rdi     # 0x74fb0
leaq 0x3d97a(%rip), %rsi     # 0x4b238
callq 0xa410
movq %rax, -0x668(%rbp)
jmp 0xd8cc
movq -0x668(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0xa3e0
movq %rax, -0x670(%rbp)
jmp 0xd8e5
movq -0x670(%rbp), %rdi
movq 0x6766d(%rip), %rsi     # 0x74f60
callq 0xa460
jmp 0xd8fa
movl $0x1, -0x4(%rbp)
movl $0x1, -0x288(%rbp)
callq 0xa730
jmp 0xd92b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
callq 0xa730
jmp 0xd92d
jmp 0xd96e
jmp 0xd9bc
leaq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0xc4c0
jmp 0xd94b
leaq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0xad70
jmp 0xd964
movl $0x0, -0x288(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x10440
leaq -0x130(%rbp), %rdi
callq 0x104a0
leaq -0xb0(%rbp), %rdi
callq 0xa2b0
leaq -0x90(%rbp), %rdi
callq 0xa2b0
leaq -0x70(%rbp), %rdi
callq 0xa2b0
leaq -0x48(%rbp), %rdi
callq 0x104f0
movl -0x4(%rbp), %eax
addq $0x670, %rsp            # imm = 0x670
popq %rbp
retq
leaq -0x210(%rbp), %rdi
callq 0x10440
leaq -0x130(%rbp), %rdi
callq 0x104a0
leaq -0xb0(%rbp), %rdi
callq 0xa2b0
leaq -0x90(%rbp), %rdi
callq 0xa2b0
leaq -0x70(%rbp), %rdi
callq 0xa2b0
leaq -0x48(%rbp), %rdi
callq 0x104f0
movq -0x160(%rbp), %rdi
callq 0xa7d0
movq %rax, %rdi
callq 0xe060
nopw %cs:(%rax,%rax)