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

	std::string outfile="fasta.skf";
	long int kmersize=15;
	bool circular=false;
	std::vector < std::string > args;

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

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

		if (arg=="-h" || arg=="--help"){
			fastaHelp();
			return 0;
		}
		else if (arg=="-c"){
			circular=true;
		}
		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 == "-o"){
			i++;
			if (i<argc){
				outfile = std::string(argv[i])+".skf";
			}
			else {
				std::cerr << std::endl << "Expecting file name after -o flag" << 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;
		fastaHelp();
		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;
	if (circular){
		std::cout << "Contigs will be treated as circular" << std::endl;
	}
	else {
		std::cout << "Contigs will be treated as linear" << std::endl;
	}
	std::cout << "Output will be written to " << outfile << std::endl;

	std::cout << std::endl;

	if (fastaToKmers(args, outfile, kmersize, circular)){return 1;}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, %r14
movl %edi, %r15d
leaq 0x78(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xb851(%rip), %rsi      # 0x35d49
leaq 0xb853(%rip), %rdx      # 0x35d52
leaq 0x68(%rsp), %rdi
callq 0x85fc
movq $0xf, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
cmpl $0x3, %r15d
jl 0x2ac81
leaq 0x58(%rsp), %rbx
movl $0x2, %r12d
movl $0x0, 0x14(%rsp)
leaq 0x48(%rsp), %rdx
movq %r14, 0x18(%rsp)
movl %r15d, 0xc(%rsp)
movslq %r12d, %rax
movq (%r14,%rax,8), %rsi
leaq 0x88(%rsp), %rbp
movq %rbp, %rdi
movq %rdx, %r14
callq 0x182e0
movq %rbp, %rdi
leaq 0xaaac(%rip), %rsi      # 0x3501f
callq 0x50f0
testl %eax, %eax
je 0x2a6c1
movq %rbp, %rdi
leaq 0xaa98(%rip), %rsi      # 0x35022
callq 0x50f0
testl %eax, %eax
je 0x2a6c1
movq %rbp, %rdi
leaq 0xb40e(%rip), %rsi      # 0x359af
callq 0x50f0
movb $0x1, %r15b
testl %eax, %eax
je 0x2a718
movq %rbp, %rdi
leaq 0xaa6e(%rip), %rsi      # 0x35029
callq 0x50f0
testl %eax, %eax
je 0x2a720
movq %rbp, %rdi
leaq 0xad57(%rip), %rsi      # 0x35329
callq 0x50f0
testl %eax, %eax
je 0x2a864
movq %rbp, %rdi
leaq 0xaab6(%rip), %rsi      # 0x3509f
callq 0x50f0
testl %eax, %eax
je 0x2a96f
movq 0x88(%rsp), %rax
cmpb $0x2d, (%rax)
jne 0x2a9c1
movq 0x169e2(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x169c4(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x12, %edx
movq %rax, %rdi
leaq 0xaa79(%rip), %rsi      # 0x350c4
callq 0x5420
movq 0x88(%rsp), %rsi
movq 0x90(%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 0x2ab13
xorl %r15d, %r15d
callq 0x2a266
xorl %r13d, %r13d
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x2a6f1
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x53c0
testb %r15b, %r15b
je 0x2ae6e
incl %r12d
movl 0xc(%rsp), %r15d
cmpl %r15d, %r12d
movq %r14, %rdx
movq 0x18(%rsp), %r14
jl 0x2a54f
jmp 0x2abe3
movb $0x1, %al
movl %eax, 0x14(%rsp)
jmp 0x2a6cc
incl %r12d
cmpl 0xc(%rsp), %r12d
jge 0x2a8cf
movslq %r12d, %rax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x25cfc
movq %rax, 0x40(%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 0x2a78d
movslq 0x16d68(%rip), %rcx     # 0x414e0
cmpq %rcx, %rax
jl 0x2a78d
movslq 0x16d60(%rip), %rcx     # 0x414e4
cmpq %rcx, %rax
jle 0x2a6cc
movq 0x1685c(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1683e(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x2d, %edx
movq %rax, %rdi
leaq 0xa884(%rip), %rsi      # 0x35055
callq 0x5420
movl 0x16d04(%rip), %esi     # 0x414e0
movq %r13, %rdi
callq 0x5690
movq %rax, %r13
movl $0x5, %edx
movq %rax, %rdi
leaq 0x9dbb(%rip), %rsi      # 0x345b1
callq 0x5420
movl 0x16ce3(%rip), %esi     # 0x414e4
movq %r13, %rdi
callq 0x5690
movq %rax, %r13
movl $0x1b, %edx
movq %rax, %rdi
leaq 0xa868(%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 0x2a957
incl %r12d
cmpl 0xc(%rsp), %r12d
jge 0x2a9d8
movslq %r12d, %rax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0xa8(%rsp), %rbp
movq %rbp, %rdi
leaq 0x13(%rsp), %rdx
callq 0x182e0
movq %rbp, %rdi
leaq 0xb4b1(%rip), %rsi      # 0x35d4e
callq 0x5710
movq %rbx, %rbp
movq %rbx, 0x48(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2ab21
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0x2ab28
movq 0x1671a(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x166fc(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x28, %edx
movq %rax, %rdi
leaq 0xa719(%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 0x2ab13
incl %r12d
cmpl 0xc(%rsp), %r12d
jge 0x2aa78
movslq %r12d, %rax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %r14, %rbp
movq %r14, %rdi
leaq 0xa8(%rsp), %rdx
callq 0x182e0
movq %rbp, %rdi
leaq 0x20(%rsp), %rsi
callq 0x8148
movq 0x48(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2a6cc
movq 0x58(%rsp), %rsi
jmp 0x2ab85
leaq 0x20(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x8528
jmp 0x2a6cc
movq 0x16611(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x165f3(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0xab58(%rip), %rsi      # 0x35574
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 0x2ab13
movq 0x16571(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x16553(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0xa5e6(%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
jmp 0x2a6cc
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
movq 0x8(%rax), %rdx
movq %rdx, 0x50(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x68(%rsp), %rdi
movq %r14, %rsi
callq 0x5470
movq 0x48(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2ab64
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x2a6cc
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x2a6cc
movq %rax, %r13
cmpl $0x1, %edx
jne 0x2af10
movq %r13, %rdi
callq 0x5160
movq 0x16443(%rip), %rdi     # 0x40ff0
callq 0x5190
movq %rax, %r13
movl $0x28, %edx
movq %rax, %rdi
leaq 0xa468(%rip), %rsi      # 0x3502c
callq 0x5420
movq %r13, %rdi
callq 0x5190
movq %rax, %rdi
callq 0x5190
callq 0x5630
jmp 0x2ab13
movq 0x28(%rsp), %rax
cmpq 0x20(%rsp), %rax
je 0x2ac81
callq 0x26352
movq 0x163c1(%rip), %rdi     # 0x40fc0
leaq 0xa4e3(%rip), %rsi      # 0x350e9
movl $0xf, %edx
callq 0x5420
movq 0x40(%rsp), %rsi
movq 0x163a4(%rip), %rbx     # 0x40fc0
movq %rbx, %rdi
callq 0x5390
leaq 0x8baa(%rip), %rsi      # 0x337d5
movl $0x9, %edx
movq %rax, %rdi
callq 0x5420
movq 0x20(%rsp), %r12
movq 0x28(%rsp), %rax
movq %rax, %rsi
subq %r12, %rsi
sarq $0x5, %rsi
movslq 0x1689d(%rip), %rcx     # 0x414f0
cmpq %rcx, %rsi
jbe 0x2acfe
movq 0x1635d(%rip), %rdi     # 0x40fc0
callq 0x5240
leaq 0x9e82(%rip), %rsi      # 0x34af1
movl $0x6, %edx
movq %rax, %rdi
callq 0x5420
jmp 0x2ad3d
movq 0x16368(%rip), %rdi     # 0x40ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1634d(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
leaq 0xa41d(%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, %r13d
callq 0x2a266
jmp 0x2ae6e
cmpq %rax, %r12
je 0x2ad3d
movq 0x162b6(%rip), %r14     # 0x40fc0
leaq 0x9677(%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 0x28(%rsp), %r12
jne 0x2ad11
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x16265(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
leaq 0xafe4(%rip), %rax      # 0x35d53
leaq 0xb001(%rip), %rsi      # 0x35d77
movl 0x14(%rsp), %ecx
testb $0x1, %cl
cmovneq %rax, %rsi
movzbl %cl, %ebx
andl $0x1, %ebx
leaq 0x21(,%rbx,2), %rdx
movq 0x1622a(%rip), %r14     # 0x40fc0
movq %r14, %rdi
callq 0x5420
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x16204(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq 0x161f0(%rip), %rdi     # 0x40fc0
leaq 0xa66d(%rip), %rsi      # 0x35444
movl $0x1a, %edx
callq 0x5420
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq 0x161ce(%rip), %r14     # 0x40fc0
movq %r14, %rdi
callq 0x5420
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1617e(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
leaq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x40(%rsp), %rdx
movl %ebx, %ecx
callq 0x1310c
xorl %r13d, %r13d
testl %eax, %eax
setne %r13b
leaq 0x20(%rsp), %rdi
callq 0xab8e
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x2ae94
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x53c0
movl %r13d, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2af0d
movq %rax, %r13
callq 0x5630
jmp 0x2af10
movq %rax, %rdi
callq 0x7d38
movq %rax, %r13
movq 0x48(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2af10
movq 0x58(%rsp), %rsi
jmp 0x2aef3
jmp 0x2af0d
movq %rax, %r13
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x2af10
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x2af10
jmp 0x2af0d
movq %rax, %r13
jmp 0x2af5b
jmp 0x2af08
jmp 0x2af08
movq %rax, %r13
jmp 0x2af35
movq %rax, %r13
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x2af35
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0x20(%rsp), %rdi
callq 0xab8e
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x2af5b
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x53c0
movq %r13, %rdi
callq 0x56a0