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

	std::vector < std::string > args;
	std::string queryfile="";
	std::string profilefile="";

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

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

		if (arg=="-h" || arg=="--help"){
			typeHelp();
			return 0;
		}
		else if (arg == "-q"){
			i++;
			if (i<argc){
				queryfile = argv[i];
			}
			else {
				std::cerr << std::endl << "Expecting file name after -q 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 == "-p"){
			i++;
			if (i<argc){
				profilefile = argv[i];
			}
			else {
				std::cerr << std::endl << "Expecting file name after -p 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;
		typeHelp();
		return 1;
	}

	if (queryfile==""){
		std::cerr << std::endl << "Query kmer file is required" << std::endl;
		typeHelp();
		return 1;
	}

	if (typeKmerFile(queryfile, profilefile, args)){return 1;}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x1ab40
leaq -0x49(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x6910
movq -0xe0(%rbp), %rdx
leaq 0x45e9(%rip), %rsi      # 0x5a2b2
leaq -0x48(%rbp), %rdi
callq 0xab20
jmp 0x55cd4
leaq -0x49(%rbp), %rdi
callq 0x65a0
leaq -0x81(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x6910
movq -0xe8(%rbp), %rdx
leaq 0x45b4(%rip), %rsi      # 0x5a2b2
leaq -0x80(%rbp), %rdi
callq 0xab20
jmp 0x55d09
leaq -0x81(%rbp), %rdi
callq 0x65a0
movl $0x2, -0x88(%rbp)
movl -0x88(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x562be
movq -0x10(%rbp), %rax
movslq -0x88(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xf8(%rbp)
leaq -0xa9(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x6910
movq -0xf8(%rbp), %rsi
movq -0xf0(%rbp), %rdx
leaq -0xa8(%rbp), %rdi
callq 0xab20
jmp 0x55d73
leaq -0xa9(%rbp), %rdi
callq 0x65a0
leaq 0x5261(%rip), %rsi      # 0x5afe7
leaq -0xa8(%rbp), %rdi
callq 0x2dce0
movb %al, -0xf9(%rbp)
jmp 0x55d9a
movb -0xf9(%rbp), %al
testb $0x1, %al
jne 0x55dd0
jmp 0x55da6
leaq 0x523d(%rip), %rsi      # 0x5afea
leaq -0xa8(%rbp), %rdi
callq 0x2dce0
movb %al, -0xfa(%rbp)
jmp 0x55dc1
movb -0xfa(%rbp), %al
testb $0x1, %al
jne 0x55dd0
jmp 0x55e52
callq 0x55b60
jmp 0x55dd7
movl $0x0, -0x4(%rbp)
movl $0x1, -0xb0(%rbp)
jmp 0x5627b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x65a0
jmp 0x56454
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x81(%rbp), %rdi
callq 0x65a0
jmp 0x5644b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa9(%rbp), %rdi
callq 0x65a0
jmp 0x56442
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x562ad
leaq 0x588b(%rip), %rsi      # 0x5b6e4
leaq -0xa8(%rbp), %rdi
callq 0x2dce0
movb %al, -0xfb(%rbp)
jmp 0x55e6d
movb -0xfb(%rbp), %al
testb $0x1, %al
jne 0x55e7c
jmp 0x55f36
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
movl -0x88(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x55eb2
movq -0x10(%rbp), %rax
movslq -0x88(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x48(%rbp), %rdi
callq 0x6710
jmp 0x55eb0
jmp 0x55f31
movq 0x23137(%rip), %rdi     # 0x78ff0
movq 0x230d0(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x108(%rbp)
jmp 0x55ece
movq -0x108(%rbp), %rdi
leaq 0x580b(%rip), %rsi      # 0x5b6e7
callq 0x6520
movq %rax, -0x110(%rbp)
jmp 0x55eea
movq -0x110(%rbp), %rdi
movq 0x23098(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x118(%rbp)
jmp 0x55f06
movq -0x118(%rbp), %rdi
movq 0x2307c(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x55f1b
movl $0x1, -0x4(%rbp)
movl $0x1, -0xb0(%rbp)
jmp 0x5627b
jmp 0x5626f
leaq 0x512a(%rip), %rsi      # 0x5b067
leaq -0xa8(%rbp), %rdi
callq 0x2dce0
movb %al, -0x119(%rbp)
jmp 0x55f51
movb -0x119(%rbp), %al
testb $0x1, %al
jne 0x55f60
jmp 0x560ad
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
movl -0x88(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x56029
movq -0x10(%rbp), %rax
movslq -0x88(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x130(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x6910
movq -0x130(%rbp), %rsi
movq -0x128(%rbp), %rdx
leaq -0xd0(%rbp), %rdi
callq 0xab20
jmp 0x55fc3
leaq -0xd0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0xa6a0
jmp 0x55fd5
leaq -0xd0(%rbp), %rdi
callq 0x6a08
leaq -0xd1(%rbp), %rdi
callq 0x65a0
jmp 0x560a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x56018
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x6a08
leaq -0xd1(%rbp), %rdi
callq 0x65a0
jmp 0x562ad
movq 0x22fc0(%rip), %rdi     # 0x78ff0
movq 0x22f59(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x138(%rbp)
jmp 0x56045
movq -0x138(%rbp), %rdi
leaq 0x5017(%rip), %rsi      # 0x5b06a
callq 0x6520
movq %rax, -0x140(%rbp)
jmp 0x56061
movq -0x140(%rbp), %rdi
movq 0x22f21(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x148(%rbp)
jmp 0x5607d
movq -0x148(%rbp), %rdi
movq 0x22f05(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x56092
movl $0x1, -0x4(%rbp)
movl $0x1, -0xb0(%rbp)
jmp 0x5627b
jmp 0x5626d
leaq 0x525f(%rip), %rsi      # 0x5b313
leaq -0xa8(%rbp), %rdi
callq 0x2dce0
movb %al, -0x149(%rbp)
jmp 0x560c8
movb -0x149(%rbp), %al
testb $0x1, %al
jne 0x560d7
jmp 0x56191
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
movl -0x88(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x5610d
movq -0x10(%rbp), %rax
movslq -0x88(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x80(%rbp), %rdi
callq 0x6710
jmp 0x5610b
jmp 0x5618c
movq 0x22edc(%rip), %rdi     # 0x78ff0
movq 0x22e75(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x158(%rbp)
jmp 0x56129
movq -0x158(%rbp), %rdi
leaq 0x68c7(%rip), %rsi      # 0x5c9fe
callq 0x6520
movq %rax, -0x160(%rbp)
jmp 0x56145
movq -0x160(%rbp), %rdi
movq 0x22e3d(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x168(%rbp)
jmp 0x56161
movq -0x168(%rbp), %rdi
movq 0x22e21(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x56176
movl $0x1, -0x4(%rbp)
movl $0x1, -0xb0(%rbp)
jmp 0x5627b
jmp 0x5626b
xorl %eax, %eax
movl %eax, %esi
leaq -0xa8(%rbp), %rdi
callq 0x69e0
movq %rax, -0x170(%rbp)
jmp 0x561aa
movq -0x170(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x56255
movq 0x22e2c(%rip), %rdi     # 0x78ff0
movq 0x22dc5(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x178(%rbp)
jmp 0x561d9
movq -0x178(%rbp), %rdi
leaq 0x4ea5(%rip), %rsi      # 0x5b08c
callq 0x6520
movq %rax, -0x180(%rbp)
jmp 0x561f5
movq -0x180(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x64d0
movq %rax, -0x188(%rbp)
jmp 0x56211
movq -0x188(%rbp), %rdi
movq 0x22d71(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x190(%rbp)
jmp 0x5622d
movq -0x190(%rbp), %rdi
movq 0x22d55(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x56242
movl $0x1, -0x4(%rbp)
movl $0x1, -0xb0(%rbp)
jmp 0x5627b
leaq -0x28(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0xabd0
jmp 0x56267
jmp 0x56269
jmp 0x5626b
jmp 0x5626d
jmp 0x5626f
jmp 0x56271
movl $0x0, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x6a08
movl -0xb0(%rbp), %eax
testl %eax, %eax
jne 0x5641b
jmp 0x56297
jmp 0x56299
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x55d1f
leaq -0xa8(%rbp), %rdi
callq 0x6a08
jmp 0x56442
leaq -0x28(%rbp), %rdi
callq 0xb670
cmpq $0x1, %rax
jae 0x56348
movq 0x22d1c(%rip), %rdi     # 0x78ff0
movq 0x22cb5(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x198(%rbp)
jmp 0x562e9
movq -0x198(%rbp), %rdi
leaq 0x4da8(%rip), %rsi      # 0x5b09f
callq 0x6520
movq %rax, -0x1a0(%rbp)
jmp 0x56305
movq -0x1a0(%rbp), %rdi
movq 0x22c7d(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x5631a
callq 0x55b60
jmp 0x56321
movl $0x1, -0x4(%rbp)
movl $0x1, -0xb0(%rbp)
jmp 0x5641b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x56442
leaq 0x3f63(%rip), %rsi      # 0x5a2b2
leaq -0x48(%rbp), %rdi
callq 0x2dce0
movb %al, -0x1a1(%rbp)
jmp 0x56360
movb -0x1a1(%rbp), %al
testb $0x1, %al
jne 0x5636c
jmp 0x563d3
movq 0x22c7d(%rip), %rdi     # 0x78ff0
movq 0x22c16(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x1b0(%rbp)
jmp 0x56388
movq -0x1b0(%rbp), %rdi
leaq 0x5373(%rip), %rsi      # 0x5b709
callq 0x6520
movq %rax, -0x1b8(%rbp)
jmp 0x563a4
movq -0x1b8(%rbp), %rdi
movq 0x22bde(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x563b9
callq 0x55b60
jmp 0x563c0
movl $0x1, -0x4(%rbp)
movl $0x1, -0xb0(%rbp)
jmp 0x5641b
leaq -0x48(%rbp), %rdi
leaq -0x80(%rbp), %rsi
leaq -0x28(%rbp), %rdx
callq 0x3de30
movl %eax, -0x1bc(%rbp)
jmp 0x563ec
movl -0x1bc(%rbp), %eax
cmpl $0x0, %eax
je 0x5640a
movl $0x1, -0x4(%rbp)
movl $0x1, -0xb0(%rbp)
jmp 0x5641b
movl $0x0, -0x4(%rbp)
movl $0x1, -0xb0(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x6a08
leaq -0x48(%rbp), %rdi
callq 0x6a08
leaq -0x28(%rbp), %rdi
callq 0xfe90
movl -0x4(%rbp), %eax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
leaq -0x80(%rbp), %rdi
callq 0x6a08
leaq -0x48(%rbp), %rdi
callq 0x6a08
leaq -0x28(%rbp), %rdi
callq 0xfe90
movq -0x58(%rbp), %rdi
callq 0x6900
nopw %cs:(%rax,%rax)