// File: /workspace/github_cpp_makefile_star2_O3/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 $0x78, %rsp
movq $0xf, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl $0x3, %edi
jl 0x26d9e
movq %rsi, %rbx
movl %edi, %ebp
movl $0x2, %r12d
leaq 0x38(%rsp), %r14
leaq 0x58(%rsp), %r15
movslq %r12d, %rax
movq (%rbx,%rax,8), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x182e0
movq %r14, %rdi
leaq 0xe7b6(%rip), %rsi      # 0x3501f
callq 0x50f0
testl %eax, %eax
je 0x2697d
movq %r14, %rdi
leaq 0xe7a2(%rip), %rsi      # 0x35022
callq 0x50f0
testl %eax, %eax
je 0x2697d
movq %r14, %rdi
leaq 0xe792(%rip), %rsi      # 0x35029
callq 0x50f0
testl %eax, %eax
je 0x2698d
movq %r14, %rdi
leaq 0xe7f1(%rip), %rsi      # 0x3509f
callq 0x50f0
testl %eax, %eax
je 0x26acd
movq 0x38(%rsp), %rax
cmpb $0x2d, (%rax)
jne 0x26b1e
movq 0x1a720(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1a702(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x12, %edx
movq %rax, %rdi
leaq 0xe7b7(%rip), %rsi      # 0x350c4
callq 0x5420
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq %r13, %rdi
callq 0x5420
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r13, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r13, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
jmp 0x26c6e
xorl %r15d, %r15d
callq 0x2649e
xorl %r13d, %r13d
jmp 0x26c77
incl %r12d
cmpl %ebp, %r12d
jge 0x26b33
movslq %r12d, %rax
movq (%rbx,%rax,8), %rdi
callq 0x25cfc
movq %rax, 0x30(%rsp)
movq %rax, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
movabsq $0x2aaaaaaaaaaaaaaa, %rdx # imm = 0x2AAAAAAAAAAAAAAA
addq %rdx, %rcx
movabsq $0x5555555555555554, %rdx # imm = 0x5555555555555554
cmpq %rdx, %rcx
ja 0x269f6
movslq 0x1ab02(%rip), %rcx     # 0x414e0
cmpq %rcx, %rax
jl 0x269f6
movslq 0x1aafa(%rip), %rcx     # 0x414e4
movb $0x1, %r15b
cmpq %rcx, %rax
jle 0x26c77
movq 0x1a5f3(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1a5d5(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x2d, %edx
movq %rax, %rdi
leaq 0xe61b(%rip), %rsi      # 0x35055
callq 0x5420
movl 0x1aa9b(%rip), %esi     # 0x414e0
movq %r13, %rdi
callq 0x5690
movq %rax, %r13
movl $0x5, %edx
movq %rax, %rdi
leaq 0xdb52(%rip), %rsi      # 0x345b1
callq 0x5420
movl 0x1aa7a(%rip), %esi     # 0x414e4
movq %r13, %rdi
callq 0x5690
movq %rax, %r13
movl $0x1b, %edx
movq %rax, %rdi
leaq 0xe5ff(%rip), %rsi      # 0x35083
callq 0x5420
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r13, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x53a0
jmp 0x26bbb
incl %r12d
cmpl %ebp, %r12d
jge 0x26bd3
movslq %r12d, %rax
movq (%rbx,%rax,8), %rsi
movq %r15, %rdi
leaq 0xf(%rsp), %rdx
callq 0x182e0
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
callq 0x8148
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x26b16
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x53c0
movb $0x1, %r15b
jmp 0x26c77
movb $0x1, %r15b
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x8528
jmp 0x26c77
movq 0x1a4b6(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1a498(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x28, %edx
movq %rax, %rdi
leaq 0xe4b5(%rip), %rsi      # 0x3502c
callq 0x5420
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r13, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r13, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
jmp 0x26c6e
movq 0x1a416(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1a3f8(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0xe48b(%rip), %rsi      # 0x350a2
callq 0x5420
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r13, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r13, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movl $0x1, %r13d
xorl %r15d, %r15d
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x26c93
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x53c0
testb %r15b, %r15b
je 0x26ef1
incl %r12d
cmpl %ebp, %r12d
leaq 0x58(%rsp), %r15
jl 0x2684d
jmp 0x26d00
movq %rax, %r13
cmpl $0x1, %edx
jne 0x26f50
movq %r13, %rdi
callq 0x5160
movq 0x1a326(%rip), %rdi     # 0x40ff0
callq 0x5190
movq %rax, %r13
movl $0x28, %edx
movq %rax, %rdi
leaq 0xe34b(%rip), %rsi      # 0x3502c
callq 0x5420
movq %r13, %rdi
callq 0x5190
movq %rax, %rdi
callq 0x5190
callq 0x5630
jmp 0x26c6e
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
je 0x26d9e
callq 0x26352
movq 0x1a2a4(%rip), %rdi     # 0x40fc0
leaq 0xe3c6(%rip), %rsi      # 0x350e9
movl $0xf, %edx
callq 0x5420
movq 0x30(%rsp), %rsi
movq 0x1a287(%rip), %rbx     # 0x40fc0
movq %rbx, %rdi
callq 0x5390
leaq 0xca8d(%rip), %rsi      # 0x337d5
movl $0x9, %edx
movq %rax, %rdi
callq 0x5420
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %rax
movq %rax, %rsi
subq %r12, %rsi
sarq $0x5, %rsi
movslq 0x1a780(%rip), %rcx     # 0x414f0
cmpq %rcx, %rsi
jbe 0x26e45
movq 0x1a240(%rip), %rdi     # 0x40fc0
callq 0x5240
leaq 0xdd65(%rip), %rsi      # 0x34af1
movl $0x6, %edx
movq %rax, %rdi
callq 0x5420
jmp 0x26e84
movq 0x1a24b(%rip), %rdi     # 0x40ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1a230(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
leaq 0xe300(%rip), %rsi      # 0x350d7
movl $0x11, %edx
movq %rax, %rdi
callq 0x5420
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movl $0x1, %r13d
callq 0x2649e
jmp 0x26ef1
cmpq %rax, %r12
je 0x26e84
movq 0x1a16f(%rip), %r14     # 0x40fc0
leaq 0xd530(%rip), %r15      # 0x34388
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %r14, %rdi
callq 0x5420
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x5420
addq $0x20, %r12
cmpq 0x18(%rsp), %r12
jne 0x26e58
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1a11e(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xe4d9
xorl %r13d, %r13d
testl %eax, %eax
setne %r13b
leaq 0x10(%rsp), %rdi
callq 0xab8e
movl %r13d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x26f4d
movq %rax, %r13
callq 0x5630
jmp 0x26f50
movq %rax, %rdi
callq 0x7d38
movq %rax, %r13
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x26f50
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x26f50
jmp 0x26f4d
jmp 0x26f48
jmp 0x26f48
movq %rax, %r13
jmp 0x26f6c
movq %rax, %r13
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x26f6c
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0x10(%rsp), %rdi
callq 0xab8e
movq %r13, %rdi
callq 0x56a0