// File: /workspace/github_cpp_makefile_star2_O3/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 $0xc8, %rsp
movq %rdx, %rbp
movq %rsi, %rbx
movq %rdi, %r12
movq 0x8(%rsi), %rsi
movl 0x78(%rdi), %eax
subq %rax, %rsi
incq %rsi
movq %rdx, %rdi
callq 0x4193bc
leaq 0x60(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0x408000
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x417e54
movq 0x50(%rsp), %rcx
xorl %edx, %edx
movq $0x1b70940, %rsi        # imm = 0x1B70940
movzbl (%rcx,%rdx), %edi
movb (%rsi,%rdi), %dil
movb %dil, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x417e40
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
leaq 0x50(%rsp), %rsi
movq %r12, %rdi
callq 0x418fa8
movq 0x70(%rsp), %r15
movq 0x78(%rsp), %rax
movq %rax, 0xa8(%rsp)
cmpq %rax, %r15
je 0x417f03
movq %r12, 0x20(%rsp)
movl 0x78(%r12), %esi
testq %rsi, %rsi
movq %rsi, 0x8(%rsp)
je 0x417f2c
movl %esi, %eax
andl $0x3, %eax
movb $0x4, %cl
subb %al, %cl
testl %eax, %eax
movzbl %cl, %r13d
cmovel %eax, %r13d
movb %r13b, 0x44(%rsp)
movzbl %r13b, %ecx
addl %esi, %ecx
movl %ecx, %eax
andl $0x1f, %eax
shrl $0x5, %ecx
cmpl $0x1, %eax
sbbl $-0x1, %ecx
movl %ecx, 0x48(%rsp)
movq %rcx, 0x10(%rsp)
leal (,%rcx,8), %ebx
movq %rbx, %rdi
callq 0x41bd90
movq %rax, %r12
movq %rax, 0x38(%rsp)
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x401098
movq 0x8(%rsp), %rsi
jmp 0x417f51
movq (%rbp), %rdi
movq 0x8(%rbp), %rdx
subq %rdi, %rdx
je 0x4181f5
addq $-0x4, %rdx
andq $-0x4, %rdx
addq $0x4, %rdx
xorl %esi, %esi
callq 0x401098
jmp 0x4181f5
movq $0x0, 0x38(%rsp)
movl $0x0, 0x48(%rsp)
movb $0x0, 0x44(%rsp)
xorl %r13d, %r13d
movq $0x0, 0x10(%rsp)
xorl %r12d, %r12d
movl %esi, 0x40(%rsp)
movl 0x8(%r15), %edx
testq %rdx, %rdx
je 0x417f78
movq (%rbp), %rdi
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x401098
movq 0x8(%rsp), %rsi
movl 0x8(%r15), %r14d
jmp 0x417f7b
xorl %r14d, %r14d
movzbl %r13b, %edi
leal (%rdi,%rdi), %ecx
movq $-0x1, %rax
shlq %cl, %rax
movq 0x10(%rsp), %rdx
movl %edx, %ebx
notq %rax
movl %ecx, 0x28(%rsp)
negb %cl
shlq %cl, %rax
leaq (,%rbx,8), %rcx
movq %rcx, 0x98(%rsp)
notq %rax
leal (%rsi,%rdi), %ecx
negl %ecx
addl %ecx, %ecx
andl $0x3e, %ecx
movq %rcx, 0xc0(%rsp)
leal -0x1(%rdx), %ecx
movq %rcx, 0xb8(%rsp)
movq %rbp, 0x90(%rsp)
movq (%rbp), %rcx
movq %rcx, 0x18(%rsp)
xorl %ecx, %ecx
movq %rdi, 0xa0(%rsp)
cmpb $0x1, %dil
sbbq %rcx, %rcx
movq 0x50(%rsp), %rdx
movq %rdx, 0x30(%rsp)
orq %rax, %rcx
movq %rcx, 0xb0(%rsp)
movl %r14d, %eax
movl 0x8(%r15), %ebp
movl %ebp, %r13d
subl %eax, %r13d
jbe 0x418051
movq 0x20(%rsp), %rdx
movl 0x78(%rdx), %eax
leal (%rax,%r13), %ecx
decl %ecx
je 0x418048
movl %r14d, %eax
movq %rdx, %rbp
movq 0x18(%rsp), %rdx
leaq (%rdx,%rax,4), %rdi
movl %ecx, %edx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x401098
movl 0x78(%rbp), %eax
movl 0x8(%r15), %ebp
addl %r13d, %r14d
addl %eax, %r14d
decl %r14d
movl 0x4(%r15), %eax
addl %ebp, %eax
movl %eax, 0x2c(%rsp)
movq %r12, %rdi
xorl %esi, %esi
movq 0x98(%rsp), %rdx
callq 0x401098
movq 0x8(%rsp), %r9
testl %r9d, %r9d
movq 0xa0(%rsp), %r10
je 0x4180b1
movl %ebp, %eax
addq 0x30(%rsp), %rax
movl 0x28(%rsp), %edx
xorl %esi, %esi
movzbl (%rax,%rsi), %edi
leal (%r10,%rsi), %r8d
movl %edx, %ecx
notb %cl
andb $0x3e, %cl
shlq %cl, %rdi
shrl $0x5, %r8d
addq %rdi, (%r12,%r8,8)
incq %rsi
addl $0x2, %edx
cmpq %rsi, %r9
jne 0x41808c
movq 0x20(%rsp), %rbp
movl 0x48(%rbp), %r13d
imull (%r15), %r13d
movq %rbp, %rdi
leaq 0x38(%rsp), %rsi
movl %r13d, %edx
callq 0x418f4e
movl %r14d, %ecx
movq 0x18(%rsp), %rdx
movl %eax, (%rdx,%rcx,4)
movl 0x8(%r15), %ecx
movl 0x78(%rbp), %eax
addl %ecx, %eax
incl %r14d
addl 0x4(%r15), %ecx
cmpl %ecx, %eax
jae 0x41818d
movl %eax, %ebp
movq (%r12), %rcx
shlq $0x2, %rcx
andq 0xb0(%rsp), %rcx
movq 0x30(%rsp), %rax
movzbl (%rax,%rbp), %eax
movq %rcx, (%r12)
cmpl $0x2, 0x10(%rsp)
jb 0x418142
movl $0x1, %edx
movq (%r12,%rdx,8), %rsi
movq %rsi, %rdi
shrq $0x3e, %rdi
addq %rcx, %rdi
movq %rdi, -0x8(%r12,%rdx,8)
shlq $0x2, %rsi
movq %rsi, (%r12,%rdx,8)
incq %rdx
movq %rsi, %rcx
cmpq %rdx, %rbx
jne 0x41811c
movq 0xc0(%rsp), %rcx
shlq %cl, %rax
movq 0xb8(%rsp), %rcx
addq %rax, (%r12,%rcx,8)
movq 0x20(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movl %r13d, %edx
callq 0x418f4e
movl %r14d, %ecx
movq 0x18(%rsp), %rdx
movl %eax, (%rdx,%rcx,4)
incq %rbp
incl %r14d
movl 0x4(%r15), %eax
addl 0x8(%r15), %eax
cmpq %rax, %rbp
jb 0x4180f3
addq $0xc, %r15
cmpq 0xa8(%rsp), %r15
movl 0x2c(%rsp), %eax
jne 0x418009
movl %r14d, %eax
movq 0x90(%rsp), %rdx
movq (%rdx), %rcx
movq 0x8(%rdx), %rdx
movq %rdx, %rsi
subq %rcx, %rsi
sarq $0x2, %rsi
cmpq %rax, %rsi
jbe 0x4181de
leaq (%rcx,%rax,4), %rdi
subq %rdi, %rdx
addq $-0x4, %rdx
andq $-0x4, %rdx
addq $0x4, %rdx
xorl %esi, %esi
callq 0x401098
testq %r12, %r12
leaq 0x60(%rsp), %r14
je 0x4181f0
movq %r12, %rdi
callq 0x41aea0
movq 0x70(%rsp), %r15
testq %r15, %r15
je 0x41820d
movq 0x80(%rsp), %rsi
subq %r15, %rsi
movq %r15, %rdi
callq 0x41ae90
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x418224
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x41ae90
movb $0x1, %al
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x418245
movq %rax, %rbx
movq 0x70(%rsp), %r15
testq %r15, %r15
je 0x41825d
movq 0x80(%rsp), %rsi
subq %r15, %rsi
movq %r15, %rdi
callq 0x41ae90
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x418274
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x41ae90
movq %rbx, %rdi
callq 0x4bfce0