// File: /workspace/github_cpp_makefile_star2_O3/ChnMasterOG[P]KmerGO2/kmergo/../kmc_api/kmer_api.h
// Function: bool CKmerAPI::from_string_impl<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>(__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, unsigned int)
inline bool from_string_impl(const RandomAccessIterator iter, uint32 len)
	{
		unsigned char c_char;
		uchar c_binary;
		uchar temp_byte_alignment;
		if (kmer_length != len)
		{
			if (kmer_length && kmer_data)
				delete[] kmer_data;

			kmer_length = len;

			if (kmer_length % 4)
				byte_alignment = 4 - (kmer_length % 4);
			else
				byte_alignment = 0;


			if (kmer_length != 0)
			{
				no_of_rows = (((kmer_length + byte_alignment) % 32) ? (kmer_length + byte_alignment) / 32 + 1 : (kmer_length + byte_alignment) / 32);
				//no_of_rows = (int)ceil((double)(kmer_length + byte_alignment) / 32);
				kmer_data = new uint64[no_of_rows];
				//memset(kmer_data, 0, sizeof(*kmer_data) * no_of_rows);
			}
		}

		memset(kmer_data, 0, sizeof(*kmer_data) * no_of_rows);
		temp_byte_alignment = byte_alignment;
		uint32 i = 0;
		uint32 i_in_string = 0;
		uchar *byte_ptr;

		for (uint32 row_index = 0; row_index < no_of_rows; row_index++)
		{
			byte_ptr = reinterpret_cast<uchar*>(&kmer_data[row_index]);
			byte_ptr += 7;					// shift a pointer towards a MSB

			while (i < kmer_length)
			{
				if ((i_in_string == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
				{
					temp_byte_alignment--;
					i++;
				}
				else
				{
					c_char = *(iter + i_in_string);
					c_binary = num_codes[c_char];
					c_binary = c_binary << 6;		//11000000
					*byte_ptr = *byte_ptr | c_binary;
					i++;
					i_in_string++;
					if (i_in_string == kmer_length) break;
				}

				if ((i_in_string == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
				{
					temp_byte_alignment--;
					i++;
				}
				else
				{
					c_char = *(iter + i_in_string);
					c_binary = num_codes[c_char];
					c_binary = c_binary << 4;
					*byte_ptr = *byte_ptr | c_binary;
					i++;
					i_in_string++;
					if (i_in_string == kmer_length) break;
				}

				//!!!if((i == 0) && temp_byte_alignment)	//poprawka zg3oszona przez Maaka D3ugosza			// check if a byte_alignment placed before a prefix is to be skipped
				if ((i_in_string == 0) && temp_byte_alignment)				// check if a byte_alignment placed before a prefix is to be skipped
				{
					temp_byte_alignment--;
					i++;
				}
				else
				{
					c_char = *(iter + i_in_string);
					c_binary = num_codes[c_char];
					c_binary = c_binary << 2;
					*byte_ptr = *byte_ptr | c_binary;
					i++;
					i_in_string++;
					if (i_in_string == kmer_length) break;
				}

				c_char = *(iter + i_in_string);
				c_binary = num_codes[c_char];
				*byte_ptr = *byte_ptr | c_binary;
				i++;
				i_in_string++;
				if (i_in_string == kmer_length) break;

				if (i % 32 == 0)
					break; //check if a new "row" is to be started
				byte_ptr--;
			}
		};
		return true;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl 0x8(%rdi), %eax
cmpl %edx, %eax
je 0x40b0f9
movl %edx, %ebp
testl %eax, %eax
je 0x40b0b7
movq (%r14), %rdi
testq %rdi, %rdi
je 0x40b0b7
callq 0x41aea0
movl %ebp, 0x8(%r14)
movl %ebp, %eax
andl $0x3, %eax
je 0x40b0cf
movb $0x4, %cl
subb %al, %cl
movb %cl, 0xc(%r14)
movzbl %cl, %edi
jmp 0x40b0da
movb $0x0, 0xc(%r14)
xorl %edi, %edi
testl %ebp, %ebp
je 0x40b0f9
addl %ebp, %edi
movl %edi, %eax
andl $0x1f, %eax
shrl $0x5, %edi
cmpl $0x1, %eax
sbbl $-0x1, %edi
movl %edi, 0x10(%r14)
shll $0x3, %edi
callq 0x41bd90
movq %rax, (%r14)
movq (%r14), %rdi
movl 0x10(%r14), %edx
shlq $0x3, %rdx
xorl %r15d, %r15d
xorl %esi, %esi
callq 0x401098
movl 0x10(%r14), %edi
testl %edi, %edi
je 0x40b229
movb 0xc(%r14), %al
movl 0x8(%r14), %r8d
movq $0x1b70940, %rcx        # imm = 0x1B70940
xorl %edx, %edx
xorl %esi, %esi
cmpl %r8d, %esi
jae 0x40b21a
movq (%r14), %rdi
leaq (%rdi,%rdx,8), %rdi
addq $0x7, %rdi
testl %r15d, %r15d
jne 0x40b153
testb %al, %al
je 0x40b153
decb %al
incl %esi
xorl %r15d, %r15d
jmp 0x40b178
movl %r15d, %r8d
movzbl (%rbx,%r8), %r8d
movb (%rcx,%r8), %r8b
shlb $0x6, %r8b
orb %r8b, (%rdi)
incl %esi
incl %r15d
movl %r15d, %r8d
cmpl 0x8(%r14), %r15d
je 0x40b216
testl %r15d, %r15d
jne 0x40b18a
testb %al, %al
je 0x40b18a
decb %al
incl %esi
xorl %r15d, %r15d
jmp 0x40b1ab
movl %r15d, %r8d
movzbl (%rbx,%r8), %r8d
movb (%rcx,%r8), %r8b
shlb $0x4, %r8b
orb %r8b, (%rdi)
incl %esi
incl %r15d
movl %r15d, %r8d
cmpl 0x8(%r14), %r15d
je 0x40b216
testl %r15d, %r15d
jne 0x40b1c0
testb %al, %al
je 0x40b1c0
decb %al
incl %esi
movb (%rdi), %r9b
xorl %r15d, %r15d
jmp 0x40b1e4
movl %r15d, %r8d
movzbl (%rbx,%r8), %r8d
movb (%rcx,%r8), %r9b
shlb $0x2, %r9b
orb (%rdi), %r9b
movb %r9b, (%rdi)
incl %esi
incl %r15d
movl %r15d, %r8d
cmpl 0x8(%r14), %r15d
je 0x40b216
movl %r15d, %r8d
movzbl (%rbx,%r8), %r8d
orb (%rcx,%r8), %r9b
movb %r9b, (%rdi)
incl %esi
incl %r15d
movl 0x8(%r14), %r8d
cmpl %r8d, %r15d
je 0x40b216
movl %esi, %r9d
andl $0x1f, %r9d
je 0x40b216
decq %rdi
cmpl %r8d, %esi
jb 0x40b141
movl 0x10(%r14), %edi
incq %rdx
movl %edi, %r9d
cmpq %r9, %rdx
jb 0x40b12d
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq