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

	std::string outprefix="reference_free";
	float minproportion=0.9;
	bool variantonly=false;
	bool printkmers=false;
	std::vector < std::string > args;
	std::vector < std::string > sample;

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

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

		if (arg=="-h" || arg=="--help"){
			alignHelp();
			return 0;
		}
		else if (arg == "-o"){
			i++;
			if (i<argc){
				outprefix = std::string(argv[i]);
			}
			else {
				std::cerr << std::endl << "Expecting string after -o flag" << std::endl << std::endl;
				return 1;
			}
		}
		else if (arg == "-p"){
			i++;
			if (i<argc){
				try {
					minproportion = getfloat(argv[i]);
				}
				catch (const std::invalid_argument& e) {
					std::cerr << std::endl << "Expecting float between 0 and 1 after -p flag" << std::endl << std::endl;
					return 1;
				}
			}
			else {
				std::cerr << std::endl << "Expecting float between 0 and 1 after -p flag" << std::endl << std::endl;
				return 1;
			}
			if (minproportion < 0 || minproportion > 1){
				std::cerr << std::endl << "Minimum proportion must be between 0 and 1" << 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 == "-k"){
			printkmers = true;
		}
		else if (arg == "-s"){
			i++;
			if (i<argc){
				fileToVector(argv[i], sample);
			}
			else {
				std::cerr << std::endl << "Expecting file name after -s flag" << std::endl << std::endl;
				return 1;
			}
		}
		else if (arg == "-v"){
			variantonly = true;
		}
		else if (arg[0]=='-'){
			std::cerr << std::endl << "Unrecognised flag " << arg << std::endl << std::endl;
				return 1;
		}
		else {
			args.push_back(arg);
		}
	}

	if (variantonly){
		outprefix+="_variants";
	}

	//outprefix+=".aln";
	
	if (args.size()<1){
		std::cerr << std::endl << "Too few arguments" << std::endl;
		alignHelp();
		return 1;
	}

	skaVersion();

	std::cout << "Creating reference free alignment 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;
	std::cout << "Variable sites present in more than " << minproportion*100 << "% of isolates will be included" << std::endl;
	std::cout << "Output will be written to " << outprefix << std::endl << std::endl;

	if (alignKmers(minproportion, outprefix, args, variantonly, printkmers, sample)){return 1;}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, 0x8(%rsp)
movl %edi, %ebp
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xdc97(%rip), %rsi      # 0x3532a
leaq 0xdc9e(%rip), %rdx      # 0x35338
leaq 0x50(%rsp), %rdi
callq 0x862a
movl $0x3f666666, 0x4(%rsp)  # imm = 0x3F666666
xorl %eax, %eax
movb %al, 0x1(%rsp)
movb %al, 0x3(%rsp)
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq %rax, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
cmpl $0x3, %ebp
setge %r12b
jl 0x27d4f
movl $0x2, %r15d
leaq 0x70(%rsp), %r14
leaq 0x30(%rsp), %rbx
movslq %r15d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x184a2
movq %r14, %rdi
leaq 0xd91e(%rip), %rsi      # 0x3502f
callq 0x50f0
testl %eax, %eax
je 0x27881
movq %r14, %rdi
leaq 0xd90a(%rip), %rsi      # 0x35032
callq 0x50f0
testl %eax, %eax
je 0x27881
movq %r14, %rdi
leaq 0xdbfa(%rip), %rsi      # 0x35339
callq 0x50f0
testl %eax, %eax
je 0x27890
movq %r14, %rdi
leaq 0xdc05(%rip), %rsi      # 0x3535b
callq 0x50f0
testl %eax, %eax
je 0x278c7
movq %r14, %rdi
leaq 0xd942(%rip), %rsi      # 0x350af
callq 0x50f0
testl %eax, %eax
je 0x27a2e
movq %r14, %rdi
leaq 0xd8b5(%rip), %rsi      # 0x35039
callq 0x50f0
testl %eax, %eax
je 0x27b05
movq %r14, %rdi
leaq 0xdc1c(%rip), %rsi      # 0x353b7
callq 0x50f0
testl %eax, %eax
je 0x27baf
movq %r14, %rdi
leaq 0xdc2a(%rip), %rsi      # 0x353dc
callq 0x50f0
testl %eax, %eax
je 0x27c03
movq 0x70(%rsp), %rax
cmpb $0x2d, (%rax)
jne 0x27c0a
movq 0x1981c(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x197fe(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x12, %edx
movq %rax, %rdi
leaq 0xd8c3(%rip), %rsi      # 0x350d4
callq 0x5420
movq 0x70(%rsp), %rsi
movq 0x78(%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 0x27cb9
xorl %ebx, %ebx
callq 0x2738a
xorl %r13d, %r13d
jmp 0x27cc1
incl %r15d
cmpl %ebp, %r15d
jge 0x2798e
movslq %r15d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %rbx, %rdi
leaq 0x2(%rsp), %rdx
callq 0x184a2
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x5470
jmp 0x27be0
incl %r15d
cmpl %ebp, %r15d
jge 0x27a65
movslq %r15d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x26159
movss %xmm0, 0x4(%rsp)
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
ja 0x27901
movb $0x1, %bl
ucomiss 0xb709(%rip), %xmm0     # 0x33004
jbe 0x27cc1
movq 0x196e8(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x196ca(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x2a, %edx
movq %rax, %rdi
leaq 0xda47(%rip), %rsi      # 0x3538c
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 0x27aed
movq 0x1965b(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1963d(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x1e, %edx
movq %rax, %rdi
leaq 0xd96a(%rip), %rsi      # 0x3533c
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 0x27cb9
incl %r15d
cmpl %ebp, %r15d
jge 0x27b0f
movslq %r15d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %rbx, %rdi
leaq 0x2(%rsp), %rdx
callq 0x184a2
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
callq 0x817c
jmp 0x27be0
movq 0x19584(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x19566(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x2d, %edx
movq %rax, %rdi
leaq 0xd8b5(%rip), %rsi      # 0x3535e
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 0x27cb9
movb $0x1, 0x3(%rsp)
jmp 0x27bfc
movq 0x194da(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x194bc(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0xd55f(%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
jmp 0x27cb9
incl %r15d
cmpl %ebp, %r15d
jge 0x27c1e
movslq %r15d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %rbx, %rdi
leaq 0x2(%rsp), %rdx
callq 0x184a2
movq %rbx, %rdi
leaq 0x90(%rsp), %rsi
callq 0x817c
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x27bfc
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x53c0
movb $0x1, %bl
jmp 0x27cc1
movb $0x1, 0x1(%rsp)
jmp 0x27bfc
movb $0x1, %bl
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x855c
jmp 0x27cc1
movq 0x193cb(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x193ad(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0xd758(%rip), %rsi      # 0x353ba
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
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x27ce3
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x53c0
testb %bl, %bl
je 0x27d4f
incl %r15d
cmpl %ebp, %r15d
setl %r12b
leaq 0x30(%rsp), %rbx
jl 0x276f0
jmp 0x27d4f
movq %rax, %r13
cmpl $0x1, %edx
jne 0x28087
movq %r13, %rdi
callq 0x5160
movq 0x192d7(%rip), %rdi     # 0x40ff0
callq 0x5190
movq %rax, %r13
movl $0x2d, %edx
movq %rax, %rdi
leaq 0xd62e(%rip), %rsi      # 0x3535e
callq 0x5420
movq %r13, %rdi
callq 0x5190
movq %rax, %rdi
callq 0x5190
callq 0x5630
jmp 0x27cb9
testb $0x1, %r12b
jne 0x27ff1
cmpb $0x1, 0x1(%rsp)
jne 0x27d71
leaq 0xd678(%rip), %rsi      # 0x353df
leaq 0x50(%rsp), %rdi
callq 0x5710
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
je 0x27de3
callq 0x26746
movq 0x19237(%rip), %rbx     # 0x40fc0
leaq 0xd659(%rip), %rsi      # 0x353e9
movl $0x26, %edx
movq %rbx, %rdi
callq 0x5420
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %rsi
subq %r12, %rsi
sarq $0x5, %rsi
movslq 0x1973b(%rip), %rax     # 0x414f0
cmpq %rax, %rsi
jbe 0x27e60
movq 0x191fb(%rip), %rdi     # 0x40fc0
callq 0x5240
leaq 0xcd30(%rip), %rsi      # 0x34b01
movl $0x6, %edx
movq %rax, %rdi
callq 0x5420
jmp 0x27ea1
movq 0x19206(%rip), %rdi     # 0x40ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x191eb(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
leaq 0xd2cb(%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 0x2738a
jmp 0x27ff1
cmpq 0x18(%rsp), %r12
je 0x27ea1
movq 0x19152(%rip), %r14     # 0x40fc0
leaq 0xc523(%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 0x18(%rsp), %r12
jne 0x27e75
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x19101(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq 0x190ed(%rip), %rdi     # 0x40fc0
leaq 0xd536(%rip), %rsi      # 0x35410
movl $0x24, %edx
callq 0x5420
movss 0x4(%rsp), %xmm0
mulss 0xb78a(%rip), %xmm0     # 0x3367c
cvtss2sd %xmm0, %xmm0
movq 0x190c3(%rip), %rdi     # 0x40fc0
callq 0x5610
movq %rax, %rbx
leaq 0xd529(%rip), %rsi      # 0x35435
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
movq 0x19079(%rip), %rdi     # 0x40fc0
leaq 0xd506(%rip), %rsi      # 0x35454
movl $0x1a, %edx
callq 0x5420
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x19057(%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
leaq 0x4(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x1(%rsp), %rcx
leaq 0x3(%rsp), %r8
leaq 0x90(%rsp), %r9
callq 0xcf50
xorl %r13d, %r13d
testl %eax, %eax
setne %r13b
leaq 0x90(%rsp), %rdi
callq 0xabee
leaq 0x10(%rsp), %rdi
callq 0xabee
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x28024
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x53c0
movl %r13d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x28084
movq %rax, %r13
callq 0x5630
jmp 0x28087
movq %rax, %rdi
callq 0x7d6a
jmp 0x28051
jmp 0x28084
movq %rax, %r13
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x28087
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x28087
jmp 0x28084
jmp 0x28084
movq %rax, %r13
jmp 0x280dc
jmp 0x2807f
jmp 0x2807f
movq %rax, %r13
jmp 0x280a9
movq %rax, %r13
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x280a9
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0x90(%rsp), %rdi
callq 0xabee
leaq 0x10(%rsp), %rdi
callq 0xabee
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x280dc
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x53c0
movq %r13, %rdi
callq 0x56a0