// File: 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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rsi, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movl 0x8(%rax), %eax
cmpl -0x14(%rbp), %eax
je 0x40c47e
movq -0x58(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x40c3c7
movq -0x58(%rbp), %rax
cmpq $0x0, (%rax)
je 0x40c3c7
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x40c3c5
movq -0x60(%rbp), %rdi
callq 0x42eca0
jmp 0x40c3c7
movq -0x58(%rbp), %rax
movl -0x14(%rbp), %ecx
movl %ecx, 0x8(%rax)
movl 0x8(%rax), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x40c3f2
movq -0x58(%rbp), %rax
movl 0x8(%rax), %edx
andl $0x3, %edx
movl $0x4, %ecx
subl %edx, %ecx
movb %cl, 0xc(%rax)
jmp 0x40c3fa
movq -0x58(%rbp), %rax
movb $0x0, 0xc(%rax)
movq -0x58(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x40c47c
movq -0x58(%rbp), %rcx
movl 0x8(%rcx), %eax
movzbl 0xc(%rcx), %ecx
addl %ecx, %eax
andl $0x1f, %eax
cmpl $0x0, %eax
je 0x40c431
movq -0x58(%rbp), %rcx
movl 0x8(%rcx), %eax
movzbl 0xc(%rcx), %ecx
addl %ecx, %eax
shrl $0x5, %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x40c444
movq -0x58(%rbp), %rcx
movl 0x8(%rcx), %eax
movzbl 0xc(%rcx), %ecx
addl %ecx, %eax
shrl $0x5, %eax
movl %eax, -0x64(%rbp)
movq -0x58(%rbp), %rax
movl -0x64(%rbp), %ecx
movl %ecx, 0x10(%rax)
movl 0x10(%rax), %eax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x42fb90
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
jmp 0x40c47e
movq -0x58(%rbp), %rax
movq (%rax), %rdi
movl 0x10(%rax), %eax
movl %eax, %edx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x401090
movq -0x58(%rbp), %rax
movb 0xc(%rax), %al
movb %al, -0x17(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x58(%rbp), %rcx
movl -0x2c(%rbp), %eax
cmpl 0x10(%rcx), %eax
jae 0x40c74d
movq -0x58(%rbp), %rax
movq (%rax), %rax
movl -0x2c(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
addq $0x7, %rax
movq %rax, -0x28(%rbp)
movq -0x58(%rbp), %rcx
movl -0x1c(%rbp), %eax
cmpl 0x8(%rcx), %eax
jae 0x40c73d
cmpl $0x0, -0x20(%rbp)
jne 0x40c514
cmpb $0x0, -0x17(%rbp)
je 0x40c514
movb -0x17(%rbp), %al
addb $-0x1, %al
movb %al, -0x17(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x40c58b
movl -0x20(%rbp), %eax
movl %eax, %esi
leaq -0x8(%rbp), %rdi
callq 0x40c760
movq %rax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x40c7a0
movq -0x58(%rbp), %rcx
movb (%rax), %al
movb %al, -0x15(%rbp)
movzbl -0x15(%rbp), %eax
movl %eax, %edx
movq $0x1b8f8e0, %rax        # imm = 0x1B8F8E0
movb (%rax,%rdx), %al
movb %al, -0x16(%rbp)
movzbl -0x16(%rbp), %eax
shll $0x6, %eax
movb %al, -0x16(%rbp)
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
movzbl -0x16(%rbp), %edx
orl %edx, %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movb %dl, (%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl 0x8(%rcx), %eax
jne 0x40c589
jmp 0x40c73d
jmp 0x40c58b
cmpl $0x0, -0x20(%rbp)
jne 0x40c5aa
cmpb $0x0, -0x17(%rbp)
je 0x40c5aa
movb -0x17(%rbp), %al
addb $-0x1, %al
movb %al, -0x17(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x40c621
movl -0x20(%rbp), %eax
movl %eax, %esi
leaq -0x8(%rbp), %rdi
callq 0x40c760
movq %rax, -0x40(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x40c7a0
movq -0x58(%rbp), %rcx
movb (%rax), %al
movb %al, -0x15(%rbp)
movzbl -0x15(%rbp), %eax
movl %eax, %edx
movq $0x1b8f8e0, %rax        # imm = 0x1B8F8E0
movb (%rax,%rdx), %al
movb %al, -0x16(%rbp)
movzbl -0x16(%rbp), %eax
shll $0x4, %eax
movb %al, -0x16(%rbp)
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
movzbl -0x16(%rbp), %edx
orl %edx, %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movb %dl, (%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl 0x8(%rcx), %eax
jne 0x40c61f
jmp 0x40c73d
jmp 0x40c621
cmpl $0x0, -0x20(%rbp)
jne 0x40c640
cmpb $0x0, -0x17(%rbp)
je 0x40c640
movb -0x17(%rbp), %al
addb $-0x1, %al
movb %al, -0x17(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x40c6b7
movl -0x20(%rbp), %eax
movl %eax, %esi
leaq -0x8(%rbp), %rdi
callq 0x40c760
movq %rax, -0x48(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x40c7a0
movq -0x58(%rbp), %rcx
movb (%rax), %al
movb %al, -0x15(%rbp)
movzbl -0x15(%rbp), %eax
movl %eax, %edx
movq $0x1b8f8e0, %rax        # imm = 0x1B8F8E0
movb (%rax,%rdx), %al
movb %al, -0x16(%rbp)
movzbl -0x16(%rbp), %eax
shll $0x2, %eax
movb %al, -0x16(%rbp)
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
movzbl -0x16(%rbp), %edx
orl %edx, %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movb %dl, (%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl 0x8(%rcx), %eax
jne 0x40c6b5
jmp 0x40c73d
jmp 0x40c6b7
movl -0x20(%rbp), %eax
movl %eax, %esi
leaq -0x8(%rbp), %rdi
callq 0x40c760
movq %rax, -0x50(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x40c7a0
movq -0x58(%rbp), %rcx
movb (%rax), %al
movb %al, -0x15(%rbp)
movzbl -0x15(%rbp), %eax
movl %eax, %edx
movq $0x1b8f8e0, %rax        # imm = 0x1B8F8E0
movb (%rax,%rdx), %al
movb %al, -0x16(%rbp)
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
movzbl -0x16(%rbp), %edx
orl %edx, %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movb %dl, (%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl 0x8(%rcx), %eax
jne 0x40c71f
jmp 0x40c73d
movl -0x1c(%rbp), %eax
andl $0x1f, %eax
cmpl $0x0, %eax
jne 0x40c72c
jmp 0x40c73d
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x40c4e5
jmp 0x40c73f
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x40c4b4
movb $0x1, %al
andb $0x1, %al
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)