// File: /workspace/github_cpp_makefile_star2_O1/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 $0x118, %rsp            # imm = 0x118
movq %rsi, %rbx
movq 0x8(%rsi), %rsi
movq %rdi, 0x8(%rsp)
movl 0x78(%rdi), %eax
subq %rax, %rsi
incq %rsi
movq %rdx, 0x10(%rsp)
movq %rdx, %rdi
callq 0x419934
leaq 0x90(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
callq 0x40805e
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x417ba1
movq 0x80(%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 0x417b8d
xorps %xmm0, %xmm0
leaq 0xa0(%rsp), %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
leaq 0x80(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x419526
movq 0xa0(%rsp), %rax
movq 0xa8(%rsp), %rcx
movq %rax, %r15
movq %rcx, 0x60(%rsp)
cmpq %rcx, %rax
movq 0x10(%rsp), %rax
je 0x417c52
movq 0x8(%rsp), %rcx
movl 0x78(%rcx), %esi
testq %rsi, %rsi
movq %rsi, 0x18(%rsp)
je 0x417c7a
movl %esi, %eax
andl $0x3, %eax
movb $0x4, %cl
subb %al, %cl
testl %eax, %eax
movzbl %cl, %ecx
cmovel %eax, %ecx
movb %cl, 0x34(%rsp)
movzbl %cl, %ebx
addl %esi, %ebx
movl %ebx, %eax
andl $0x1f, %eax
shrl $0x5, %ebx
cmpl $0x1, %eax
sbbl $-0x1, %ebx
movl %ebx, 0x38(%rsp)
shll $0x3, %ebx
movq %rbx, %rdi
callq 0x41c2a0
movq %rax, 0x28(%rsp)
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x401098
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rsi
jmp 0x417c90
movq (%rax), %rdi
movq 0x8(%rax), %rdx
subq %rdi, %rdx
je 0x418207
addq $-0x4, %rdx
andq $-0x4, %rdx
addq $0x4, %rdx
xorl %esi, %esi
callq 0x401098
jmp 0x418207
movq $0x0, 0x28(%rsp)
movl $0x0, 0x38(%rsp)
movb $0x0, 0x34(%rsp)
movl %esi, 0x30(%rsp)
testl %esi, %esi
je 0x417ced
movl %esi, %eax
andl $0x3, %eax
movb $0x4, %cl
subb %al, %cl
testl %eax, %eax
movzbl %cl, %ecx
cmovel %eax, %ecx
movb %cl, 0x54(%rsp)
movzbl %cl, %ebx
addl %esi, %ebx
movl %ebx, %eax
andl $0x1f, %eax
shrl $0x5, %ebx
cmpl $0x1, %eax
sbbl $-0x1, %ebx
movl %ebx, 0x58(%rsp)
shll $0x3, %ebx
movq %rbx, %rdi
callq 0x41c2a0
movq %rax, 0x48(%rsp)
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x401098
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rsi
jmp 0x417d03
movq $0x0, 0x48(%rsp)
movl $0x0, 0x58(%rsp)
movb $0x0, 0x54(%rsp)
movl %esi, 0x50(%rsp)
movq %r15, %r14
movl 0x8(%r15), %edx
testq %rdx, %rdx
je 0x417d2c
movq (%rax), %rdi
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x401098
movq 0x18(%rsp), %rsi
movl 0x8(%r14), %r13d
jmp 0x417d2f
xorl %r13d, %r13d
cmpq 0x60(%rsp), %r14
je 0x4181a9
leaq 0x28(%rsp), %rax
movq (%rax), %r15
movl 0x10(%rax), %ebp
testq %rbp, %rbp
setne 0x7(%rsp)
movzbl 0xc(%rax), %edi
leaq 0x48(%rsp), %r8
movl 0x10(%r8), %eax
leal -0x1(%rax), %r9d
shlq $0x3, %rax
movq %rax, 0xd0(%rsp)
movzbl 0xc(%r8), %r10d
movl %ebp, %eax
addl $-0x1, %eax
movq %rax, 0x100(%rsp)
setb 0x6(%rsp)
leal (%rdi,%rdi), %ecx
movq $-0x1, %rax
shlq %cl, %rax
movq $-0x1, %r11
notq %rax
movl %ecx, 0x40(%rsp)
negb %cl
shlq %cl, %rax
notq %rax
leal (%rsi,%r10), %edx
movl %r9d, %ecx
shll $0x6, %ecx
addl %edx, %edx
subl %edx, %ecx
leal (%rsi,%rdi), %edx
negl %edx
shlq %cl, %r11
movq %r11, 0xf8(%rsp)
addl %edx, %edx
andl $0x3e, %edx
movq %rdx, 0xf0(%rsp)
xorl %ecx, %ecx
cmpq $0x1, %rdi
sbbq %rcx, %rcx
orq %rax, %rcx
movq %rcx, 0xe8(%rsp)
leaq (,%rbp,8), %rax
movq %rax, 0xc8(%rsp)
movq (%r8), %r12
movq %r10, 0xc0(%rsp)
leal (%r10,%r10), %eax
movq %rax, 0x68(%rsp)
movq %r9, 0x78(%rsp)
leaq -0x1(%r9), %rax
movq %rax, 0xe0(%rsp)
movl %r13d, %eax
movq %rdi, 0xd8(%rsp)
movl 0x8(%r14), %ebx
subl %eax, %ebx
jbe 0x417e66
movq 0x8(%rsp), %rax
movl 0x78(%rax), %eax
addl %ebx, %eax
decl %eax
je 0x417e55
movl %r13d, %edi
shlq $0x2, %rdi
movq 0x10(%rsp), %rcx
addq (%rcx), %rdi
movl %eax, %edx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x401098
movq 0x8(%rsp), %rax
movl 0x78(%rax), %eax
addl %ebx, %r13d
addl %eax, %r13d
decl %r13d
movl 0x8(%r14), %ebx
movl 0x4(%r14), %eax
addl %ebx, %eax
movl %eax, 0x44(%rsp)
addq 0x80(%rsp), %rbx
movq %r15, %rdi
xorl %esi, %esi
movq 0xc8(%rsp), %rdx
callq 0x401098
movq 0x18(%rsp), %r8
testl %r8d, %r8d
movq 0xd8(%rsp), %r9
je 0x417eca
movl 0x40(%rsp), %eax
xorl %edx, %edx
movzbl (%rbx,%rdx), %esi
leal (%r9,%rdx), %edi
movl %eax, %ecx
notb %cl
andb $0x3e, %cl
shlq %cl, %rsi
shrl $0x5, %edi
addq %rsi, (%r15,%rdi,8)
incq %rdx
addl $0x2, %eax
cmpq %rdx, %r8
jne 0x417ea6
movl 0x8(%r14), %ebx
addq 0x80(%rsp), %rbx
movq %r12, %rdi
xorl %esi, %esi
movq 0xd0(%rsp), %rdx
callq 0x401098
movq 0x18(%rsp), %rsi
testl %esi, %esi
je 0x417f2d
movq 0x68(%rsp), %rax
movq 0xc0(%rsp), %rcx
movl %ecx, %edx
decq %rsi
movl %esi, %ecx
movb $0x3, %dil
subb (%rbx,%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 0x417f00
movq 0x8(%rsp), %rax
movl 0x48(%rax), %eax
movq %r14, 0x70(%rsp)
imull (%r14), %eax
movl %eax, 0x24(%rsp)
movb 0x6(%rsp), %al
testq %rbp, %rbp
je 0x417f92
movq (%r12), %rcx
movq (%r15), %rdx
movb $0x1, %al
cmpq %rdx, %rcx
jbe 0x417f5d
movb $0x1, %cl
jmp 0x417f92
jae 0x417f63
xorl %ecx, %ecx
jmp 0x417f92
movl $0x1, %ecx
movq %rcx, %rax
cmpq %rax, %rbp
je 0x417f8c
movq (%r12,%rax,8), %rdx
movq (%r15,%rax,8), %rsi
cmpq %rsi, %rdx
ja 0x417f8a
leaq 0x1(%rax), %rcx
cmpq %rsi, %rdx
jae 0x417f68
xorl %ecx, %ecx
jmp 0x417f8c
movb $0x1, %cl
cmpq %rbp, %rax
setb %al
testb $0x1, %cl
leaq 0x48(%rsp), %rdx
movq %rdx, %rsi
leaq 0x28(%rsp), %rcx
cmovneq %rcx, %rsi
movl %r13d, %ebx
testb %al, %al
cmoveq %rdx, %rsi
movq 0x8(%rsp), %r14
movq %r14, %rdi
movl 0x24(%rsp), %edx
callq 0x4194cc
movq 0x10(%rsp), %rdx
movq (%rdx), %rcx
movl %eax, (%rcx,%rbx,4)
movq 0x70(%rsp), %rsi
movl 0x8(%rsi), %ecx
movl 0x78(%r14), %eax
addl %ecx, %eax
incl %r13d
movq %r13, %r8
addl 0x4(%rsi), %ecx
cmpl %ecx, %eax
jae 0x418190
movq 0x80(%rsp), %r13
movq (%rdx), %rcx
movq %rcx, 0x108(%rsp)
movl %eax, %r9d
movq (%r15), %rcx
shlq $0x2, %rcx
andq 0xe8(%rsp), %rcx
movzbl (%r13,%r9), %eax
movq %rcx, (%r15)
cmpl $0x2, %ebp
jb 0x41804b
movq (%r15), %rdx
movl $0x1, %ecx
movq (%r15,%rcx,8), %rsi
movq %rsi, %rdi
shrq $0x3e, %rdi
addq %rdx, %rdi
movq %rdi, -0x8(%r15,%rcx,8)
shlq $0x2, %rsi
movq %rsi, (%r15,%rcx,8)
incq %rcx
movq %rsi, %rdx
cmpq %rcx, %rbp
jne 0x418025
movq 0xf0(%rsp), %rcx
shlq %cl, %rax
movq 0x100(%rsp), %rcx
addq %rax, (%r15,%rcx,8)
movb $0x3, %al
subb (%r13,%r9), %al
cmpq $0x0, 0x78(%rsp)
je 0x4180a7
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 0x41807c
movq %r9, 0x110(%rsp)
shrq $0x2, (%r12)
movq 0x78(%rsp), %rcx
movq 0xf8(%rsp), %rdx
andq %rdx, (%r12,%rcx,8)
movzbl %al, %eax
shlq $0x3e, %rax
movq 0x68(%rsp), %rcx
shrq %cl, %rax
addq %rax, (%r12)
movb 0x7(%rsp), %al
testq %rbp, %rbp
je 0x418128
movq (%r12), %rcx
movq (%r15), %rdx
movb $0x1, %al
cmpq %rdx, %rcx
jbe 0x4180f3
movb $0x1, %cl
jmp 0x418128
jae 0x4180f9
xorl %ecx, %ecx
jmp 0x418128
movl $0x1, %ecx
movq %rcx, %rax
cmpq %rax, %rbp
je 0x418122
movq (%r12,%rax,8), %rdx
movq (%r15,%rax,8), %rsi
cmpq %rsi, %rdx
ja 0x418120
leaq 0x1(%rax), %rcx
cmpq %rsi, %rdx
jae 0x4180fe
xorl %ecx, %ecx
jmp 0x418122
movb $0x1, %cl
cmpq %rbp, %rax
setb %al
testb $0x1, %cl
leaq 0x48(%rsp), %rdx
movq %rdx, %rsi
leaq 0x28(%rsp), %rcx
cmovneq %rcx, %rsi
movq %rbp, %rbx
movq %r8, %rbp
movl %ebp, %r14d
testb %al, %al
cmoveq %rdx, %rsi
movq 0x8(%rsp), %rdi
movl 0x24(%rsp), %edx
callq 0x4194cc
movq 0x108(%rsp), %rcx
movl %eax, (%rcx,%r14,4)
movq 0x110(%rsp), %r9
incq %r9
incl %ebp
movq %rbp, %r8
movq %rbx, %rbp
movq 0x70(%rsp), %r14
movl 0x4(%r14), %eax
addl 0x8(%r14), %eax
cmpq %rax, %r9
jb 0x418000
jmp 0x418193
movq %rsi, %r14
addq $0xc, %r14
cmpq 0x60(%rsp), %r14
movl 0x44(%rsp), %eax
movq %r8, %r13
jne 0x417e23
movl %r13d, %eax
movq 0x10(%rsp), %rdx
movq (%rdx), %rcx
movq 0x8(%rdx), %rdx
movq %rdx, %rsi
subq %rcx, %rsi
sarq $0x2, %rsi
cmpq %rax, %rsi
jbe 0x4181e1
leaq (%rcx,%rax,4), %rdi
subq %rdi, %rdx
addq $-0x4, %rdx
andq $-0x4, %rdx
addq $0x4, %rdx
xorl %esi, %esi
callq 0x401098
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
leaq 0x90(%rsp), %r14
je 0x4181f8
callq 0x41b3b0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x418207
callq 0x41b3b0
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x418224
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x41b3a0
movq 0x80(%rsp), %rdi
cmpq %r14, %rdi
je 0x418241
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x41b3a0
movb $0x1, %al
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x41826e
callq 0x41b3b0
jmp 0x41826e
jmp 0x41826b
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x41828b
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x41b3a0
movq 0x80(%rsp), %rdi
cmpq %r14, %rdi
je 0x4182a8
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x41b3a0
movq %rbx, %rdi
callq 0x4c0230