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

	std::string outfile="annotation.vcf";
	std::string reference="";
	std::vector < std::string > args;
	bool snponly=false;
	bool includerepeats=false;
	bool includeproduct=false;

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

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

		if (arg=="-h" || arg=="--help"){
			annotateHelp();
			return 0;
		}
		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 == "-i"){
			includerepeats = true;
		}
		else if (arg == "-p"){
			includeproduct = true;
		}
		else if (arg == "-o"){
			i++;
			if (i<argc){
				outfile = std::string(argv[i])+".vcf";
			}
			else {
				std::cerr << std::endl << "Expecting file name after -o flag" << std::endl << std::endl;
				return 1;
			}
		}
		else if (arg == "-r"){
			i++;
			if (i<argc){
				reference = argv[i];
			}
			else {
				std::cerr << std::endl << "Expecting file name after -r flag" << std::endl << std::endl;
				return 1;
			}
		}
		else if (arg == "-v"){
			snponly = true;
		}
		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;
		annotateHelp();
		return 1;
	}
	if (reference==""){
		std::cerr << std::endl << "Reference sequence is required" << std::endl;
		annotateHelp();
		return 1;
	}

	skaVersion();

	std::cout << "Annotating split kmer matches in " << reference << " from ";
	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;

	if (snponly){
		std::cout << "Only variant sites will be included" << std::endl;
	}
	if (includerepeats){
		std::cout << "Matches in repeats will be included" << std::endl;
	}
	else {
		std::cout << "Matches in repeats will not be included" << std::endl;
	}
	if (includeproduct){
		std::cout << "Product information for CDSs will be printed" << std::endl;
	}
	else{
		std::cout << "Product information for CDSs will not be printed" << std::endl;
	}

	std::cout << "Output will be written to " << outfile << std::endl << std::endl;


	if (findKmersInFasta(args, reference, snponly, includerepeats, includeproduct, outfile)){return 1;}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rsi, 0x18(%rsp)
movl %edi, %ebx
leaq 0x90(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xd182(%rip), %rsi      # 0x35572
leaq 0xd189(%rip), %rdx      # 0x35580
leaq 0x80(%rsp), %rdi
callq 0x862a
leaq 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xbe9e(%rip), %rdx      # 0x342b2
leaq 0x58(%rsp), %rdi
movq %rdx, %rsi
callq 0x862a
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
cmpl $0x3, %ebx
setge %r15b
jl 0x289ff
movl %ebx, 0x10(%rsp)
leaq 0x48(%rsp), %rbx
movl $0x2, %r12d
movq $0x0, 0x78(%rsp)
leaq 0xa0(%rsp), %r14
movl $0x0, 0xc(%rsp)
movl $0x0, 0x8(%rsp)
movslq %r12d, %rax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %r14, %rdi
leaq 0x38(%rsp), %rdx
callq 0x184a2
movq %r14, %rdi
leaq 0xcb9d(%rip), %rsi      # 0x3502f
callq 0x50f0
testl %eax, %eax
je 0x2860f
movq %r14, %rdi
leaq 0xcb89(%rip), %rsi      # 0x35032
callq 0x50f0
testl %eax, %eax
je 0x2860f
movq %r14, %rdi
leaq 0xcbef(%rip), %rsi      # 0x350af
callq 0x50f0
testl %eax, %eax
je 0x2861e
movq %r14, %rdi
leaq 0xd0aa(%rip), %rsi      # 0x35581
callq 0x50f0
testl %eax, %eax
je 0x2866f
movq %r14, %rdi
leaq 0xce6d(%rip), %rsi      # 0x3535b
callq 0x50f0
movb $0x1, %bl
testl %eax, %eax
je 0x28721
movq %r14, %rdi
leaq 0xce32(%rip), %rsi      # 0x35339
callq 0x50f0
testl %eax, %eax
je 0x28771
movq %r14, %rdi
leaq 0xd088(%rip), %rsi      # 0x355a6
callq 0x50f0
testl %eax, %eax
je 0x287de
movq %r14, %rdi
leaq 0xcea7(%rip), %rsi      # 0x353dc
callq 0x50f0
movb $0x1, %bl
testl %eax, %eax
je 0x288cc
movq 0xa0(%rsp), %rax
cmpb $0x2d, (%rax)
jne 0x288d7
movq 0x18a94(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x18a76(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x12, %edx
movq %rax, %rdi
leaq 0xcb3b(%rip), %rsi      # 0x350d4
callq 0x5420
movq 0xa0(%rsp), %rsi
movq 0xa8(%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 0x28717
xorl %r13d, %r13d
callq 0x280e4
xorl %ebx, %ebx
jmp 0x28728
incl %r12d
cmpl 0x10(%rsp), %r12d
jge 0x2867c
movslq %r12d, %rax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0x38(%rsp), %rbp
movq %rbp, %rdi
leaq 0xc8(%rsp), %rdx
callq 0x184a2
movq %rbp, %rdi
leaq 0x20(%rsp), %rsi
callq 0x817c
movq 0x38(%rsp), %rdi
cmpq %rbx, %rdi
je 0x28675
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x28675
movb $0x1, %al
movl %eax, 0xc(%rsp)
movb $0x1, %bl
jmp 0x28728
movq 0x1896d(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1894f(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0xc9f2(%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
jmp 0x28728
movb $0x1, %al
movq %rax, 0x78(%rsp)
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x2874d
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x53c0
testb %bl, %bl
leaq 0x48(%rsp), %rbx
je 0x28a13
incl %r12d
cmpl 0x10(%rsp), %r12d
setl %r15b
jl 0x2846f
jmp 0x28a13
incl %r12d
cmpl 0x10(%rsp), %r12d
jge 0x2882c
movslq %r12d, %rax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0xc8(%rsp), %rbp
movq %rbp, %rdi
leaq 0x17(%rsp), %rdx
callq 0x184a2
movq %rbp, %rdi
leaq 0xcdd2(%rip), %rsi      # 0x3557c
callq 0x5710
leaq 0x48(%rsp), %rbp
movq %rbp, 0x38(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x28989
movq %rdx, 0x38(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x48(%rsp)
jmp 0x28990
incl %r12d
cmpl 0x10(%rsp), %r12d
jge 0x288e9
movslq %r12d, %rax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rbp
movq 0x60(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq %rbp, %rdi
callq 0x5180
leaq 0x58(%rsp), %rdi
xorl %esi, %esi
movq 0xc0(%rsp), %rdx
movq %rbp, %rcx
movq %rax, %r8
callq 0x55e0
jmp 0x28728
movq 0x187bd(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1879f(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0xcd14(%rip), %rsi      # 0x35584
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 0x28717
movb $0x1, %al
movl %eax, 0x8(%rsp)
jmp 0x28728
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x855c
jmp 0x28728
movq 0x18700(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x186e2(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0xcc7c(%rip), %rsi      # 0x355a9
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 0x28717
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
movq 0x8(%rax), %rdx
movq %rdx, 0x40(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x80(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x5470
movq 0x38(%rsp), %rdi
cmpq %rbp, %rdi
je 0x289d1
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x28728
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x28728
movl $0x0, 0x8(%rsp)
movl $0x0, 0xc(%rsp)
xorl %ebp, %ebp
jmp 0x28a18
movq 0x78(%rsp), %rbp
testb $0x1, %r15b
jne 0x28df4
movq 0x28(%rsp), %rax
cmpq 0x20(%rsp), %rax
je 0x28adb
leaq 0xb879(%rip), %rsi      # 0x342b2
leaq 0x58(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
je 0x28b37
callq 0x26746
movq 0x18569(%rip), %rdi     # 0x40fc0
leaq 0xcb8c(%rip), %rsi      # 0x355ea
movl $0x21, %edx
callq 0x5420
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0x18547(%rip), %rbx     # 0x40fc0
movq %rbx, %rdi
callq 0x5420
leaq 0xaee6(%rip), %rsi      # 0x3396e
movl $0x6, %edx
movq %rax, %rdi
callq 0x5420
movq 0x20(%rsp), %r12
movq 0x28(%rsp), %rsi
subq %r12, %rsi
sarq $0x5, %rsi
movslq 0x18a43(%rip), %rax     # 0x414f0
cmpq %rax, %rsi
jbe 0x28bb4
movq 0x18503(%rip), %rdi     # 0x40fc0
callq 0x5240
leaq 0xc038(%rip), %rsi      # 0x34b01
movl $0x6, %edx
movq %rax, %rdi
callq 0x5420
jmp 0x28bf5
movq 0x1850e(%rip), %rdi     # 0x40ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x184f3(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
leaq 0xc5d3(%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
jmp 0x28b91
movq 0x184b2(%rip), %rdi     # 0x40ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x18497(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
leaq 0xca5b(%rip), %rsi      # 0x355cb
movl $0x1e, %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
movl $0x1, %r13d
callq 0x280e4
jmp 0x28df4
cmpq 0x28(%rsp), %r12
je 0x28bf5
movq 0x183fe(%rip), %r14     # 0x40fc0
leaq 0xb7cf(%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 0x28(%rsp), %r12
jne 0x28bc9
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x183ad(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
testb $0x1, 0x8(%rsp)
je 0x28c6d
movq 0x18392(%rip), %rbx     # 0x40fc0
leaq 0xc9d7(%rip), %rsi      # 0x3560c
movl $0x23, %edx
movq %rbx, %rdi
callq 0x5420
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x18360(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
leaq 0xc9bc(%rip), %rax      # 0x35630
leaq 0xc9d9(%rip), %rsi      # 0x35654
movl 0xc(%rsp), %ecx
testb $0x1, %cl
cmovneq %rax, %rsi
movl %ecx, %eax
notb %al
movzbl %al, %eax
andl $0x1, %eax
leaq 0x23(,%rax,4), %rdx
movq 0x18321(%rip), %rbx     # 0x40fc0
movq %rbx, %rdi
callq 0x5420
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x182fb(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
leaq 0xc9a3(%rip), %rax      # 0x3567c
leaq 0xc9c9(%rip), %rsi      # 0x356a9
testb $0x1, %bpl
cmovneq %rax, %rsi
movl %ebp, %eax
notb %al
movzbl %al, %eax
andl $0x1, %eax
leaq 0x2c(,%rax,4), %rdx
movq 0x182bf(%rip), %rbx     # 0x40fc0
movq %rbx, %rdi
callq 0x5420
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x18299(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq 0x18285(%rip), %rdi     # 0x40fc0
leaq 0xc712(%rip), %rsi      # 0x35454
movl $0x1a, %edx
callq 0x5420
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq 0x1825d(%rip), %rdi     # 0x40fc0
callq 0x5420
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
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
movzbl 0x8(%rsp), %edx
andl $0x1, %edx
movzbl 0xc(%rsp), %ecx
andl $0x1, %ecx
movzbl %bpl, %r8d
andl $0x1, %r8d
leaq 0x20(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0x80(%rsp), %r9
callq 0x14466
xorl %r13d, %r13d
testl %eax, %eax
setne %r13b
leaq 0x20(%rsp), %rdi
callq 0xabee
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x28e1a
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x28e3f
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x53c0
movl %r13d, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x28eaa
movq 0xd8(%rsp), %rsi
jmp 0x28e8d
jmp 0x28ea7
movq %rbx, %rcx
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %rcx, %rdi
je 0x28eaa
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x28eaa
jmp 0x28ea7
movq %rax, %rbx
jmp 0x28ef5
jmp 0x28ea2
jmp 0x28ea2
movq %rax, %rbx
jmp 0x28ecf
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x28ecf
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0x20(%rsp), %rdi
callq 0xabee
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x28ef5
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x28f1a
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x53c0
movq %rbx, %rdi
callq 0x56a0