// File: /workspace/github_cpp_makefile_star2_O3/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, %rbx
movl %edi, %ebp
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xe095(%rip), %rsi      # 0x3531a
leaq 0xe09c(%rip), %rdx      # 0x35328
leaq 0x50(%rsp), %rdi
callq 0x85fc
movl $0x3f666666, 0xc(%rsp)  # imm = 0x3F666666
xorl %eax, %eax
movb %al, 0x9(%rsp)
movb %al, 0xb(%rsp)
movq %rax, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq %rax, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
cmpl $0x3, %ebp
jl 0x27942
movl $0x2, %r12d
leaq 0x70(%rsp), %r14
leaq 0x10(%rsp), %r15
movslq %r12d, %rax
movq (%rbx,%rax,8), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x182e0
movq %r14, %rdi
leaq 0xdd25(%rip), %rsi      # 0x3501f
callq 0x50f0
testl %eax, %eax
je 0x2746a
movq %r14, %rdi
leaq 0xdd11(%rip), %rsi      # 0x35022
callq 0x50f0
testl %eax, %eax
je 0x2746a
movq %r14, %rdi
leaq 0xe001(%rip), %rsi      # 0x35329
callq 0x50f0
testl %eax, %eax
je 0x2747a
movq %r14, %rdi
leaq 0xe00c(%rip), %rsi      # 0x3534b
callq 0x50f0
testl %eax, %eax
je 0x274ac
movq %r14, %rdi
leaq 0xdd49(%rip), %rsi      # 0x3509f
callq 0x50f0
testl %eax, %eax
je 0x2760f
movq %r14, %rdi
leaq 0xdcbc(%rip), %rsi      # 0x35029
callq 0x50f0
testl %eax, %eax
je 0x276e1
movq %r14, %rdi
leaq 0xe023(%rip), %rsi      # 0x353a7
callq 0x50f0
testl %eax, %eax
je 0x2778b
movq %r14, %rdi
leaq 0xe031(%rip), %rsi      # 0x353cc
callq 0x50f0
testl %eax, %eax
je 0x277db
movq 0x70(%rsp), %rax
cmpb $0x2d, (%rax)
jne 0x277e2
movq 0x19c33(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x19c15(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x12, %edx
movq %rax, %rdi
leaq 0xdcca(%rip), %rsi      # 0x350c4
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 0x27892
xorl %r15d, %r15d
callq 0x26f7e
xorl %r13d, %r13d
jmp 0x2789b
incl %r12d
cmpl %ebp, %r12d
jge 0x2756f
movslq %r12d, %rax
movq (%rbx,%rax,8), %rsi
movq %r15, %rdi
leaq 0xa(%rsp), %rdx
callq 0x182e0
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0x5470
jmp 0x277b7
incl %r12d
cmpl %ebp, %r12d
jge 0x27641
movslq %r12d, %rax
movq (%rbx,%rax,8), %rdi
callq 0x25d65
movss %xmm0, 0xc(%rsp)
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
ja 0x274e2
movb $0x1, %r15b
ucomiss 0xbb28(%rip), %xmm0     # 0x33004
jbe 0x2789b
movq 0x19b07(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x19ae9(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x2a, %edx
movq %rax, %rdi
leaq 0xde56(%rip), %rsi      # 0x3537c
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 0x276c9
movq 0x19a7a(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x19a5c(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x1e, %edx
movq %rax, %rdi
leaq 0xdd79(%rip), %rsi      # 0x3532c
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 0x27892
incl %r12d
cmpl %ebp, %r12d
jge 0x276eb
movslq %r12d, %rax
movq (%rbx,%rax,8), %rsi
movq %r15, %rdi
leaq 0xa(%rsp), %rdx
callq 0x182e0
movq %r15, %rdi
leaq 0x30(%rsp), %rsi
callq 0x8148
jmp 0x277b7
movq 0x199a8(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1998a(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x2d, %edx
movq %rax, %rdi
leaq 0xdcc9(%rip), %rsi      # 0x3534e
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 0x27892
movb $0x1, 0xb(%rsp)
jmp 0x277d3
movq 0x198fe(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x198e0(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0xd973(%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
jmp 0x27892
incl %r12d
cmpl %ebp, %r12d
jge 0x277f7
movslq %r12d, %rax
movq (%rbx,%rax,8), %rsi
movq %r15, %rdi
leaq 0xa(%rsp), %rdx
callq 0x182e0
movq %r15, %rdi
leaq 0x90(%rsp), %rsi
callq 0x8148
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x277d3
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53c0
movb $0x1, %r15b
jmp 0x2789b
movb $0x1, 0x9(%rsp)
jmp 0x277d3
movb $0x1, %r15b
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0x8528
jmp 0x2789b
movq 0x197f2(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x197d4(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0xdb6f(%rip), %rsi      # 0x353aa
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
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x278bd
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x53c0
testb %r15b, %r15b
je 0x27bc3
incl %r12d
cmpl %ebp, %r12d
leaq 0x10(%rsp), %r15
jl 0x272de
jmp 0x2792a
movq %rax, %r13
cmpl $0x1, %edx
jne 0x27c59
movq %r13, %rdi
callq 0x5160
movq 0x196fc(%rip), %rdi     # 0x40ff0
callq 0x5190
movq %rax, %r13
movl $0x2d, %edx
movq %rax, %rdi
leaq 0xda43(%rip), %rsi      # 0x3534e
callq 0x5420
movq %r13, %rdi
callq 0x5190
movq %rax, %rdi
callq 0x5190
callq 0x5630
jmp 0x27892
testb $0x1, 0x9(%rsp)
je 0x27942
leaq 0xda97(%rip), %rsi      # 0x353cf
leaq 0x50(%rsp), %rdi
callq 0x5710
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
je 0x279b7
callq 0x26352
movq 0x19666(%rip), %rbx     # 0x40fc0
leaq 0xda78(%rip), %rsi      # 0x353d9
movl $0x26, %edx
movq %rbx, %rdi
callq 0x5420
movq 0x30(%rsp), %r12
movq 0x38(%rsp), %rax
movq %rax, %rsi
subq %r12, %rsi
sarq $0x5, %rsi
movslq 0x19b67(%rip), %rcx     # 0x414f0
cmpq %rcx, %rsi
jbe 0x27a34
movq 0x19627(%rip), %rdi     # 0x40fc0
callq 0x5240
leaq 0xd14c(%rip), %rsi      # 0x34af1
movl $0x6, %edx
movq %rax, %rdi
callq 0x5420
jmp 0x27a73
movq 0x19632(%rip), %rdi     # 0x40ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x19617(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
leaq 0xd6e7(%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 0x26f7e
jmp 0x27bc3
cmpq %rax, %r12
je 0x27a73
movq 0x19580(%rip), %r14     # 0x40fc0
leaq 0xc941(%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 0x38(%rsp), %r12
jne 0x27a47
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1952f(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq 0x1951b(%rip), %rdi     # 0x40fc0
leaq 0xd954(%rip), %rsi      # 0x35400
movl $0x24, %edx
callq 0x5420
movss 0xc(%rsp), %xmm0
mulss 0xbbb8(%rip), %xmm0     # 0x3367c
cvtss2sd %xmm0, %xmm0
movq 0x194f1(%rip), %rdi     # 0x40fc0
callq 0x5610
movq %rax, %rbx
leaq 0xd947(%rip), %rsi      # 0x35425
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 0x194a7(%rip), %rdi     # 0x40fc0
leaq 0xd924(%rip), %rsi      # 0x35444
movl $0x1a, %edx
callq 0x5420
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x19485(%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 0xc(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0x9(%rsp), %rcx
leaq 0xb(%rsp), %r8
leaq 0x90(%rsp), %r9
callq 0xcea4
xorl %r13d, %r13d
testl %eax, %eax
setne %r13b
leaq 0x90(%rsp), %rdi
callq 0xab8e
leaq 0x30(%rsp), %rdi
callq 0xab8e
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x27bf6
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 0x27c56
movq %rax, %r13
callq 0x5630
jmp 0x27c59
movq %rax, %rdi
callq 0x7d38
jmp 0x27c23
jmp 0x27c56
movq %rax, %r13
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x27c59
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x27c59
jmp 0x27c56
jmp 0x27c56
movq %rax, %r13
jmp 0x27cae
jmp 0x27c51
jmp 0x27c51
movq %rax, %r13
jmp 0x27c7b
movq %rax, %r13
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x27c7b
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0x90(%rsp), %rdi
callq 0xab8e
leaq 0x30(%rsp), %rdi
callq 0xab8e
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x27cae
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x53c0
movq %r13, %rdi
callq 0x56a0