// File: /workspace/github_cpp_makefile_star2_O1/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, %ebx
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 0x7c30(%rip), %rsi      # 0x368c0
leaq 0x7c33(%rip), %rdx      # 0x368ca
leaq 0x50(%rsp), %rdi
callq 0x862a
cmpl $0x3, %ebx
setge %r12b
jl 0x2f1bd
movl %ebx, (%rsp)
leaq 0x20(%rsp), %rbx
movl $0x2, %r15d
leaq 0x70(%rsp), %r14
movslq %r15d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %r14, %rdi
leaq 0x10(%rsp), %rdx
callq 0x184a2
movq %r14, %rdi
leaq 0x634b(%rip), %rsi      # 0x3502f
callq 0x50f0
testl %eax, %eax
je 0x2ee0f
movq %r14, %rdi
leaq 0x6337(%rip), %rsi      # 0x35032
callq 0x50f0
testl %eax, %eax
je 0x2ee0f
movq %r14, %rdi
leaq 0x6627(%rip), %rsi      # 0x35339
callq 0x50f0
testl %eax, %eax
je 0x2ee1e
movq %r14, %rdi
leaq 0x6386(%rip), %rsi      # 0x350af
callq 0x50f0
testl %eax, %eax
je 0x2ee85
movq %r14, %rdi
leaq 0x6677(%rip), %rsi      # 0x353b7
callq 0x50f0
testl %eax, %eax
je 0x2ef65
movq 0x70(%rsp), %rax
cmpb $0x2d, (%rax)
jne 0x2efbb
movq 0x1228e(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x12270(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x12, %edx
movq %rax, %rdi
leaq 0x6335(%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 0x2f10a
xorl %r13d, %r13d
callq 0x2ea19
xorl %ebx, %ebx
jmp 0x2f17f
incl %r15d
cmpl (%rsp), %r15d
jge 0x2eec5
movslq %r15d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0x90(%rsp), %rbp
movq %rbp, %rdi
leaq 0x7(%rsp), %rdx
callq 0x184a2
movq %rbp, %rdi
leaq 0x6f08(%rip), %rsi      # 0x35d5e
callq 0x5710
movq %rbx, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2f114
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x2f11a
incl %r15d
cmpl (%rsp), %r15d
jge 0x2efcf
movslq %r15d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
leaq 0x90(%rsp), %rdx
callq 0x184a2
movq %rbp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x817c
jmp 0x2efa3
movq 0x12124(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x12106(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0x667b(%rip), %rsi      # 0x35584
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 0x2f10a
incl %r15d
cmpl (%rsp), %r15d
jge 0x2f06f
movslq %r15d, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
leaq 0x90(%rsp), %rdx
callq 0x184a2
movq %rbp, %rdi
leaq 0xb0(%rsp), %rsi
callq 0x817c
movq 0x10(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2f17d
movq 0x20(%rsp), %rsi
jmp 0x2f175
movb $0x1, %bl
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0x855c
jmp 0x2f17f
movq 0x1201a(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x11ffc(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0x609f(%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 0x2f10a
movq 0x11f7a(%rip), %rcx     # 0x40ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x11f5c(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %r13
movl $0x21, %edx
movq %rax, %rdi
leaq 0x6307(%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
jmp 0x2f17f
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
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 %rbx, %rdi
je 0x2f158
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x2f17d
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x53c0
movb $0x1, %bl
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x2f1a1
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x53c0
testb %bl, %bl
je 0x2f1bd
incl %r15d
cmpl (%rsp), %r15d
setl %r12b
leaq 0x20(%rsp), %rbx
jl 0x2ecc1
jmp 0x2f1bd
testb $0x1, %r12b
jne 0x2f439
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
je 0x2f252
leaq 0x50d8(%rip), %rsi      # 0x342b2
leaq 0x50(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
je 0x2f2ae
callq 0x26746
movq 0x11dc8(%rip), %rbx     # 0x40fc0
leaq 0x76e9(%rip), %rsi      # 0x368e8
movl $0x8, %edx
movq %rbx, %rdi
callq 0x5420
movq 0x30(%rsp), %r12
movq 0x38(%rsp), %rsi
subq %r12, %rsi
sarq $0x5, %rsi
movslq 0x122cc(%rip), %rax     # 0x414f0
cmpq %rax, %rsi
jbe 0x2f32b
movq 0x11d8c(%rip), %rdi     # 0x40fc0
callq 0x5240
leaq 0x58c1(%rip), %rsi      # 0x34b01
movl $0x6, %edx
movq %rax, %rdi
callq 0x5420
jmp 0x2f36c
movq 0x11d97(%rip), %rdi     # 0x40ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x11d7c(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
leaq 0x5e5c(%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
jmp 0x2f308
movq 0x11d3b(%rip), %rdi     # 0x40ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x11d20(%rip), %rdi     # 0x40ff0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
leaq 0x75e4(%rip), %rsi      # 0x368cb
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 0x2ea19
jmp 0x2f439
cmpq 0x38(%rsp), %r12
je 0x2f36c
movq 0x11c87(%rip), %r14     # 0x40fc0
leaq 0x5058(%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 0x38(%rsp), %r12
jne 0x2f340
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x11c36(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq 0x11c22(%rip), %rdi     # 0x40fc0
leaq 0x60af(%rip), %rsi      # 0x35454
movl $0x1a, %edx
callq 0x5420
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x11c00(%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 0x1a610
xorl %r13d, %r13d
testl %eax, %eax
setne %r13b
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x2f455
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0xb0(%rsp), %rdi
callq 0xabee
leaq 0x30(%rsp), %rdi
callq 0xabee
movl %r13d, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2f485
jmp 0x2f4d8
movq %rbx, %rcx
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %rcx, %rdi
je 0x2f4db
movq 0x20(%rsp), %rsi
jmp 0x2f4be
jmp 0x2f4d8
movq %rax, %rbx
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x2f4db
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x2f4db
jmp 0x2f4d8
movq %rax, %rbx
jmp 0x2f519
jmp 0x2f4d3
jmp 0x2f4d3
movq %rax, %rbx
jmp 0x2f4fd
movq %rax, %rbx
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x2f4fd
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x2f519
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0xb0(%rsp), %rdi
callq 0xabee
leaq 0x30(%rsp), %rdi
callq 0xabee
movq %rbx, %rdi
callq 0x56a0