// File: /workspace/github_cpp_makefile_star2_O3/ratulSharker[P]Havec/src/vector_with_rehash_8_hash_with_N_detection_5_bytes.cpp
// Function: findGivenKhmer5Byte(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, khmerInfo5Byte*, unsigned long long, unsigned long long, unsigned int)
int findGivenKhmer5Byte(string sample,struct khmerInfo5Byte *memBlock,unsigned long long blockSize, unsigned long long khmer_h,unsigned int whichHashFunc){
		unsigned long long index;
		unsigned long long qutioned; //this value must be under 12bit
		char neighbour_musk = 0xF0;
		
		//cout<<sample << " whichhash::"<<whichHashFunc;
		
		//unsigned char upperQution,lowerQution;//this shit must be unsigned

		//find the index value in the memBlock
		index = khmer_h % blockSize;
		qutioned = khmer_h / blockSize;//this value must be under 12bit
		
		//cout<<"rechecking blcoksize "<<blockSize<<" index "<<index<<" khmer_h "<<khmer_h<<endl;

		/*lowerQution = (qutioned & 0xFF);
		upperQution = ((qutioned & 0x0F00) >> 8);
		*/

		//check that index in the memBlock
		//1.neighbour table
		//2.qutioned table
		if(((memBlock[index].data[4] >> 1) & 0x07) == whichHashFunc && //hash value matched
			(memBlock[index].data[0] == (qutioned & 0xFF)) &&
			(memBlock[index].data[1] == (qutioned & 0xFF00)>>8) &&
			(memBlock[index].data[2] == (qutioned & 0xFF0000)>>16) &&
			(memBlock[index].data[3] == (qutioned & 0xFF000000)>>24) &&
			((memBlock[index].data[4] & 0x01) == ((qutioned & 0x0100000000) >> 32))){

			return FOUND;
		}
		else if(whichHashFunc == LAST_HASH_FUNC){
			//cout<<"asche 01 for "<<sample<<endl;//delete this
			vector<struct vector_trial_5_byte>::iterator it;
			int index_v=index%num_of_vector;
			int index_vect=0;
			for(it = mapPointer5Byte[index_v].begin();it!=mapPointer5Byte[index_v].end();it++)
			{
				if(it->index_val == index)
				{
					break;
				}
				index_vect++;
			}
			if(it == mapPointer5Byte[index_v].end())
			{
				//cout<<"asche 02 for "<<sample<<" searching in "<<index_v<<" for memblock index "<<index<<" hash func no "<<whichHashFunc<<endl;//delete this
				return NOT_FOUND;
			}
			else
			{	//its actuallty found
				//cout<<"asche 03 for "<<sample<<endl;//delete this
				bool isFound = false;
				for(std::vector<khmerInfo5Byte>::iterator pi = mapPointer5Byte[index_v][index_vect].vect.begin();
						pi != mapPointer5Byte[index_v][index_vect].vect.end() ; pi++)
				{
					if(
						((pi->data[4] >> 1) & 0x07) == whichHashFunc && //hash value matched
						(pi->data[0] == (qutioned & 0xFF)) &&
						(pi->data[1] == (qutioned & 0xFF00)>>8) &&
						(pi->data[2] == (qutioned & 0xFF0000)>>16) &&
						(pi->data[3] == (qutioned & 0xFF000000)>>24) &&
						((pi->data[4] & 0x01) == ((qutioned & 0x0100000000) >> 32))){
					//(pi->data[0] == (qutioned & 0xFF)) && ((pi->data[1] & 0x0F) == ((qutioned & 0x0F00) >> 8))){
						//cout<<"asche 04 for "<<sample<<endl;//delete this
						isFound = true;
						break;
					}
				}
				if(isFound==true)
					return FOUND;
				else
					return NOT_FOUND;
			}
				
		}
	return NOT_FOUND;
}

// Assembly:
movq %rcx, %rax
movq %rdx, %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %rcx
movq %rdx, %rdi
leaq (%rdx,%rdx,4), %rdx
movzbl 0x4(%rsi,%rdx), %eax
movl %eax, %r9d
shrl %r9d
andl $0x7, %r9d
cmpl %r8d, %r9d
jne 0x4654
addq %rdx, %rsi
cmpb %cl, (%rsi)
jne 0x4654
movl %ecx, %edx
shrl $0x8, %edx
cmpb %dl, 0x1(%rsi)
jne 0x4654
movl %ecx, %edx
shrl $0x10, %edx
cmpb %dl, 0x2(%rsi)
jne 0x4654
movl %ecx, %edx
shrl $0x18, %edx
cmpb %dl, 0x3(%rsi)
jne 0x4654
andl $0x1, %eax
movq %rcx, %rdx
shrq $0x20, %rdx
andl $0x1, %edx
movl $0x4, %esi
cmpl %eax, %edx
je 0x4725
pushq %rbp
pushq %rbx
leaq 0x9c57(%rip), %rax      # 0xe2b4
movl $0x5, %esi
cmpl %r8d, (%rax)
jne 0x4723
leaq 0x9c6e(%rip), %r10      # 0xe2e0
xorl %r9d, %r9d
movq %rdi, %rax
xorl %edx, %edx
divq (%r10)
movq 0x9bfc(%rip), %rax      # 0xe280
movslq %edx, %rdx
leaq (%rdx,%rdx,2), %r10
movq (%rax,%r10,8), %rdx
movq 0x8(%rax,%r10,8), %rax
movq %rdx, %r10
cmpq %rax, %rdx
je 0x46b6
movq %rdx, %r10
cmpq %rdi, (%r10)
je 0x46b3
incl %r9d
addq $0x20, %r10
cmpq %rax, %r10
jne 0x469f
movq %rax, %r10
movl %r9d, %r9d
cmpq %rax, %r10
je 0x4723
shlq $0x5, %r9
movq 0x8(%rdx,%r9), %rax
movq 0x10(%rdx,%r9), %rdx
cmpq %rdx, %rax
je 0x4723
movl %ecx, %edi
shrl $0x8, %edi
movl %ecx, %r9d
shrl $0x10, %r9d
movl %ecx, %r10d
shrl $0x18, %r10d
movq %rcx, %r11
shrq $0x20, %r11
andl $0x1, %r11d
movzbl 0x4(%rax), %ebx
movl %ebx, %ebp
shrl %ebp
andl $0x7, %ebp
cmpl %r8d, %ebp
jne 0x471a
cmpb %cl, (%rax)
jne 0x471a
cmpb %dil, 0x1(%rax)
jne 0x471a
cmpb %r9b, 0x2(%rax)
jne 0x471a
cmpb %r10b, 0x3(%rax)
jne 0x471a
andl $0x1, %ebx
cmpl %ebx, %r11d
je 0x4728
addq $0x5, %rax
cmpq %rdx, %rax
jne 0x46ec
popq %rbx
popq %rbp
movl %esi, %eax
retq
movl $0x4, %esi
jmp 0x4723