// File: 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
movq %rsp, %rbp
subq $0x520, %rsp            # imm = 0x520
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
leaq 0xb264(%rip), %rdi      # 0x11305
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 0xaf26(%rip), %rsi      # 0x11006
callq 0x3560
leaq -0x430(%rbp), %rdi
leaq 0xaf13(%rip), %rsi      # 0x11006
callq 0x3560
leaq -0x230(%rbp), %rdi
leaq 0xb22d(%rip), %rsi      # 0x11333
callq 0x3560
leaq -0x430(%rbp), %rdi
leaq 0xb22f(%rip), %rsi      # 0x11348
callq 0x3560
leaq -0x230(%rbp), %rdi
leaq 0xb238(%rip), %rsi      # 0x11364
callq 0x33c0
movq %rax, -0x438(%rbp)
leaq -0x430(%rbp), %rdi
leaq 0xb21e(%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 0x6431
movq -0x460(%rbp), %rax
imulq $0x5, -0x468(%rbp), %rcx
addq %rcx, %rax
movzbl 0x4(%rax), %eax
movsbl -0x21(%rbp), %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x6418
movq $0x0, -0x448(%rbp)
movq $0x0, -0x450(%rbp)
movw $0x0, -0x452(%rbp)
movb $0x0, -0x453(%rbp)
movq -0x460(%rbp), %rax
imulq $0x5, -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 $0x5, -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 $0x5, -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 $0x5, -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 $0x5, -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 0xb052(%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 0x6403
movb $0x20, -0x453(%rbp)
movq -0x460(%rbp), %rax
movq -0x468(%rbp), %rcx
leaq (%rcx,%rcx,4), %rcx
movzbl 0x4(%rax,%rcx), %eax
movsbl -0x489(%rbp), %ecx
andl %ecx, %eax
movl %eax, -0x4e4(%rbp)
subl $0x10, %eax
je 0x63bd
jmp 0x6379
movl -0x4e4(%rbp), %eax
subl $0x20, %eax
je 0x63b4
jmp 0x6386
movl -0x4e4(%rbp), %eax
subl $0x40, %eax
je 0x63ab
jmp 0x6393
movl -0x4e4(%rbp), %eax
subl $0x80, %eax
jne 0x63c4
jmp 0x63a2
movb $0x41, -0x453(%rbp)
jmp 0x63c4
movb $0x54, -0x453(%rbp)
jmp 0x63c4
movb $0x43, -0x453(%rbp)
jmp 0x63c4
movb $0x47, -0x453(%rbp)
movq -0x438(%rbp), %rdi
movsbl -0x453(%rbp), %edx
leaq 0xaf90(%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 0x6338
movq -0x438(%rbp), %rdi
leaq 0xb31c(%rip), %rsi      # 0x1172d
movb $0x0, %al
callq 0x3490
jmp 0x641a
movq -0x468(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x468(%rbp)
jmp 0x618e
movq $0x0, -0x498(%rbp)
movq $0x0, -0x4a0(%rbp)
movq -0x4a0(%rbp), %rax
leaq 0x10f2b(%rip), %rcx     # 0x17380
cmpq (%rcx), %rax
jae 0x68d4
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 0x7370
movq %rax, %rcx
movq -0x4f0(%rbp), %rax
cmpq %rcx, %rax
jae 0x68bb
movq -0x20(%rbp), %rdi
imulq $0x18, -0x4a0(%rbp), %rax
addq %rax, %rdi
movq -0x4a8(%rbp), %rsi
callq 0x7390
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 0x7390
movq %rax, %rdi
addq $0x8, %rdi
callq 0x73b0
movq %rax, %rcx
movq -0x4f8(%rbp), %rax
cmpq %rcx, %rax
jae 0x68a2
movq -0x20(%rbp), %rdi
imulq $0x18, -0x4a0(%rbp), %rax
addq %rax, %rdi
movq -0x4a8(%rbp), %rsi
callq 0x7390
movq %rax, %rdi
addq $0x8, %rdi
movq -0x4b0(%rbp), %rsi
callq 0x7890
movzbl 0x4(%rax), %eax
movsbl -0x21(%rbp), %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x6889
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 0x7390
movq %rax, %rdi
addq $0x8, %rdi
movq -0x4b0(%rbp), %rsi
callq 0x7890
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 0x7390
movq %rax, %rdi
addq $0x8, %rdi
movq -0x4b0(%rbp), %rsi
callq 0x7890
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 0x7390
movq %rax, %rdi
addq $0x8, %rdi
movq -0x4b0(%rbp), %rsi
callq 0x7890
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 0x7390
movq %rax, %rdi
addq $0x8, %rdi
movq -0x4b0(%rbp), %rsi
callq 0x7890
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 0x7390
movq %rax, %rdi
addq $0x8, %rdi
movq -0x4b0(%rbp), %rsi
callq 0x7890
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 0xac00(%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 0x6874
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 0x7390
movq %rax, %rdi
addq $0x8, %rdi
movq -0x4b0(%rbp), %rsi
callq 0x7890
movzbl 0x4(%rax), %eax
movsbl -0x4d1(%rbp), %ecx
andl %ecx, %eax
movl %eax, -0x51c(%rbp)
subl $0x10, %eax
je 0x682e
jmp 0x67ea
movl -0x51c(%rbp), %eax
subl $0x20, %eax
je 0x6825
jmp 0x67f7
movl -0x51c(%rbp), %eax
subl $0x40, %eax
je 0x681c
jmp 0x6804
movl -0x51c(%rbp), %eax
subl $0x80, %eax
jne 0x6835
jmp 0x6813
movb $0x41, -0x453(%rbp)
jmp 0x6835
movb $0x54, -0x453(%rbp)
jmp 0x6835
movb $0x43, -0x453(%rbp)
jmp 0x6835
movb $0x47, -0x453(%rbp)
movq -0x440(%rbp), %rdi
movsbl -0x453(%rbp), %edx
leaq 0xab1f(%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 0x678a
movq -0x440(%rbp), %rdi
leaq 0xaeab(%rip), %rsi      # 0x1172d
movb $0x0, %al
callq 0x3490
jmp 0x688b
movq -0x4b0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x4b0(%rbp)
jmp 0x64ce
jmp 0x68a4
movq -0x4a8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x4a8(%rbp)
jmp 0x6469
jmp 0x68bd
movq -0x4a0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x4a0(%rbp)
jmp 0x6447
movq -0x438(%rbp), %rdi
callq 0x3300
movq -0x440(%rbp), %rdi
callq 0x3300
leaq 0xaa7a(%rip), %rdi      # 0x1136d
movb $0x0, %al
callq 0x3070
addq $0x520, %rsp            # imm = 0x520
popq %rbp
retq
nopw %cs:(%rax,%rax)