// File: /workspace/github_cpp_makefile_star2_O2/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, %r9
movq %rdx, %rdi
leaq (%rdx,%rdx,4), %rdx
movzbl 0x4(%rsi,%rdx), %eax
movl %eax, %r10d
shrl %r10d
andl $0x7, %r10d
movl $0x4, %ecx
cmpl %r8d, %r10d
jne 0x3126
addq %rdx, %rsi
cmpb %r9b, (%rsi)
jne 0x3126
movl %r9d, %edx
shrl $0x8, %edx
cmpb %dl, 0x1(%rsi)
jne 0x3126
movl %r9d, %edx
shrl $0x10, %edx
cmpb %dl, 0x2(%rsi)
jne 0x3126
movl %r9d, %edx
shrl $0x18, %edx
cmpb %dl, 0x3(%rsi)
jne 0x3126
andl $0x1, %eax
movq %r9, %rdx
shrq $0x20, %rdx
andl $0x1, %edx
cmpl %eax, %edx
je 0x31e3
pushq %rbp
pushq %r14
pushq %rbx
leaq 0x8163(%rip), %rax      # 0xb294
movl $0x5, %esi
cmpl %r8d, (%rax)
jne 0x31dd
leaq 0x817a(%rip), %r10      # 0xb2c0
movq %rdi, %rax
xorl %edx, %edx
divq (%r10)
movq 0x810b(%rip), %rax      # 0xb260
movslq %edx, %rdx
imulq $0x18, %rdx, %r10
movq (%rax,%r10), %rdx
movq 0x8(%rax,%r10), %rax
cmpq %rax, %rdx
je 0x31dd
cmpq %rdi, (%rdx)
je 0x3175
addq $0x20, %rdx
jmp 0x3165
cmpq %rax, %rdx
je 0x31dd
movq 0x8(%rdx), %rax
movq 0x10(%rdx), %rdx
movl %r9d, %edi
shrl $0x8, %edi
movl %r9d, %r10d
shrl $0x10, %r10d
movl %r9d, %r11d
shrl $0x18, %r11d
movq %r9, %rbx
shrq $0x20, %rbx
andl $0x1, %ebx
cmpq %rdx, %rax
je 0x31dd
movzbl 0x4(%rax), %r14d
movl %r14d, %ebp
shrl %ebp
andl $0x7, %ebp
cmpl %r8d, %ebp
jne 0x31d7
cmpb %r9b, (%rax)
jne 0x31d7
cmpb %dil, 0x1(%rax)
jne 0x31d7
cmpb %r10b, 0x2(%rax)
jne 0x31d7
cmpb %r11b, 0x3(%rax)
jne 0x31d7
andl $0x1, %r14d
cmpl %r14d, %ebx
je 0x31df
addq $0x5, %rax
jmp 0x31a0
movl %esi, %ecx
popq %rbx
popq %r14
popq %rbp
movl %ecx, %eax
retq