// File: /workspace/github_cpp_makefile_star2_O2/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 0x4084f3
movl %edx, %ebp
testl %eax, %eax
je 0x4084b1
movq (%r14), %rdi
testq %rdi, %rdi
je 0x4084b1
callq 0x413f40
movl %ebp, 0x8(%r14)
movl %ebp, %eax
andl $0x3, %eax
je 0x4084c9
movb $0x4, %cl
subb %al, %cl
movb %cl, 0xc(%r14)
movzbl %cl, %edi
jmp 0x4084d4
movb $0x0, 0xc(%r14)
xorl %edi, %edi
testl %ebp, %ebp
je 0x4084f3
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 0x414e30
movq %rax, (%r14)
movq (%r14), %rdi
movl 0x10(%r14), %edx
shlq $0x3, %rdx
xorl %r15d, %r15d
xorl %esi, %esi
callq 0x401090
movb 0xc(%r14), %al
movq $0x1b6b940, %rcx        # imm = 0x1B6B940
xorl %edx, %edx
xorl %esi, %esi
movl 0x10(%r14), %edi
cmpq %rdi, %r15
jae 0x408604
movq (%r14), %rdi
leaq (%rdi,%r15,8), %rdi
addq $0x7, %rdi
movl 0x8(%r14), %r8d
cmpl %r8d, %edx
jae 0x4085fc
testl %esi, %esi
jne 0x40854c
testb %al, %al
je 0x40854c
decb %al
incl %edx
xorl %esi, %esi
jmp 0x40856d
movl %esi, %r8d
movzbl (%rbx,%r8), %r8d
movb (%rcx,%r8), %r8b
shlb $0x6, %r8b
orb %r8b, (%rdi)
incl %edx
incl %esi
cmpl 0x8(%r14), %esi
je 0x4085fc
testl %esi, %esi
jne 0x40857d
testb %al, %al
je 0x40857d
decb %al
incl %edx
xorl %esi, %esi
jmp 0x40859a
movl %esi, %r8d
movzbl (%rbx,%r8), %r8d
movb (%rcx,%r8), %r8b
shlb $0x4, %r8b
orb %r8b, (%rdi)
incl %edx
incl %esi
cmpl 0x8(%r14), %esi
je 0x4085fc
testl %esi, %esi
jne 0x4085ad
testb %al, %al
je 0x4085ad
decb %al
incl %edx
movb (%rdi), %r8b
xorl %esi, %esi
jmp 0x4085cd
movl %esi, %r8d
movzbl (%rbx,%r8), %r8d
movb (%rcx,%r8), %r8b
shlb $0x2, %r8b
orb (%rdi), %r8b
movb %r8b, (%rdi)
incl %edx
incl %esi
cmpl 0x8(%r14), %esi
je 0x4085fc
movl %esi, %r9d
movzbl (%rbx,%r9), %r9d
orb (%rcx,%r9), %r8b
movb %r8b, (%rdi)
incl %edx
incl %esi
movl 0x8(%r14), %r8d
cmpl %r8d, %esi
je 0x4085fc
movl %edx, %r9d
andl $0x1f, %r9d
decq %rdi
testl %r9d, %r9d
jne 0x408533
incq %r15
jmp 0x408517
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop