// File: /workspace/github_cpp_makefile_star2_O3/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, %r14
movq %rdi, %rbp
leaq 0x61e9(%rip), %rdi      # 0xb3d7
callq 0x33a0
leaq 0x260(%rsp), %r15
movl $0x200, %edx            # imm = 0x200
movq %r15, %rdi
xorl %esi, %esi
callq 0x3120
leaq 0x60(%rsp), %r12
movl $0x200, %edx            # imm = 0x200
movq %r12, %rdi
xorl %esi, %esi
callq 0x3120
movq %r15, %rdi
callq 0x30c0
movabsq $0x2f74757074756f, %rbx # imm = 0x2F74757074756F
movq %rbx, 0x260(%rsp,%rax)
movq %r12, %rdi
callq 0x30c0
movq %rbx, 0x60(%rsp,%rax)
movq %r15, %rdi
callq 0x30c0
movabsq $0x7478742e657479, %rcx # imm = 0x7478742E657479
movq %rcx, 0x26d(%rsp,%rax)
movups 0x5faf(%rip), %xmm0     # 0xb215
movups %xmm0, 0x260(%rsp,%rax)
movq %r12, %rdi
callq 0x30c0
movups 0x5fad(%rip), %xmm0     # 0xb22a
movups %xmm0, 0x60(%rsp,%rax)
movups 0x5fad(%rip), %xmm0     # 0xb236
movups %xmm0, 0x6c(%rsp,%rax)
leaq 0x5fb1(%rip), %r13      # 0xb246
movq %r15, %rdi
movq %r13, %rsi
callq 0x32d0
movq %rax, 0x8(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x32d0
movq %rax, 0x10(%rsp)
movq %r14, 0x18(%rsp)
testq %r14, %r14
je 0x53ca
movq %rbp, %rcx
leaq 0x6167(%rip), %r15      # 0xb434
leaq 0x5f74(%rip), %r13      # 0xb248
xorl %ebp, %ebp
movq %rcx, 0x20(%rsp)
leaq (,%rbp,4), %r14
addq %rbp, %r14
movzbl 0x4(%rcx,%r14), %eax
cmpq $0x10, %rax
jb 0x53bc
addq %rcx, %r14
movl %eax, %ecx
andl $0x1, %ecx
shll $0x8, %ecx
movzbl 0x3(%r14), %edx
orl %ecx, %edx
movzbl 0x2(%r14), %ecx
shll $0x10, %edx
shll $0x8, %ecx
orl %edx, %ecx
movzbl 0x1(%r14), %esi
orq %rcx, %rsi
imulq 0x18(%rsp), %rsi
addq %rbp, %rsi
shrb %al
andb $0x7, %al
movzbl %al, %edx
leaq 0x30(%rsp), %rdi
movl 0x4(%rsp), %ecx
callq 0xa3de
movq 0x30(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x32a0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x5366
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3260
movl $0x10000000, %r12d      # imm = 0x10000000
movl $0x4, %ebx
movzbl 0x4(%r14), %ecx
movl %r12d, %eax
shrl $0x18, %eax
andl %ecx, %eax
addl $-0x10, %eax
movl $0x20, %edx
cmpl $0x7f, %eax
ja 0x5392
shrl $0x2, %eax
movl (%rax,%r15), %edx
movq 0x8(%rsp), %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x3360
addl %r12d, %r12d
decl %ebx
jne 0x5371
movl $0xa, %edi
movq 0x8(%rsp), %rsi
callq 0x3310
movq 0x20(%rsp), %rcx
incq %rbp
cmpq 0x18(%rsp), %rbp
jne 0x52db
leaq 0x8f0f(%rip), %rax      # 0xe2e0
movq (%rax), %rcx
testq %rcx, %rcx
movq 0x28(%rsp), %rdi
je 0x558a
movabsq $-0x3333333333333333, %r8 # imm = 0xCCCCCCCCCCCCCCCD
xorl %r9d, %r9d
leaq (%r9,%r9,2), %rsi
movq (%rdi,%rsi,8), %rax
movq 0x8(%rdi,%rsi,8), %rdx
cmpq %rax, %rdx
je 0x557e
movq %r9, 0x50(%rsp)
leaq (%rdi,%rsi,8), %rbp
xorl %esi, %esi
movq %rsi, %r14
shlq $0x5, %r14
movq 0x8(%rax,%r14), %rcx
cmpq %rcx, 0x10(%rax,%r14)
je 0x5554
movq %rsi, 0x58(%rsp)
movq (%rax,%r14), %rdx
movq %rdx, 0x20(%rsp)
xorl %r15d, %r15d
leaq (%r15,%r15,4), %r13
movzbl 0x4(%rcx,%r13), %edx
cmpq $0x10, %rdx
jb 0x552e
addq %r13, %rcx
movl %edx, %eax
andl $0x1, %eax
movzbl 0x3(%rcx), %esi
shll $0x10, %eax
shll $0x8, %esi
orl %eax, %esi
movzbl 0x2(%rcx), %eax
orl %esi, %eax
shll $0x8, %eax
movzbl 0x1(%rcx), %esi
orq %rax, %rsi
imulq 0x18(%rsp), %rsi
addq 0x20(%rsp), %rsi
shrb %dl
andb $0x7, %dl
movzbl %dl, %edx
leaq 0x30(%rsp), %rdi
movl 0x4(%rsp), %ecx
callq 0xa3de
movq 0x30(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x32a0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x54bc
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3260
movl $0x10000000, %ebx       # imm = 0x10000000
movl $0x4, %r12d
movq (%rbp), %rax
movq 0x8(%rax,%r14), %rax
movzbl 0x4(%rax,%r13), %ecx
movl %ebx, %eax
shrl $0x18, %eax
andl %ecx, %eax
addl $-0x10, %eax
movl $0x20, %edx
cmpl $0x7f, %eax
ja 0x54f7
shrl $0x2, %eax
leaq 0x5f40(%rip), %rcx      # 0xb434
movl (%rax,%rcx), %edx
movq 0x10(%rsp), %rdi
leaq 0x5d45(%rip), %rsi      # 0xb248
xorl %eax, %eax
callq 0x3360
addl %ebx, %ebx
decl %r12d
jne 0x54c7
movl $0xa, %edi
movq 0x10(%rsp), %rsi
callq 0x3310
movq (%rbp), %rax
movabsq $-0x3333333333333333, %r8 # imm = 0xCCCCCCCCCCCCCCCD
incq %r15
movq 0x8(%rax,%r14), %rcx
movq 0x10(%rax,%r14), %rdx
subq %rcx, %rdx
imulq %r8, %rdx
cmpq %rdx, %r15
jb 0x5438
movq 0x8(%rbp), %rdx
movq 0x58(%rsp), %rsi
incq %rsi
movq %rdx, %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %rcx, %rsi
jb 0x5410
leaq 0x8d6f(%rip), %rax      # 0xe2e0
movq (%rax), %rcx
movq 0x28(%rsp), %rdi
movq 0x50(%rsp), %r9
incq %r9
cmpq %rcx, %r9
jb 0x53ef
movq 0x8(%rsp), %rdi
callq 0x3240
movq 0x10(%rsp), %rdi
callq 0x3240
leaq 0x5e5f(%rip), %rdi      # 0xb404
callq 0x33a0
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq