// File: /workspace/github_cpp_makefile_star2_O1/ChnMasterOG[P]KmerGO2/kmc_api/kmc_file.cpp
// Function: CKMCFile::GetCountersForRead_kmc1_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_kmc1_both_strands(const std::string& read, std::vector<uint32>& counters)
{
	uint32 read_len = static_cast<uint32>(read.length());
	counters.resize(read.length() - kmer_length + 1);
	std::string transformed_read = read;
	for (char& c : transformed_read)
		c = CKmerAPI::num_codes[(uchar)c];

	uint32 i = 0;
	CKmerAPI kmer(kmer_length), kmer_rev(kmer_length);
	uint32 pos = 0;
	uint32 rev_pos = kmer_length - 1;

	uint32 counters_pos = 0;

	while (i + kmer_length - 1 < read_len)
	{
		bool contains_N = false;
		while (i < read_len && pos < kmer_length)
		{
			if (CKmerAPI::num_codes[(uchar)read[i]] < 0)
			{
				pos = 0;
				rev_pos = kmer_length - 1;
				kmer.clear();
				kmer_rev.clear();
				++i;
				uint32 wrong_kmers = MIN(i - counters_pos, static_cast<uint32>(counters.size()) - counters_pos);
				fill_n(counters.begin() + counters_pos, wrong_kmers, 0);
				counters_pos += wrong_kmers;
				contains_N = true;
				break;
			}
			else
			{
				kmer_rev.insert2bits(rev_pos--, 3 - CKmerAPI::num_codes[(uchar)read[i]]);
				kmer.insert2bits(pos++, CKmerAPI::num_codes[(uchar)read[i++]]);
				
			}
		}
		if (contains_N)
			continue;
		if (pos == kmer_length)
		{
			if(kmer < kmer_rev)
				counters[counters_pos++] = count_for_kmer_kmc1(kmer);
			else
				counters[counters_pos++] = count_for_kmer_kmc1(kmer_rev);
		}
		else
			break;

		while (i < read_len)
		{
			if (CKmerAPI::num_codes[(uchar)read[i]] < 0)
			{
				pos = 0;
				break;
			}
			kmer_rev.SHR_insert2bits(3 - CKmerAPI::num_codes[(uchar)read[i]]);
			kmer.SHL_insert2bits(CKmerAPI::num_codes[(uchar)read[i++]]);
			if(kmer < kmer_rev)
				counters[counters_pos++] = count_for_kmer_kmc1(kmer);
			else
				counters[counters_pos++] = count_for_kmer_kmc1(kmer_rev);
		}
	}
	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 $0xf8, %rsp
movq %rdx, %r12
movq %rsi, %rbx
movq 0x8(%rsi), %rsi
movq %rdi, 0x8(%rsp)
movl 0x78(%rdi), %eax
movq %rsi, 0x20(%rsp)
subq %rax, %rsi
incq %rsi
movq %rdx, %rdi
callq 0x419934
leaq 0xe8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rbx), %rsi
movq %rbx, 0x70(%rsp)
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %r14
movq %r14, %rdi
callq 0x40805e
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x4187b3
movq 0xd8(%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 0x41879f
movq 0x8(%rsp), %rax
movl 0x78(%rax), %ebx
testl %ebx, %ebx
je 0x418811
movl %ebx, %eax
andl $0x3, %eax
movb $0x4, %cl
subb %al, %cl
testl %eax, %eax
movzbl %cl, %ecx
cmovel %eax, %ecx
movb %cl, 0x4c(%rsp)
movzbl %cl, %r14d
addl %ebx, %r14d
movl %r14d, %eax
andl $0x1f, %eax
shrl $0x5, %r14d
cmpl $0x1, %eax
sbbl $-0x1, %r14d
movl %r14d, 0x50(%rsp)
shll $0x3, %r14d
movq %r14, %rdi
callq 0x41c2a0
movq %rax, 0x40(%rsp)
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401098
jmp 0x418827
movq $0x0, 0x40(%rsp)
movl $0x0, 0x50(%rsp)
movb $0x0, 0x4c(%rsp)
movl %ebx, 0x48(%rsp)
testl %ebx, %ebx
movq %r12, 0x38(%rsp)
je 0x418886
movl %ebx, %eax
andl $0x3, %eax
movb $0x4, %cl
subb %al, %cl
testl %eax, %eax
movzbl %cl, %ecx
cmovel %eax, %ecx
movb %cl, 0x64(%rsp)
movzbl %cl, %r14d
addl %ebx, %r14d
movl %r14d, %eax
andl $0x1f, %eax
shrl $0x5, %r14d
cmpl $0x1, %eax
sbbl $-0x1, %r14d
movl %r14d, 0x68(%rsp)
shll $0x3, %r14d
movq %r14, %rdi
callq 0x41c2a0
movq %rax, 0x58(%rsp)
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401098
jmp 0x41889c
movq $0x0, 0x58(%rsp)
movl $0x0, 0x68(%rsp)
movb $0x0, 0x64(%rsp)
leaq 0x58(%rsp), %rsi
movl %ebx, 0x8(%rsi)
movzbl 0xc(%rsi), %edi
leaq 0x40(%rsp), %r8
movzbl 0xc(%r8), %r9d
movl 0x10(%r8), %r14d
testq %r14, %r14
setne 0x6(%rsp)
movl 0x10(%rsi), %edx
leal -0x1(%rdx), %r10d
leal (%rbx,%rdi), %eax
movl %r10d, %ecx
shll $0x6, %ecx
addl %eax, %eax
subl %eax, %ecx
movq $-0x1, %rax
movq $-0x1, %r11
shlq %cl, %r11
movq %r11, 0xc8(%rsp)
leal (%r9,%r9), %ecx
shlq %cl, %rax
leal -0x1(%rbx), %r11d
movq %r11, 0x18(%rsp)
notq %rax
negb %cl
shlq %cl, %rax
shlq $0x3, %rdx
movq %rdx, 0x98(%rsp)
notq %rax
leal (%rbx,%r9), %ecx
decl %ecx
notl %ecx
addl %ecx, %ecx
andl $0x3e, %ecx
movq %rcx, 0xc0(%rsp)
movl %r14d, %ecx
addl $-0x1, %ecx
movq %rcx, 0xb8(%rsp)
setb 0x7(%rsp)
movq $0x0, 0x10(%rsp)
movq %r9, 0x80(%rsp)
cmpl $0x1, %r9d
movl $0x0, %ecx
sbbq %rcx, %rcx
orq %rax, %rcx
movq %rcx, 0xb0(%rsp)
movq (%rsi), %rbp
movq (%r8), %r12
leaq (,%r14,8), %rax
movq %rax, 0x90(%rsp)
movq %rdi, 0x88(%rsp)
leal (%rdi,%rdi), %eax
movq %rax, 0xa8(%rsp)
movq %r10, 0x78(%rsp)
leaq -0x1(%r10), %rax
movq %rax, 0xa0(%rsp)
movq $0x1b71940, %r13        # imm = 0x1B71940
xorl %ecx, %ecx
xorl %r15d, %r15d
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl 0x78(%rdi), %eax
addl %r15d, %eax
decl %eax
cmpl %esi, %eax
jae 0x418e45
cmpl %esi, %r15d
setb %al
movl 0x78(%rdi), %edx
cmpl %edx, %ecx
setb %bl
andb %al, %bl
cmpb $0x1, %bl
jne 0x418ba3
movq %rcx, 0x28(%rsp)
movq 0x70(%rsp), %rax
movq (%rax), %rsi
movl %r15d, %eax
movzbl (%rsi,%rax), %ecx
movb (%r13,%rcx), %cl
testb %cl, %cl
js 0x418ad6
leaq (%rsi,%rax), %rdx
incq %rdx
movq 0x88(%rsp), %rsi
movq 0x18(%rsp), %rdi
addl %edi, %esi
leal (%rsi,%rsi), %edi
movq 0x80(%rsp), %r8
movq %rax, 0x30(%rsp)
movq 0x28(%rsp), %rax
leal (%r8,%rax), %r9d
movl %r9d, %r10d
addl %r9d, %r10d
leal 0x1(%rax), %r11d
movq 0x30(%rsp), %rax
xorl %r8d, %r8d
movb $0x3, %bl
subb %cl, %bl
movzbl %bl, %ebx
movl %edi, %ecx
notb %cl
andb $0x3e, %cl
shlq %cl, %rbx
movl %esi, %ecx
shrl $0x5, %ecx
addq %rbx, (%rbp,%rcx,8)
movzbl -0x1(%rdx,%r8), %ecx
movzbl (%r13,%rcx), %ebx
leal (%r9,%r8), %r15d
movl %r10d, %ecx
notb %cl
andb $0x3e, %cl
shlq %cl, %rbx
shrl $0x5, %r15d
addq %rbx, (%r12,%r15,8)
leal (%r11,%r8), %ecx
leal (%rax,%r8), %ebx
incl %ebx
cmpl 0x20(%rsp), %ebx
setb %al
movq 0x8(%rsp), %rbx
movl 0x78(%rbx), %r15d
cmpl %r15d, %ecx
setb %bl
andb %al, %bl
je 0x418b72
movzbl (%rdx,%r8), %ecx
movb (%r13,%rcx), %cl
incq %r8
decl %esi
addl $-0x2, %edi
addl $0x2, %r10d
testb %cl, %cl
movq 0x30(%rsp), %rax
jns 0x418a3d
addl %r8d, %eax
movl %r15d, %ecx
movq %rcx, 0x18(%rsp)
movl %eax, %r15d
jmp 0x418add
movl %edx, %eax
movq %rax, 0x18(%rsp)
movq %r12, %rdi
xorl %esi, %esi
movq 0x90(%rsp), %rdx
callq 0x401098
movq %rbp, %rdi
xorl %esi, %esi
movq 0x98(%rsp), %rdx
callq 0x401098
incl %r15d
movl %r15d, %ecx
movq 0x10(%rsp), %rsi
subl %esi, %ecx
movq 0x38(%rsp), %rdx
movq (%rdx), %rax
movq 0x8(%rdx), %r13
subq %rax, %r13
shrq $0x2, %r13
subl %esi, %r13d
cmpl %r13d, %ecx
cmovbl %ecx, %r13d
testl %r13d, %r13d
je 0x418b49
movl %esi, %ecx
leaq (%rax,%rcx,4), %rdi
movl %r13d, %edx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x401098
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rax
decl %eax
movq %rax, 0x18(%rsp)
addl %esi, %r13d
xorl %ecx, %ecx
movq %r13, 0x10(%rsp)
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq $0x1b71940, %r13        # imm = 0x1B71940
jmp 0x418ba3
movl %r8d, %ecx
notl %ecx
addl 0x18(%rsp), %ecx
movq 0x28(%rsp), %rdx
addl %r8d, %edx
incl %edx
movq 0x30(%rsp), %rax
leal 0x1(%rax,%r8), %r15d
movl %ecx, %eax
movq %rdx, %rcx
movq %rax, 0x18(%rsp)
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rsi
testb %bl, %bl
je 0x418bae
xorl %eax, %eax
jmp 0x418e3d
movb $0x1, %al
cmpl 0x78(%rdi), %ecx
jne 0x418e3d
movq %rcx, 0x28(%rsp)
movb 0x6(%rsp), %al
testq %r14, %r14
je 0x418c10
movq (%rbp), %rcx
movq (%r12), %rdx
movb $0x1, %al
cmpq %rdx, %rcx
jbe 0x418bda
movb $0x1, %cl
jmp 0x418c10
jae 0x418be0
xorl %ecx, %ecx
jmp 0x418c10
movl $0x1, %ecx
movq %rcx, %rax
cmpq %rax, %r14
je 0x418c0a
movq (%rbp,%rax,8), %rdx
movq (%r12,%rax,8), %rsi
cmpq %rsi, %rdx
ja 0x418c08
leaq 0x1(%rax), %rcx
cmpq %rsi, %rdx
jae 0x418be5
xorl %ecx, %ecx
jmp 0x418c0a
movb $0x1, %cl
cmpq %r14, %rax
setb %al
testb $0x1, %cl
leaq 0x58(%rsp), %rcx
movq %rcx, %rsi
leaq 0x40(%rsp), %rdx
cmovneq %rdx, %rsi
movq 0x10(%rsp), %r13
movl %r13d, %ebx
testb %al, %al
cmoveq %rcx, %rsi
callq 0x419478
movq 0x38(%rsp), %rdx
movq (%rdx), %rcx
movl %eax, (%rcx,%rbx,4)
incl %r13d
movq %r13, 0x10(%rsp)
movq 0x20(%rsp), %rsi
cmpl %esi, %r15d
jae 0x418e24
movq 0x70(%rsp), %rax
movq (%rax), %r9
movq (%rdx), %rax
movq %rax, 0xd0(%rsp)
movq $0x1b71940, %r13        # imm = 0x1B71940
movq %r9, 0x30(%rsp)
movl %r15d, %eax
movzbl (%r9,%rax), %ecx
movb (%r13,%rcx), %cl
testb %cl, %cl
js 0x418e34
cmpq $0x0, 0x78(%rsp)
je 0x418ccc
movq 0xa0(%rsp), %rsi
movq %rsi, %rdx
movq 0x8(%rbp,%rsi,8), %rdi
movq %rdi, %r8
shrq $0x2, %r8
movq %r8, 0x8(%rbp,%rsi,8)
movl %esi, %r8d
movq (%rbp,%r8,8), %r8
shldq $0x3e, %rdi, %r8
movq %r8, 0x8(%rbp,%rsi,8)
decq %rdx
testl %esi, %esi
movq %rdx, %rsi
jne 0x418c9f
shrq $0x2, (%rbp)
movq 0x78(%rsp), %rdx
movq 0xc8(%rsp), %rsi
andq %rsi, (%rbp,%rdx,8)
movb $0x3, %dl
subb %cl, %dl
movzbl %dl, %edx
shlq $0x3e, %rdx
movq 0xa8(%rsp), %rcx
shrq %cl, %rdx
addq %rdx, (%rbp)
movq (%r12), %rcx
shlq $0x2, %rcx
andq 0xb0(%rsp), %rcx
movzbl (%r9,%rax), %eax
movzbl (%r13,%rax), %eax
movq %rcx, (%r12)
cmpl $0x2, %r14d
jb 0x418d51
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, %r14
jne 0x418d2b
movq 0xc0(%rsp), %rcx
shlq %cl, %rax
movq 0xb8(%rsp), %rcx
addq %rax, (%r12,%rcx,8)
movb 0x7(%rsp), %al
testq %r14, %r14
je 0x418dba
movq (%rbp), %rcx
movq (%r12), %rdx
movb $0x1, %al
cmpq %rdx, %rcx
jbe 0x418d84
movb $0x1, %cl
jmp 0x418dba
jae 0x418d8a
xorl %ecx, %ecx
jmp 0x418dba
movl $0x1, %ecx
movq %rcx, %rax
cmpq %rax, %r14
je 0x418db4
movq (%rbp,%rax,8), %rdx
movq (%r12,%rax,8), %rsi
cmpq %rsi, %rdx
ja 0x418db2
leaq 0x1(%rax), %rcx
cmpq %rsi, %rdx
jae 0x418d8f
xorl %ecx, %ecx
jmp 0x418db4
movb $0x1, %cl
cmpq %r14, %rax
setb %al
incl %r15d
testb $0x1, %cl
leaq 0x58(%rsp), %rcx
movq %rcx, %rsi
leaq 0x40(%rsp), %rdx
cmovneq %rdx, %rsi
movq 0x10(%rsp), %rbx
movl %ebx, %r13d
testb %al, %al
cmoveq %rcx, %rsi
movq 0x8(%rsp), %rdi
callq 0x419478
movq 0xd0(%rsp), %rcx
movl %eax, (%rcx,%r13,4)
incl %ebx
movq %rbx, 0x10(%rsp)
movq 0x20(%rsp), %rsi
cmpl %esi, %r15d
movq $0x1b71940, %r13        # imm = 0x1B71940
movq 0x30(%rsp), %r9
jne 0x418c77
xorl %eax, %eax
movq 0x8(%rsp), %rdi
movq 0x28(%rsp), %rcx
jmp 0x418e3d
xorl %eax, %eax
movq $0x1b71940, %r13        # imm = 0x1B71940
movq 0x28(%rsp), %rcx
jmp 0x418e38
xorl %ecx, %ecx
xorl %eax, %eax
movq 0x8(%rsp), %rdi
testb %al, %al
je 0x4189b2
movl 0x10(%rsp), %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 0x418e7e
leaq (%rcx,%rax,4), %rdi
subq %rdi, %rdx
addq $-0x4, %rdx
andq $-0x4, %rdx
addq $0x4, %rdx
xorl %esi, %esi
callq 0x401098
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
leaq 0xe8(%rsp), %rbx
je 0x418e95
callq 0x41b3b0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x418ea4
callq 0x41b3b0
movq 0xd8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x418ec1
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x41b3a0
movb $0x1, %al
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x418eec
callq 0x41b3b0
jmp 0x418eec
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r15, %rdi
je 0x418f09
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x41b3a0
movq %rbx, %rdi
callq 0x4c0230
nop