// File: 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
movq %rsp, %rbp
subq $0x530, %rsp            # imm = 0x530
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
leaq 0x51aa(%rip), %rdi      # 0x116cb
movb $0x0, %al
callq 0x3070
movb $-0x10, -0x21(%rbp)
leaq -0x230(%rbp), %rdi
xorl %esi, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x3160
leaq -0x430(%rbp), %rdi
xorl %esi, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x3160
leaq -0x230(%rbp), %rdi
leaq 0x4aa6(%rip), %rsi      # 0x11006
callq 0x3560
leaq -0x430(%rbp), %rdi
leaq 0x4a93(%rip), %rsi      # 0x11006
callq 0x3560
leaq -0x230(%rbp), %rdi
leaq 0x5173(%rip), %rsi      # 0x116f9
callq 0x3560
leaq -0x430(%rbp), %rdi
leaq 0x5175(%rip), %rsi      # 0x1170e
callq 0x3560
leaq -0x230(%rbp), %rdi
leaq 0x4db8(%rip), %rsi      # 0x11364
callq 0x33c0
movq %rax, -0x438(%rbp)
leaq -0x430(%rbp), %rdi
leaq 0x4d9e(%rip), %rsi      # 0x11364
callq 0x33c0
movq %rax, -0x440(%rbp)
movq $0x0, -0x448(%rbp)
movq $0x0, -0x450(%rbp)
movw $0x0, -0x452(%rbp)
movb $0x0, -0x453(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x460(%rbp)
movq $0x0, -0x468(%rbp)
movq -0x468(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0xc8a1
movq -0x460(%rbp), %rax
imulq $0x6, -0x468(%rbp), %rcx
addq %rcx, %rax
movzbl 0x4(%rax), %eax
movsbl -0x21(%rbp), %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0xc888
movq -0x460(%rbp), %rax
imulq $0x6, -0x468(%rbp), %rcx
addq %rcx, %rax
movzbl 0x4(%rax), %eax
andl $0x1, %eax
cltq
movq %rax, -0x450(%rbp)
movq -0x450(%rbp), %rax
shlq $0x8, %rax
movq -0x460(%rbp), %rcx
imulq $0x6, -0x468(%rbp), %rdx
addq %rdx, %rcx
movzbl 0x3(%rcx), %ecx
orq %rcx, %rax
movq %rax, -0x450(%rbp)
movq -0x450(%rbp), %rax
shlq $0x8, %rax
movq -0x460(%rbp), %rcx
imulq $0x6, -0x468(%rbp), %rdx
addq %rdx, %rcx
movzbl 0x2(%rcx), %ecx
orq %rcx, %rax
movq %rax, -0x450(%rbp)
movq -0x450(%rbp), %rax
shlq $0x8, %rax
movq -0x460(%rbp), %rcx
imulq $0x6, -0x468(%rbp), %rdx
addq %rdx, %rcx
movzbl 0x1(%rcx), %ecx
orq %rcx, %rax
movq %rax, -0x450(%rbp)
movq -0x10(%rbp), %rax
imulq -0x450(%rbp), %rax
addq -0x468(%rbp), %rax
movq %rax, -0x448(%rbp)
movq -0x460(%rbp), %rax
imulq $0x6, -0x468(%rbp), %rcx
addq %rcx, %rax
movzbl 0x4(%rax), %eax
andl $0xe, %eax
sarl %eax
movw %ax, -0x452(%rbp)
movq -0x438(%rbp), %rax
movq %rax, -0x4e0(%rbp)
movq -0x448(%rbp), %rsi
movw -0x452(%rbp), %ax
movl -0x14(%rbp), %ecx
leaq -0x488(%rbp), %rdi
movzwl %ax, %edx
callq 0x103d0
leaq -0x488(%rbp), %rdi
callq 0x3110
movq -0x4e0(%rbp), %rdi
movq %rax, %rdx
leaq 0x4bf8(%rip), %rsi      # 0x11366
movb $0x0, %al
callq 0x3490
leaq -0x488(%rbp), %rdi
callq 0x31b0
movb $0x10, -0x489(%rbp)
movl $0x0, -0x490(%rbp)
cmpl $0x4, -0x490(%rbp)
jae 0xc85d
movb $0x20, -0x453(%rbp)
movq -0x460(%rbp), %rax
movq -0x468(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
movzbl 0x4(%rax,%rcx,2), %eax
movsbl -0x489(%rbp), %ecx
andl %ecx, %eax
movl %eax, -0x4e4(%rbp)
subl $0x10, %eax
je 0xc817
jmp 0xc7d3
movl -0x4e4(%rbp), %eax
subl $0x20, %eax
je 0xc80e
jmp 0xc7e0
movl -0x4e4(%rbp), %eax
subl $0x40, %eax
je 0xc805
jmp 0xc7ed
movl -0x4e4(%rbp), %eax
subl $0x80, %eax
jne 0xc81e
jmp 0xc7fc
movb $0x41, -0x453(%rbp)
jmp 0xc81e
movb $0x54, -0x453(%rbp)
jmp 0xc81e
movb $0x43, -0x453(%rbp)
jmp 0xc81e
movb $0x47, -0x453(%rbp)
movq -0x438(%rbp), %rdi
movsbl -0x453(%rbp), %edx
leaq 0x4b36(%rip), %rsi      # 0x11369
movb $0x0, %al
callq 0x3490
movsbl -0x489(%rbp), %eax
shll %eax
movb %al, -0x489(%rbp)
movl -0x490(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x490(%rbp)
jmp 0xc792
movq -0x438(%rbp), %rdi
movq -0x460(%rbp), %rax
imulq $0x6, -0x468(%rbp), %rcx
addq %rcx, %rax
movzbl 0x5(%rax), %edx
leaq 0x4ea9(%rip), %rsi      # 0x1172a
movb $0x0, %al
callq 0x3490
jmp 0xc88a
movq -0x468(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x468(%rbp)
jmp 0xc60e
movq $0x0, -0x498(%rbp)
movq $0x0, -0x4a0(%rbp)
movq -0x4a0(%rbp), %rax
leaq 0xaabb(%rip), %rcx      # 0x17380
cmpq (%rcx), %rax
jae 0xcd84
movq $0x0, -0x4a8(%rbp)
movq -0x4a8(%rbp), %rax
movq %rax, -0x4f0(%rbp)
movq -0x20(%rbp), %rdi
imulq $0x18, -0x4a0(%rbp), %rax
addq %rax, %rdi
callq 0xd8a0
movq %rax, %rcx
movq -0x4f0(%rbp), %rax
cmpq %rcx, %rax
jae 0xcd6b
movq -0x20(%rbp), %rdi
imulq $0x18, -0x4a0(%rbp), %rax
addq %rax, %rdi
movq -0x4a8(%rbp), %rsi
callq 0xd8c0
movq (%rax), %rax
movq %rax, -0x498(%rbp)
movq $0x0, -0x4b0(%rbp)
movq -0x4b0(%rbp), %rax
movq %rax, -0x4f8(%rbp)
movq -0x20(%rbp), %rdi
imulq $0x18, -0x4a0(%rbp), %rax
addq %rax, %rdi
movq -0x4a8(%rbp), %rsi
callq 0xd8c0
movq %rax, %rdi
addq $0x8, %rdi
callq 0xd8e0
movq %rax, %rcx
movq -0x4f8(%rbp), %rax
cmpq %rcx, %rax
jae 0xcd52
movq -0x20(%rbp), %rdi
imulq $0x18, -0x4a0(%rbp), %rax
addq %rax, %rdi
movq -0x4a8(%rbp), %rsi
callq 0xd8c0
movq %rax, %rdi
addq $0x8, %rdi
movq -0x4b0(%rbp), %rsi
callq 0xd910
movzbl 0x4(%rax), %eax
movsbl -0x21(%rbp), %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0xcd39
movq $0x0, -0x448(%rbp)
movq $0x0, -0x450(%rbp)
movw $0x0, -0x452(%rbp)
movb $0x0, -0x453(%rbp)
movq -0x20(%rbp), %rdi
imulq $0x18, -0x4a0(%rbp), %rax
addq %rax, %rdi
movq -0x4a8(%rbp), %rsi
callq 0xd8c0
movq %rax, %rdi
addq $0x8, %rdi
movq -0x4b0(%rbp), %rsi
callq 0xd910
movzbl 0x4(%rax), %eax
andl $0x1, %eax
cltq
movq %rax, -0x450(%rbp)
movq -0x450(%rbp), %rax
shlq $0x8, %rax
movq %rax, -0x518(%rbp)
movq -0x20(%rbp), %rdi
imulq $0x18, -0x4a0(%rbp), %rax
addq %rax, %rdi
movq -0x4a8(%rbp), %rsi
callq 0xd8c0
movq %rax, %rdi
addq $0x8, %rdi
movq -0x4b0(%rbp), %rsi
callq 0xd910
movq %rax, %rcx
movq -0x518(%rbp), %rax
movzbl 0x3(%rcx), %ecx
orq %rcx, %rax
movq %rax, -0x450(%rbp)
movq -0x450(%rbp), %rax
shlq $0x8, %rax
movq %rax, -0x510(%rbp)
movq -0x20(%rbp), %rdi
imulq $0x18, -0x4a0(%rbp), %rax
addq %rax, %rdi
movq -0x4a8(%rbp), %rsi
callq 0xd8c0
movq %rax, %rdi
addq $0x8, %rdi
movq -0x4b0(%rbp), %rsi
callq 0xd910
movq %rax, %rcx
movq -0x510(%rbp), %rax
movzbl 0x2(%rcx), %ecx
orq %rcx, %rax
movq %rax, -0x450(%rbp)
movq -0x450(%rbp), %rax
shlq $0x8, %rax
movq %rax, -0x508(%rbp)
movq -0x20(%rbp), %rdi
imulq $0x18, -0x4a0(%rbp), %rax
addq %rax, %rdi
movq -0x4a8(%rbp), %rsi
callq 0xd8c0
movq %rax, %rdi
addq $0x8, %rdi
movq -0x4b0(%rbp), %rsi
callq 0xd910
movq %rax, %rcx
movq -0x508(%rbp), %rax
movzbl 0x1(%rcx), %ecx
orq %rcx, %rax
movq %rax, -0x450(%rbp)
movq -0x10(%rbp), %rax
imulq -0x450(%rbp), %rax
addq -0x498(%rbp), %rax
movq %rax, -0x448(%rbp)
movq -0x20(%rbp), %rdi
imulq $0x18, -0x4a0(%rbp), %rax
addq %rax, %rdi
movq -0x4a8(%rbp), %rsi
callq 0xd8c0
movq %rax, %rdi
addq $0x8, %rdi
movq -0x4b0(%rbp), %rsi
callq 0xd910
movzbl 0x4(%rax), %eax
andl $0xe, %eax
sarl %eax
movw %ax, -0x452(%rbp)
movq -0x440(%rbp), %rax
movq %rax, -0x500(%rbp)
movq -0x448(%rbp), %rsi
movw -0x452(%rbp), %ax
movl -0x14(%rbp), %ecx
leaq -0x4d0(%rbp), %rdi
movzwl %ax, %edx
callq 0x103d0
leaq -0x4d0(%rbp), %rdi
callq 0x3110
movq -0x500(%rbp), %rdi
movq %rax, %rdx
leaq 0x4790(%rip), %rsi      # 0x11366
movb $0x0, %al
callq 0x3490
leaq -0x4d0(%rbp), %rdi
callq 0x31b0
movb $0x10, -0x4d1(%rbp)
movl $0x0, -0x4d8(%rbp)
cmpl $0x4, -0x4d8(%rbp)
jae 0xcce4
movb $0x20, -0x453(%rbp)
movq -0x20(%rbp), %rax
movq -0x4a0(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rdi
movq -0x4a8(%rbp), %rsi
callq 0xd8c0
movq %rax, %rdi
addq $0x8, %rdi
movq -0x4b0(%rbp), %rsi
callq 0xd910
movzbl 0x4(%rax), %eax
movsbl -0x4d1(%rbp), %ecx
andl %ecx, %eax
movl %eax, -0x51c(%rbp)
subl $0x10, %eax
je 0xcc9e
jmp 0xcc5a
movl -0x51c(%rbp), %eax
subl $0x20, %eax
je 0xcc95
jmp 0xcc67
movl -0x51c(%rbp), %eax
subl $0x40, %eax
je 0xcc8c
jmp 0xcc74
movl -0x51c(%rbp), %eax
subl $0x80, %eax
jne 0xcca5
jmp 0xcc83
movb $0x41, -0x453(%rbp)
jmp 0xcca5
movb $0x54, -0x453(%rbp)
jmp 0xcca5
movb $0x43, -0x453(%rbp)
jmp 0xcca5
movb $0x47, -0x453(%rbp)
movq -0x440(%rbp), %rdi
movsbl -0x453(%rbp), %edx
leaq 0x46af(%rip), %rsi      # 0x11369
movb $0x0, %al
callq 0x3490
movsbl -0x4d1(%rbp), %eax
shll %eax
movb %al, -0x4d1(%rbp)
movl -0x4d8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4d8(%rbp)
jmp 0xcbfa
movq -0x440(%rbp), %rax
movq %rax, -0x528(%rbp)
movq -0x20(%rbp), %rdi
imulq $0x18, -0x4a0(%rbp), %rax
addq %rax, %rdi
movq -0x4a8(%rbp), %rsi
callq 0xd8c0
movq %rax, %rdi
addq $0x8, %rdi
movq -0x4b0(%rbp), %rsi
callq 0xd910
movq -0x528(%rbp), %rdi
movzbl 0x5(%rax), %edx
leaq 0x49f8(%rip), %rsi      # 0x1172a
movb $0x0, %al
callq 0x3490
jmp 0xcd3b
movq -0x4b0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x4b0(%rbp)
jmp 0xc93e
jmp 0xcd54
movq -0x4a8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x4a8(%rbp)
jmp 0xc8d9
jmp 0xcd6d
movq -0x4a0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x4a0(%rbp)
jmp 0xc8b7
movq -0x438(%rbp), %rdi
callq 0x3300
movq -0x440(%rbp), %rdi
callq 0x3300
leaq 0x498c(%rip), %rdi      # 0x1172f
movb $0x0, %al
callq 0x3070
addq $0x530, %rsp            # imm = 0x530
popq %rbp
retq
nopw %cs:(%rax,%rax)