// File: /workspace/github_cpp_makefile_star2_O2/simonrharris[P]SKA/src/ska.cpp
// Function: allelesSubcommand(int, char**)
int allelesSubcommand(int argc, char *argv[]){

	long int kmersize=15;
	std::vector < std::string > args;

	for (int i=2; i<argc; ++i){

		std::string arg=(argv[i]);

		if (arg=="-h" || arg=="--help"){
			allelesHelp();
			return 0;
		}
		else if (arg == "-k"){
			i++;
			if (i<argc){
				try {
					kmersize = getint(argv[i]);
				}
				catch (const std::invalid_argument& e) {
					std::cerr << std::endl << "Expecting positive integer after -k flag" << std::endl << std::endl;
					return 1;
				}
			}
			else {
				std::cerr << std::endl << "Expecting positive integer after -k flag" << std::endl << std::endl;
				return 1;
			}
			if (kmersize < MinKmer || kmersize > MaxKmer || kmersize % 3 != 0){
				std::cerr << std::endl << "Kmer size must be a positive integer between " << MinKmer << " and " << MaxKmer << " and must be divisible by 3" << std::endl << std::endl;
				return 1;
			}
		}
		else if (arg == "-f"){
			i++;
			if (i<argc){
				fileToVector(argv[i], args);
			}
			else {
				std::cerr << std::endl << "Expecting file name after -f flag" << std::endl << std::endl;
				return 1;
			}
		}
		else if (arg[0]=='-'){
			std::cerr << std::endl << "Unrecognised flag " << arg << std::endl << std::endl;
				return 1;
		}
		else {
			args.push_back(arg);
		}
	}

	if (args.size()<1){
		std::cerr << std::endl << "Too few arguments" << std::endl << std::endl;
		allelesHelp();
		return 1;
	}

	skaVersion();

	std::cout << "Creating split " << kmersize << "mers for ";
	if (args.size()>maxNamesToPrint){
		std::cout << args.size() << " files";
	}
	else {
		for (std::vector <std::string>::iterator it = args.begin(); it != args.end(); ++it){
			std::cout << *it << " ";
		}
	}
	std::cout << std::endl << std::endl;

	if (allelesToKmers(args, kmersize)){return 1;}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %rbx
movl %edi, %ebp
movq $0xf, 0x8(%rsp)
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
pushq $0x2
popq %r13
leaq 0x48(%rsp), %r15
leaq 0x28(%rsp), %r12
cmpl %ebp, %r13d
jge 0x1e3e0
movslq %r13d, %rax
movq (%rbx,%rax,8), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x77c0
movq %r15, %rdi
leaq 0x8e53(%rip), %rsi      # 0x26ff3
callq 0x132f3
testb %al, %al
jne 0x1e1bc
movq %r15, %rdi
leaq 0x8e43(%rip), %rsi      # 0x26ff6
callq 0x132f3
testb %al, %al
je 0x1e1e1
xorl %r12d, %r12d
callq 0x1e009
xorl %r14d, %r14d
movq %r15, %rdi
callq 0x5778
incl %r13d
testb %r12b, %r12b
leaq 0x28(%rsp), %r12
jne 0x1e17b
jmp 0x1e4c5
movq %r15, %rdi
leaq 0x8e12(%rip), %rsi      # 0x26ffd
callq 0x132f3
testb %al, %al
je 0x1e28f
incl %r13d
cmpl %ebp, %r13d
jge 0x1e2df
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
callq 0x1dca8
movq %rax, %rcx
movq %rax, 0x8(%rsp)
cqto
pushq $0x3
popq %rsi
idivq %rsi
testq %rdx, %rdx
jne 0x1e240
movslq 0x182c4(%rip), %rax     # 0x364f0
cmpq %rax, %rcx
jl 0x1e240
movslq 0x182bc(%rip), %rax     # 0x364f4
movb $0x1, %r12b
cmpq %rax, %rcx
jle 0x1e1c7
movq 0x17da9(%rip), %rdi     # 0x35ff0
callq 0x51c0
movq %rax, %rdi
leaq 0x8dd3(%rip), %rsi      # 0x27029
callq 0x53f0
movl 0x1828f(%rip), %esi     # 0x364f0
movq %rax, %rdi
callq 0x56a0
movq %rax, %rdi
leaq 0x8313(%rip), %rsi      # 0x26586
callq 0x53f0
movl 0x18276(%rip), %esi     # 0x364f4
movq %rax, %rdi
callq 0x56a0
leaq 0x8dca(%rip), %rsi      # 0x27057
jmp 0x1e2f2
movq %r15, %rdi
leaq 0x8dda(%rip), %rsi      # 0x27073
callq 0x132f3
testb %al, %al
je 0x1e30c
incl %r13d
cmpl %ebp, %r13d
jge 0x1e34e
movslq %r13d, %rax
movq (%rbx,%rax,8), %rsi
movq %r12, %rdi
leaq 0x7(%rsp), %rdx
callq 0x77c0
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
callq 0x7529
movq %r12, %rdi
callq 0x5778
movb $0x1, %r12b
jmp 0x1e1c7
movq 0x17d0a(%rip), %rdi     # 0x35ff0
callq 0x51c0
leaq 0x8d0e(%rip), %rsi      # 0x27000
movq %rax, %rdi
callq 0x53f0
movq %rax, %rdi
callq 0x51c0
movq %rax, %rdi
callq 0x51c0
jmp 0x1e379
movq 0x48(%rsp), %rax
cmpb $0x2d, (%rax)
jne 0x1e385
movq 0x17cd3(%rip), %rdi     # 0x35ff0
callq 0x51c0
movq %rax, %rdi
leaq 0x8d6c(%rip), %rsi      # 0x27098
callq 0x53f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x53a0
movq %rax, %rdi
callq 0x51c0
movq %rax, %rdi
callq 0x51c0
jmp 0x1e379
movq 0x17c9b(%rip), %rdi     # 0x35ff0
callq 0x51c0
movq %rax, %rdi
leaq 0x8d12(%rip), %rsi      # 0x27076
callq 0x53f0
movq %rax, %rdi
callq 0x51c0
movq %rax, %rdi
callq 0x51c0
xorl %r12d, %r12d
pushq $0x1
popq %r14
jmp 0x1e1c7
movb $0x1, %r12b
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x77fc
jmp 0x1e1c7
movq %rax, %r14
cmpl $0x1, %edx
jne 0x1e54a
movq %r14, %rdi
callq 0x5170
movq 0x17c3b(%rip), %rdi     # 0x35ff0
callq 0x51c0
movq %rax, %rdi
leaq 0x8c3c(%rip), %rsi      # 0x27000
callq 0x53f0
movq %rax, %rdi
callq 0x51c0
movq %rax, %rdi
callq 0x51c0
callq 0x5640
jmp 0x1e379
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
je 0x1e491
callq 0x1df8a
movq 0x17bbc(%rip), %rdi     # 0x35fb8
leaq 0x8cba(%rip), %rsi      # 0x270bd
callq 0x53f0
movq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x53e0
leaq 0x73c5(%rip), %rsi      # 0x257e1
movq %rax, %rdi
callq 0x53f0
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %rax
movq %rax, %rsi
subq %rbx, %rsi
sarq $0x5, %rsi
movslq 0x180c1(%rip), %rcx     # 0x36500
cmpq %rcx, %rsi
jbe 0x1e4e1
movq 0x17b69(%rip), %rdi     # 0x35fb8
callq 0x5280
leaq 0x866a(%rip), %rsi      # 0x26ac5
movq %rax, %rdi
callq 0x53f0
movq 0x17b4e(%rip), %rdi     # 0x35fb8
callq 0x51c0
movq %rax, %rdi
callq 0x51c0
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xc67f
xorl %r14d, %r14d
testl %eax, %eax
setne %r14b
jmp 0x1e4c5
movq 0x17b58(%rip), %rdi     # 0x35ff0
callq 0x51c0
leaq 0x8c07(%rip), %rsi      # 0x270ab
movq %rax, %rdi
callq 0x53f0
movq %rax, %rdi
callq 0x51c0
movq %rax, %rdi
callq 0x51c0
callq 0x1e009
pushq $0x1
popq %r14
leaq 0x10(%rsp), %rdi
callq 0x911e
movl %r14d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x17ad0(%rip), %r14     # 0x35fb8
leaq 0x7e6e(%rip), %r15      # 0x2635d
cmpq %rax, %rbx
je 0x1e463
movq %r14, %rdi
movq %rbx, %rsi
callq 0x53a0
movq %rax, %rdi
movq %r15, %rsi
callq 0x53f0
addq $0x20, %rbx
movq 0x18(%rsp), %rax
jmp 0x1e4ef
jmp 0x1e547
movq %rax, %r14
callq 0x5640
jmp 0x1e54a
movq %rax, %rdi
callq 0x7102
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x5778
jmp 0x1e54a
jmp 0x1e547
jmp 0x1e542
jmp 0x1e542
movq %rax, %r14
jmp 0x1e554
movq %rax, %r14
leaq 0x48(%rsp), %rdi
callq 0x5778
leaq 0x10(%rsp), %rdi
callq 0x911e
movq %r14, %rdi
callq 0x56c0