// File: /workspace/github_cpp_makefile_star2_O2/ratulSharker[P]Havec/src/vector_with_rehash_8_hash_with_N_detection_5_bytes.cpp
// Function: print5ByteHashTableAndVectorStructure(void*, unsigned long long, unsigned int, std::vector<vector_trial_5_byte, std::allocator<vector_trial_5_byte>>*)
void print5ByteHashTableAndVectorStructure(void* blockArr,unsigned long long hashSize, unsigned int kSize,vector<struct vector_trial_5_byte> *mapPointer5Byte)
{

	printf("5 byte hashtable & vector info dumping began\n");
	char neighbour_musk = 0xF0;

	char hashtableFilename[512],
		 vectorFilename[512];
	memset(hashtableFilename, 0, sizeof(hashtableFilename));
	memset(vectorFilename, 0, sizeof(vectorFilename));

	strcat(hashtableFilename, OUTPUT_DIRECTORY_NAME);
	strcat(vectorFilename, OUTPUT_DIRECTORY_NAME);

	strcat(hashtableFilename, 	"hashtable_5_Byte.txt");
	strcat(vectorFilename, 		"vector_structure_5_byte.txt");
	
	FILE *fp, *fp2;
	fp		=fopen(hashtableFilename, "w");
	fp2 	=fopen(vectorFilename, "w"); 
	
		/**
		* dumping the HashTable
		**/
		//its a 5 byte structure
		unsigned long long hashValue 	= 0;
		unsigned long long qutioned 	= 0;
		unsigned short hashFunc			= 0;
		char 		   neighbour		= 0;
		
		khmerInfo5Byte *blockArray5 = (khmerInfo5Byte*) blockArr;
		for(unsigned long long index = 0; index < hashSize;index++)
		{
			//now check specified index is occupied or not
			if((blockArray5[index].data[4] & neighbour_musk) != 0){
				//occupuying here
				
				//cleaning the syringe to push injection ;) beware of aids :P
				neighbour = hashFunc = qutioned = hashValue = 0;
	
				//forming the qutioned
				qutioned = blockArray5[index].data[4] & 1; // only the last bit is the part of the qutioned
				qutioned = (qutioned << 8) | blockArray5[index].data[3];
				qutioned = (qutioned << 8) | blockArray5[index].data[2];
				qutioned = (qutioned << 8) | blockArray5[index].data[1];

				//forming the hash value
				hashValue = (hashSize * qutioned) + index;
				hashFunc = (blockArray5[index].data[4] & 0x0E ) >> 1; //mask out the hash function
				
				
				
				//prints the khmer
				fprintf(fp, "%s", _revhash(hashValue,hashFunc,kSize).c_str());
				
				char tempMask = 0x10;
				for(unsigned int ii = 0;ii < 4;ii++)
				{
					//looping through this values
					//0001 0000
					//0010 0000
					//0100 0000
					//1000 0000
					neighbour = ' ';
					//forming the neighbour
					switch(blockArray5[index].data[4] & tempMask)//making out the first 4 bit
					{
						case 0x80://found A
							neighbour = 'A';
						break;
						
						case 0x40://found T
							neighbour = 'T';
						break;
						
						case 0x20://found C
							neighbour = 'C';
						break;
						
						case 0x10://found G
							neighbour = 'G';
						break;
					}
					
					fprintf(fp, "-%c", neighbour);
					tempMask = tempMask << 1;
				}
				
				fprintf(fp, "\n");
			}
		}
		
		
		/**
		* dumping the VectorStructure -- using the same variable as dumping the hashtable :)
		**/
		unsigned long long vect_index = 0;
		for(unsigned long long i=0;i<num_of_vector;i++)//number of vector is declared in the common.cpp -- so no need to pass around
		{
			for(unsigned long long j=0;j<mapPointer5Byte[i].size();j++)
			{
				vect_index = mapPointer5Byte[i][j].index_val;
				for(unsigned long long k=0;k < mapPointer5Byte[i][j].vect.size() ; k++)//newly changes in the loop
				{
					//now take steps to print 
					//now check specified index is occupied or not
					if((mapPointer5Byte[i][j].vect[k].data[4] & neighbour_musk) != 0){
						//occupuying here
						
						//cleaning the syringe to push injection ;) beware of aids :P
						neighbour = hashFunc = qutioned = hashValue = 0;
			
						//forming the qutioned
						qutioned = mapPointer5Byte[i][j].vect[k].data[4] & 1; // only the last bit is the part of the qutioned
						qutioned = (qutioned << 8) | mapPointer5Byte[i][j].vect[k].data[3];
						qutioned = (qutioned << 8) | mapPointer5Byte[i][j].vect[k].data[2];
						qutioned = (qutioned << 8) | mapPointer5Byte[i][j].vect[k].data[1];

						//forming the hash value
						hashValue = (hashSize * qutioned) + vect_index;
						hashFunc = (mapPointer5Byte[i][j].vect[k].data[4] & 0x0E ) >> 1; //mask out the hash function
						
						//prints the khmer
						fprintf(fp2, "%s", _revhash(hashValue,hashFunc,kSize).c_str());
						
						char tempMask = 0x10;
						for(unsigned int ii = 0;ii < 4;ii++)
						{
							//looping through this values
							//0001 0000
							//0010 0000
							//0100 0000
							//1000 0000
							neighbour = ' ';
							//forming the neighbour
							switch(mapPointer5Byte[i][j].vect[k].data[4] & tempMask)//making out the first 4 bit
							{
								case 0x80://found A
									neighbour = 'A';
								break;
								
								case 0x40://found T
									neighbour = 'T';
								break;
								
								case 0x20://found C
									neighbour = 'C';
								break;
								
								case 0x10://found G
									neighbour = 'G';
								break;
							}
							
							fprintf(fp2, "-%c", neighbour);
							tempMask = tempMask << 1;
						 }
						
						 fprintf(fp2, "\n");
					}
				}
			}
		}

	fclose(fp);
	fclose(fp2);
	
	printf("5 byte hashtable & vector info dumping ended\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x468, %rsp            # imm = 0x468
movq %rcx, 0x28(%rsp)
movl %edx, 0x4(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, %r13
leaq 0x4b1d(%rip), %rdi      # 0x83d7
callq 0x2390
leaq 0x260(%rsp), %rbx
movl $0x200, %edx            # imm = 0x200
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2120
leaq 0x60(%rsp), %r15
movl $0x200, %edx            # imm = 0x200
movq %r15, %rdi
xorl %esi, %esi
callq 0x2120
movq %rbx, %rdi
callq 0x20b0
movabsq $0x2f74757074756f, %r14 # imm = 0x2F74757074756F
movq %r14, 0x260(%rsp,%rax)
movq %r15, %rdi
callq 0x20b0
movq %r14, 0x60(%rsp,%rax)
movq %rbx, %rdi
callq 0x20b0
movabsq $0x7478742e657479, %rcx # imm = 0x7478742E657479
movq %rcx, 0x26d(%rsp,%rax)
movups 0x48e3(%rip), %xmm0     # 0x8215
movups %xmm0, 0x260(%rsp,%rax)
movq %r15, %rdi
callq 0x20b0
movups 0x48e1(%rip), %xmm0     # 0x822a
movups %xmm0, 0x60(%rsp,%rax)
movups 0x48e1(%rip), %xmm0     # 0x8236
movups %xmm0, 0x6c(%rsp,%rax)
leaq 0x48e5(%rip), %r12      # 0x8246
movq %rbx, %rdi
movq %r12, %rsi
callq 0x22c0
movq %rax, 0x8(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x22c0
movq %rax, %r12
pushq $0x20
popq %rbp
leaq 0x48bf(%rip), %r15      # 0x8248
xorl %edi, %edi
movq %r13, 0x18(%rsp)
cmpq 0x10(%rsp), %rdi
je 0x3a76
leaq (%rdi,%rdi,4), %rbx
movzbl 0x4(%r13,%rbx), %eax
cmpq $0x10, %rax
jb 0x3a6e
addq %r13, %rbx
movl %eax, %ecx
andl $0x1, %ecx
shll $0x8, %ecx
movzbl 0x3(%rbx), %edx
orl %ecx, %edx
movzbl 0x2(%rbx), %ecx
shll $0x10, %edx
shll $0x8, %ecx
orl %edx, %ecx
movzbl 0x1(%rbx), %esi
orq %rcx, %rsi
imulq 0x10(%rsp), %rsi
movq %rdi, 0x20(%rsp)
addq %rdi, %rsi
shrb %al
andb $0x7, %al
movzbl %al, %edx
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movl 0x4(%rsp), %ecx
callq 0x7828
movq 0x40(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x22a0
movq %r14, %rdi
callq 0x20c0
movl $0x10000000, %r13d      # imm = 0x10000000
pushq $0x4
popq %r14
subl $0x1, %r14d
jb 0x3a57
movzbl 0x4(%rbx), %ecx
movl %r13d, %eax
shrl $0x18, %eax
andl %ecx, %eax
addl $-0x10, %eax
movl %ebp, %edx
cmpl $0x7f, %eax
ja 0x3a43
shrl $0x2, %eax
leaq 0x49f4(%rip), %rcx      # 0x8434
movl (%rax,%rcx), %edx
movq 0x8(%rsp), %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2350
addl %r13d, %r13d
jmp 0x3a1a
pushq $0xa
popq %rdi
movq 0x8(%rsp), %rsi
callq 0x2300
movq 0x18(%rsp), %r13
movq 0x20(%rsp), %rdi
incq %rdi
jmp 0x3990
pushq $0x5
popq %rdi
xorl %ecx, %ecx
leaq 0x783e(%rip), %rax      # 0xb2c0
cmpq (%rax), %rcx
jae 0x3be8
movq %rcx, 0x30(%rsp)
imulq $0x18, %rcx, %rax
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax), %r13
movq (%rcx,%rax), %rcx
xorl %ebp, %ebp
movq 0x8(%r13), %rax
subq %rcx, %rax
sarq $0x5, %rax
cmpq %rax, %rbp
jae 0x3bdb
movq %rbp, 0x38(%rsp)
shlq $0x5, %rbp
movq (%rcx,%rbp), %rax
movq %rax, 0x18(%rsp)
xorl %r8d, %r8d
movq 0x8(%rcx,%rbp), %rsi
movq 0x10(%rcx,%rbp), %rax
subq %rsi, %rax
cqto
idivq %rdi
cmpq %rax, %r8
jae 0x3bce
leaq (%r8,%r8,4), %rbx
movzbl 0x4(%rsi,%rbx), %eax
cmpq $0x10, %rax
jb 0x3bc6
movq %r8, 0x20(%rsp)
addq %rbx, %rsi
movl %eax, %ecx
andl $0x1, %ecx
movzbl 0x3(%rsi), %edx
shll $0x10, %ecx
shll $0x8, %edx
orl %ecx, %edx
movzbl 0x2(%rsi), %ecx
orl %edx, %ecx
shll $0x8, %ecx
movzbl 0x1(%rsi), %esi
orq %rcx, %rsi
imulq 0x10(%rsp), %rsi
addq 0x18(%rsp), %rsi
shrb %al
andb $0x7, %al
movzbl %al, %edx
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movl 0x4(%rsp), %ecx
callq 0x7828
movq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0x22a0
movq %r14, %rdi
callq 0x20c0
movl $0x10000000, %r14d      # imm = 0x10000000
pushq $0x4
popq %r15
subl $0x1, %r15d
jb 0x3baf
movq (%r13), %rax
movq 0x8(%rax,%rbp), %rax
movzbl 0x4(%rax,%rbx), %ecx
movl %r14d, %eax
shrl $0x18, %eax
andl %ecx, %eax
addl $-0x10, %eax
pushq $0x20
popq %rdx
cmpl $0x7f, %eax
ja 0x3b99
shrl $0x2, %eax
leaq 0x489e(%rip), %rcx      # 0x8434
movl (%rax,%rcx), %edx
movq %r12, %rdi
leaq 0x46a5(%rip), %rsi      # 0x8248
xorl %eax, %eax
callq 0x2350
addl %r14d, %r14d
jmp 0x3b65
pushq $0xa
popq %rdi
movq %r12, %rsi
callq 0x2300
movq (%r13), %rcx
pushq $0x5
popq %rdi
movq 0x20(%rsp), %r8
incq %r8
jmp 0x3acc
movq 0x38(%rsp), %rbp
incq %rbp
jmp 0x3aa3
movq 0x30(%rsp), %rcx
incq %rcx
jmp 0x3a7b
movq 0x8(%rsp), %rdi
callq 0x2230
movq %r12, %rdi
callq 0x2230
leaq 0x4803(%rip), %rdi      # 0x8404
callq 0x2390
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq