// File: simonrharris[P]SKA/src/kmers.cpp
// Function: getSubsample(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, std::vector<bool, std::allocator<bool>>&)
int getSubsample(const std::vector < std::string > & sample, const std::vector < std::string > & names, std::vector < bool > & include){
	std::set < std::string > sampleSet;

	if (sample.size()>0){
		for (std::vector < std::string >::const_iterator it=sample.begin(); it!=sample.end(); ++it){
			std::pair < std::set < std::string >::iterator,bool> ret = sampleSet.insert(*it);
			if (not ret.second){
				std::cerr << "Warning " << *it << " is in your sample file more than once" << std::endl;
			}
		}
		std::cout << sampleSet.size() << " unique sample names found in your sample file" << std::endl;
	}
	else {
		for (std::vector < std::string >::const_iterator it=names.begin(); it!=names.end(); ++it){
			sampleSet.insert(*it);
		}
	}

	std::vector < bool > included(sampleSet.size());

	for (std::vector < std::string >::const_iterator it=names.begin(); it!=names.end(); ++it){
		std::set < std::string >::iterator it2 = sampleSet.find(*it);
		if (it2 != sampleSet.end()){
			if (included[distance(sampleSet.begin(), it2)]==true){
				std::cerr << "Warning " << *it << " is in your input files more than once. Only the first occurrence will be kept" << std::endl;
			}
			else{
				included[distance(sampleSet.begin(), it2)]=true;
				include[distance(names.begin(), it)]=true;		
			}
		}
	}

	for (std::vector < bool >::iterator it=included.begin(); it!=included.end(); ++it){
		if (not *it){
			std::set < std::string >::iterator it2 = sampleSet.begin();
			advance(it2, distance(included.begin(), it));
			std::cerr << "Warning " << *it2 << " is in your sample file but not in any of your input files" << std::endl;
		}
	}
	std::cout << std::endl;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xf2f0
movq -0x8(%rbp), %rdi
callq 0xb670
cmpq $0x0, %rax
jbe 0xd3e1
movq -0x8(%rbp), %rdi
callq 0xefe0
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
callq 0xf050
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0xf010
testb $0x1, %al
jne 0xd2a3
jmp 0xd38a
leaq -0x50(%rbp), %rdi
callq 0xf080
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0xf310
movb %dl, -0x1e9(%rbp)
movq %rax, -0x1e8(%rbp)
jmp 0xd2c7
movb -0x1e9(%rbp), %al
movq -0x1e8(%rbp), %rcx
movq %rcx, -0x88(%rbp)
movb %al, -0x80(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x68(%rbp)
movb -0x80(%rbp), %al
movb %al, -0x60(%rbp)
testb $0x1, -0x60(%rbp)
jne 0xd37a
movq 0x6bcf0(%rip), %rdi     # 0x78ff0
leaq 0x4c1b6(%rip), %rsi     # 0x594bd
callq 0x6520
movq %rax, -0x1f8(%rbp)
jmp 0xd315
leaq -0x50(%rbp), %rdi
callq 0xf080
movq -0x1f8(%rbp), %rdi
movq %rax, %rsi
callq 0x64d0
movq %rax, -0x200(%rbp)
jmp 0xd336
movq -0x200(%rbp), %rdi
leaq 0x4c182(%rip), %rsi     # 0x594c6
callq 0x6520
movq %rax, -0x208(%rbp)
jmp 0xd352
movq -0x208(%rbp), %rdi
movq 0x6bc30(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0xd367
jmp 0xd37a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xd9ee
jmp 0xd37c
leaq -0x50(%rbp), %rdi
callq 0xf0a0
jmp 0xd280
leaq -0x48(%rbp), %rdi
callq 0xf360
movq %rax, %rsi
movq 0x6bc0b(%rip), %rdi     # 0x78fa8
callq 0x6120
movq %rax, -0x210(%rbp)
jmp 0xd3ab
movq -0x210(%rbp), %rdi
leaq 0x4c134(%rip), %rsi     # 0x594ed
callq 0x6520
movq %rax, -0x218(%rbp)
jmp 0xd3c7
movq -0x218(%rbp), %rdi
movq 0x6bbbb(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0xd3dc
jmp 0xd46b
movq -0x10(%rbp), %rdi
callq 0xefe0
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rdi
callq 0xf050
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0xf010
testb $0x1, %al
jne 0xd41a
jmp 0xd469
leaq -0x90(%rbp), %rdi
callq 0xf080
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0xf310
movb %dl, -0x221(%rbp)
movq %rax, -0x220(%rbp)
jmp 0xd441
movb -0x221(%rbp), %al
movq -0x220(%rbp), %rcx
movq %rcx, -0xa8(%rbp)
movb %al, -0xa0(%rbp)
leaq -0x90(%rbp), %rdi
callq 0xf0a0
jmp 0xd3f1
jmp 0xd46b
leaq -0x48(%rbp), %rdi
callq 0xf360
movq %rax, -0x238(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0xf380
movq -0x238(%rbp), %rsi
movq -0x230(%rbp), %rdx
leaq -0xd0(%rbp), %rdi
callq 0xf3a0
jmp 0xd4aa
leaq -0xd1(%rbp), %rdi
callq 0xf3e0
movq -0x10(%rbp), %rdi
callq 0xefe0
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rdi
callq 0xf050
movq %rax, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0xf010
testb $0x1, %al
jne 0xd4f2
jmp 0xd7c4
leaq -0xe0(%rbp), %rdi
callq 0xf080
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0xf400
movq %rax, -0x240(%rbp)
jmp 0xd513
movq -0x240(%rbp), %rax
movq %rax, -0xf0(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xf470
movq %rax, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0xf440
testb $0x1, %al
jne 0xd54d
jmp 0xd7b1
leaq -0x48(%rbp), %rdi
callq 0xf4e0
movq %rax, -0x110(%rbp)
movq -0xf0(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x110(%rbp), %rdi
movq -0x118(%rbp), %rsi
callq 0xf4a0
movq %rax, -0x248(%rbp)
jmp 0xd587
movq -0x248(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0xedc0
movq %rdx, -0x258(%rbp)
movq %rax, -0x250(%rbp)
jmp 0xd5aa
movq -0x258(%rbp), %rax
movq -0x250(%rbp), %rcx
movq %rcx, -0x108(%rbp)
movq %rax, -0x100(%rbp)
leaq -0x108(%rbp), %rdi
callq 0xf510
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0xd690
movq 0x6ba09(%rip), %rdi     # 0x78ff0
leaq 0x4becf(%rip), %rsi     # 0x594bd
callq 0x6520
movq %rax, -0x260(%rbp)
jmp 0xd5fc
leaq -0xe0(%rbp), %rdi
callq 0xf080
movq -0x260(%rbp), %rdi
movq %rax, %rsi
callq 0x64d0
movq %rax, -0x268(%rbp)
jmp 0xd620
movq -0x268(%rbp), %rdi
leaq 0x4beee(%rip), %rsi     # 0x5951c
callq 0x6520
movq %rax, -0x270(%rbp)
jmp 0xd63c
movq -0x270(%rbp), %rdi
movq 0x6b946(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0xd651
jmp 0xd7af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xd1(%rbp), %rdi
callq 0xf3e0
jmp 0xd9ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0xf720
jmp 0xd9ee
leaq -0x48(%rbp), %rdi
callq 0xf4e0
movq %rax, -0x130(%rbp)
movq -0xf0(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x130(%rbp), %rdi
movq -0x138(%rbp), %rsi
callq 0xf4a0
movq %rax, -0x278(%rbp)
jmp 0xd6ca
movq -0x278(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0xedc0
movq %rdx, -0x288(%rbp)
movq %rax, -0x280(%rbp)
jmp 0xd6ed
movq -0x288(%rbp), %rax
movq -0x280(%rbp), %rcx
movq %rcx, -0x128(%rbp)
movq %rax, -0x120(%rbp)
leaq -0x128(%rbp), %rdi
movl $0x1, %esi
callq 0xee20
movq -0x18(%rbp), %rax
movq %rax, -0x298(%rbp)
movq -0x10(%rbp), %rdi
callq 0xefe0
movq %rax, -0x150(%rbp)
movq -0xe0(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x150(%rbp), %rdi
movq -0x158(%rbp), %rsi
callq 0xf540
movq %rax, -0x290(%rbp)
jmp 0xd75f
movq -0x290(%rbp), %rsi
movq -0x298(%rbp), %rdi
callq 0xedc0
movq %rdx, -0x2a8(%rbp)
movq %rax, -0x2a0(%rbp)
jmp 0xd782
movq -0x2a8(%rbp), %rax
movq -0x2a0(%rbp), %rcx
movq %rcx, -0x148(%rbp)
movq %rax, -0x140(%rbp)
leaq -0x148(%rbp), %rdi
movl $0x1, %esi
callq 0xee20
jmp 0xd7b1
jmp 0xd7b3
leaq -0xe0(%rbp), %rdi
callq 0xf0a0
jmp 0xd4c6
leaq -0xd0(%rbp), %rdi
callq 0xf580
movl %edx, -0x170(%rbp)
movq %rax, -0x178(%rbp)
movq -0x178(%rbp), %rax
movq %rax, -0x168(%rbp)
movl -0x170(%rbp), %eax
movl %eax, -0x160(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0xf5c0
movl %edx, -0x190(%rbp)
movq %rax, -0x198(%rbp)
movl -0x190(%rbp), %eax
movl %eax, -0x180(%rbp)
movq -0x198(%rbp), %rax
movq %rax, -0x188(%rbp)
leaq -0x168(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0xf1c0
movb %al, -0x2a9(%rbp)
jmp 0xd845
movb -0x2a9(%rbp), %al
testb $0x1, %al
jne 0xd854
jmp 0xd9b9
leaq -0x168(%rbp), %rdi
callq 0xf5e0
movq %rdx, -0x2c0(%rbp)
movq %rax, -0x2b8(%rbp)
jmp 0xd870
movq -0x2c0(%rbp), %rax
movq -0x2b8(%rbp), %rcx
movq %rcx, -0x1a8(%rbp)
movq %rax, -0x1a0(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0xf510
xorb $-0x1, %al
testb $0x1, %al
jne 0xd8a3
jmp 0xd9a4
leaq -0x48(%rbp), %rdi
callq 0xf4e0
movq %rax, -0x1b0(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0xf580
movl %edx, -0x1c8(%rbp)
movq %rax, -0x1d0(%rbp)
movl -0x1c8(%rbp), %eax
movl %eax, -0x1b8(%rbp)
movq -0x1d0(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movups -0x168(%rbp), %xmm0
movaps %xmm0, -0x1e0(%rbp)
movq -0x1c0(%rbp), %rdi
movl -0x1b8(%rbp), %esi
movq -0x1e0(%rbp), %rdx
movl -0x1d8(%rbp), %ecx
callq 0xf670
movq %rax, -0x2c8(%rbp)
jmp 0xd91c
movq -0x2c8(%rbp), %rsi
leaq -0x1b0(%rbp), %rdi
callq 0xf620
jmp 0xd931
movq 0x6b6b8(%rip), %rdi     # 0x78ff0
leaq 0x4bb7e(%rip), %rsi     # 0x594bd
callq 0x6520
movq %rax, -0x2d0(%rbp)
jmp 0xd94d
leaq -0x1b0(%rbp), %rdi
callq 0xf6d0
movq -0x2d0(%rbp), %rdi
movq %rax, %rsi
callq 0x64d0
movq %rax, -0x2d8(%rbp)
jmp 0xd971
movq -0x2d8(%rbp), %rdi
leaq 0x4bbec(%rip), %rsi     # 0x5956b
callq 0x6520
movq %rax, -0x2e0(%rbp)
jmp 0xd98d
movq -0x2e0(%rbp), %rdi
movq 0x6b5f5(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0xd9a2
jmp 0xd9a4
jmp 0xd9a6
leaq -0x168(%rbp), %rdi
callq 0xf6f0
jmp 0xd9b4
jmp 0xd7f7
movq 0x6b5e8(%rip), %rdi     # 0x78fa8
movq 0x6b5c9(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0xd9ce
leaq -0xd0(%rbp), %rdi
callq 0xf720
leaq -0x48(%rbp), %rdi
callq 0xf740
xorl %eax, %eax
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0xf740
movq -0x70(%rbp), %rdi
callq 0x6900