// File: /workspace/github_cpp_makefile_star2_O1/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 %rsi, 0x28(%rsp)
movq $0xf, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl $0x3, %edi
setge %r12b
jl 0x27103
movl %edi, %ebp
movl $0x2, %r15d
leaq 0x38(%rsp), %r14
leaq 0x58(%rsp), %rbx
movslq %r15d, %rax
movq 0x28(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x184a2
movq %r14, %rdi
leaq 0xe3c7(%rip), %rsi      # 0x3502f
callq 0x50f0
testl %eax, %eax
je 0x26d7c
movq %r14, %rdi
leaq 0xe3b3(%rip), %rsi      # 0x35032
callq 0x50f0
testl %eax, %eax
je 0x26d7c
movq %r14, %rdi
leaq 0xe3a3(%rip), %rsi      # 0x35039
callq 0x50f0
testl %eax, %eax
je 0x26d8b
movq %r14, %rdi
leaq 0xe402(%rip), %rsi      # 0x350af
callq 0x50f0
testl %eax, %eax
je 0x26ecf
movq 0x38(%rsp), %rax
cmpb $0x2d, (%rax)
jne 0x26f24
movq 0x1a321(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1a303(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x12, %edx
movq %rax, %rdi
leaq 0xe3c8(%rip), %rsi      # 0x350d4
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 0x27073
xorl %ebx, %ebx
callq 0x26892
xorl %r13d, %r13d
jmp 0x2707b
incl %r15d
cmpl %ebp, %r15d
jge 0x26f38
movslq %r15d, %rax
movq 0x28(%rsp), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x260f0
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 0x26df8
movslq 0x1a6ff(%rip), %rcx     # 0x414e0
cmpq %rcx, %rax
jl 0x26df8
movslq 0x1a6f7(%rip), %rcx     # 0x414e4
movb $0x1, %bl
cmpq %rcx, %rax
jle 0x2707b
movq 0x1a1f1(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1a1d3(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x2d, %edx
movq %rax, %rdi
leaq 0xe229(%rip), %rsi      # 0x35065
callq 0x5420
movl 0x1a699(%rip), %esi     # 0x414e0
movq %r13, %rdi
callq 0x5690
movq %rax, %r13
movl $0x5, %edx
movq %rax, %rdi
leaq 0xd760(%rip), %rsi      # 0x345c1
callq 0x5420
movl 0x1a678(%rip), %esi     # 0x414e4
movq %r13, %rdi
callq 0x5690
movq %rax, %r13
movl $0x1b, %edx
movq %rax, %rdi
leaq 0xe20d(%rip), %rsi      # 0x35093
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 0x26fc0
incl %r15d
cmpl %ebp, %r15d
jge 0x26fd8
movslq %r15d, %rax
movq 0x28(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %rbx, %rdi
leaq 0xf(%rsp), %rdx
callq 0x184a2
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
callq 0x817c
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x26f1d
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x53c0
movb $0x1, %bl
jmp 0x2707b
movb $0x1, %bl
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x855c
jmp 0x2707b
movq 0x1a0b1(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1a093(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x28, %edx
movq %rax, %rdi
leaq 0xe0c0(%rip), %rsi      # 0x3503c
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 0x27073
movq 0x1a011(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x19ff3(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0xe096(%rip), %rsi      # 0x350b2
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 %ebx, %ebx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x27097
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x53c0
testb %bl, %bl
je 0x27103
incl %r15d
cmpl %ebp, %r15d
setl %r12b
leaq 0x58(%rsp), %rbx
jl 0x26c47
jmp 0x27103
movq %rax, %r13
cmpl $0x1, %edx
jne 0x2735c
movq %r13, %rdi
callq 0x5160
movq 0x19f23(%rip), %rdi     # 0x40ff0
callq 0x5190
movq %rax, %r13
movl $0x28, %edx
movq %rax, %rdi
leaq 0xdf58(%rip), %rsi      # 0x3503c
callq 0x5420
movq %r13, %rdi
callq 0x5190
movq %rax, %rdi
callq 0x5190
callq 0x5630
jmp 0x27073
testb $0x1, %r12b
jne 0x272fd
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
je 0x271a8
callq 0x26746
movq 0x19e97(%rip), %rdi     # 0x40fc0
leaq 0xdfc9(%rip), %rsi      # 0x350f9
movl $0xf, %edx
callq 0x5420
movq 0x30(%rsp), %rsi
movq 0x19e7a(%rip), %rbx     # 0x40fc0
movq %rbx, %rdi
callq 0x5390
leaq 0xc680(%rip), %rsi      # 0x337d5
movl $0x9, %edx
movq %rax, %rdi
callq 0x5420
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %rsi
subq %r12, %rsi
sarq $0x5, %rsi
movslq 0x1a376(%rip), %rax     # 0x414f0
cmpq %rax, %rsi
jbe 0x2724f
movq 0x19e36(%rip), %rdi     # 0x40fc0
callq 0x5240
leaq 0xd96b(%rip), %rsi      # 0x34b01
movl $0x6, %edx
movq %rax, %rdi
callq 0x5420
jmp 0x27290
movq 0x19e41(%rip), %rdi     # 0x40ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x19e26(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
leaq 0xdf06(%rip), %rsi      # 0x350e7
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 0x26892
jmp 0x272fd
cmpq 0x18(%rsp), %r12
je 0x27290
movq 0x19d63(%rip), %r14     # 0x40fc0
leaq 0xd134(%rip), %r15      # 0x34398
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 0x27264
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x19d12(%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 0xe69d
xorl %r13d, %r13d
testl %eax, %eax
setne %r13b
leaq 0x10(%rsp), %rdi
callq 0xabee
movl %r13d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x27359
movq %rax, %r13
callq 0x5630
jmp 0x2735c
movq %rax, %rdi
callq 0x7d6a
movq %rax, %r13
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x2735c
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x2735c
jmp 0x27359
jmp 0x27354
jmp 0x27354
movq %rax, %r13
jmp 0x27378
movq %rax, %r13
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x27378
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0x10(%rsp), %rdi
callq 0xabee
movq %r13, %rdi
callq 0x56a0