// File: /workspace/github_c_makefile_star2_O2/richarddurbin[P]hash10x/moshasm.c
// Function: main
int main (int argc, char *argv[])
{
  --argc ; ++argv ;		/* eat program name */

  outFile = stdout ;
  
  timeUpdate (stdout) ;		/* initialise timer */
#ifdef OMP
  numThreads = omp_get_max_threads () ;
  omp_set_num_threads (numThreads) ;
#endif

  if (!argc) usage () ;

  int i ;			/* generically useful variables */
  FILE *f ;
  Moshset *ms = 0 ;
  Readset *rs = 0 ;

  while (argc) {
    if (**argv != '-')
      die ("option/command %s does not start with '-': run without arguments for usage", *argv) ;
    fprintf (stderr, "COMMAND %s", *argv) ;
    for (i = 1 ; i < argc && *argv[i] != '-' ; ++i) fprintf (stderr, " %s", argv[i]) ;
    fputc ('\n', stderr) ;
    
#define ARGMATCH(x,y,n)	((!strcmp (*argv, x) || (!strcmp (*argv,y))) && argc >= n && (argc -= n, argv += n))
    if (ARGMATCH("-t","--threads",2))
      {
#ifdef OMP
	numThreads = atoi(argv[-1]) ;
	if (numThreads > omp_get_max_threads ()) numThreads = omp_get_max_threads () ;
	omp_set_num_threads (numThreads) ;
#else
	fprintf (stderr, "  can't set thread number - not compiled with OMP\n") ;
#endif
      }
    else if (ARGMATCH("-v","--verbose",1)) isVerbose = !isVerbose ;
    else if (ARGMATCH("-o","--output",2))
      { if (!strcmp (argv[-1], "-"))
	  outFile = stdout ;
	else if (!(outFile = fopen (argv[-1], "w")))
	  { fprintf (stderr, "can't open output file %s - resetting to stdout\n", argv[-1]) ;
	    outFile = stdout ;
	  }
      }
    else if (ARGMATCH("-m","--moshset",2))
      { if (!(f = fopen (argv[-1], "r"))) die ("failed to open mosh file %s", argv[-1]) ;
	if (ms) moshsetDestroy (ms) ;
	ms = moshsetRead (f) ;
	if (ms->max >= TOPBIT) die ("too many entries in moshset") ;
	moshsetSummary (ms, outFile) ;
      }
    else if (ARGMATCH("-f","--seqfile",2))
      { if (ms)
	  { if (rs) readsetDestroy (rs) ;
	    rs = readsetCreate (ms, 1<<16) ;
	    readsetFileRead (rs, argv[-1]) ;
	    fclose (f) ;
	  }
	else fprintf (stderr, "** need to read a moshset before a sequence file\n") ;
      }
    else if (ARGMATCH("-r","--read",2))
      { if (rs) readsetDestroy (rs) ;
	rs = readsetRead (argv[-1]) ;
      }
    else if (ARGMATCH("-w","--write",2))
      readsetWrite (rs, argv[-1]) ;
    else if (ARGMATCH("-S","--stats",1))
      readsetStats (rs) ;
    else if (ARGMATCH("-o1","--overlaps1",2))
      { Array a = findOverlaps (rs, arrp(rs->reads,(U32)atoi(argv[-1]), Read), 2) ;
	arrayDestroy (a) ;
      }
    else if (ARGMATCH("-o2","--overlaps2",2))
      { int d = atoi(argv[-1]) ;
	U32 ix ;
	Array a ;
	for (ix = d ; ix < arrayMax(rs->reads) ; ix += d)
	  { a = findOverlaps (rs, arrp(rs->reads,ix,Read), 1) ; arrayDestroy (a) ; }
      }
    else if (ARGMATCH("-o3","--overlap",3))
      printOverlap (rs, (U32)atoi(argv[-2]), (U32)atoi(argv[-1])) ;
    else if (ARGMATCH("-b","--markBadReads",1)) markBadReads (rs) ;
    else if (ARGMATCH("-c","--markContained",1)) markContained (rs) ;
    else if (ARGMATCH("-a1","--assemble1",2)) assembleFromRead (rs, (U32)atoi(argv[-1])) ;
    else die ("unkown command %s - run without arguments for usage", *argv) ;

    timeUpdate (outFile) ;
  }

  fprintf (outFile, "total resources used: ") ; timeTotal (outFile) ;
  if (outFile != stdout) { printf ("total resources used: ") ; timeTotal (stdout) ; }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r13
movl %edi, %ebx
movq 0x7f30(%rip), %rax      # 0xafd0
movq (%rax), %rdi
movq %rdi, 0x92c6(%rip)      # 0xc370
callq 0x67a3
decl %ebx
jne 0x30b8
callq 0x2f1c
addq $0x8, %r13
movq 0x7f35(%rip), %rbp      # 0xaff8
movq $0x0, (%rsp)
xorl %r12d, %r12d
testl %ebx, %ebx
je 0x3781
movq (%r13), %rdx
cmpb $0x2d, (%rdx)
jne 0x30e4
movq %r12, %r14
jmp 0x30fc
movq %r12, %r14
leaq 0x478a(%rip), %rdi      # 0x7878
movq %rdx, %rsi
xorl %eax, %eax
callq 0x64dc
movq (%r13), %rdx
movq (%rbp), %rdi
leaq 0x47bc(%rip), %rsi      # 0x78c3
xorl %eax, %eax
callq 0x1130
movslq %ebx, %r15
pushq $0x1
popq %r12
cmpq %r15, %r12
jge 0x313b
movq (%r13,%r12,8), %rdx
cmpb $0x2d, (%rdx)
je 0x313b
movq (%rbp), %rdi
leaq 0x479b(%rip), %rsi      # 0x78ca
xorl %eax, %eax
callq 0x1130
incq %r12
jmp 0x3115
movq (%rbp), %rsi
pushq $0xa
popq %rdi
callq 0x10f0
movq (%r13), %r15
movb (%r15), %r12b
cmpb $0x2d, %r12b
jne 0x3166
cmpb $0x74, 0x1(%r15)
jne 0x3166
cmpb $0x0, 0x2(%r15)
je 0x33bb
movq %r15, %rdi
leaq 0x475e(%rip), %rsi      # 0x78ce
callq 0x1110
cmpl $0x2, %ebx
jl 0x3182
testl %eax, %eax
je 0x33c4
cmpb $0x2d, %r12b
jne 0x319a
cmpb $0x76, 0x1(%r15)
jne 0x319a
cmpb $0x0, 0x2(%r15)
je 0x33ae
movq %r15, %rdi
leaq 0x4767(%rip), %rsi      # 0x790b
callq 0x1110
testl %ebx, %ebx
jle 0x31cd
testl %eax, %eax
jne 0x31cd
addq $0x8, %r13
decl %ebx
cmpb $0x0, 0x91aa(%rip)      # 0xc368
sete 0x91a3(%rip)            # 0xc368
movq %r14, %r12
jmp 0x339d
cmpb $0x2d, %r12b
jne 0x31e5
cmpb $0x6f, 0x1(%r15)
jne 0x31e5
cmpb $0x0, 0x2(%r15)
je 0x343b
movq %r15, %rdi
leaq 0x4726(%rip), %rsi      # 0x7915
callq 0x1110
cmpl $0x2, %ebx
jl 0x325e
testl %eax, %eax
jne 0x325e
addl $-0x2, %ebx
leaq 0x10(%r13), %r15
movq 0x8(%r13), %rdi
cmpb $0x2d, (%rdi)
movq %r14, %r12
jne 0x3216
cmpb $0x0, 0x1(%rdi)
je 0x3248
leaq 0x3e1b(%rip), %rsi      # 0x7038
callq 0x11d0
movq %rax, 0x9147(%rip)      # 0xc370
testq %rax, %rax
jne 0x339a
movq (%rbp), %rdi
movq 0x8(%r13), %rdx
leaq 0x46dd(%rip), %rsi      # 0x791e
xorl %eax, %eax
callq 0x1130
movq 0x7d81(%rip), %rax      # 0xafd0
movq (%rax), %rax
movq %rax, 0x9117(%rip)      # 0xc370
jmp 0x339a
cmpb $0x2d, %r12b
jne 0x3276
cmpb $0x6d, 0x1(%r15)
jne 0x3276
cmpb $0x0, 0x2(%r15)
je 0x3494
movq %r15, %rdi
leaq 0x46cf(%rip), %rsi      # 0x794f
callq 0x1110
cmpl $0x2, %ebx
jl 0x331b
testl %eax, %eax
jne 0x331b
movq 0x8(%r13), %rdi
leaq 0x4c49(%rip), %rsi      # 0x7eea
callq 0x11d0
testq %rax, %rax
movq %rax, 0x8(%rsp)
jne 0x32c7
movq 0x8(%r13), %rsi
leaq 0x469e(%rip), %rdi      # 0x7959
xorl %eax, %eax
callq 0x64dc
movq 0x8(%rsp), %rax
movq (%rsp), %rdi
testq %rdi, %rdi
movq %r14, %r12
je 0x32dd
callq 0x4b29
movq 0x8(%rsp), %rax
movq %rax, %rdi
callq 0x4eb9
movq %rax, %r14
cmpl $0x0, 0x40(%rax)
jns 0x32fc
leaq 0x4680(%rip), %rdi      # 0x7975
xorl %eax, %eax
callq 0x64dc
addl $-0x2, %ebx
addq $0x10, %r13
movq 0x9066(%rip), %rsi      # 0xc370
movq %r14, (%rsp)
movq %r14, %rdi
callq 0x50f3
jmp 0x339d
cmpb $0x2d, %r12b
jne 0x3333
cmpb $0x66, 0x1(%r15)
jne 0x3333
cmpb $0x0, 0x2(%r15)
je 0x34e3
movq %r15, %rdi
leaq 0x4654(%rip), %rsi      # 0x7991
callq 0x1110
cmpl $0x2, %ebx
jl 0x33e6
testl %eax, %eax
jne 0x33e6
addl $-0x2, %ebx
leaq 0x10(%r13), %r15
movq (%rsp), %r12
testq %r12, %r12
je 0x34ff
testq %r14, %r14
je 0x3374
movq %r14, %rdi
callq 0x13ac
movq %r12, %rdi
movl $0x10000, %esi          # imm = 0x10000
callq 0x136c
movq %rax, %r12
movq 0x8(%r13), %rsi
movq %rax, %rdi
callq 0x189e
movq 0x8(%rsp), %rdi
callq 0x10a0
movq %r15, %r13
movq 0x8fcc(%rip), %rdi      # 0xc370
callq 0x67a3
jmp 0x30ce
testl %ebx, %ebx
jg 0x31b1
jmp 0x31d3
cmpl $0x2, %ebx
jl 0x3188
addq $0x10, %r13
addl $-0x2, %ebx
movq (%rbp), %rcx
leaq 0x4502(%rip), %rdi      # 0x78d8
pushq $0x32
popq %rsi
pushq $0x1
popq %rdx
callq 0x1230
jmp 0x31c5
cmpb $0x2d, %r12b
jne 0x33fe
cmpb $0x72, 0x1(%r15)
jne 0x33fe
cmpb $0x0, 0x2(%r15)
je 0x34f1
movq %r15, %rdi
leaq 0x45c5(%rip), %rsi      # 0x79cd
callq 0x1110
cmpl $0x2, %ebx
jl 0x3449
testl %eax, %eax
jne 0x3449
testq %r14, %r14
je 0x3423
movq %r14, %rdi
callq 0x13ac
addl $-0x2, %ebx
movq 0x8(%r13), %rdi
addq $0x10, %r13
callq 0x158a
movq %rax, %r12
jmp 0x339d
cmpl $0x2, %ebx
jge 0x31fd
jmp 0x3264
cmpb $0x2d, %r12b
jne 0x3461
cmpb $0x77, 0x1(%r15)
jne 0x3461
cmpb $0x0, 0x2(%r15)
je 0x3525
movq %r15, %rdi
leaq 0x4569(%rip), %rsi      # 0x79d4
callq 0x1110
cmpl $0x2, %ebx
jl 0x34a2
testl %eax, %eax
jne 0x34a2
addl $-0x2, %ebx
movq 0x8(%r13), %rsi
addq $0x10, %r13
movq %r14, %r12
movq %r14, %rdi
callq 0x1418
jmp 0x339d
cmpl $0x2, %ebx
jge 0x3296
jmp 0x3321
cmpb $0x2d, %r12b
jne 0x34b6
cmpb $0x53, 0x1(%r15)
jne 0x34b6
cmpb $0x0, 0x2(%r15)
je 0x3533
movq %r15, %rdi
leaq 0x451c(%rip), %rsi      # 0x79dc
callq 0x1110
testl %ebx, %ebx
jle 0x3537
testl %eax, %eax
jne 0x3537
addq $0x8, %r13
decl %ebx
movq %r14, %r12
movq %r14, %rdi
callq 0x1af9
jmp 0x339d
cmpl $0x2, %ebx
jge 0x3353
jmp 0x33ec
cmpl $0x2, %ebx
jge 0x3416
jmp 0x344f
movq (%rbp), %rcx
leaq 0x4491(%rip), %rdi      # 0x799b
pushq $0x31
popq %rsi
pushq $0x1
popq %rdx
callq 0x1230
movq $0x0, (%rsp)
movq %r15, %r13
jmp 0x31c5
cmpl $0x2, %ebx
jge 0x3479
jmp 0x34a8
testl %ebx, %ebx
jg 0x34cd
movq %r15, %rdi
leaq 0x44a3(%rip), %rsi      # 0x79e4
callq 0x1110
testl %eax, %eax
je 0x35a2
movq %r15, %rdi
leaq 0x4494(%rip), %rsi      # 0x79e8
callq 0x1110
cmpl $0x2, %ebx
jl 0x35a7
testl %eax, %eax
jne 0x35a7
addl $-0x2, %ebx
movq 0x8(%r14), %r12
movq 0x8(%r12), %r15
movq 0x8(%r13), %rdi
addq $0x10, %r13
callq 0x1200
imull 0x14(%r12), %eax
movq %r14, %r12
addq %rax, %r15
movq %r14, %rdi
movq %r15, %rsi
pushq $0x2
popq %rdx
callq 0x2142
movq %rax, %rdi
callq 0x5ea8
jmp 0x339d
cmpl $0x2, %ebx
jge 0x3562
movq %r15, %rdi
leaq 0x4443(%rip), %rsi      # 0x79f4
callq 0x1110
testl %eax, %eax
je 0x3620
movq %r15, %rdi
leaq 0x4434(%rip), %rsi      # 0x79f8
callq 0x1110
cmpl $0x2, %ebx
jl 0x3625
testl %eax, %eax
jne 0x3625
addl $-0x2, %ebx
movq 0x8(%r13), %rdi
callq 0x1200
movl %eax, %r12d
movq %r14, %r15
movl %eax, %r14d
movq 0x8(%r15), %rax
cmpl 0x18(%rax), %r12d
jae 0x3614
movl 0x14(%rax), %esi
imull %r12d, %esi
addq 0x8(%rax), %rsi
movq %r15, %rdi
pushq $0x1
popq %rdx
callq 0x2142
movq %rax, %rdi
callq 0x5ea8
addl %r14d, %r12d
jmp 0x35e7
addq $0x10, %r13
movq %r15, %r12
jmp 0x339d
cmpl $0x2, %ebx
jge 0x35d2
movq %r15, %rdi
leaq 0x43d5(%rip), %rsi      # 0x7a04
callq 0x1110
testl %eax, %eax
je 0x3688
movq %r15, %rdi
leaq 0x43c6(%rip), %rsi      # 0x7a08
callq 0x1110
cmpl $0x3, %ebx
jl 0x368d
testl %eax, %eax
jne 0x368d
leaq 0x18(%r13), %rax
movq %rax, 0x10(%rsp)
addl $-0x3, %ebx
movq 0x8(%r13), %rdi
callq 0x1200
movl %eax, %r15d
movq 0x10(%r13), %rdi
callq 0x1200
movq %r14, %rdi
movl %r15d, %esi
movl %eax, %edx
callq 0x26d3
movq 0x10(%rsp), %r13
jmp 0x31c5
cmpl $0x3, %ebx
jge 0x3650
cmpb $0x2d, %r12b
jne 0x36a1
cmpb $0x62, 0x1(%r15)
jne 0x36a1
cmpb $0x0, 0x2(%r15)
je 0x370f
movq %r15, %rdi
leaq 0x4367(%rip), %rsi      # 0x7a12
callq 0x1110
testl %ebx, %ebx
jle 0x36ce
testl %eax, %eax
jne 0x36ce
addq $0x8, %r13
decl %ebx
movq %r14, %r12
movq %r14, %rdi
callq 0x2941
jmp 0x339d
cmpb $0x2d, %r12b
jne 0x36e2
cmpb $0x63, 0x1(%r15)
jne 0x36e2
cmpb $0x0, 0x2(%r15)
je 0x3715
movq %r15, %rdi
leaq 0x4335(%rip), %rsi      # 0x7a21
callq 0x1110
testl %ebx, %ebx
jle 0x3719
testl %eax, %eax
jne 0x3719
addq $0x8, %r13
decl %ebx
movq %r14, %r12
movq %r14, %rdi
callq 0x2a4e
jmp 0x339d
testl %ebx, %ebx
jg 0x36b8
jmp 0x36d4
testl %ebx, %ebx
jg 0x36f9
movq %r15, %rdi
leaq 0x430e(%rip), %rsi      # 0x7a31
callq 0x1110
testl %eax, %eax
movq %r14, %r12
je 0x3766
movq %r15, %rdi
leaq 0x42fc(%rip), %rsi      # 0x7a35
callq 0x1110
cmpl $0x2, %ebx
jl 0x376b
testl %eax, %eax
jne 0x376b
addl $-0x2, %ebx
movq 0x8(%r13), %rdi
addq $0x10, %r13
callq 0x1200
movq %r12, %rdi
movl %eax, %esi
callq 0x2b9a
jmp 0x339d
cmpl $0x2, %ebx
jge 0x3747
leaq 0x42cf(%rip), %rdi      # 0x7a41
movq %r15, %rsi
xorl %eax, %eax
callq 0x64dc
jmp 0x339d
movq 0x8be8(%rip), %rcx      # 0xc370
leaq 0x42e6(%rip), %rdi      # 0x7a75
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
callq 0x1230
movq 0x8bcf(%rip), %rdi      # 0xc370
callq 0x68bc
movq 0x8bc3(%rip), %rax      # 0xc370
movq 0x781c(%rip), %rbx      # 0xafd0
cmpq (%rbx), %rax
je 0x37cf
leaq 0x42b5(%rip), %rdi      # 0x7a75
xorl %eax, %eax
callq 0x10c0
movq (%rbx), %rdi
callq 0x68bc
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq