// File: /workspace/github_c_makefile_star2_O2/richarddurbin[P]hash10x/moshmap.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

  /* command line parameters */
  params.k = 19 ;
  params.w = 31 ;
  params.s = 17 ;
  params.B = 28 ;

  if (!argc) usage () ;

  int i ;			/* generically useful variables */
  FILE *f ;

  Reference *ref = 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("-K","--kmer",2)) params.k = atoi(argv[-1]) ;
    else if (ARGMATCH("-W","--window",2)) params.w = atoi(argv[-1]) ;
    else if (ARGMATCH("-S","--seed",2)) params.s = atoi(argv[-1]) ;
    else if (ARGMATCH("-B","--tableBits",2)) params.B = atoi(argv[-1]) ;
    else 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("-f","--referenceFasta",2))
      { if (!(f = fopen (argv[-1], "r"))) die ("failed to open fasta file %s", argv[-1]) ;
	srandom (params.s) ;
	if (params.k <= 0 || params.w <= 0) die ("k %d, w %d must be > 0", params.k, params.w) ;
	Seqhash *hasher = seqhashCreate (params.k, params.w) ;
	fprintf (outFile, "  moshmap initialised with k = %d, w = %d, random seed = %d\n",
		 params.k, params.w, params.s) ;
	Moshset *ms = moshsetCreate (hasher, params.B, 0) ;
	ref = referenceCreate (ms, 1 << 26) ;
	referenceFastaRead (ref, f, TRUE) ;
      }
    else if (ARGMATCH("-q","--query",2))
      { if (!ref) die ("need to read a reference before processing query sequences") ;
	if (!(f = fopen (argv[-1], "r"))) die ("failed to open query file %s", argv[-1]) ;
	queryProcess (ref, f) ;
      }
    else if (ARGMATCH("-r","--referenceRead",2))
      { if (ref) referenceDestroy (ref) ;
	ref = referenceRead (argv[-1]) ;
      }
    else if (ARGMATCH("-w","--referenceWrite",2))
      referenceWrite (ref, 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
pushq %rax
movq %rsi, %r14
movl %edi, %ebx
movq 0x7acf(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
movq %rdi, 0x8e35(%rip)      # 0xb348
callq 0x5e17
movaps 0x3af1(%rip), %xmm0     # 0x6010
movaps %xmm0, 0x8e2a(%rip)     # 0xb350
decl %ebx
jne 0x252f
callq 0x23c2
addq $0x8, %r14
movq 0x7abe(%rip), %rbp      # 0x9ff8
xorl %r12d, %r12d
testl %ebx, %ebx
je 0x2af9
movq (%r14), %rdx
cmpb $0x2d, (%rdx)
jne 0x2552
movq %r12, %r13
jmp 0x2569
movq %r12, %r13
leaq 0x40b8(%rip), %rdi      # 0x6614
movq %rdx, %rsi
xorl %eax, %eax
callq 0x5b50
movq (%r14), %rdx
movq (%rbp), %rdi
leaq 0x40eb(%rip), %rsi      # 0x665f
xorl %eax, %eax
callq 0x1120
movslq %ebx, %r15
pushq $0x1
popq %r12
cmpq %r15, %r12
jge 0x25a7
movq (%r14,%r12,8), %rdx
cmpb $0x2d, (%rdx)
je 0x25a7
movq (%rbp), %rdi
leaq 0x40cb(%rip), %rsi      # 0x6666
xorl %eax, %eax
callq 0x1120
incq %r12
jmp 0x2582
movq (%rbp), %rsi
pushq $0xa
popq %rdi
callq 0x10e0
movq (%r14), %r15
movb (%r15), %r12b
cmpb $0x2d, %r12b
jne 0x25d1
cmpb $0x4b, 0x1(%r15)
jne 0x25d1
cmpb $0x0, 0x2(%r15)
je 0x26e5
movq %r15, %rdi
leaq 0x408f(%rip), %rsi      # 0x666a
callq 0x1110
cmpl $0x2, %ebx
jl 0x2604
testl %eax, %eax
jne 0x2604
addl $-0x2, %ebx
movq 0x8(%r14), %rdi
addq $0x10, %r14
callq 0x11c0
movl %eax, 0x8d51(%rip)      # 0xb350
jmp 0x276a
cmpb $0x2d, %r12b
jne 0x261c
cmpb $0x57, 0x1(%r15)
jne 0x261c
cmpb $0x0, 0x2(%r15)
je 0x277e
movq %r15, %rdi
leaq 0x404b(%rip), %rsi      # 0x6671
callq 0x1110
cmpl $0x2, %ebx
jl 0x264f
testl %eax, %eax
jne 0x264f
addl $-0x2, %ebx
movq 0x8(%r14), %rdi
addq $0x10, %r14
callq 0x11c0
movl %eax, 0x8d0a(%rip)      # 0xb354
jmp 0x276a
cmpb $0x2d, %r12b
jne 0x2667
cmpb $0x53, 0x1(%r15)
jne 0x2667
cmpb $0x0, 0x2(%r15)
je 0x2820
movq %r15, %rdi
leaq 0x4009(%rip), %rsi      # 0x667a
callq 0x1110
cmpl $0x2, %ebx
jl 0x269a
testl %eax, %eax
jne 0x269a
addl $-0x2, %ebx
movq 0x8(%r14), %rdi
addq $0x10, %r14
callq 0x11c0
movl %eax, 0x8cc3(%rip)      # 0xb358
jmp 0x276a
cmpb $0x2d, %r12b
jne 0x26b2
cmpb $0x42, 0x1(%r15)
jne 0x26b2
cmpb $0x0, 0x2(%r15)
je 0x282e
movq %r15, %rdi
leaq 0x3fc5(%rip), %rsi      # 0x6681
callq 0x1110
cmpl $0x2, %ebx
jl 0x26f3
testl %eax, %eax
jne 0x26f3
addl $-0x2, %ebx
movq 0x8(%r14), %rdi
addq $0x10, %r14
callq 0x11c0
movl %eax, 0x8c7c(%rip)      # 0xb35c
jmp 0x276a
cmpl $0x2, %ebx
jge 0x25e9
jmp 0x260a
cmpb $0x2d, %r12b
jne 0x270b
cmpb $0x74, 0x1(%r15)
jne 0x270b
cmpb $0x0, 0x2(%r15)
je 0x294e
movq %r15, %rdi
leaq 0x3f78(%rip), %rsi      # 0x668d
callq 0x1110
cmpl $0x2, %ebx
jl 0x2727
testl %eax, %eax
je 0x2957
cmpb $0x2d, %r12b
jne 0x273f
cmpb $0x76, 0x1(%r15)
jne 0x273f
cmpb $0x0, 0x2(%r15)
je 0x2a00
movq %r15, %rdi
leaq 0x3f81(%rip), %rsi      # 0x66ca
callq 0x1110
testl %ebx, %ebx
jle 0x278c
testl %eax, %eax
jne 0x278c
addq $0x8, %r14
decl %ebx
cmpb $0x0, 0x8bdd(%rip)      # 0xb340
sete 0x8bd6(%rip)            # 0xb340
movq %r13, %r12
movq 0x8bd4(%rip), %rdi      # 0xb348
callq 0x5e17
jmp 0x253d
cmpl $0x2, %ebx
jge 0x2634
jmp 0x2655
cmpb $0x2d, %r12b
jne 0x27a4
cmpb $0x6f, 0x1(%r15)
jne 0x27a4
cmpb $0x0, 0x2(%r15)
je 0x2a62
movq %r15, %rdi
leaq 0x3f26(%rip), %rsi      # 0x66d4
callq 0x1110
cmpl $0x2, %ebx
jl 0x283c
testl %eax, %eax
jne 0x283c
addl $-0x2, %ebx
leaq 0x10(%r14), %r15
movq 0x8(%r14), %rdi
cmpb $0x2d, (%rdi)
movq %r13, %r12
jne 0x27d9
cmpb $0x0, 0x1(%rdi)
je 0x2807
leaq 0x3e98(%rip), %rsi      # 0x6678
callq 0x1190
movq %rax, 0x8b5c(%rip)      # 0xb348
testq %rax, %rax
jne 0x2818
movq (%rbp), %rdi
movq 0x8(%r14), %rdx
leaq 0x3edd(%rip), %rsi      # 0x66dd
xorl %eax, %eax
callq 0x1120
movq 0x77ca(%rip), %rax      # 0x9fd8
movq (%rax), %rax
movq %rax, 0x8b30(%rip)      # 0xb348
movq %r15, %r14
jmp 0x276d
cmpl $0x2, %ebx
jge 0x267f
jmp 0x26a0
cmpl $0x2, %ebx
jge 0x26ca
jmp 0x26f9
cmpb $0x2d, %r12b
jne 0x2854
cmpb $0x66, 0x1(%r15)
jne 0x2854
cmpb $0x0, 0x2(%r15)
je 0x2ab7
movq %r15, %rdi
leaq 0x3eb0(%rip), %rsi      # 0x670e
callq 0x1110
cmpl $0x2, %ebx
jl 0x2979
testl %eax, %eax
jne 0x2979
movq 0x8(%r14), %rdi
leaq 0x3a18(%rip), %rsi      # 0x6297
callq 0x1190
movq %rax, %r13
testq %rax, %rax
jne 0x289e
movq 0x8(%r14), %rsi
leaq 0x3e88(%rip), %rdi      # 0x671f
xorl %eax, %eax
callq 0x5b50
movl 0x8ab4(%rip), %edi      # 0xb358
callq 0x1050
movl 0x8aa1(%rip), %esi      # 0xb350
testl %esi, %esi
setle %al
movl 0x8a9a(%rip), %edx      # 0xb354
testl %edx, %edx
setle %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x28e0
leaq 0x3e6f(%rip), %rdi      # 0x673c
xorl %eax, %eax
callq 0x5b50
movl 0x8a76(%rip), %esi      # 0xb350
movl 0x8a74(%rip), %edx      # 0xb354
addl $-0x2, %ebx
addq $0x10, %r14
movl %esi, %edi
movl %edx, %esi
callq 0x3a10
movq %rax, %r15
movq 0x8a4e(%rip), %rdi      # 0xb348
movl 0x8a50(%rip), %edx      # 0xb350
movl 0x8a4e(%rip), %ecx      # 0xb354
movl 0x8a4b(%rip), %r8d      # 0xb358
leaq 0x3e3f(%rip), %rsi      # 0x6753
xorl %eax, %eax
callq 0x1120
movl 0x8a3b(%rip), %esi      # 0xb35c
movq %r15, %rdi
xorl %edx, %edx
callq 0x40c8
movq %rax, %rdi
movl $0x4000000, %esi        # imm = 0x4000000
callq 0x131c
movq %rax, %r12
movq %rax, %rdi
movq %r13, %rsi
pushq $0x1
popq %rdx
callq 0x15ab
jmp 0x276d
cmpl $0x2, %ebx
jl 0x272d
addq $0x10, %r14
addl $-0x2, %ebx
movq (%rbp), %rcx
leaq 0x3d2e(%rip), %rdi      # 0x6697
pushq $0x32
popq %rsi
pushq $0x1
popq %rdx
callq 0x11f0
jmp 0x276a
cmpb $0x2d, %r12b
jne 0x2991
cmpb $0x71, 0x1(%r15)
jne 0x2991
cmpb $0x0, 0x2(%r15)
je 0x2ac5
movq %r15, %rdi
leaq 0x3df5(%rip), %rsi      # 0x6790
callq 0x1110
cmpl $0x2, %ebx
jl 0x2a0d
testl %eax, %eax
jne 0x2a0d
movq %r13, %r12
testq %r13, %r13
jne 0x29bf
leaq 0x3de0(%rip), %rdi      # 0x6798
xorl %eax, %eax
callq 0x5b50
movq 0x8(%r14), %rdi
leaq 0x38cd(%rip), %rsi      # 0x6297
callq 0x1190
movq %rax, %r15
testq %rax, %rax
jne 0x29e9
movq 0x8(%r14), %rsi
leaq 0x3df1(%rip), %rdi      # 0x67d3
xorl %eax, %eax
callq 0x5b50
addl $-0x2, %ebx
addq $0x10, %r14
movq %r12, %rdi
movq %r15, %rsi
callq 0x1ced
jmp 0x276d
testl %ebx, %ebx
jg 0x2756
jmp 0x2792
cmpb $0x2d, %r12b
jne 0x2a25
cmpb $0x72, 0x1(%r15)
jne 0x2a25
cmpb $0x0, 0x2(%r15)
je 0x2ad3
movq %r15, %rdi
leaq 0x3dc1(%rip), %rsi      # 0x67f0
callq 0x1110
cmpl $0x2, %ebx
jl 0x2a70
testl %eax, %eax
jne 0x2a70
testq %r13, %r13
je 0x2a4a
movq %r13, %rdi
callq 0x13d3
addl $-0x2, %ebx
movq 0x8(%r14), %rdi
addq $0x10, %r14
callq 0x1a4a
movq %rax, %r12
jmp 0x276d
cmpl $0x2, %ebx
jge 0x27c0
jmp 0x2842
cmpb $0x2d, %r12b
jne 0x2a84
cmpb $0x77, 0x1(%r15)
jne 0x2a84
cmpb $0x0, 0x2(%r15)
je 0x2ade
movq %r15, %rdi
leaq 0x3d72(%rip), %rsi      # 0x6800
callq 0x1110
cmpl $0x2, %ebx
jl 0x2ae3
testl %eax, %eax
jne 0x2ae3
addl $-0x2, %ebx
movq 0x8(%r14), %rsi
addq $0x10, %r14
movq %r13, %r12
movq %r13, %rdi
callq 0x1802
jmp 0x276d
cmpl $0x2, %ebx
jge 0x2874
jmp 0x297f
cmpl $0x2, %ebx
jge 0x29a9
jmp 0x2a13
cmpl $0x2, %ebx
jge 0x2a3d
jmp 0x2a76
cmpl $0x2, %ebx
jge 0x2a9c
leaq 0x3d27(%rip), %rdi      # 0x6811
movq %r15, %rsi
xorl %eax, %eax
callq 0x5b50
jmp 0x276a
movq 0x8848(%rip), %rcx      # 0xb348
leaq 0x3d3e(%rip), %rdi      # 0x6845
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
callq 0x11f0
movq 0x882f(%rip), %rdi      # 0xb348
callq 0x5f30
movq 0x8823(%rip), %rax      # 0xb348
movq 0x74ac(%rip), %rbx      # 0x9fd8
cmpq (%rbx), %rax
je 0x2b47
leaq 0x3d0d(%rip), %rdi      # 0x6845
xorl %eax, %eax
callq 0x10b0
movq (%rbx), %rdi
callq 0x5f30
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq