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

	std::string outfile="unique.skf";
	std::vector < std::string > ingroup;
	float minproportion=0.9;
	std::vector < std::string > args;
	bool allowNs = false;

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

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

		if (arg=="-h" || arg=="--help"){
			uniqueHelp();
			return 0;
		}
		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 == "-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 == "-i"){
			i++;
			if (i<argc){
				fileToVector(argv[i], ingroup);
			}
			else {
				std::cerr << std::endl << "Expecting file name after -i flag" << std::endl << std::endl;
				return 1;
			}
		}
		else if (arg == "-n"){
			allowNs = true;
		}
		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 {
			args.push_back(arg);
		}
	}

	if (ingroup.size()<1){
		std::cerr << std::endl << "At least one ingroup kmer file must be specified" << std::endl;
		uniqueHelp();
		return 1;
	}

	if (args.size()<1){
		std::cerr << std::endl << "At least one kmer file must be specified" << std::endl;
		uniqueHelp();
		return 1;
	}

	skaVersion();

	std::cout << "Finding unique kmers in at least " << minproportion*100 << "% of ";
	for (std::vector < std::string >::iterator it = ingroup.begin(); it != ingroup.end(); ++it){
		std::cout << *it << " ";
	}

	std::cout << std::endl;

	std::cout << "Output will be written to " << outfile << std::endl;

	std::cout << std::endl;

	if (uniqueKmers(ingroup, args, minproportion, outfile, allowNs)){return 1;}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %rbp
movl %edi, (%rsp)
leaq 0x5bad(%rip), %rsi      # 0x28b7c
leaq 0x58(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x77c0
leaq 0x10(%rsp), %rax
andq $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movl $0x3f666666, 0x4(%rsp)  # imm = 0x3F666666
leaq 0x30(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
pushq $0x2
popq %r14
movl $0x0, 0xc(%rsp)
leaq 0x98(%rsp), %r12
leaq 0x78(%rsp), %r13
leaq 0xb8(%rsp), %rbx
cmpl (%rsp), %r14d
jge 0x23333
movslq %r14d, %rax
movq (%rbp,%rax,8), %rsi
movq %r12, %rdi
movq %r13, %rdx
callq 0x77c0
movq %r12, %rdi
leaq 0x3fa5(%rip), %rsi      # 0x26ff3
callq 0x132f3
testb %al, %al
jne 0x2306a
movq %r12, %rdi
leaq 0x3f95(%rip), %rsi      # 0x26ff6
callq 0x132f3
testb %al, %al
je 0x2308f
xorl %r13d, %r13d
callq 0x22ebe
xorl %r15d, %r15d
movq %r12, %rdi
callq 0x5778
incl %r14d
testb %r13b, %r13b
leaq 0x78(%rsp), %r13
jne 0x23027
jmp 0x23475
movq %r12, %rdi
leaq 0x3fda(%rip), %rsi      # 0x27073
callq 0x132f3
testb %al, %al
je 0x230dc
incl %r14d
cmpl (%rsp), %r14d
jge 0x23159
movslq %r14d, %rax
movq (%rbp,%rax,8), %rsi
movq %r13, %rdi
movq %rbx, %rdx
callq 0x77c0
movq %r13, %rdi
leaq 0x30(%rsp), %rsi
callq 0x7529
movq %r13, %rdi
callq 0x5778
movb $0x1, %r13b
jmp 0x23075
movq %r12, %rdi
leaq 0x4217(%rip), %rsi      # 0x272fd
callq 0x132f3
testb %al, %al
je 0x23189
incl %r14d
cmpl (%rsp), %r14d
jge 0x231ca
movslq %r14d, %rax
movq %rbp, 0x50(%rsp)
movq (%rbp,%rax,8), %rsi
movq %rbx, %rbp
movq %rbx, %rdi
leaq 0xb(%rsp), %rdx
callq 0x77c0
movq %r13, %rdi
movq %rbp, %rsi
leaq 0x4bf8(%rip), %rdx      # 0x27d22
callq 0xf751
leaq 0x58(%rsp), %rdi
movq %r13, %rsi
callq 0x54a0
movq %r13, %rdi
callq 0x5778
movq %rbp, %rdi
callq 0x5778
movb $0x1, %r13b
movq 0x50(%rsp), %rbp
jmp 0x23075
movq 0x12e90(%rip), %rdi     # 0x35ff0
callq 0x51c0
movq %rax, %rdi
leaq 0x3f07(%rip), %rsi      # 0x27076
callq 0x53f0
movq %rax, %rdi
callq 0x51c0
movq %rax, %rdi
callq 0x51c0
jmp 0x232e1
movq %r12, %rdi
leaq 0x43b2(%rip), %rsi      # 0x27545
callq 0x132f3
testb %al, %al
je 0x231fa
incl %r14d
cmpl (%rsp), %r14d
jge 0x2321b
movslq %r14d, %rax
movq (%rbp,%rax,8), %rsi
movq %r13, %rdi
movq %rbx, %rdx
callq 0x77c0
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
callq 0x7529
jmp 0x230cf
movq 0x12e1f(%rip), %rdi     # 0x35ff0
callq 0x51c0
movq %rax, %rdi
leaq 0x4368(%rip), %rsi      # 0x27548
callq 0x53f0
movq %rax, %rdi
callq 0x51c0
movq %rax, %rdi
callq 0x51c0
jmp 0x232e1
movq %r12, %rdi
leaq 0x5983(%rip), %rsi      # 0x28b87
callq 0x132f3
movb $0x1, %r13b
testb %al, %al
je 0x2324b
movb $0x1, %al
movl %eax, 0xc(%rsp)
jmp 0x23075
movq 0x12dce(%rip), %rdi     # 0x35ff0
callq 0x51c0
movq %rax, %rdi
leaq 0x50b5(%rip), %rsi      # 0x282e6
callq 0x53f0
movq %rax, %rdi
callq 0x51c0
movq %rax, %rdi
callq 0x51c0
jmp 0x232e1
movq %r12, %rdi
leaq 0x40ca(%rip), %rsi      # 0x2731f
callq 0x132f3
testb %al, %al
je 0x232a4
incl %r14d
cmpl (%rsp), %r14d
jge 0x232b6
movslq %r14d, %rax
movq (%rbp,%rax,8), %rdi
callq 0x1dd0d
movss %xmm0, 0x4(%rsp)
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
ja 0x2328f
ucomiss 0x1d7b(%rip), %xmm0     # 0x25004
jbe 0x23075
movq 0x12d5a(%rip), %rdi     # 0x35ff0
callq 0x51c0
leaq 0x40ae(%rip), %rsi      # 0x27350
jmp 0x232c9
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x77fc
jmp 0x23075
movq 0x12d33(%rip), %rdi     # 0x35ff0
callq 0x51c0
leaq 0x4059(%rip), %rsi      # 0x27322
movq %rax, %rdi
callq 0x53f0
movq %rax, %rdi
callq 0x51c0
movq %rax, %rdi
callq 0x51c0
xorl %r13d, %r13d
pushq $0x1
popq %r15
jmp 0x23075
movq %rax, %r15
cmpl $0x1, %edx
jne 0x234f1
movq %r15, %rdi
callq 0x5170
movq 0x12ce8(%rip), %rdi     # 0x35ff0
callq 0x51c0
movq %rax, %rdi
leaq 0x400b(%rip), %rsi      # 0x27322
callq 0x53f0
movq %rax, %rdi
callq 0x51c0
movq %rax, %rdi
callq 0x51c0
callq 0x5640
jmp 0x232e1
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
je 0x23434
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
je 0x23449
callq 0x1df8a
movq 0x12c59(%rip), %rdi     # 0x35fb8
leaq 0x587e(%rip), %rsi      # 0x28be4
callq 0x53f0
movss 0x4(%rsp), %xmm0
mulss 0x22f3(%rip), %xmm0     # 0x2566c
movq %rax, %rdi
callq 0x5300
leaq 0x587e(%rip), %rsi      # 0x28c06
movq %rax, %rdi
callq 0x53f0
movq 0x10(%rsp), %rbx
movq 0x12c1c(%rip), %r14     # 0x35fb8
leaq 0x2fba(%rip), %r15      # 0x2635d
cmpq 0x18(%rsp), %rbx
je 0x233c6
movq %r14, %rdi
movq %rbx, %rsi
callq 0x53a0
movq %rax, %rdi
movq %r15, %rsi
callq 0x53f0
addq $0x20, %rbx
jmp 0x233a3
movq 0x12beb(%rip), %rdi     # 0x35fb8
callq 0x51c0
movq 0x12bdf(%rip), %rdi     # 0x35fb8
leaq 0x4038(%rip), %rsi      # 0x27418
callq 0x53f0
leaq 0x58(%rsp), %rsi
movq %rax, %rdi
callq 0x53a0
movq %rax, %rdi
callq 0x51c0
movq 0x12bb7(%rip), %rdi     # 0x35fb8
callq 0x51c0
movzbl 0xc(%rsp), %r8d
andl $0x1, %r8d
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x4(%rsp), %rdx
leaq 0x58(%rsp), %rcx
callq 0x1b9e8
xorl %r15d, %r15d
testl %eax, %eax
setne %r15b
jmp 0x23475
movq 0x12bb5(%rip), %rdi     # 0x35ff0
callq 0x51c0
leaq 0x5743(%rip), %rsi      # 0x28b8a
jmp 0x2345c
movq 0x12ba0(%rip), %rdi     # 0x35ff0
callq 0x51c0
leaq 0x575f(%rip), %rsi      # 0x28bbb
movq %rax, %rdi
callq 0x53f0
movq %rax, %rdi
callq 0x51c0
callq 0x22ebe
pushq $0x1
popq %r15
leaq 0x30(%rsp), %rdi
callq 0x911e
leaq 0x10(%rsp), %rdi
callq 0x911e
leaq 0x58(%rsp), %rdi
callq 0x5778
movl %r15d, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x234ee
movq %rax, %r15
callq 0x5640
jmp 0x234f1
movq %rax, %rdi
callq 0x7102
jmp 0x234cf
jmp 0x234ee
movq %rax, %r15
leaq 0xb8(%rsp), %rdi
jmp 0x234d7
jmp 0x234ee
movq %rax, %r15
leaq 0x78(%rsp), %rdi
callq 0x5778
jmp 0x234f1
jmp 0x234ee
movq %rax, %r15
jmp 0x2351c
jmp 0x234e9
jmp 0x234e9
movq %rax, %r15
jmp 0x234fe
movq %rax, %r15
leaq 0x98(%rsp), %rdi
callq 0x5778
leaq 0x30(%rsp), %rdi
callq 0x911e
leaq 0x10(%rsp), %rdi
callq 0x911e
leaq 0x58(%rsp), %rdi
callq 0x5778
movq %r15, %rdi
callq 0x56c0