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

	std::vector < std::string > args;
	std::vector < std::string > sample;
	std::string outfile="merged.skf";

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

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

		if (arg=="-h" || arg=="--help"){
			mergeHelp();
			return 0;
		}
		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 == "-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[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;
		mergeHelp();
		return 1;
	}

	if (outfile==""){
		std::cerr << std::endl << "Output file name is required" << std::endl;
		mergeHelp();
		return 1;
	}

	skaVersion();

	std::cout << "Merging ";
	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 << "Output will be written to " << outfile << std::endl << std::endl;

	if (mergeKmerFiles(outfile, args, sample)){return 1;}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, 0x8(%rsp)
movl %edi, %ebp
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
xorl %eax, %eax
movq %rax, 0x40(%rsp)
movq %rax, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x8186(%rip), %rsi      # 0x368b0
leaq 0x8189(%rip), %rdx      # 0x368ba
leaq 0x50(%rsp), %rdi
callq 0x85fc
cmpl $0x3, %ebp
jl 0x2ec50
leaq 0x20(%rsp), %r15
movl $0x2, %r12d
leaq 0x70(%rsp), %r14
movslq %r12d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %r14, %rdi
leaq 0x10(%rsp), %rdx
callq 0x182e0
movq %r14, %rdi
leaq 0x68a8(%rip), %rsi      # 0x3501f
callq 0x50f0
testl %eax, %eax
je 0x2e8a2
movq %r14, %rdi
leaq 0x6894(%rip), %rsi      # 0x35022
callq 0x50f0
testl %eax, %eax
je 0x2e8a2
movq %r14, %rdi
leaq 0x6b84(%rip), %rsi      # 0x35329
callq 0x50f0
testl %eax, %eax
je 0x2e8b2
movq %r14, %rdi
leaq 0x68e3(%rip), %rsi      # 0x3509f
callq 0x50f0
testl %eax, %eax
je 0x2e918
movq %r14, %rdi
leaq 0x6bd4(%rip), %rsi      # 0x353a7
callq 0x50f0
testl %eax, %eax
je 0x2e9f7
movq 0x70(%rsp), %rax
cmpb $0x2d, (%rax)
jne 0x2ea4c
movq 0x127fb(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x127dd(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x12, %edx
movq %rax, %rdi
leaq 0x6892(%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 0x2eb9c
xorl %r13d, %r13d
callq 0x2e4b3
xorl %r15d, %r15d
jmp 0x2ec14
incl %r12d
cmpl %ebp, %r12d
jge 0x2e957
movslq %r12d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
leaq 0x7(%rsp), %rdx
callq 0x182e0
movq %rbx, %rdi
leaq 0x7465(%rip), %rsi      # 0x35d4e
callq 0x5710
movq %r15, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2eba7
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x2ebae
incl %r12d
cmpl %ebp, %r12d
jge 0x2ea61
movslq %r12d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
leaq 0x90(%rsp), %rdx
callq 0x182e0
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
callq 0x8148
jmp 0x2ea34
movq 0x12692(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x12674(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0x6bd9(%rip), %rsi      # 0x35574
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 0x2eb9c
incl %r12d
cmpl %ebp, %r12d
jge 0x2eb01
movslq %r12d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
leaq 0x90(%rsp), %rdx
callq 0x182e0
movq %rbx, %rdi
leaq 0xb0(%rsp), %rsi
callq 0x8148
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x2ec11
movq 0x20(%rsp), %rsi
jmp 0x2ec09
movb $0x1, %r15b
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0x8528
jmp 0x2ec14
movq 0x12588(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x1256a(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0x65fd(%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 0x2eb9c
movq 0x124e8(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x124ca(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0x6865(%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
jmp 0x2ec14
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x5470
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x2ebec
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x2ec11
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x53c0
movb $0x1, %r15b
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x2ec36
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x53c0
testb %r15b, %r15b
je 0x2eec7
incl %r12d
cmpl %ebp, %r12d
leaq 0x20(%rsp), %r15
jl 0x2e754
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
je 0x2ece2
leaq 0x563b(%rip), %rsi      # 0x342a2
leaq 0x50(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
je 0x2ed3e
callq 0x26352
movq 0x1233b(%rip), %rbx     # 0x40fc0
leaq 0x7c4c(%rip), %rsi      # 0x368d8
movl $0x8, %edx
movq %rbx, %rdi
callq 0x5420
movq 0x30(%rsp), %r12
movq 0x38(%rsp), %rax
movq %rax, %rsi
subq %r12, %rsi
sarq $0x5, %rsi
movslq 0x1283c(%rip), %rcx     # 0x414f0
cmpq %rcx, %rsi
jbe 0x2edbb
movq 0x122fc(%rip), %rdi     # 0x40fc0
callq 0x5240
leaq 0x5e21(%rip), %rsi      # 0x34af1
movl $0x6, %edx
movq %rax, %rdi
callq 0x5420
jmp 0x2edfa
movq 0x12307(%rip), %rdi     # 0x40ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x122ec(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
leaq 0x63bc(%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
jmp 0x2ed98
movq 0x122ab(%rip), %rdi     # 0x40ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x12290(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
leaq 0x7b44(%rip), %rsi      # 0x368bb
movl $0x1c, %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 0x2e4b3
jmp 0x2eec7
cmpq %rax, %r12
je 0x2edfa
movq 0x121f9(%rip), %r14     # 0x40fc0
leaq 0x55ba(%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 0x2edce
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x121a8(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq 0x12194(%rip), %rdi     # 0x40fc0
leaq 0x6611(%rip), %rsi      # 0x35444
movl $0x1a, %edx
callq 0x5420
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x12172(%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 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
callq 0x1a41c
xorl %r13d, %r13d
testl %eax, %eax
setne %r13b
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x2eee3
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0xb0(%rsp), %rdi
callq 0xab8e
leaq 0x30(%rsp), %rdi
callq 0xab8e
movl %r13d, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2ef13
jmp 0x2ef63
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x2ef66
movq 0x20(%rsp), %rsi
jmp 0x2ef49
jmp 0x2ef63
movq %rax, %rbx
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x2ef66
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x2ef66
jmp 0x2ef63
movq %rax, %rbx
jmp 0x2efa4
jmp 0x2ef5e
jmp 0x2ef5e
movq %rax, %rbx
jmp 0x2ef88
movq %rax, %rbx
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x2ef88
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x2efa4
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0xb0(%rsp), %rdi
callq 0xab8e
leaq 0x30(%rsp), %rdi
callq 0xab8e
movq %rbx, %rdi
callq 0x56a0