// File: /workspace/github_cpp_makefile_star2_O3/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, 0x8(%rsp)
movl %edi, %ebp
leaq 0x90(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xd5a0(%rip), %rsi      # 0x35562
leaq 0xd5a7(%rip), %rdx      # 0x35570
leaq 0x80(%rsp), %rdi
callq 0x85fc
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xc2bc(%rip), %rdx      # 0x342a2
leaq 0x50(%rsp), %rdi
movq %rdx, %rsi
callq 0x85fc
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl $0x3, %ebp
jl 0x28689
leaq 0x40(%rsp), %r13
movl $0x2, %r12d
movq $0x0, 0x70(%rsp)
leaq 0xa0(%rsp), %r15
movq $0x0, 0x78(%rsp)
movq $0x0, 0x28(%rsp)
movslq %r12d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %r15, %rdi
leaq 0x30(%rsp), %rdx
callq 0x182e0
movq %r15, %rdi
leaq 0xcfc1(%rip), %rsi      # 0x3501f
callq 0x50f0
testl %eax, %eax
je 0x281dd
movq %r15, %rdi
leaq 0xcfad(%rip), %rsi      # 0x35022
callq 0x50f0
testl %eax, %eax
je 0x281dd
movq %r15, %rdi
leaq 0xd013(%rip), %rsi      # 0x3509f
callq 0x50f0
testl %eax, %eax
je 0x281ed
movq %r15, %rdi
leaq 0xd4ce(%rip), %rsi      # 0x35571
callq 0x50f0
testl %eax, %eax
je 0x2823c
movq %r15, %rdi
leaq 0xd291(%rip), %rsi      # 0x3534b
callq 0x50f0
movb $0x1, %r13b
testl %eax, %eax
je 0x282f0
movq %r15, %rdi
leaq 0xd255(%rip), %rsi      # 0x35329
callq 0x50f0
testl %eax, %eax
je 0x2833b
movq %r15, %rdi
leaq 0xd4ab(%rip), %rsi      # 0x35596
callq 0x50f0
testl %eax, %eax
je 0x283a6
movq %r15, %rdi
leaq 0xd2ca(%rip), %rsi      # 0x353cc
callq 0x50f0
movb $0x1, %r13b
testl %eax, %eax
je 0x28491
movq 0xa0(%rsp), %rax
cmpb $0x2d, (%rax)
jne 0x2849d
movq 0x18ec6(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x18ea8(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r14
movl $0x12, %edx
movq %rax, %rdi
leaq 0xcf5d(%rip), %rsi      # 0x350c4
callq 0x5420
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
movq %r14, %rdi
callq 0x5420
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
jmp 0x282e5
xorl %r14d, %r14d
callq 0x27cb6
xorl %r13d, %r13d
jmp 0x282f7
incl %r12d
cmpl %ebp, %r12d
jge 0x2824b
movslq %r12d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
leaq 0xc8(%rsp), %rdx
callq 0x182e0
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
callq 0x8148
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x28243
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x28243
movb $0x1, %al
movq %rax, 0x78(%rsp)
movb $0x1, %r13b
jmp 0x282f7
movq 0x18d9e(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x18d80(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r14
movl $0x21, %edx
movq %rax, %rdi
leaq 0xce13(%rip), %rsi      # 0x350a2
callq 0x5420
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movl $0x1, %r14d
xorl %r13d, %r13d
jmp 0x282f7
movb $0x1, %al
movq %rax, 0x70(%rsp)
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x2831c
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x53c0
testb %r13b, %r13b
je 0x28701
incl %r12d
cmpl %ebp, %r12d
leaq 0x40(%rsp), %r13
jl 0x2803b
jmp 0x285c3
incl %r12d
cmpl %ebp, %r12d
jge 0x283f2
movslq %r12d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0xc8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x7(%rsp), %rdx
callq 0x182e0
movq %rbx, %rdi
leaq 0xd1fa(%rip), %rsi      # 0x3556c
callq 0x5710
leaq 0x40(%rsp), %rbx
movq %rbx, 0x30(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2854e
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x28554
incl %r12d
cmpl %ebp, %r12d
jge 0x284af
movslq %r12d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rbx
movq 0x58(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq %rbx, %rdi
callq 0x5180
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
movq 0xc0(%rsp), %rdx
movq %rbx, %rcx
movq %rax, %r8
callq 0x55e0
jmp 0x282f7
movq 0x18bf7(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x18bd9(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r14
movl $0x21, %edx
movq %rax, %rdi
leaq 0xd13e(%rip), %rsi      # 0x35574
callq 0x5420
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
jmp 0x282e5
movb $0x1, %al
movq %rax, 0x28(%rsp)
jmp 0x282f7
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x8528
jmp 0x282f7
movq 0x18b3a(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x18b1c(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r14
movl $0x21, %edx
movq %rax, %rdi
leaq 0xd0a6(%rip), %rsi      # 0x35599
callq 0x5420
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
jmp 0x282e5
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
movq %rdx, 0x38(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x80(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x5470
movq 0x30(%rsp), %rdi
cmpq %rbx, %rdi
je 0x28595
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x282f7
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x282f7
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
je 0x28689
leaq 0xbcc8(%rip), %rsi      # 0x342a2
leaq 0x50(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
je 0x28761
callq 0x26352
movq 0x70(%rsp), %r13
movq 0x78(%rsp), %rbp
movq 0x189be(%rip), %rdi     # 0x40fc0
leaq 0xcfd1(%rip), %rsi      # 0x355da
movl $0x21, %edx
callq 0x5420
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x1899c(%rip), %rbx     # 0x40fc0
movq %rbx, %rdi
callq 0x5420
leaq 0xb373(%rip), %rsi      # 0x339a6
movl $0x6, %edx
movq %rax, %rdi
callq 0x5420
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %rax
movq %rax, %rsi
subq %r12, %rsi
sarq $0x5, %rsi
movslq 0x18e95(%rip), %rcx     # 0x414f0
cmpq %rcx, %rsi
jbe 0x287c0
movq 0x18955(%rip), %rdi     # 0x40fc0
callq 0x5240
leaq 0xc47a(%rip), %rsi      # 0x34af1
movl $0x6, %edx
movq %rax, %rdi
callq 0x5420
jmp 0x287ff
movq 0x18960(%rip), %rdi     # 0x40ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x18945(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
leaq 0xca15(%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
movl $0x1, %r14d
callq 0x27cb6
leaq 0x10(%rsp), %rdi
callq 0xab8e
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x28727
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x2874c
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x53c0
movl %r14d, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18888(%rip), %rdi     # 0x40ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1886d(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
leaq 0xce21(%rip), %rsi      # 0x355bb
movl $0x1e, %edx
movq %rax, %rdi
callq 0x5420
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
jmp 0x286e3
cmpq %rax, %r12
je 0x287ff
movq 0x187f4(%rip), %r14     # 0x40fc0
leaq 0xbbb5(%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 0x287d3
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x187a3(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
testb $0x1, 0x28(%rsp)
je 0x28877
movq 0x18788(%rip), %rbx     # 0x40fc0
leaq 0xcdbd(%rip), %rsi      # 0x355fc
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 0x18756(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
leaq 0xcda2(%rip), %rax      # 0x35620
leaq 0xcdbf(%rip), %rsi      # 0x35644
testb $0x1, %bpl
cmovneq %rax, %rsi
movl %ebp, %eax
notb %al
movzbl %al, %eax
andl $0x1, %eax
leaq 0x23(,%rax,4), %rdx
movq 0x1871a(%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 0x186f4(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
leaq 0xcd8c(%rip), %rax      # 0x3566c
leaq 0xcdb2(%rip), %rsi      # 0x35699
testb $0x1, %r13b
cmovneq %rax, %rsi
movl %r13d, %eax
notb %al
movzbl %al, %eax
andl $0x1, %eax
leaq 0x2c(,%rax,4), %rdx
movq 0x186b7(%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 0x18691(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq 0x1867d(%rip), %rdi     # 0x40fc0
leaq 0xcafa(%rip), %rsi      # 0x35444
movl $0x1a, %edx
callq 0x5420
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq 0x18655(%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 0x28(%rsp), %edx
andl $0x1, %edx
movzbl %bpl, %ecx
andl $0x1, %ecx
movzbl %r13b, %r8d
andl $0x1, %r8d
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x80(%rsp), %r9
callq 0x142ce
xorl %r14d, %r14d
testl %eax, %eax
setne %r14b
jmp 0x28701
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x28a53
movq 0xd8(%rsp), %rsi
jmp 0x28a36
jmp 0x28a50
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x28a53
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x28a53
jmp 0x28a50
movq %rax, %rbx
jmp 0x28a9e
jmp 0x28a4b
jmp 0x28a4b
movq %rax, %rbx
jmp 0x28a78
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x28a78
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0x10(%rsp), %rdi
callq 0xab8e
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x28a9e
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x28ac3
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x53c0
movq %rbx, %rdi
callq 0x56a0