// File: /workspace/github_cpp_makefile_star2_O1/ratulSharker[P]Havec/src/vector_with_rehash_8_hash_with_N_detection_6_bytes.cpp
// Function: print6ByteHashTableAndVectorStructure(void*, unsigned long long, unsigned int, std::vector<vector_trial_6_byte, std::allocator<vector_trial_6_byte>>*)
void print6ByteHashTableAndVectorStructure(void* blockArr,unsigned long long hashSize, unsigned int kSize,vector<struct vector_trial_6_byte> *mapPointer6Byte)
{
	printf("6 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_6_Byte.txt");
	strcat(vectorFilename, 		"vector_structure_6_byte.txt");
	
	FILE *fp, *fp2;
	fp		=fopen(hashtableFilename, "w");
	fp2 	=fopen(vectorFilename, "w"); 

	    /**
		* dumping the HashTable
		**/
		//its a 6 byte structure
		unsigned long long hashValue 	= 0;
		unsigned long long qutioned 	= 0;
		unsigned short hashFunc			= 0;
		char 		   neighbour		= 0;
		
		khmerInfo6Byte *blockArray6 = (khmerInfo6Byte*) blockArr;
		for(unsigned long long index = 0; index < hashSize;index++)
		{
			//now check specified index is occupied or not
			if((blockArray6[index].data[4] & neighbour_musk) != 0){
				//occupuying here

				//forming the qutioned
				qutioned = blockArray6[index].data[4] & 1; // only the last bit is the part of the qutioned
				qutioned = (qutioned << 8) | blockArray6[index].data[3];
				qutioned = (qutioned << 8) | blockArray6[index].data[2];
				qutioned = (qutioned << 8) | blockArray6[index].data[1];

				//forming the hash value
				hashValue = (hashSize * qutioned) + index;
				hashFunc = (blockArray6[index].data[4] & 0x0E ) >> 1; //mask out the hash function

				//prints the khmer with the count information
				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(blockArray6[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, "-%d\n",blockArray6[index].count);
			}
		}
		
		/**
		* dumping the Vector Strcuture -- 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<mapPointer6Byte[i].size();j++)
			{	
				
				vect_index = mapPointer6Byte[i][j].index_val;
				for(unsigned long long k=0;k < mapPointer6Byte[i][j].vect.size() ; k++)//newly changes in the loop
				{
					//now take steps to print 
					//now check specified index is occupied or not
					if((mapPointer6Byte[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 = mapPointer6Byte[i][j].vect[k].data[4] & 1; // only the last bit is the part of the qutioned
						qutioned = (qutioned << 8) | mapPointer6Byte[i][j].vect[k].data[3];
						qutioned = (qutioned << 8) | mapPointer6Byte[i][j].vect[k].data[2];
						qutioned = (qutioned << 8) | mapPointer6Byte[i][j].vect[k].data[1];

						//forming the hash value
						hashValue = (hashSize * qutioned) + vect_index;
						hashFunc = (mapPointer6Byte[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(mapPointer6Byte[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;
						 }
						
						//prints the khmer with the count information
						fprintf(fp2, "-%d\n", mapPointer6Byte[i][j].vect[k].count);
					}
				}
			}
		}
		
	fclose(fp);
	fclose(fp2);
	
	printf("6 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, %r13
movq %rdi, %rbp
leaq 0x346f(%rip), %rdi      # 0xb5a7
callq 0x33c0
leaq 0x260(%rsp), %rbx
movl $0x200, %edx            # imm = 0x200
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3120
leaq 0x60(%rsp), %r15
movl $0x200, %edx            # imm = 0x200
movq %r15, %rdi
xorl %esi, %esi
callq 0x3120
movq %rbx, %rdi
callq 0x30c0
movabsq $0x2f74757074756f, %r14 # imm = 0x2F74757074756F
movq %r14, 0x260(%rsp,%rax)
movq %r15, %rdi
callq 0x30c0
movq %r14, 0x60(%rsp,%rax)
movq %rbx, %rdi
callq 0x30c0
movabsq $0x7478742e657479, %rcx # imm = 0x7478742E657479
movq %rcx, 0x26d(%rsp,%rax)
movups 0x334b(%rip), %xmm0     # 0xb4fb
movups %xmm0, 0x260(%rsp,%rax)
movq %r15, %rdi
callq 0x30c0
movups 0x3349(%rip), %xmm0     # 0xb510
movups %xmm0, 0x60(%rsp,%rax)
movups 0x3349(%rip), %xmm0     # 0xb51c
movups %xmm0, 0x6c(%rsp,%rax)
leaq 0x3067(%rip), %r12      # 0xb246
movq %rbx, %rdi
movq %r12, %rsi
callq 0x32e0
movq %rax, 0x8(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x32e0
movq %rax, 0x10(%rsp)
movq %r13, 0x18(%rsp)
testq %r13, %r13
je 0x8313
movq %rbp, %rdx
leaq 0x3221(%rip), %rbp      # 0xb438
leaq 0x302a(%rip), %r15      # 0xb248
xorl %r14d, %r14d
movq %rdx, 0x20(%rsp)
leaq (%r14,%r14,2), %rcx
movzbl 0x4(%rdx,%rcx,2), %eax
cmpq $0x10, %rax
jb 0x8305
leaq (%rdx,%rcx,2), %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 0x18(%rsp), %rsi
addq %r14, %rsi
shrb %al
andb $0x7, %al
movzbl %al, %edx
leaq 0x30(%rsp), %rdi
movl 0x4(%rsp), %ecx
callq 0x9fef
movq 0x30(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x32b0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x82a7
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3270
movl $0x10000000, %r12d      # imm = 0x10000000
movl $0x4, %r13d
movzbl 0x4(%rbx), %ecx
movl %r12d, %eax
shrl $0x18, %eax
andl %ecx, %eax
addl $-0x10, %eax
movl $0x20, %edx
cmpl $0x7f, %eax
ja 0x82d2
shrl $0x2, %eax
movl (%rax,%rbp), %edx
movq 0x8(%rsp), %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x3380
addl %r12d, %r12d
decl %r13d
jne 0x82b3
movzbl 0x5(%rbx), %edx
movq 0x8(%rsp), %rdi
leaq 0x3233(%rip), %rsi      # 0xb52c
xorl %eax, %eax
callq 0x3380
movq 0x20(%rsp), %rdx
incq %r14
cmpq 0x18(%rsp), %r14
jne 0x8226
leaq 0x5fd6(%rip), %rax      # 0xe2f0
cmpq $0x0, (%rax)
je 0x84e2
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
xorl %ecx, %ecx
movq %rcx, 0x50(%rsp)
leaq (%rcx,%rcx,2), %rcx
movq 0x28(%rsp), %rdx
movq (%rdx,%rcx,8), %rax
cmpq %rax, 0x8(%rdx,%rcx,8)
je 0x84ca
movq 0x28(%rsp), %rdx
leaq (%rdx,%rcx,8), %r14
xorl %r15d, %r15d
movq %r15, 0x58(%rsp)
shlq $0x5, %r15
movq (%r14), %rdx
movq 0x8(%rdx,%r15), %rcx
cmpq %rcx, 0x10(%rdx,%r15)
je 0x84ab
movq (%rax,%r15), %rax
movq %rax, 0x20(%rsp)
xorl %r13d, %r13d
leaq (,%r13,2), %rbp
addq %r13, %rbp
movzbl 0x4(%rcx,%rbp,2), %eax
cmpq $0x10, %rax
jb 0x8488
leaq (%rcx,%rbp,2), %rcx
movl %eax, %edx
andl $0x1, %edx
movzbl 0x3(%rcx), %esi
shll $0x10, %edx
shll $0x8, %esi
orl %edx, %esi
movzbl 0x2(%rcx), %edx
orl %esi, %edx
shll $0x8, %edx
movzbl 0x1(%rcx), %esi
orq %rdx, %rsi
imulq 0x18(%rsp), %rsi
addq 0x20(%rsp), %rsi
shrb %al
andb $0x7, %al
movzbl %al, %edx
leaq 0x30(%rsp), %rdi
movl 0x4(%rsp), %ecx
callq 0x9fef
movq 0x30(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x32b0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x840b
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3270
movl $0x10000000, %ebx       # imm = 0x10000000
movl $0x4, %r12d
movq (%r14), %rax
movq 0x8(%rax,%r15), %rax
movzbl 0x4(%rax,%rbp,2), %ecx
movl %ebx, %eax
shrl $0x18, %eax
andl %ecx, %eax
addl $-0x10, %eax
movl $0x20, %edx
cmpl $0x7f, %eax
ja 0x8444
shrl $0x2, %eax
leaq 0x2ff7(%rip), %rcx      # 0xb438
movl (%rax,%rcx), %edx
movq 0x10(%rsp), %rdi
leaq 0x2df8(%rip), %rsi      # 0xb248
xorl %eax, %eax
callq 0x3380
addl %ebx, %ebx
decl %r12d
jne 0x8416
movq (%r14), %rax
movq 0x8(%rax,%r15), %rax
movzbl 0x5(%rax,%rbp,2), %edx
movq 0x10(%rsp), %rdi
leaq 0x30b5(%rip), %rsi      # 0xb52c
xorl %eax, %eax
callq 0x3380
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
incq %r13
movq (%r14), %rax
movq 0x8(%rax,%r15), %rcx
movq 0x10(%rax,%r15), %rax
subq %rcx, %rax
sarq %rax
imulq %rsi, %rax
cmpq %rax, %r13
jb 0x8381
movq 0x58(%rsp), %r15
incq %r15
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %rcx, %r15
jb 0x8359
movq 0x50(%rsp), %rcx
incq %rcx
leaq 0x5e17(%rip), %rax      # 0xe2f0
cmpq (%rax), %rcx
jb 0x8330
movq 0x8(%rsp), %rdi
callq 0x3250
movq 0x10(%rsp), %rdi
callq 0x3250
leaq 0x30d7(%rip), %rdi      # 0xb5d4
callq 0x33c0
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq