// File: kingufl[P]Rmapper/src/buildgraph.cpp
// Function: parseArgs(int, char* const*, Args&)
void parseArgs(int argc, char *const argv[], Args &arg)
{
  int c;
  extern char *optarg;
  extern int optind;

  std::string usage("usage: " + std::string(argv[0]) + " infile [-k ksize] [-d dsize] [-f tf] [-l tl] [-r rev] [-o output]\n\n" +
                    "Computes the bi-labelled de Bruijn graph of the error-corrected rmaps in [infile].\n" +
                    "  ksize: [integer] - k-mer size (def. 6)\n" +
                    "  dsize: [integer] - minimum distance between two k-mers in a bi-label. (def. 15000)\n" +
                    "     tf: [integer] - fragment proximal error tollerance. (def. 500)\n" +
                    "     tl: [integer] - length proximal error tollerance. (def. 2000)\n" +
                    "    rev: [boolean] - include reverse rmaps. (def. false)\n" +
                    " output: [string]  - output directory that must exists. (def. .)\n");

  std::string sarg;
  while ((c = getopt(argc, argv, "k:d:f:l:ro:")) != -1)
  {
    switch (c)
    {
    case 'k':
      sarg.assign(optarg);
      arg.k = stoi(sarg);
      break;
    case 'd':
      sarg.assign(optarg);
      arg.d = stoi(sarg);
      break;
    case 'f':
      sarg.assign(optarg);
      arg.tf = stoi(sarg);
      break;
    case 'l':
      sarg.assign(optarg);
      arg.tl = stoi(sarg);
      break;
    case 'r':
      arg.rev = true;
      break;
    case 'o':
      arg.output.assign(optarg);
      break;
    case 'h':
      cerr << usage;
      exit(1);
    case '?':
      cerr << "Unknown option.\n" << usage;
      exit(1);
    }
  }
  // the only input parameter is the file name
  if (argc == optind + 1)
  {
    arg.filename.assign(argv[optind]);
  }
  else
  {
    cerr << "Invalid number of arguments\n" << usage;
    exit(1);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1d0, %rsp            # imm = 0x1D0
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x1a8(%rbp)
leaq -0x161(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x33e0
movq -0x1a8(%rbp), %rsi
movq -0x1a0(%rbp), %rdx
leaq -0x160(%rbp), %rdi
callq 0x3300
jmp 0xe6d3
leaq 0x1abb6(%rip), %rsi     # 0x29290
leaq -0x140(%rbp), %rdi
leaq -0x160(%rbp), %rdx
callq 0x175b0
jmp 0xe6ef
leaq 0x1aba2(%rip), %rdx     # 0x29298
leaq -0x120(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x17560
jmp 0xe70b
leaq 0x1abcb(%rip), %rdx     # 0x292dd
leaq -0x100(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x17560
jmp 0xe727
leaq 0x1ac03(%rip), %rdx     # 0x29331
leaq -0xe0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x17560
jmp 0xe743
leaq 0x1ac11(%rip), %rdx     # 0x2935b
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x17560
jmp 0xe75f
leaq 0x1ac4b(%rip), %rdx     # 0x293b1
leaq -0xa0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x17560
jmp 0xe77b
leaq 0x1ac74(%rip), %rdx     # 0x293f6
leaq -0x80(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x17560
jmp 0xe794
leaq 0x1ac9f(%rip), %rdx     # 0x2943a
leaq -0x60(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x17560
jmp 0xe7aa
leaq 0x1acc3(%rip), %rdx     # 0x29474
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x17560
jmp 0xe7c0
leaq -0x60(%rbp), %rdi
callq 0x31a0
leaq -0x80(%rbp), %rdi
callq 0x31a0
leaq -0xa0(%rbp), %rdi
callq 0x31a0
leaq -0xc0(%rbp), %rdi
callq 0x31a0
leaq -0xe0(%rbp), %rdi
callq 0x31a0
leaq -0x100(%rbp), %rdi
callq 0x31a0
leaq -0x120(%rbp), %rdi
callq 0x31a0
leaq -0x140(%rbp), %rdi
callq 0x31a0
leaq -0x160(%rbp), %rdi
callq 0x31a0
leaq -0x161(%rbp), %rdi
callq 0x32b0
leaq -0x198(%rbp), %rdi
callq 0x3310
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x1ac6a(%rip), %rdx     # 0x294b6
callq 0x30a0
movl %eax, -0x1c(%rbp)
cmpl $-0x1, %eax
je 0xebab
movl -0x1c(%rbp), %eax
addl $-0x3f, %eax
movl %eax, %ecx
movq %rcx, -0x1b0(%rbp)
subl $0x33, %eax
ja 0xeba6
movq -0x1b0(%rbp), %rax
leaq 0x1a8ed(%rip), %rcx     # 0x29170
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
jmp 0xe9c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
jmp 0xe9bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
jmp 0xe9af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
jmp 0xe9a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
jmp 0xe997
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
jmp 0xe98b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
jmp 0xe97f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
jmp 0xe973
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
jmp 0xe96a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x31a0
leaq -0x80(%rbp), %rdi
callq 0x31a0
leaq -0xa0(%rbp), %rdi
callq 0x31a0
leaq -0xc0(%rbp), %rdi
callq 0x31a0
leaq -0xe0(%rbp), %rdi
callq 0x31a0
leaq -0x100(%rbp), %rdi
callq 0x31a0
leaq -0x120(%rbp), %rdi
callq 0x31a0
leaq -0x140(%rbp), %rdi
callq 0x31a0
leaq -0x160(%rbp), %rdi
callq 0x31a0
leaq -0x161(%rbp), %rdi
callq 0x32b0
jmp 0xec33
movq 0x2d5b9(%rip), %rax     # 0x3bf98
movq (%rax), %rsi
leaq -0x198(%rbp), %rdi
callq 0x3410
jmp 0xe9f0
xorl %eax, %eax
movl %eax, %esi
leaq -0x198(%rbp), %rdi
movl $0xa, %edx
callq 0x17600
movl %eax, -0x1b4(%rbp)
jmp 0xea0d
movl -0x1b4(%rbp), %eax
movslq %eax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0xeba6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x170(%rbp)
movl %eax, -0x174(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x31a0
leaq -0x40(%rbp), %rdi
callq 0x31a0
jmp 0xec33
movq 0x2d542(%rip), %rax     # 0x3bf98
movq (%rax), %rsi
leaq -0x198(%rbp), %rdi
callq 0x3410
jmp 0xea67
xorl %eax, %eax
movl %eax, %esi
leaq -0x198(%rbp), %rdi
movl $0xa, %edx
callq 0x17600
movl %eax, -0x1b8(%rbp)
jmp 0xea84
movl -0x1b8(%rbp), %eax
movslq %eax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
jmp 0xeba6
movq 0x2d4f7(%rip), %rax     # 0x3bf98
movq (%rax), %rsi
leaq -0x198(%rbp), %rdi
callq 0x3410
jmp 0xeab2
xorl %eax, %eax
movl %eax, %esi
leaq -0x198(%rbp), %rdi
movl $0xa, %edx
callq 0x17600
movl %eax, -0x1bc(%rbp)
jmp 0xeacf
movl -0x1bc(%rbp), %eax
movslq %eax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0xeba6
movq 0x2d4ac(%rip), %rax     # 0x3bf98
movq (%rax), %rsi
leaq -0x198(%rbp), %rdi
callq 0x3410
jmp 0xeafd
xorl %eax, %eax
movl %eax, %esi
leaq -0x198(%rbp), %rdi
movl $0xa, %edx
callq 0x17600
movl %eax, -0x1c0(%rbp)
jmp 0xeb1a
movl -0x1c0(%rbp), %eax
movslq %eax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x38(%rax)
jmp 0xeba6
movq -0x18(%rbp), %rax
movb $0x1, 0x40(%rax)
jmp 0xeba6
movq -0x18(%rbp), %rdi
addq $0x48, %rdi
movq 0x2d452(%rip), %rax     # 0x3bf98
movq (%rax), %rsi
callq 0x3410
jmp 0xeb50
jmp 0xeba6
movq 0x2d48f(%rip), %rdi     # 0x3bfe8
leaq -0x40(%rbp), %rsi
callq 0x3230
jmp 0xeb64
movl $0x1, %edi
callq 0x32c0
movq 0x2d473(%rip), %rdi     # 0x3bfe8
leaq 0x1a946(%rip), %rsi     # 0x294c2
callq 0x3260
movq %rax, -0x1c8(%rbp)
jmp 0xeb8a
movq -0x1c8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3230
jmp 0xeb9c
movl $0x1, %edi
callq 0x32c0
jmp 0xe83e
movl -0x4(%rbp), %eax
movq 0x2d40b(%rip), %rcx     # 0x3bfc0
movl (%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0xebdd
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x2d3f3(%rip), %rcx     # 0x3bfc0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x3410
jmp 0xebdb
jmp 0xec15
movq 0x2d404(%rip), %rdi     # 0x3bfe8
leaq 0x1a8e8(%rip), %rsi     # 0x294d3
callq 0x3260
movq %rax, -0x1d0(%rbp)
jmp 0xebf9
movq -0x1d0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3230
jmp 0xec0b
movl $0x1, %edi
callq 0x32c0
leaq -0x198(%rbp), %rdi
callq 0x31a0
leaq -0x40(%rbp), %rdi
callq 0x31a0
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
movq -0x170(%rbp), %rdi
callq 0x33d0
nop