// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %rbx
movq 0x8(%rsi), %rsi
movq %rdi, (%rsp)
movl 0x78(%rdi), %eax
subq %rax, %rsi
incq %rsi
movq %rdx, 0x8(%rsp)
movq %rdx, %rdi
callq 0x419934
leaq 0x50(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x40805e
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x41832d
movq 0x40(%rsp), %rcx
xorl %edx, %edx
movq $0x1b71940, %rsi        # imm = 0x1B71940
movzbl (%rcx,%rdx), %edi
movb (%rsi,%rdi), %dil
movb %dil, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x418319
xorps %xmm0, %xmm0
leaq 0x60(%rsp), %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
leaq 0x40(%rsp), %rsi
movq (%rsp), %rdi
callq 0x419526
movq 0x60(%rsp), %rbp
movq 0x68(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq %rax, %rbp
je 0x4183bc
movq (%rsp), %rax
movl 0x78(%rax), %r13d
testq %r13, %r13
je 0x4183e9
movl %r13d, %eax
andl $0x3, %eax
movb $0x4, %cl
subb %al, %cl
testl %eax, %eax
movzbl %cl, %ecx
cmovel %eax, %ecx
movb %cl, 0x2c(%rsp)
movzbl %cl, %ebx
addl %r13d, %ebx
movl %ebx, %eax
andl $0x1f, %eax
shrl $0x5, %ebx
cmpl $0x1, %eax
sbbl $-0x1, %ebx
movl %ebx, 0x30(%rsp)
shll $0x3, %ebx
movq %rbx, %rdi
callq 0x41c2a0
movq %rax, 0x20(%rsp)
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x401098
jmp 0x4183ff
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq 0x8(%rax), %rdx
subq %rdi, %rdx
je 0x4186a7
addq $-0x4, %rdx
andq $-0x4, %rdx
addq $0x4, %rdx
xorl %esi, %esi
callq 0x401098
jmp 0x4186a7
movq $0x0, 0x20(%rsp)
movl $0x0, 0x30(%rsp)
movb $0x0, 0x2c(%rsp)
movl %r13d, 0x28(%rsp)
movl 0x8(%rbp), %edx
testq %rdx, %rdx
je 0x418425
movq 0x8(%rsp), %rax
movq (%rax), %rdi
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x401098
movl 0x8(%rbp), %r14d
jmp 0x418428
xorl %r14d, %r14d
cmpq 0x38(%rsp), %rbp
je 0x41865b
leaq 0x20(%rsp), %rax
movq (%rax), %r12
movl 0x10(%rax), %r15d
movzbl 0xc(%rax), %edx
leal (%rdx,%rdx), %ecx
movq $-0x1, %rax
shlq %cl, %rax
leaq (,%r15,8), %rsi
movq %rsi, 0x80(%rsp)
notq %rax
movl %ecx, 0x14(%rsp)
negb %cl
shlq %cl, %rax
notq %rax
leal (%rdx,%r13), %ecx
negl %ecx
addl %ecx, %ecx
andl $0x3e, %ecx
movq %rcx, 0xa8(%rsp)
leal -0x1(%r15), %ecx
movq %rcx, 0xa0(%rsp)
xorl %ecx, %ecx
movq %rdx, 0x88(%rsp)
cmpl $0x1, %edx
sbbq %rcx, %rcx
orq %rax, %rcx
movq %rcx, 0x98(%rsp)
movl %r14d, %eax
movq %r13, 0x90(%rsp)
movl 0x8(%rbp), %ebx
subl %eax, %ebx
jbe 0x4184f4
movq (%rsp), %rax
movl 0x78(%rax), %eax
addl %ebx, %eax
decl %eax
je 0x4184e4
movl %r14d, %edi
shlq $0x2, %rdi
movq 0x8(%rsp), %rcx
addq (%rcx), %rdi
movl %eax, %edx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x401098
movq (%rsp), %rax
movl 0x78(%rax), %eax
addl %ebx, %r14d
addl %eax, %r14d
decl %r14d
movl 0x8(%rbp), %ebx
movl 0x4(%rbp), %eax
addl %ebx, %eax
movl %eax, 0x18(%rsp)
addq 0x40(%rsp), %rbx
movq %r12, %rdi
xorl %esi, %esi
movq 0x80(%rsp), %rdx
callq 0x401098
testl %r13d, %r13d
movq 0x88(%rsp), %r8
je 0x41854e
movl 0x14(%rsp), %eax
xorl %edx, %edx
movzbl (%rbx,%rdx), %esi
leal (%r8,%rdx), %edi
movl %eax, %ecx
notb %cl
andb $0x3e, %cl
shlq %cl, %rsi
shrl $0x5, %edi
addq %rsi, (%r12,%rdi,8)
incq %rdx
addl $0x2, %eax
cmpq %rdx, %r13
jne 0x41852a
movq (%rsp), %r13
movl 0x48(%r13), %edx
imull (%rbp), %edx
movq %r13, %rdi
leaq 0x20(%rsp), %rsi
movl %edx, 0x1c(%rsp)
callq 0x4194cc
movl %r14d, %ecx
movq 0x8(%rsp), %rdx
movq (%rdx), %rdx
movq %rdx, 0xb0(%rsp)
movl %eax, (%rdx,%rcx,4)
movl 0x8(%rbp), %ecx
movl 0x78(%r13), %eax
addl %ecx, %eax
incl %r14d
movq %rbp, %rbx
addl 0x4(%rbp), %ecx
cmpl %ecx, %eax
jae 0x41863d
movq 0x40(%rsp), %r13
movl %eax, %ebp
movq (%r12), %rcx
shlq $0x2, %rcx
andq 0x98(%rsp), %rcx
movzbl (%r13,%rbp), %eax
movq %rcx, (%r12)
cmpl $0x2, %r15d
jb 0x4185f1
movq (%r12), %rdx
movl $0x1, %ecx
movq (%r12,%rcx,8), %rsi
movq %rsi, %rdi
shrq $0x3e, %rdi
addq %rdx, %rdi
movq %rdi, -0x8(%r12,%rcx,8)
shlq $0x2, %rsi
movq %rsi, (%r12,%rcx,8)
incq %rcx
movq %rsi, %rdx
cmpq %rcx, %r15
jne 0x4185cb
movq 0xa8(%rsp), %rcx
shlq %cl, %rax
movq 0xa0(%rsp), %rcx
addq %rax, (%r12,%rcx,8)
movq (%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl 0x1c(%rsp), %edx
callq 0x4194cc
movl %r14d, %ecx
movq 0xb0(%rsp), %rdx
movl %eax, (%rdx,%rcx,4)
incq %rbp
incl %r14d
movl 0x4(%rbx), %eax
addl 0x8(%rbx), %eax
cmpq %rax, %rbp
jb 0x4185a2
movq %rbx, %rbp
addq $0xc, %rbp
cmpq 0x38(%rsp), %rbp
movq 0x90(%rsp), %r13
movl 0x18(%rsp), %eax
jne 0x4184b4
movl %r14d, %eax
movq 0x8(%rsp), %rdx
movq (%rdx), %rcx
movq 0x8(%rdx), %rdx
movq %rdx, %rsi
subq %rcx, %rsi
sarq $0x2, %rsi
cmpq %rax, %rsi
jbe 0x418693
leaq (%rcx,%rax,4), %rdi
subq %rdi, %rdx
addq $-0x4, %rdx
andq $-0x4, %rdx
addq $0x4, %rdx
xorl %esi, %esi
callq 0x401098
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
leaq 0x50(%rsp), %r14
je 0x4186a7
callq 0x41b3b0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x4186be
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x41b3a0
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x4186d5
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x41b3a0
movb $0x1, %al
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4186eb
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x418705
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x41b3a0
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x41871c
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x41b3a0
movq %rbx, %rdi
callq 0x4c0230