// File: /workspace/github_cpp_makefile_star2_O3/ChnMasterOG[P]KmerGO2/kmc_api/kmc_file.cpp
// Function: CKMCFile::GetCountersForRead_kmc2_both_strands(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_both_strands(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), rev_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));
		rev_kmer.from_binary_rev(transformed_read.c_str() + std::get<0>(super_kmer));

		uint32 bin_start_pos = std::get<2>(super_kmer) * single_LUT_size;
		if(kmer < rev_kmer)
			counters[counters_pos++] = count_for_kmer_kmc2(kmer, bin_start_pos);
		else
			counters[counters_pos++] = count_for_kmer_kmc2(rev_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]);
			rev_kmer.SHR_insert2bits(3 - transformed_read[i]);
			if(kmer < rev_kmer)
				counters[counters_pos++] = count_for_kmer_kmc2(kmer, bin_start_pos);
			else
				counters[counters_pos++] = count_for_kmer_kmc2(rev_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 $0x108, %rsp            # imm = 0x108
movq %rdx, %rbp
movq %rsi, %rbx
movq 0x8(%rsi), %rsi
movq %rdi, 0x18(%rsp)
movl 0x78(%rdi), %eax
subq %rax, %rsi
incq %rsi
movq %rdx, %rdi
callq 0x4193bc
leaq 0xb0(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
callq 0x408000
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x41774b
movq 0xa0(%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 0x417737
xorps %xmm0, %xmm0
leaq 0xc0(%rsp), %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
leaq 0xa0(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x418fa8
movq 0xc0(%rsp), %rsi
movq 0xc8(%rsp), %rax
movq %rax, 0xd8(%rsp)
cmpq %rax, %rsi
je 0x417851
movq 0x18(%rsp), %rax
movl 0x78(%rax), %r12d
testq %r12, %r12
movq %r12, 0x20(%rsp)
movq %rbp, 0x38(%rsp)
je 0x41787a
movq %rsi, 0x10(%rsp)
movl %r12d, %eax
andl $0x3, %eax
movb $0x4, %cl
subb %al, %cl
testl %eax, %eax
movzbl %cl, %r14d
cmovel %eax, %r14d
movb %r14b, 0x54(%rsp)
movzbl %r14b, %ebx
addl %r12d, %ebx
movl %ebx, %eax
andl $0x1f, %eax
shrl $0x5, %ebx
cmpl $0x1, %eax
sbbl $-0x1, %ebx
movl %ebx, 0x58(%rsp)
leal (,%rbx,8), %ebp
movq %rbp, %rdi
callq 0x41bd90
movq %rax, %r15
movq %rax, 0x48(%rsp)
movq %rax, %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x401098
movl %r12d, 0x50(%rsp)
movb %r14b, 0x94(%rsp)
movq %rbx, %r13
movl %ebx, 0x98(%rsp)
movq %rbp, %rdi
callq 0x41bd90
movq %rax, %r12
movq %rax, 0x88(%rsp)
movq %rax, %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x401098
movq 0x38(%rsp), %rbp
movq 0x10(%rsp), %rsi
movq %r13, %rdi
jmp 0x4178b1
movq (%rbp), %rdi
movq 0x8(%rbp), %rdx
subq %rdi, %rdx
je 0x417d30
addq $-0x4, %rdx
andq $-0x4, %rdx
addq $0x4, %rdx
xorl %esi, %esi
callq 0x401098
jmp 0x417d30
xorl %r12d, %r12d
movq %r12, 0x48(%rsp)
movl %r12d, 0x58(%rsp)
movb %r12b, 0x54(%rsp)
movl %r12d, 0x50(%rsp)
movq %r12, 0x88(%rsp)
movl %r12d, 0x98(%rsp)
movb %r12b, 0x94(%rsp)
xorl %r14d, %r14d
xorl %edi, %edi
xorl %r15d, %r15d
movq 0x20(%rsp), %rax
movl %eax, 0x90(%rsp)
movl 0x8(%rsi), %edx
testq %rdx, %rdx
movq %rdi, 0x28(%rsp)
je 0x4178e9
movq (%rbp), %rdi
shlq $0x2, %rdx
movq %rsi, %rbx
xorl %esi, %esi
callq 0x401098
movq 0x28(%rsp), %rdi
movq %rbx, %rsi
movl 0x8(%rbx), %ebx
jmp 0x4178eb
xorl %ebx, %ebx
movl %edi, %r13d
movzbl %r14b, %r8d
leal (%r8,%r8), %ecx
movq $-0x1, %rax
shlq %cl, %rax
leaq (,%r13,8), %rdx
movq %rdx, 0x78(%rsp)
notq %rax
movq %rcx, 0x40(%rsp)
negb %cl
shlq %cl, %rax
movq $-0x1, %r9
notq %rax
movq 0x20(%rsp), %rcx
leal (%rcx,%r8), %edx
movl %edx, %ecx
negl %ecx
addl %ecx, %ecx
andl $0x3e, %ecx
movq %rcx, 0xf0(%rsp)
decl %edi
movl %edi, %ecx
shll $0x6, %ecx
addl %edx, %edx
subl %edx, %ecx
shlq %cl, %r9
movq %r9, 0xf8(%rsp)
movq (%rbp), %rcx
movq %rcx, 0x68(%rsp)
movq 0xa0(%rsp), %rcx
movq %rcx, 0x30(%rsp)
xorl %ecx, %ecx
movq %r8, 0x70(%rsp)
cmpb $0x1, %r8b
sbbq %rcx, %rcx
orq %rax, %rcx
movq %rcx, 0xe8(%rsp)
leaq -0x1(%r13), %rbp
movq %rdi, 0x80(%rsp)
leaq -0x1(%rdi), %rax
movq %rax, 0xe0(%rsp)
movl %ebx, %eax
movl 0x8(%rsi), %edx
movl %edx, %r14d
subl %eax, %r14d
movq %rsi, 0x10(%rsp)
jbe 0x4179ec
movq 0x18(%rsp), %rdi
movl 0x78(%rdi), %eax
leal (%r14,%rax), %ecx
decl %ecx
je 0x4179e5
movl %ebx, %eax
movq 0x68(%rsp), %rdx
leaq (%rdx,%rax,4), %rdi
movl %ecx, %edx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x401098
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rax
movl 0x78(%rax), %eax
movl 0x8(%rsi), %edx
addl %r14d, %ebx
addl %eax, %ebx
decl %ebx
movl %edx, 0xc(%rsp)
movl 0x4(%rsi), %eax
addl %edx, %eax
movl %eax, 0x64(%rsp)
movq %r15, %rdi
xorl %esi, %esi
movq 0x78(%rsp), %r14
movq %r14, %rdx
callq 0x401098
movq 0x20(%rsp), %r9
testl %r9d, %r9d
movq 0x70(%rsp), %r10
je 0x417ab9
movl 0xc(%rsp), %eax
addq 0x30(%rsp), %rax
movq 0x40(%rsp), %rcx
movl %ecx, %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, (%r15,%r8,8)
incq %rsi
addl $0x2, %edx
cmpq %rsi, %r9
jne 0x417a30
movq 0x10(%rsp), %rax
movl 0x8(%rax), %r14d
movq %r12, %rdi
xorl %esi, %esi
movq 0x78(%rsp), %rdx
callq 0x401098
cmpl $0x0, 0x20(%rsp)
je 0x417ac6
addq 0x30(%rsp), %r14
movq 0x40(%rsp), %rax
movq 0x70(%rsp), %rcx
movl %ecx, %edx
movq 0x20(%rsp), %rsi
decq %rsi
movl %esi, %ecx
movb $0x3, %dil
subb (%r14,%rcx), %dil
movzbl %dil, %edi
movl %eax, %ecx
notb %cl
andb $0x3e, %cl
shlq %cl, %rdi
movl %edx, %ecx
shrl $0x5, %ecx
addq %rdi, (%r12,%rcx,8)
incl %edx
addl $0x2, %eax
testq %rsi, %rsi
jne 0x417a8a
jmp 0x417ac6
movq %r12, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401098
movq 0x18(%rsp), %r14
movl 0x48(%r14), %ecx
movq 0x10(%rsp), %rax
imull (%rax), %ecx
movl %ecx, 0xc(%rsp)
cmpl $0x0, 0x28(%rsp)
je 0x417b1b
movq (%r12), %rcx
movq (%r15), %rdx
leaq 0x48(%rsp), %rsi
cmpq %rdx, %rcx
ja 0x417b23
xorl %eax, %eax
cmpq %rdx, %rcx
jb 0x417b1b
cmpq %rax, %rbp
je 0x417b1b
movq 0x8(%r12,%rax,8), %rcx
movq 0x8(%r15,%rax,8), %rdx
incq %rax
cmpq %rdx, %rcx
jbe 0x417af5
leaq 0x48(%rsp), %rsi
cmpq %r13, %rax
jb 0x417b23
leaq 0x88(%rsp), %rsi
movq %r14, %rdi
movl 0xc(%rsp), %edx
callq 0x418f4e
movl %ebx, %ecx
movq 0x68(%rsp), %rdx
movl %eax, (%rdx,%rcx,4)
movq 0x10(%rsp), %rsi
movl 0x8(%rsi), %ecx
movl 0x78(%r14), %eax
addl %ecx, %eax
incl %ebx
addl 0x4(%rsi), %ecx
cmpl %ecx, %eax
jae 0x417cc1
movq 0x38(%rsp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x100(%rsp)
movl %eax, %r14d
movq 0x28(%rsp), %r8
movq (%r15), %rcx
shlq $0x2, %rcx
andq 0xe8(%rsp), %rcx
movq 0x30(%rsp), %rax
movzbl (%rax,%r14), %eax
movq %rcx, (%r15)
cmpl $0x2, %r8d
jb 0x417bb9
movl $0x1, %edx
movq (%r15,%rdx,8), %rsi
movq %rsi, %rdi
shrq $0x3e, %rdi
addq %rcx, %rdi
movq %rdi, -0x8(%r15,%rdx,8)
shlq $0x2, %rsi
movq %rsi, (%r15,%rdx,8)
incq %rdx
movq %rsi, %rcx
cmpq %rdx, %r13
jne 0x417b93
movq 0xf0(%rsp), %rcx
shlq %cl, %rax
movq 0x80(%rsp), %rcx
addq %rax, (%r15,%rcx,8)
movb $0x3, %al
movq 0x30(%rsp), %rdx
subb (%rdx,%r14), %al
testq %rcx, %rcx
je 0x417c16
movq 0xe0(%rsp), %rdx
movq %rdx, %rcx
movq 0x8(%r12,%rdx,8), %rsi
movq %rsi, %rdi
shrq $0x2, %rdi
movq %rdi, 0x8(%r12,%rdx,8)
movl %edx, %edi
movq (%r12,%rdi,8), %rdi
shldq $0x3e, %rsi, %rdi
movq %rdi, 0x8(%r12,%rdx,8)
decq %rcx
testl %edx, %edx
movq %rcx, %rdx
jne 0x417beb
shrq $0x2, (%r12)
movq 0xf8(%rsp), %rcx
movq 0x80(%rsp), %rdx
andq %rcx, (%r12,%rdx,8)
movzbl %al, %eax
shlq $0x3e, %rax
movq 0x40(%rsp), %rcx
shrq %cl, %rax
addq (%r12), %rax
movq %rax, (%r12)
testl %r8d, %r8d
je 0x417c80
movq (%r15), %rdx
leaq 0x48(%rsp), %rsi
cmpq %rdx, %rax
ja 0x417c88
xorl %ecx, %ecx
cmpq %rdx, %rax
jb 0x417c80
cmpq %rcx, %rbp
je 0x417c80
movq 0x8(%r12,%rcx,8), %rax
movq 0x8(%r15,%rcx,8), %rdx
incq %rcx
cmpq %rdx, %rax
jbe 0x417c5a
leaq 0x48(%rsp), %rsi
cmpq %r13, %rcx
jb 0x417c88
leaq 0x88(%rsp), %rsi
movq 0x18(%rsp), %rdi
movl 0xc(%rsp), %edx
callq 0x418f4e
movq 0x28(%rsp), %r8
movl %ebx, %ecx
movq 0x100(%rsp), %rdx
movl %eax, (%rdx,%rcx,4)
incq %r14
incl %ebx
movq 0x10(%rsp), %rsi
movl 0x4(%rsi), %eax
addl 0x8(%rsi), %eax
cmpq %rax, %r14
jb 0x417b6c
addq $0xc, %rsi
cmpq 0xd8(%rsp), %rsi
movl 0x64(%rsp), %eax
jne 0x41799d
movl %ebx, %eax
movq 0x38(%rsp), %rdx
movq (%rdx), %rcx
movq 0x8(%rdx), %rdx
movq %rdx, %rsi
subq %rcx, %rsi
sarq $0x2, %rsi
cmpq %rax, %rsi
jbe 0x417d0e
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
je 0x417d1b
movq %r12, %rdi
callq 0x41aea0
testq %r15, %r15
je 0x417d28
movq %r15, %rdi
callq 0x41aea0
leaq 0xb0(%rsp), %r14
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x417d4d
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x41ae90
movq 0xa0(%rsp), %rdi
cmpq %r14, %rdi
je 0x417d6a
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x41ae90
movb $0x1, %al
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r15, %rdi
callq 0x41aea0
jmp 0x417d90
jmp 0x417d8d
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x417dad
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x41ae90
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x417dd2
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x41ae90
movq %rbx, %rdi
callq 0x4bfce0