// File: BenLangmead[P]bowtie/ebwt_build.cpp
// Function: parseOptions(int, char const**)
static void parseOptions(int argc, const char **argv) {
	int option_index = 0;
	int next_option;
	bool bmaxDivNSet = false;
	do {
		next_option = getopt_long(
			argc, const_cast<char**>(argv),
			short_options, long_options, &option_index);
		switch (next_option) {
			case ARG_WRAPPER: wrapper = optarg;	break;
			case 'f': format = FASTA; break;
			case 'c': format = CMDLINE; break;
			case 'p': packed = true; break;
			case 'l':
				lineRate = parseNumber<int>(3, "-l/--lineRate arg must be at least 3");
				break;
			case 'i':
				linesPerSide = parseNumber<int>(1, "-i/--linesPerSide arg must be at least 1");
				break;
			case 'o':
				offRate = parseNumber<int>(0, "-o/--offRate arg must be at least 0");
				break;
			case '3':
				justRef = true;
				break;
			case 't':
				ftabChars = parseNumber<int>(1, "-t/--ftabChars arg must be at least 1");
				break;
			case 'n':
				// all f-s is used to mean "not set", so put 'e' on end
				bmax = 0xfffffffe;
				break;
			case 'h':
			case ARG_USAGE:
				printUsage(cout);
				throw 0;
				break;
			case ARG_BMAX:
				bmax = parseNumber<TIndexOffU>(1, "--bmax arg must be at least 1");
				bmaxMultSqrt = OFF_MASK; // don't use multSqrt
				bmaxDivN = 0xffffffff;     // don't use multSqrt
				break;
			case ARG_BMAX_MULT:
				bmaxMultSqrt = parseNumber<TIndexOffU>(1, "--bmaxmultsqrt arg must be at least 1");
				bmax = OFF_MASK;     // don't use bmax
				bmaxDivN = 0xffffffff; // don't use multSqrt
				break;
			case ARG_BMAX_DIV:
				bmaxDivNSet = true;
				bmaxDivN = parseNumber<uint32_t>(1, "--bmaxdivn arg must be at least 1");
				bmax = OFF_MASK;         // don't use bmax
				bmaxMultSqrt = OFF_MASK; // don't use multSqrt
				break;
			case ARG_DCV:
				dcv = parseNumber<int>(3, "--dcv arg must be at least 3");
				break;
			case ARG_SEED:
				seed = parseNumber<int>(0, "--seed arg must be at least 0");
				break;
			case ARG_NTOA: nsToAs = true; break;
	        	case ARG_THREADS:
			        nthreads = parseNumber<int>(0, "--threads arg must be at least 1");
		                break;
			case ARG_NEW_REVERSE: reverseType = REF_READ_REVERSE; break;
			case 'a': autoMem = false; break;
			case 'q': verbose = false; break;
			case 's': sanityCheck = true; break;
			case 'r': writeRef = false; break;

			case -1: /* Done with options. */
				break;
			case 0:
				if (long_options[option_index].flag != 0)
					break;
			default:
				printUsage(cerr);
				throw 1;
		}
	} while(next_option != -1);
	if(bmax < 40) {
		cerr << "Warning: specified bmax is very small (" << bmax << ").  This can lead to" << endl
		     << "extremely slow performance and memory exhaustion.  Perhaps you meant to specify" << endl
		     << "a small --bmaxdivn?" << endl;
	}
	if (!bmaxDivNSet) {
		bmaxDivN *= nthreads;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movb $0x0, -0x19(%rbp)
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
movq 0x44fa8(%rip), %rdx     # 0x524e0
leaq 0x44fb1(%rip), %rcx     # 0x524f0
leaq -0x14(%rbp), %r8
callq 0x6790
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x20(%rbp)
subl $-0x1, %eax
je 0xd8ea
jmp 0xd55c
movl -0x20(%rbp), %eax
testl %eax, %eax
je 0xd8ec
jmp 0xd569
movl -0x20(%rbp), %eax
subl $0x33, %eax
je 0xd763
jmp 0xd577
movl -0x20(%rbp), %eax
subl $0x61, %eax
je 0xd8c3
jmp 0xd585
movl -0x20(%rbp), %eax
subl $0x63, %eax
je 0xd6f7
jmp 0xd593
movl -0x20(%rbp), %eax
subl $0x66, %eax
je 0xd6e8
jmp 0xd5a1
movl -0x20(%rbp), %eax
subl $0x68, %eax
je 0xd79a
jmp 0xd5af
movl -0x20(%rbp), %eax
subl $0x69, %eax
je 0xd72e
jmp 0xd5bd
movl -0x20(%rbp), %eax
subl $0x6c, %eax
je 0xd712
jmp 0xd5cb
movl -0x20(%rbp), %eax
subl $0x6e, %eax
je 0xd78b
jmp 0xd5d9
movl -0x20(%rbp), %eax
subl $0x6f, %eax
je 0xd74a
jmp 0xd5e7
movl -0x20(%rbp), %eax
subl $0x70, %eax
je 0xd706
jmp 0xd5f5
movl -0x20(%rbp), %eax
subl $0x71, %eax
je 0xd8cc
jmp 0xd603
movl -0x20(%rbp), %eax
subl $0x72, %eax
je 0xd8e1
jmp 0xd611
movl -0x20(%rbp), %eax
subl $0x73, %eax
je 0xd8d5
jmp 0xd61f
movl -0x20(%rbp), %eax
subl $0x74, %eax
je 0xd76f
jmp 0xd62d
movl -0x20(%rbp), %eax
subl $0x100, %eax            # imm = 0x100
je 0xd7c9
jmp 0xd63d
movl -0x20(%rbp), %eax
subl $0x101, %eax            # imm = 0x101
je 0xd7f9
jmp 0xd64d
movl -0x20(%rbp), %eax
subl $0x102, %eax            # imm = 0x102
je 0xd829
jmp 0xd65d
movl -0x20(%rbp), %eax
subl $0x103, %eax            # imm = 0x103
je 0xd85d
jmp 0xd66d
movl -0x20(%rbp), %eax
subl $0x104, %eax            # imm = 0x104
je 0xd879
jmp 0xd67d
movl -0x20(%rbp), %eax
subl $0x106, %eax            # imm = 0x106
je 0xd892
jmp 0xd68d
movl -0x20(%rbp), %eax
subl $0x107, %eax            # imm = 0x107
je 0xd79a
jmp 0xd69d
movl -0x20(%rbp), %eax
subl $0x108, %eax            # imm = 0x108
je 0xd8b7
jmp 0xd6ad
movl -0x20(%rbp), %eax
subl $0x109, %eax            # imm = 0x109
je 0xd89e
jmp 0xd6bd
movl -0x20(%rbp), %eax
subl $0x10a, %eax            # imm = 0x10A
jne 0xd909
jmp 0xd6cd
movq 0x4489c(%rip), %rax     # 0x51f70
movq (%rax), %rsi
leaq 0x47772(%rip), %rdi     # 0x54e50
callq 0x6620
jmp 0xd938
movl $0x1, 0x477be(%rip)     # 0x54eb0
jmp 0xd938
movl $0x7, 0x477af(%rip)     # 0x54eb0
jmp 0xd938
movb $0x1, 0x47783(%rip)     # 0x54e90
jmp 0xd938
movl $0x3, %edi
leaq 0x3780a(%rip), %rsi     # 0x44f28
callq 0x103e0
movl %eax, 0x47757(%rip)     # 0x54e80
jmp 0xd938
movl $0x1, %edi
leaq 0x37813(%rip), %rsi     # 0x44f4d
callq 0x103e0
movl %eax, 0x4773f(%rip)     # 0x54e84
jmp 0xd938
xorl %edi, %edi
leaq 0x37823(%rip), %rsi     # 0x44f76
callq 0x103e0
movl %eax, 0x4772a(%rip)     # 0x54e88
jmp 0xd938
movb $0x1, 0x47758(%rip)     # 0x54ec2
jmp 0xd938
movl $0x1, %edi
leaq 0x3781f(%rip), %rsi     # 0x44f9a
callq 0x103e0
movl %eax, 0x47706(%rip)     # 0x54e8c
jmp 0xd938
movl $0xfffffffe, 0x476ff(%rip) # imm = 0xFFFFFFFE
jmp 0xd938
movq 0x44807(%rip), %rdi     # 0x51fa8
callq 0xd9f0
movl $0x4, %edi
callq 0x61f0
movq %rax, %rdi
movl $0x0, (%rdi)
movq 0x44790(%rip), %rsi     # 0x51f50
xorl %eax, %eax
movl %eax, %edx
callq 0x67f0
movl $0x1, %edi
leaq 0x377eb(%rip), %rsi     # 0x44fc0
callq 0x104d0
movl %eax, 0x476b4(%rip)     # 0x54e94
movl $0xffffffff, 0x476ae(%rip) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x476a8(%rip) # imm = 0xFFFFFFFF
jmp 0xd938
movl $0x1, %edi
leaq 0x377d9(%rip), %rsi     # 0x44fde
callq 0x104d0
movl %eax, 0x47688(%rip)     # 0x54e98
movl $0xffffffff, 0x4767a(%rip) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x47678(%rip) # imm = 0xFFFFFFFF
jmp 0xd938
movb $0x1, -0x19(%rbp)
movl $0x1, %edi
leaq 0x377cb(%rip), %rsi     # 0x45004
callq 0x104d0
movl %eax, 0x47658(%rip)     # 0x54e9c
movl $0xffffffff, 0x47646(%rip) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x47640(%rip) # imm = 0xFFFFFFFF
jmp 0xd938
movl $0x3, %edi
leaq 0x377bd(%rip), %rsi     # 0x45026
callq 0x103e0
movl %eax, 0x4762c(%rip)     # 0x54ea0
jmp 0xd938
xorl %edi, %edi
leaq 0x377c1(%rip), %rsi     # 0x45043
callq 0x103e0
movl %eax, 0x4761f(%rip)     # 0x54eac
jmp 0xd938
movb $0x1, 0x47627(%rip)     # 0x54ec0
jmp 0xd938
xorl %edi, %edi
leaq 0x377ba(%rip), %rsi     # 0x45061
callq 0x103e0
movl %eax, 0x47616(%rip)     # 0x54ec8
jmp 0xd938
movl $0x1, 0x47603(%rip)     # 0x54ec4
jmp 0xd938
movb $0x0, 0x475ea(%rip)     # 0x54eb4
jmp 0xd938
movb $0x0, 0x475a9(%rip)     # 0x54e7c
jmp 0xd938
movl $0x1, 0x475c9(%rip)     # 0x54ea8
jmp 0xd938
movb $0x0, 0x475d9(%rip)     # 0x54ec1
jmp 0xd938
jmp 0xd938
movslq -0x14(%rbp), %rcx
leaq 0x44bf9(%rip), %rax     # 0x524f0
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $0x0, 0x10(%rax)
je 0xd907
jmp 0xd938
jmp 0xd909
movq 0x446e0(%rip), %rdi     # 0x51ff0
callq 0xd9f0
movl $0x4, %edi
callq 0x61f0
movq %rax, %rdi
movl $0x1, (%rdi)
movq 0x44621(%rip), %rsi     # 0x51f50
xorl %eax, %eax
movl %eax, %edx
callq 0x67f0
jmp 0xd93a
cmpl $-0x1, -0x18(%rbp)
jne 0xd52a
cmpl $0x28, 0x47549(%rip)    # 0x54e94
jae 0xd9c8
movq 0x4469c(%rip), %rdi     # 0x51ff0
leaq 0x37727(%rip), %rsi     # 0x45082
callq 0x6410
movq %rax, %rdi
movl 0x4752b(%rip), %esi     # 0x54e94
callq 0x65f0
movq %rax, %rdi
leaq 0x37732(%rip), %rsi     # 0x450aa
callq 0x6410
movq %rax, %rdi
movq 0x445e1(%rip), %rsi     # 0x51f68
callq 0x6470
movq %rax, %rdi
leaq 0x37729(%rip), %rsi     # 0x450bf
callq 0x6410
movq %rax, %rdi
movq 0x445c3(%rip), %rsi     # 0x51f68
callq 0x6470
movq %rax, %rdi
leaq 0x3775b(%rip), %rsi     # 0x4510f
callq 0x6410
movq %rax, %rdi
movq 0x445a5(%rip), %rsi     # 0x51f68
callq 0x6470
testb $0x1, -0x19(%rbp)
jne 0xd9e1
movl 0x474f4(%rip), %eax     # 0x54ec8
imull 0x474c1(%rip), %eax     # 0x54e9c
movl %eax, 0x474bb(%rip)     # 0x54e9c
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)