// File: ChnMasterOG[P]KmerGO2/kmc_api/kmc_file.cpp
// Function: CKMCFile::GetCountersForRead_kmc2(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<unsigned int, std::allocator<unsigned int>>&)
bool CKMCFile::GetCountersForRead_kmc2(const std::string& read, std::vector<uint32>& counters)
{	
	counters.resize(read.length() - kmer_length + 1);
	std::string transformed_read = read;
	for (char& c : transformed_read)
		c = CKmerAPI::num_codes[(uchar)c];
	
	super_kmers_t super_kmers;
	GetSuperKmers(transformed_read, super_kmers);
	
	uint32 counters_pos = 0;
	if (super_kmers.empty())
	{
		fill_n(counters.begin(), counters.size(), 0);
		return true;
	}

	CKmerAPI kmer(kmer_length);

	uint32 last_end = 0;

	//'N' somewhere in first k-mer
	if (std::get<0>(super_kmers.front()) > 0)
	{
		fill_n(counters.begin(), std::get<0>(super_kmers.front()), 0);
		last_end = std::get<0>(super_kmers.front());
		counters_pos = std::get<0>(super_kmers.front());
	}
	for (auto& super_kmer : super_kmers)
	{
		//'N's between super k-mers
		if (last_end < std::get<0>(super_kmer))
		{
			uint32 gap = std::get<0>(super_kmer) -last_end;
			fill_n(counters.begin() + counters_pos, kmer_length + gap - 1, 0);
			counters_pos += kmer_length + gap - 1;
		}
		last_end = std::get<0>(super_kmer) + std::get<1>(super_kmer);
		
		kmer.from_binary(transformed_read.c_str() + std::get<0>(super_kmer));

		uint32 bin_start_pos = std::get<2>(super_kmer) * single_LUT_size;
		counters[counters_pos++] = count_for_kmer_kmc2(kmer, bin_start_pos);

		for (uint32 i = std::get<0>(super_kmer) +kmer_length; i < std::get<0>(super_kmer) +std::get<1>(super_kmer); ++i)
		{
			kmer.SHL_insert2bits(transformed_read[i]);
			counters[counters_pos++] = count_for_kmer_kmc2(kmer, bin_start_pos);
		}
	}
	//'N's at the end of read
	if (counters_pos < counters.size())
	{
		fill_n(counters.begin() + counters_pos, counters.size() - counters_pos, 0);
		counters_pos = static_cast<uint32>(counters.size());
	}

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x18(%rbp), %rdi
callq 0x49f200
movq -0x160(%rbp), %rdi
movq %rax, %rsi
movq -0x158(%rbp), %rax
movl 0x78(%rax), %eax
subq %rax, %rsi
addq $0x1, %rsi
callq 0x4282c0
movq -0x18(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x4a15e0
leaq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x49f100
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
callq 0x49f120
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x428350
testb $0x1, %al
jne 0x426668
jmp 0x426699
leaq -0x50(%rbp), %rdi
callq 0x408440
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movzbl (%rax), %eax
movl %eax, %ecx
movq $0x1b8f8e0, %rax        # imm = 0x1B8F8E0
movb (%rax,%rcx), %cl
movq -0x60(%rbp), %rax
movb %cl, (%rax)
leaq -0x50(%rbp), %rdi
callq 0x428390
jmp 0x426655
leaq -0x78(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x428c10
movq -0x158(%rbp), %rdi
movq -0x168(%rbp), %rdx
leaq -0x40(%rbp), %rsi
callq 0x427be0
jmp 0x4266c2
movl $0x0, -0x88(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x428c30
testb $0x1, %al
jne 0x4266db
jmp 0x426752
movq -0x20(%rbp), %rdi
callq 0x420c40
movq %rax, -0x90(%rbp)
movq -0x20(%rbp), %rdi
callq 0x420d40
movq %rax, %rsi
movl $0x0, -0x94(%rbp)
movq -0x90(%rbp), %rdi
leaq -0x94(%rbp), %rdx
callq 0x4286d0
movq %rax, -0x170(%rbp)
jmp 0x42671d
movq -0x170(%rbp), %rax
movq %rax, -0xa0(%rbp)
movb $0x1, -0x1(%rbp)
movl $0x1, -0xa4(%rbp)
jmp 0x426c0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x426c2a
movq -0x158(%rbp), %rax
movl 0x78(%rax), %esi
leaq -0xc0(%rbp), %rdi
callq 0x40b540
jmp 0x42676a
movl $0x0, -0xc4(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x428c90
movq %rax, %rdi
callq 0x428c70
cmpl $0x0, (%rax)
jbe 0x426839
movq -0x20(%rbp), %rdi
callq 0x420c40
movq %rax, -0xd0(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x428c90
movq %rax, %rdi
callq 0x428c70
movl (%rax), %esi
movl $0x0, -0xd4(%rbp)
movq -0xd0(%rbp), %rdi
leaq -0xd4(%rbp), %rdx
callq 0x4283e0
movq %rax, -0x178(%rbp)
jmp 0x4267d7
movq -0x178(%rbp), %rax
movq %rax, -0xe0(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x428c90
movq %rax, %rdi
callq 0x428c70
movl (%rax), %eax
movl %eax, -0xc4(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x428c90
movq %rax, %rdi
callq 0x428c70
movl (%rax), %eax
movl %eax, -0x88(%rbp)
jmp 0x426839
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x40bcf0
jmp 0x426c2a
leaq -0x78(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rdi
callq 0x428cc0
movq %rax, -0xf0(%rbp)
movq -0xe8(%rbp), %rdi
callq 0x428cf0
movq %rax, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x428d20
testb $0x1, %al
jne 0x426886
jmp 0x426b44
leaq -0xf0(%rbp), %rdi
callq 0x428d60
movq %rax, -0x100(%rbp)
movl -0xc4(%rbp), %eax
movl %eax, -0x17c(%rbp)
movq -0x100(%rbp), %rdi
callq 0x428c70
movq %rax, %rcx
movl -0x17c(%rbp), %eax
cmpl (%rcx), %eax
jae 0x426977
movq -0x100(%rbp), %rdi
callq 0x428c70
movl (%rax), %eax
movl -0xc4(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x104(%rbp)
movq -0x20(%rbp), %rdi
callq 0x420c40
movq %rax, -0x118(%rbp)
movl -0x88(%rbp), %eax
movl %eax, %esi
leaq -0x118(%rbp), %rdi
callq 0x428440
movq %rax, %rcx
movq -0x158(%rbp), %rax
movq %rcx, -0x110(%rbp)
movl 0x78(%rax), %edx
movl -0x104(%rbp), %eax
movl %eax, %ecx
movl %edx, %eax
leal -0x1(%rax,%rcx), %esi
movl $0x0, -0x11c(%rbp)
movq -0x110(%rbp), %rdi
leaq -0x11c(%rbp), %rdx
callq 0x4283e0
movq %rax, -0x188(%rbp)
jmp 0x42694a
movq -0x158(%rbp), %rax
movq -0x188(%rbp), %rcx
movq %rcx, -0x128(%rbp)
movl 0x78(%rax), %eax
addl -0x104(%rbp), %eax
subl $0x1, %eax
addl -0x88(%rbp), %eax
movl %eax, -0x88(%rbp)
movq -0x100(%rbp), %rdi
callq 0x428c70
movl (%rax), %eax
movl %eax, -0x194(%rbp)
movq -0x100(%rbp), %rdi
callq 0x428d80
movq %rax, %rcx
movl -0x194(%rbp), %eax
movl (%rcx), %ecx
addl %ecx, %eax
movl %eax, -0xc4(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x4a0a10
movq %rax, -0x190(%rbp)
movq -0x100(%rbp), %rdi
callq 0x428c70
movq -0x190(%rbp), %rsi
movl (%rax), %eax
addq %rax, %rsi
leaq -0xc0(%rbp), %rdi
callq 0x428da0
jmp 0x4269e0
movq -0x100(%rbp), %rdi
callq 0x428e70
movq -0x158(%rbp), %rdi
movl (%rax), %eax
movl 0x48(%rdi), %ecx
imull %ecx, %eax
movl %eax, -0x12c(%rbp)
movl -0x12c(%rbp), %edx
leaq -0xc0(%rbp), %rsi
callq 0x427ae0
movl %eax, -0x198(%rbp)
jmp 0x426a1b
movq -0x20(%rbp), %rdi
movl -0x88(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x88(%rbp)
movl %eax, %eax
movl %eax, %esi
callq 0x40b8b0
movl -0x198(%rbp), %ecx
movl %ecx, (%rax)
movq -0x100(%rbp), %rdi
callq 0x428c70
movq -0x158(%rbp), %rcx
movl (%rax), %eax
addl 0x78(%rcx), %eax
movl %eax, -0x130(%rbp)
movl -0x130(%rbp), %eax
movl %eax, -0x19c(%rbp)
movq -0x100(%rbp), %rdi
callq 0x428c70
movl (%rax), %eax
movl %eax, -0x1a0(%rbp)
movq -0x100(%rbp), %rdi
callq 0x428d80
movl -0x1a0(%rbp), %ecx
movq %rax, %rdx
movl -0x19c(%rbp), %eax
addl (%rdx), %ecx
cmpl %ecx, %eax
jae 0x426b31
movl -0x130(%rbp), %eax
movl %eax, %esi
leaq -0x40(%rbp), %rdi
callq 0x49f510
movq %rax, -0x1a8(%rbp)
jmp 0x426abe
movq -0x1a8(%rbp), %rax
movzbl (%rax), %esi
leaq -0xc0(%rbp), %rdi
callq 0x4285c0
jmp 0x426ad6
movq -0x158(%rbp), %rdi
movl -0x12c(%rbp), %edx
leaq -0xc0(%rbp), %rsi
callq 0x427ae0
movl %eax, -0x1ac(%rbp)
jmp 0x426af7
movq -0x20(%rbp), %rdi
movl -0x88(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x88(%rbp)
movl %eax, %eax
movl %eax, %esi
callq 0x40b8b0
movl -0x1ac(%rbp), %ecx
movl %ecx, (%rax)
movl -0x130(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x130(%rbp)
jmp 0x426a5f
jmp 0x426b33
leaq -0xf0(%rbp), %rdi
callq 0x428e90
jmp 0x42686a
movl -0x88(%rbp), %eax
movq %rax, -0x1b8(%rbp)
movq -0x20(%rbp), %rdi
callq 0x420d40
movq %rax, %rcx
movq -0x1b8(%rbp), %rax
cmpq %rcx, %rax
jae 0x426bf0
movq -0x20(%rbp), %rdi
callq 0x420c40
movq %rax, -0x140(%rbp)
movl -0x88(%rbp), %eax
movl %eax, %esi
leaq -0x140(%rbp), %rdi
callq 0x428440
movq %rax, -0x138(%rbp)
movq -0x20(%rbp), %rdi
callq 0x420d40
movq %rax, %rsi
movl -0x88(%rbp), %eax
subq %rax, %rsi
movl $0x0, -0x144(%rbp)
movq -0x138(%rbp), %rdi
leaq -0x144(%rbp), %rdx
callq 0x4286d0
movq %rax, -0x1c0(%rbp)
jmp 0x426bd3
movq -0x1c0(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x20(%rbp), %rdi
callq 0x420d40
movl %eax, -0x88(%rbp)
movb $0x1, -0x1(%rbp)
movl $0x1, -0xa4(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x40bcf0
leaq -0x78(%rbp), %rdi
callq 0x428eb0
leaq -0x40(%rbp), %rdi
callq 0x49efd0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
leaq -0x78(%rbp), %rdi
callq 0x428eb0
leaq -0x40(%rbp), %rdi
callq 0x49efd0
movq -0x80(%rbp), %rdi
callq 0x4d3c10
nopw %cs:(%rax,%rax)