// File: /workspace/github_cpp_makefile_star2_O3/afinit[P]afin/afin.cpp
// Function: main
int main( int argc, char** argv ){
  //////////////////////////////////
  // Process Command Line Options //
  //////////////////////////////////
  max_search_loops = 10;
  contig_sub_len = 100;
  extend_len = 40;
  max_sort_char = 4;
  min_cov = 3;
  min_overlap = 20;
  max_threads = 4;
  initial_trim = 0;
  max_missed = 5;
  stop_ext = .5;
  mismatch_threshold = 0.1;
  test_run = false;
  print_fused = 0;
  screen_output = 1;
  log_output = 1;
  verbose = 0;
  no_fusion = 0;

  int c;
  bool quit_flag = false;
  Process process;
  
  // initialize global Log object
  Log::Inst();
  
  // prevent output to stderr if erroneous option is found
  opterr = 0;
  
  int option_index = 0;

  static struct option long_options[] =
  {
    {"silent",        no_argument,  &screen_output, 0},
    {"no_log",        no_argument,  &log_output,  0},
    {"no_fusion",     no_argument,  &no_fusion,  1},
    {"verbose",       no_argument,  &verbose,  1},
    {"print_fused",   no_argument,  &print_fused, 1},
    {"contigsfiles",  required_argument,  0,  'c'},
    {"readsfiles",    required_argument,  0,  'r'},
    {"outfile",       required_argument,  0,  'o'},
    {"sort_char",     required_argument,  0,  'm'},
    {"sub_len",       required_argument,  0,  's'},
    {"search_loops",  required_argument,  0,  'l'},
    {"min_cov",       required_argument,  0,  'i'},
    {"min_overlap",   required_argument,  0,  'p'},
    {"max_threads",   required_argument,  0,  't'},
    {"initial_trim",  required_argument,  0,  'd'},
    {"max_missed",    required_argument,  0,  'e'},
    {"mismatch",      required_argument,  0,  'g'},
    {"extend_len",    required_argument,  0,  'x'},
    {"stop_ext",      required_argument,  0,  'f'},
    {"help",          no_argument,        0,  'h'},
    {"test_run",      no_argument,        0,  'z'},
    {0, 0, 0, 0}
  };
  
  // get all options that have been provided on the command line
  while (( c = getopt_long(argc, argv, "hr:c:o:s:l:x:m:i:p:t:d:e:f:g:z", long_options, &option_index )) != -1 ) {
    switch( c ) {
      case 0:
        /* If this option set a flag, do nothing else now. */
        if (long_options[option_index].flag != 0)
          break;
        printf ("option %s", long_options[option_index].name);
        if (optarg)
          printf (" with arg %s", optarg);
        printf ("\n");
        break;
      case 'h':
        print_usage( argv[0] );
        exit(0);
        break;
      // max_sort_char option
      case 'm':
        max_sort_char = atoi(optarg);
        break;
      // contig_sub_len option
      case 's':
        contig_sub_len = atoi(optarg);
        break;
      // extend_len option
      case 'x':
        extend_len = atoi(optarg);
        break;
      // max_sort_char option
      case 'l':
        max_search_loops = atoi(optarg);
        break;
      // min_cov option
      case 'i':
        min_cov = atoi(optarg);
        break;
      // min_overlap option
      case 'p':
        min_overlap = atoi(optarg);
        break;
      // max_threads option
      case 't':
        max_threads = atoi(optarg);
        break;
      // initial_trim option
      case 'd':
        initial_trim = atoi(optarg);
        break;
      // max_missed option
      case 'e':
        max_missed = atoi(optarg);
        break;
      // stop_ext option
      case 'f':
        stop_ext = atof(optarg);
        break;
      // mismatch_threshold option
      case 'g':
        mismatch_threshold = atof(optarg);
        break;
      // outputfile option
      case 'o':
        process.outfile = optarg;
        break;
      // readfile option
      case 'r':
        optind--;
        // loop through each file
        while ( optind < argc && argv[optind][0] != '-' ) { 
          if( process.readsfiles != "" ){
            process.readsfiles.append( "," );
          }
          process.readsfiles.append( argv[optind] );
          optind++;
        }   
        break;
      // contig file option
      case 'c':
        optind--;
        // loop through each file
        while ( optind < argc && argv[optind][0] != '-' ) { 
          if( process.contigsfiles != "" ){
            process.contigsfiles.append( "," );
          }
          process.contigsfiles.append( argv[optind] );
          optind++;
        }   
        break;
      // test_run option
      case 'z':
        test_run = true;
        break;
      case '?':
        if ( optopt == 'r' ){
          fprintf( stderr, "%s: Error: Option -r requires an argument. ", argv[0] );
          print_usage( argv[0] );
        }
        else if ( optopt == 'o' ){
          fprintf( stderr, "%s: Error: Option -o requires an argument. ", argv[0] );
          print_usage( argv[0] );
        }
        else if ( optopt == 'c' ){
          fprintf( stderr, "%s: Error: Option -c requires an argument. ", argv[0] );
          print_usage( argv[0] );
        }
        else if ( isprint( optopt )){
          fprintf( stderr, "%s: Error: Unknown option -%c. \n", argv[0], optopt );
          print_usage( argv[0] );
        }
        else{
          fprintf( stderr, "%s: Error: Unknown option character %x.\n", argv[0], optopt );
          print_usage( argv[0] );
        }
        return 1;
      default:
        abort();
    }
  }
  
  /////////////////
  // End Options //
  /////////////////

  //////////////////
  // Input Errors //
  //////////////////
  if( process.contigsfiles == "" ){
    fprintf( stderr, "%s: Error: contigsfile(s) must be provided.\n", argv[0] );
    quit_flag = true;
  }

  if( process.readsfiles == "" ){
    fprintf( stderr, "%s: Error: readsfile(s) must be provided.\n", argv[0] );
    quit_flag = true;
  }

  if( min_overlap < max_sort_char ){
    fprintf( stderr, "%s: Error: min_overlap must be >= max_sort_char.\n", argv[0] );
    quit_flag = true;
  }

  if( quit_flag ){
    exit(1);
  }

  ////////////////
  // End Errors //
  ////////////////

  // start run
  process.start_run();

  Log::Inst()->close_log();
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rsi, %rbx
movl %edi, %r14d
leaq 0x184c4(%rip), %rax     # 0x1d608
movl $0xa, (%rax)
leaq 0x184bb(%rip), %rax     # 0x1d60c
movl $0x64, (%rax)
leaq 0x184b2(%rip), %rax     # 0x1d610
movl $0x28, (%rax)
leaq 0x184a9(%rip), %rcx     # 0x1d614
movl $0x4, %eax
movl %eax, (%rcx)
leaq 0x1849f(%rip), %rcx     # 0x1d618
movl $0x3, (%rcx)
leaq 0x18496(%rip), %rcx     # 0x1d61c
movl $0x14, (%rcx)
leaq 0x1848d(%rip), %rcx     # 0x1d620
movl %eax, (%rcx)
xorl %r15d, %r15d
leaq 0x18491(%rip), %rcx     # 0x1d630
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
movq %rax, (%rcx)
leaq 0x1848d(%rip), %rax     # 0x1d640
movl $0x1, %ecx
movl %ecx, (%rax)
leaq 0x18483(%rip), %rax     # 0x1d644
movl %ecx, (%rax)
leaq 0x18486(%rip), %rcx     # 0x1d650
movabsq $0x3fb999999999999a, %rax # imm = 0x3FB999999999999A
movq %rax, (%rcx)
leaq 0x1845e(%rip), %rax     # 0x1d63c
movl %r15d, (%rax)
leaq 0x18460(%rip), %rax     # 0x1d648
movl %r15d, (%rax)
leaq 0x1845a(%rip), %rax     # 0x1d64c
movl %r15d, (%rax)
leaq 0x18428(%rip), %rax     # 0x1d624
movl %r15d, (%rax)
leaq 0x18422(%rip), %rax     # 0x1d628
movl $0x5, (%rax)
leaq 0x18425(%rip), %rax     # 0x1d638
movb $0x0, (%rax)
leaq -0x168(%rbp), %rdi
callq 0x6c80
callq 0x9692
movq 0x17daa(%rip), %rax     # 0x1cfd8
movl %r15d, (%rax)
leaq -0x30(%rbp), %rax
movl %r15d, (%rax)
leaq -0x110(%rbp), %r13
leaq -0x130(%rbp), %r15
movq 0x17d83(%rip), %r12     # 0x1cfd0
movl %r14d, %edi
movq %rbx, %rsi
leaq 0x10804(%rip), %rdx     # 0x15a5e
leaq 0x180cf(%rip), %rcx     # 0x1d330
leaq -0x30(%rbp), %r8
callq 0x4550
cmpl $0x62, %eax
jle 0x52ec
addl $-0x63, %eax
cmpl $0x17, %eax
ja 0x57cf
leaq 0xfd82(%rip), %rcx      # 0x15004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl (%r12), %ecx
leal -0x1(%rcx), %eax
movl %eax, (%r12)
cmpl %r14d, %ecx
jg 0x524d
cltq
movq (%rbx,%rax,8), %rax
cmpb $0x2d, (%rax)
je 0x524d
movq %r13, %rdi
leaq 0x10c9c(%rip), %rsi     # 0x15f4c
callq 0x40d0
testl %eax, %eax
je 0x52c8
movq %r13, %rdi
leaq 0x107d1(%rip), %rsi     # 0x15a94
callq 0x45f0
movslq (%r12), %rax
movq (%rbx,%rax,8), %rsi
movq %r13, %rdi
callq 0x45f0
movl (%r12), %eax
incl %eax
movl %eax, (%r12)
cmpl %r14d, %eax
jl 0x529b
jmp 0x524d
testl %eax, %eax
jne 0x5554
movslq -0x30(%rbp), %rax
shlq $0x5, %rax
leaq 0x1802d(%rip), %rcx     # 0x1d330
cmpq $0x0, 0x10(%rax,%rcx)
jne 0x524d
leaq 0x1801a(%rip), %rcx     # 0x1d330
addq %rcx, %rax
movq (%rax), %rsi
leaq 0x1075a(%rip), %rdi     # 0x15a7d
xorl %eax, %eax
callq 0x4040
movq 0x17c67(%rip), %rax     # 0x1cf98
movq (%rax), %rsi
testq %rsi, %rsi
je 0x5347
leaq 0x10747(%rip), %rdi     # 0x15a87
xorl %eax, %eax
callq 0x4040
movl $0xa, %edi
callq 0x4430
jmp 0x524d
movq 0x17c3b(%rip), %rax     # 0x1cf98
movq (%rax), %rdi
callq 0x4500
leaq 0x1829c(%rip), %rcx     # 0x1d608
movl %eax, (%rcx)
jmp 0x524d
movq 0x17c1e(%rip), %rax     # 0x1cf98
movq (%rax), %rdi
callq 0x4500
leaq 0x18297(%rip), %rcx     # 0x1d620
movl %eax, (%rcx)
jmp 0x524d
movq 0x17c01(%rip), %rax     # 0x1cf98
movq (%rax), %rdi
callq 0x4500
leaq 0x1827e(%rip), %rcx     # 0x1d624
movl %eax, (%rcx)
jmp 0x524d
movq 0x17be4(%rip), %rax     # 0x1cf98
movq (%rax), %r13
movq -0x148(%rbp), %r15
movq %r13, %rdi
callq 0x4140
leaq -0x150(%rbp), %rdi
xorl %esi, %esi
movq %r15, %rdx
leaq -0x130(%rbp), %r15
movq %r13, %rcx
leaq -0x110(%rbp), %r13
movq %rax, %r8
callq 0x44f0
jmp 0x524d
movq 0x17ba1(%rip), %rax     # 0x1cf98
movq (%rax), %rdi
callq 0x4500
leaq 0x18212(%rip), %rcx     # 0x1d618
movl %eax, (%rcx)
jmp 0x524d
movq 0x17b84(%rip), %rax     # 0x1cf98
movq (%rax), %rdi
callq 0x43c0
leaq 0x1820d(%rip), %rax     # 0x1d630
movsd %xmm0, (%rax)
jmp 0x524d
movq 0x17b65(%rip), %rax     # 0x1cf98
movq (%rax), %rdi
callq 0x4500
leaq 0x181e6(%rip), %rcx     # 0x1d628
movl %eax, (%rcx)
jmp 0x524d
movq 0x17b48(%rip), %rax     # 0x1cf98
movq (%rax), %rdi
callq 0x4500
leaq 0x181ad(%rip), %rcx     # 0x1d60c
movl %eax, (%rcx)
jmp 0x524d
movq 0x17b2b(%rip), %rax     # 0x1cf98
movq (%rax), %rdi
callq 0x43c0
leaq 0x181d4(%rip), %rax     # 0x1d650
movsd %xmm0, (%rax)
jmp 0x524d
movq 0x17b0c(%rip), %rax     # 0x1cf98
movq (%rax), %rdi
callq 0x4500
leaq 0x18179(%rip), %rcx     # 0x1d614
movl %eax, (%rcx)
jmp 0x524d
movl (%r12), %ecx
leal -0x1(%rcx), %eax
movl %eax, (%r12)
cmpl %r14d, %ecx
jg 0x524d
cltq
movq (%rbx,%rax,8), %rax
cmpb $0x2d, (%rax)
je 0x524d
movq %r15, %rdi
leaq 0x10a7d(%rip), %rsi     # 0x15f4c
callq 0x40d0
testl %eax, %eax
je 0x54e7
movq %r15, %rdi
leaq 0x105b2(%rip), %rsi     # 0x15a94
callq 0x45f0
movslq (%r12), %rax
movq (%rbx,%rax,8), %rsi
movq %r15, %rdi
callq 0x45f0
movl (%r12), %eax
incl %eax
movl %eax, (%r12)
cmpl %r14d, %eax
jl 0x54b6
jmp 0x524d
movq 0x17a86(%rip), %rax     # 0x1cf98
movq (%rax), %rdi
callq 0x4500
leaq 0x180ef(%rip), %rcx     # 0x1d610
movl %eax, (%rcx)
jmp 0x524d
movq 0x17a69(%rip), %rax     # 0x1cf98
movq (%rax), %rdi
callq 0x4500
leaq 0x180de(%rip), %rcx     # 0x1d61c
movl %eax, (%rcx)
jmp 0x524d
leaq 0x180ec(%rip), %rax     # 0x1d638
movb $0x1, (%rax)
jmp 0x524d
cmpl $-0x1, %eax
jne 0x55ea
leaq 0x109e8(%rip), %rsi     # 0x15f4c
movq %r13, %rdi
callq 0x40d0
movl %eax, %r14d
testl %eax, %eax
je 0x565d
leaq 0x109ce(%rip), %rsi     # 0x15f4c
movq %r15, %rdi
callq 0x40d0
testl %eax, %eax
je 0x566a
leaq 0x18087(%rip), %rax     # 0x1d61c
movl (%rax), %eax
leaq 0x18076(%rip), %rcx     # 0x1d614
cmpl (%rcx), %eax
jl 0x5676
testl %r14d, %r14d
je 0x567e
leaq -0x168(%rbp), %rdi
callq 0x7b98
callq 0x9692
xorl %ebx, %ebx
movq %rax, %rdi
callq 0x9720
leaq -0x168(%rbp), %rdi
callq 0x6d76
movl %ebx, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3f, %eax
jne 0x57cf
movq 0x179be(%rip), %rax     # 0x1cfb8
movl (%rax), %r14d
cmpl $0x63, %r14d
je 0x56ce
cmpl $0x6f, %r14d
je 0x5688
cmpl $0x72, %r14d
jne 0x570e
movq 0x179aa(%rip), %rax     # 0x1cfc8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x1046b(%rip), %rsi     # 0x15a96
xorl %eax, %eax
callq 0x4460
movq (%rbx), %rsi
leaq -0xd0(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4120
leaq -0xd0(%rbp), %rdi
callq 0x4a8c
leaq -0xc0(%rbp), %rax
jmp 0x5785
movq %rbx, %rdi
callq 0x4650
jmp 0x5577
movq %rbx, %rdi
callq 0x4674
testb $0x1, %al
je 0x567e
movq %rbx, %rdi
callq 0x46b1
movl $0x1, %edi
callq 0x43a0
movq 0x17939(%rip), %rax     # 0x1cfc8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x10426(%rip), %rsi     # 0x15ac2
xorl %eax, %eax
callq 0x4460
movq (%rbx), %rsi
leaq -0xb0(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4120
leaq -0xb0(%rbp), %rdi
callq 0x4a8c
leaq -0xa0(%rbp), %rax
jmp 0x5785
movq 0x178f3(%rip), %rax     # 0x1cfc8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x1040c(%rip), %rsi     # 0x15aee
xorl %eax, %eax
callq 0x4460
movq (%rbx), %rsi
leaq -0x90(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4120
leaq -0x90(%rbp), %rdi
callq 0x4a8c
leaq -0x80(%rbp), %rax
jmp 0x5785
movl %r14d, %edi
callq 0x45a0
movq 0x178ab(%rip), %rcx     # 0x1cfc8
movq (%rcx), %rdi
movq (%rbx), %rdx
testl %eax, %eax
jne 0x5757
leaq 0x1040d(%rip), %rsi     # 0x15b3b
movl %r14d, %ecx
xorl %eax, %eax
callq 0x4460
movq (%rbx), %rsi
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4120
leaq -0x50(%rbp), %rdi
callq 0x4a8c
leaq -0x40(%rbp), %rax
jmp 0x5785
leaq 0x103bc(%rip), %rsi     # 0x15b1a
movl %r14d, %ecx
xorl %eax, %eax
callq 0x4460
movq (%rbx), %rsi
leaq -0x70(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4120
leaq -0x70(%rbp), %rdi
callq 0x4a8c
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5793
callq 0x42f0
movl $0x1, %ebx
jmp 0x55ca
movq (%rbx), %rsi
leaq -0xf0(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4120
leaq -0xf0(%rbp), %rdi
callq 0x4a8c
leaq -0xf0(%rbp), %rdi
callq 0x4160
xorl %edi, %edi
callq 0x43a0
callq 0x41e0
movq %rax, %rbx
leaq -0x60(%rbp), %rax
jmp 0x581f
jmp 0x5835
movq %rax, %rbx
leaq -0x40(%rbp), %rax
jmp 0x581f
jmp 0x5835
movq %rax, %rbx
leaq -0x80(%rbp), %rax
jmp 0x581f
jmp 0x5835
movq %rax, %rbx
leaq -0xa0(%rbp), %rax
jmp 0x581f
jmp 0x5835
movq %rax, %rbx
leaq -0xc0(%rbp), %rax
jmp 0x581f
jmp 0x5835
jmp 0x5835
jmp 0x5835
movq %rax, %rbx
leaq -0xe0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5838
callq 0x42f0
jmp 0x5838
jmp 0x5835
jmp 0x5835
jmp 0x5835
movq %rax, %rbx
leaq -0x168(%rbp), %rdi
callq 0x6d76
movq %rbx, %rdi
callq 0x4590