// File: /workspace/github_cpp_makefile_star2_O1/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, 0x18(%rsp)
movl %edi, %ebx
leaq 0x98(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xb3ad(%rip), %rsi      # 0x35d59
leaq 0xb3af(%rip), %rdx      # 0x35d62
leaq 0x88(%rsp), %rdi
callq 0x862a
movq $0xf, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
cmpl $0x3, %ebx
setge %r14b
jl 0x2b08a
movl %ebx, 0xc(%rsp)
leaq 0x58(%rsp), %rbp
movl $0x2, %r15d
movl $0x0, 0x14(%rsp)
leaq 0x68(%rsp), %rbx
leaq 0x48(%rsp), %rdx
movslq %r15d, %rax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %rbx, %rdi
callq 0x184a2
movq %rbx, %rdi
leaq 0xa609(%rip), %rsi      # 0x3502f
callq 0x50f0
testl %eax, %eax
je 0x2ab6b
movq %rbx, %rdi
leaq 0xa5f5(%rip), %rsi      # 0x35032
callq 0x50f0
testl %eax, %eax
je 0x2ab6b
movq %rbx, %rdi
leaq 0xaf6b(%rip), %rsi      # 0x359bf
callq 0x50f0
movb $0x1, %r12b
testl %eax, %eax
je 0x2abbc
movq %rbx, %rdi
leaq 0xa5cb(%rip), %rsi      # 0x35039
callq 0x50f0
testl %eax, %eax
je 0x2abc4
movq %rbx, %rdi
leaq 0xa8b4(%rip), %rsi      # 0x35339
callq 0x50f0
testl %eax, %eax
je 0x2ad08
movq %rbx, %rdi
leaq 0xa613(%rip), %rsi      # 0x350af
callq 0x50f0
testl %eax, %eax
je 0x2ae13
movq 0x68(%rsp), %rax
cmpb $0x2d, (%rax)
jne 0x2ae67
movq 0x16532(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x16514(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x12, %edx
movq %rax, %rdi
leaq 0xa5d9(%rip), %rsi      # 0x350d4
callq 0x5420
movq 0x68(%rsp), %rsi
movq 0x70(%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 0x2afb6
xorl %r12d, %r12d
callq 0x2a716
xorl %r13d, %r13d
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x2ab92
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x53c0
testb %r12b, %r12b
leaq 0x68(%rsp), %rbx
leaq 0x48(%rsp), %rdx
je 0x2b08e
incl %r15d
cmpl 0xc(%rsp), %r15d
setl %r14b
jl 0x2aa08
jmp 0x2b08e
movb $0x1, %al
movl %eax, 0x14(%rsp)
jmp 0x2ab76
incl %r15d
cmpl 0xc(%rsp), %r15d
jge 0x2ad73
movslq %r15d, %rax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x260f0
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 0x2ac31
movslq 0x168c4(%rip), %rcx     # 0x414e0
cmpq %rcx, %rax
jl 0x2ac31
movslq 0x168bc(%rip), %rcx     # 0x414e4
cmpq %rcx, %rax
jle 0x2ab76
movq 0x163b8(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1639a(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x2d, %edx
movq %rax, %rdi
leaq 0xa3f0(%rip), %rsi      # 0x35065
callq 0x5420
movl 0x16860(%rip), %esi     # 0x414e0
movq %r13, %rdi
callq 0x5690
movq %rax, %r13
movl $0x5, %edx
movq %rax, %rdi
leaq 0x9927(%rip), %rsi      # 0x345c1
callq 0x5420
movl 0x1683f(%rip), %esi     # 0x414e4
movq %r13, %rdi
callq 0x5690
movq %rax, %r13
movl $0x1b, %edx
movq %rax, %rdi
leaq 0xa3d4(%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 0x2adfb
incl %r15d
cmpl 0xc(%rsp), %r15d
jge 0x2ae7b
movslq %r15d, %rax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x13(%rsp), %rdx
callq 0x184a2
movq %rbx, %rdi
leaq 0xb01d(%rip), %rsi      # 0x35d5e
callq 0x5710
movq %rbp, %rbx
movq %rbp, 0x48(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2afc4
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0x2afca
movq 0x16276(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x16258(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x28, %edx
movq %rax, %rdi
leaq 0xa285(%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 0x2afb6
incl %r15d
cmpl 0xc(%rsp), %r15d
jge 0x2af1b
movslq %r15d, %rax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
leaq 0xa8(%rsp), %rdx
callq 0x184a2
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
callq 0x817c
movq 0x48(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2ab76
movq 0x58(%rsp), %rsi
jmp 0x2b02c
leaq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x855c
jmp 0x2ab76
movq 0x1616e(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x16150(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0xa6c5(%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 0x2afb6
movq 0x160ce(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x160b0(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0xa153(%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 %r12d, %r12d
jmp 0x2ab76
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
movq %rdx, 0x50(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x88(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x5470
movq 0x48(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2b00b
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x2ab76
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x2ab76
movq %rax, %r13
cmpl $0x1, %edx
jne 0x2b3d8
movq %r13, %rdi
callq 0x5160
movq 0x15f9c(%rip), %rdi     # 0x40ff0
callq 0x5190
movq %rax, %r13
movl $0x28, %edx
movq %rax, %rdi
leaq 0x9fd1(%rip), %rsi      # 0x3503c
callq 0x5420
movq %r13, %rdi
callq 0x5190
movq %rax, %rdi
callq 0x5190
callq 0x5630
jmp 0x2afb6
xorl %ebp, %ebp
jmp 0x2b092
movl 0x14(%rsp), %ebp
testb $0x1, %r14b
jne 0x2b32d
movq 0x28(%rsp), %rax
cmpq 0x20(%rsp), %rax
je 0x2b137
callq 0x26746
movq 0x15f08(%rip), %rdi     # 0x40fc0
leaq 0xa03a(%rip), %rsi      # 0x350f9
movl $0xf, %edx
callq 0x5420
movq 0x40(%rsp), %rsi
movq 0x15eeb(%rip), %rbx     # 0x40fc0
movq %rbx, %rdi
callq 0x5390
leaq 0x86f1(%rip), %rsi      # 0x337d5
movl $0x9, %edx
movq %rax, %rdi
callq 0x5420
movq 0x20(%rsp), %r12
movq 0x28(%rsp), %rsi
subq %r12, %rsi
sarq $0x5, %rsi
movslq 0x163e7(%rip), %rax     # 0x414f0
cmpq %rax, %rsi
jbe 0x2b1b4
movq 0x15ea7(%rip), %rdi     # 0x40fc0
callq 0x5240
leaq 0x99dc(%rip), %rsi      # 0x34b01
movl $0x6, %edx
movq %rax, %rdi
callq 0x5420
jmp 0x2b1f5
movq 0x15eb2(%rip), %rdi     # 0x40ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x15e97(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
leaq 0x9f77(%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
movl $0x1, %r13d
callq 0x2a716
jmp 0x2b32d
cmpq 0x28(%rsp), %r12
je 0x2b1f5
movq 0x15dfe(%rip), %r14     # 0x40fc0
leaq 0x91cf(%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 0x2b1c9
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x15dad(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
leaq 0xab3c(%rip), %rax      # 0x35d63
leaq 0xab59(%rip), %rsi      # 0x35d87
testb $0x1, %bpl
cmovneq %rax, %rsi
movzbl %bpl, %ebx
andl $0x1, %ebx
leaq 0x21(,%rbx,2), %rdx
movq 0x15d74(%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 0x15d4e(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq 0x15d3a(%rip), %rdi     # 0x40fc0
leaq 0xa1c7(%rip), %rsi      # 0x35454
movl $0x1a, %edx
callq 0x5420
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
movq 0x15d12(%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 0x15cc2(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
leaq 0x20(%rsp), %rdi
leaq 0x88(%rsp), %rsi
leaq 0x40(%rsp), %rdx
movl %ebx, %ecx
callq 0x13278
xorl %r13d, %r13d
testl %eax, %eax
setne %r13b
leaq 0x20(%rsp), %rdi
callq 0xabee
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x2b35c
movq 0x98(%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 0x2b3d5
movq %rax, %r13
callq 0x5630
jmp 0x2b3d8
movq %rax, %rdi
callq 0x7d6a
movq %rax, %r13
movq 0x48(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2b3d8
movq 0x58(%rsp), %rsi
jmp 0x2b3bb
jmp 0x2b3d5
movq %rax, %r13
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x2b3d8
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x2b3d8
jmp 0x2b3d5
movq %rax, %r13
jmp 0x2b423
jmp 0x2b3d0
jmp 0x2b3d0
movq %rax, %r13
jmp 0x2b3f4
movq %rax, %r13
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x2b3f4
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0x20(%rsp), %rdi
callq 0xabee
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x2b423
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x53c0
movq %r13, %rdi
callq 0x56a0