// File: /workspace/github_cpp_makefile_star2_O1/ratulSharker[P]Havec/src/vector_with_rehash_8_hash_with_N_detection_6_bytes.cpp
// Function: main6Byte(int, char**)
void main6Byte(int argc, char** argv) {

	//freopen("results.txt","w",stdout);
	unsigned long long size;
	int kSize;
	std::string::size_type sz = 0;
	char *filename=new char[200];
	num_of_vector = get_a_prime_above_x(500000);
	
	/*
	* new variable introduced in the 6 byte code section --- which is cutoff value
	*/
	
	if(argc < 7){//newly changed
		std::cout<<"sufficient number of argument is not passed"<<std::endl<<" 'fileName' 'khmersize' 'howManyHash' 'cut-off or no cut-off' 'print or not print' 'hashSize' 'multiplying factor'"<<std::endl;//newly changed
		return ;
	}


	/*std::string::size_type sz = 0;
	std::cout<<"Give input file name :: "<<std::endl;
	std::cin>>filename;*/

	//fetching the args
	strcpy(filename,argv[1]);
	kSize = atoi(argv[2]);
	LAST_HASH_FUNC = atoi(argv[3])-1;//0 indexing hash function used
	
	//size =  std::stoull(argv[3],&sz,10);
	size= 0;
	if(argc == 7){ //size provided as the last argument -- so process it //newly changed
		size =  std::stoull(argv[6],&sz,10);//newly changed
	}
	else if(argc == 8)//newly changed
	{
		/*
		* here we parse the multiplying by factor --- which is not optional anymore
 		*/
		size =  std::stoull(argv[6],&sz,10) * atof(argv[7]);//newly changed
	}

/* unblock this area -- you must should (blocked this code section due to low memory space)
 * warning 
 * warning
 * WARNING --- unblock this code of section before releasing
 */
 /*
	if(size < (pow(2,2 * kSize - 33)+ 536870912)){
		size = pow(2,2 * kSize - 33)+ 536870912;
	}
*/


//building the filename
	string fileName = "6_";
	fileName.append(argv[1]);

	fileName.append("_k_");
	fileName.append(argv[2]);
	fileName.append("_h_");
	fileName.append(argv[3]);

	if(argc >= 6)
	{
		fileName.append("_s_");
		fileName.append(argv[6]);

		if(argc >= 7)
		{
			fileName.append("_mf_");
			fileName.append(argv[7]);
		}
	}
	//cant contain the dot, thats why replacing it with the 
	// - char
	replace(fileName.begin(), fileName.end(), '.', '-');
	replace(fileName.begin(), fileName.end(), '/', '~');


	string outputDir = OUTPUT_DIRECTORY_NAME;
	fileName = outputDir.append(fileName);
	fileName.append(".txt");
	
	//enable this line will give you access the whole output in the cmd
	freopen(fileName.c_str(),"w",stdout);

	
	currentDateTime();
	
	/*std::cout<<"Give Kmer Size :: "<<std::endl;
	std::cin>>kSize;
	std::cout<<"Minimum space you want to give to hash's :: "<<std::endl;
	std::cin>>size;*/
	//initial memory arrangement
	size=get_a_prime_above_x(size);
	cout<<"Hash size is "<<size<<endl;

	std::cout<<"filename::"<<filename<<" ksize::"<<kSize<<" Size::"<<size<<std::endl;

	populateTwoBitReprHashMap();//populating map
	struct khmerInfo6Byte *blockArray=new struct khmerInfo6Byte[size];
	mapPointer6Byte=new vector<struct vector_trial_6_byte>[num_of_vector];
	
	//cleaning the array
	memset( blockArray, 0, sizeof(struct khmerInfo6Byte) * size);

/*	
	bool zeroFound = true;
	for(int j=0;j<size;j++){
		if(blockArray[j].count != 0){
			zeroFound = false;
			break;
		}		
	}

	if(zeroFound == false){
		cout<<"All are not set to zero"<<endl;
	}
	else{
		cout<<"All are zero"<<endl;
	}


	cout<<"After memory allocation"<<endl;
	*/
	
	currentDateTime();

	//this function will populate the whole memblock & the vector structure
	populateBlock6Byte(blockArray, size , filename , kSize);

	show_vect_status_6_byte();
	
	currentDateTime();
	
	//rechecking ...
	//reCheckTheKhmerExistence6Byte(blockArray,size,argv[1],kSize);
	show_count_status(blockArray,size);
	currentDateTime();
	
	double vm, rss;
	process_mem_usage(vm, rss);
	
	cout<<"HashTable memory allocation (GB):: "<<((double)size * 6.0 )/(1024.0 * 1024.0 * 1024.0)<<endl;
	cout<<"Vector memory allocation    (GB):: "<<(((vm)/1024.0)/1024.0) - (((double)size * 6.0 )/(1024.0 * 1024.0 * 1024.0)) <<endl;

	cout << "Total memory used (GB):  " << ((vm)/1024.0)/1024.0 <<endl;
	
	/*//newly changed
	* before deleting the block array check for the print state
	*/
	if(strcmp("p",argv[5]) == 0 ||  strcmp("P",argv[5]) == 0 ) //newly changed
	{
		//time to print the whole block array
		print6ByteHashTableAndVectorStructure(blockArray , size, kSize,mapPointer6Byte);
	}
	
	delete [] blockArray;
	
	fclose(stdout);
	return ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %rbx
movl %edi, %r15d
movl $0xc8, %edi
callq 0x3030
movq %rax, %r14
movl $0x7a120, %edi          # imm = 0x7A120
callq 0x9d28
leaq 0x5daa(%rip), %r13      # 0xe2f0
movq %rax, (%r13)
cmpl $0x6, %r15d
jg 0x85e2
movq 0x5a7d(%rip), %rbx      # 0xdfd8
leaq 0x2cea(%rip), %rsi      # 0xb24c
movl $0x2b, %edx
movq %rbx, %rdi
callq 0x32d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
movq %rax, %rbx
leaq 0x2f91(%rip), %rsi      # 0xb531
movl $0x72, %edx
movq %rax, %rdi
callq 0x32d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3180
movq 0x8(%rbx), %rsi
movq %r14, %rdi
callq 0x3220
movq 0x10(%rbx), %rdi
callq 0x33e0
movl %eax, 0x24(%rsp)
movq 0x18(%rbx), %rdi
callq 0x33e0
decl %eax
leaq 0x5cb7(%rip), %rcx      # 0xe2c4
movl %eax, (%rcx)
cmpl $0x8, %r15d
je 0x868c
cmpl $0x7, %r15d
jne 0x86e8
movq 0x30(%rbx), %rsi
movq %rsp, %rdi
leaq 0x28(%rsp), %rdx
callq 0x5e58
movq (%rsp), %r13
callq 0x3050
movq %rax, %r12
movl (%rax), %eax
movl %eax, 0x30(%rsp)
movl $0x0, (%r12)
leaq 0x40(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
movl $0xa, %edx
callq 0x3350
cmpq %r13, (%rbp)
je 0x8ce4
movq %rax, %r15
movl (%r12), %eax
testl %eax, %eax
je 0x86f0
cmpl $0x22, %eax
leaq 0x5c72(%rip), %r13      # 0xe2f0
jne 0x86ff
leaq 0x2d09(%rip), %rdi      # 0xb390
callq 0x3390
movq 0x30(%rbx), %rsi
movq %rsp, %rdi
leaq 0x28(%rsp), %rdx
callq 0x5e58
movq (%rsp), %r12
callq 0x3050
movq %rax, %r15
movl (%rax), %ebp
movl $0x0, (%rax)
leaq 0x40(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x3350
cmpq %r12, (%r13)
je 0x8cf0
movl (%r15), %ecx
testl %ecx, %ecx
je 0x8720
cmpl $0x22, %ecx
jne 0x8723
leaq 0x2cad(%rip), %rdi      # 0xb390
callq 0x3390
xorl %r15d, %r15d
jmp 0x879a
movl 0x30(%rsp), %eax
movl %eax, (%r12)
leaq 0x5bf1(%rip), %r13      # 0xe2f0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x879a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3270
jmp 0x879a
movl %ebp, (%r15)
movq %rax, %xmm0
punpckldq 0x2940(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x2948(%rip), %xmm0     # 0xb080
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x30(%rsp)
movq 0x38(%rbx), %rdi
callq 0x3310
mulsd 0x30(%rsp), %xmm0
cvttsd2si %xmm0, %r15
movq %r15, %rax
sarq $0x3f, %rax
subsd 0x28ab(%rip), %xmm0     # 0xb018
cvttsd2si %xmm0, %r12
andq %rax, %r12
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8790
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3270
orq %r12, %r15
leaq 0x5b56(%rip), %r13      # 0xe2f0
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2dfa(%rip), %rsi      # 0xb5a4
leaq 0x2df5(%rip), %rdx      # 0xb5a6
movq %rsp, %rdi
callq 0x637e
movq 0x8(%rbx), %rsi
movq %rsp, %rdi
callq 0x34b0
leaq 0x2b23(%rip), %rsi      # 0xb2ef
movq %rsp, %rdi
callq 0x34b0
movq 0x10(%rbx), %rsi
movq %rsp, %rdi
callq 0x34b0
leaq 0x2b0c(%rip), %rsi      # 0xb2f3
movq %rsp, %rdi
callq 0x34b0
movq 0x18(%rbx), %rsi
movq %rsp, %rdi
callq 0x34b0
leaq 0x2af5(%rip), %rsi      # 0xb2f7
movq %rsp, %rdi
callq 0x34b0
movq 0x30(%rbx), %rsi
movq %rsp, %rdi
callq 0x34b0
leaq 0x2ade(%rip), %rsi      # 0xb2fb
movq %rsp, %rdi
callq 0x34b0
movq 0x38(%rbx), %rsi
movq %rsp, %rdi
callq 0x34b0
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x8853
movq (%rsp), %rcx
xorl %edx, %edx
cmpb $0x2e, (%rcx,%rdx)
jne 0x884b
movb $0x2d, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x8841
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x8875
movq (%rsp), %rcx
xorl %edx, %edx
cmpb $0x2f, (%rcx,%rdx)
jne 0x886d
movb $0x7e, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x8863
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2781(%rip), %rsi      # 0xb006
leaq 0x2781(%rip), %rdx      # 0xb00d
leaq 0x40(%rsp), %rdi
callq 0x637e
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x40(%rsp), %rdi
callq 0x3090
movq %rsp, %rdi
movq %rax, %rsi
callq 0x3100
leaq 0x296a(%rip), %rsi      # 0xb225
movq %rsp, %rdi
callq 0x34b0
movq (%rsp), %rdi
movq 0x56f2(%rip), %rax      # 0xdfc0
movq (%rax), %rdx
leaq 0x296e(%rip), %rsi      # 0xb246
callq 0x32a0
callq 0x9d69
movq %r15, %rdi
callq 0x9d28
movq %rax, %r15
movq 0x56e4(%rip), %rdi      # 0xdfd8
leaq 0x2a05(%rip), %rsi      # 0xb300
movl $0xd, %edx
callq 0x32d0
movq 0x56cc(%rip), %rdi      # 0xdfd8
movq %r15, %rsi
callq 0x3160
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
movq 0x5693(%rip), %rdi      # 0xdfd8
leaq 0x29c2(%rip), %rsi      # 0xb30e
movl $0xa, %edx
callq 0x32d0
movq %r14, %rdi
callq 0x30c0
movq 0x5673(%rip), %rdi      # 0xdfd8
movq %r14, %rsi
movq %rax, %rdx
callq 0x32d0
movq 0x5661(%rip), %rdi      # 0xdfd8
leaq 0x299b(%rip), %rsi      # 0xb319
movl $0x8, %edx
callq 0x32d0
movq 0x5649(%rip), %rdi      # 0xdfd8
movl 0x24(%rsp), %esi
callq 0x3440
movq %rax, %r12
leaq 0x2980(%rip), %rsi      # 0xb322
movl $0x7, %edx
movq %rax, %rdi
callq 0x32d0
movq %r12, %rdi
movq %r15, %rsi
callq 0x3160
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
callq 0x9e50
movl $0x6, %ecx
movq %r15, %rax
mulq %rcx
movq $-0x1, %rdi
cmovnoq %rax, %rdi
callq 0x3030
movq %rax, %r12
testq %r15, %r15
je 0x8a25
leaq (%r15,%r15), %rax
leaq (%rax,%rax,2), %rax
xorl %ecx, %ecx
movb $0x0, 0x5(%r12,%rcx)
addq $0x6, %rcx
cmpq %rcx, %rax
jne 0x8a16
movq (%r13), %r13
movl $0x18, %ecx
movq %r13, %rax
mulq %rcx
seto %cl
addq $0x8, %rax
movq $-0x1, %rdi
cmovbq %rdi, %rax
testb %cl, %cl
cmoveq %rax, %rdi
callq 0x3030
movq %rax, %rbp
movq %r13, (%rax)
addq $0x8, %rbp
testq %r13, %r13
je 0x8a9a
leaq (,%r13,2), %rax
addq %r13, %rax
leaq -0x18(,%rax,8), %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rcx
shrq $0x4, %rdx
leaq (%rdx,%rdx,2), %rax
leaq 0x18(,%rax,8), %rdx
movq %rbp, %rdi
xorl %esi, %esi
callq 0x3120
movq %rbp, 0x580f(%rip)      # 0xe2b0
leaq (%r15,%r15), %rax
leaq (%rax,%rax,2), %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x3120
callq 0x9d69
movzwl 0x24(%rsp), %ecx
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x6ac4
callq 0x6410
callq 0x9d69
movq %r12, %rdi
movq %r15, %rsi
callq 0x6556
callq 0x9d69
leaq 0x28(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x91dc
movq 0x54dd(%rip), %rdi      # 0xdfd8
leaq 0x2828(%rip), %rsi      # 0xb32a
movl $0x23, %edx
callq 0x32d0
movq %r15, %xmm1
punpckldq 0x2557(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x255f(%rip), %xmm1     # 0xb080
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x2923(%rip), %xmm0     # 0xb458
mulsd 0x24eb(%rip), %xmm0     # 0xb028
movq 0x5494(%rip), %rdi      # 0xdfd8
movapd %xmm0, 0x30(%rsp)
callq 0x3400
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
movq 0x5458(%rip), %rdi      # 0xdfd8
leaq 0x27c7(%rip), %rsi      # 0xb34e
movl $0x23, %edx
callq 0x32d0
movsd 0x2477(%rip), %xmm1     # 0xb010
movsd 0x28(%rsp), %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
subsd 0x30(%rsp), %xmm0
movq 0x5424(%rip), %rdi      # 0xdfd8
callq 0x3400
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
movq 0x53ee(%rip), %rdi      # 0xdfd8
leaq 0x2781(%rip), %rsi      # 0xb372
movl $0x19, %edx
callq 0x32d0
movsd 0x28(%rsp), %xmm0
movsd 0x2407(%rip), %xmm1     # 0xb010
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movq 0x53c0(%rip), %rdi      # 0xdfd8
callq 0x3400
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
movq 0x28(%rbx), %rbx
leaq 0x273a(%rip), %rdi      # 0xb38c
movq %rbx, %rsi
callq 0x3370
testl %eax, %eax
je 0x8c71
leaq 0x2729(%rip), %rdi      # 0xb38e
movq %rbx, %rsi
callq 0x3370
testl %eax, %eax
jne 0x8c87
movq 0x5638(%rip), %rcx      # 0xe2b0
movq %r12, %rdi
movq %r15, %rsi
movl 0x24(%rsp), %edx
callq 0x8111
movq %r12, %rdi
callq 0x3340
movq 0x532a(%rip), %rax      # 0xdfc0
movq (%rax), %rdi
callq 0x3250
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
leaq 0x10(%rsp), %rbx
je 0x8cbf
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3270
movq (%rsp), %rdi
cmpq %rbx, %rdi
je 0x8cd5
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3270
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x26a5(%rip), %rdi      # 0xb390
callq 0x3130
leaq 0x2699(%rip), %rdi      # 0xb390
callq 0x3130
jmp 0x8d2d
jmp 0x8d2d
movq %rax, %rbx
cmpl $0x0, (%r15)
jne 0x8d20
movl %ebp, (%r15)
jmp 0x8d20
movq %rax, %rbx
cmpl $0x0, (%r12)
jne 0x8d20
movl 0x30(%rsp), %eax
movl %eax, (%r12)
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x8d63
jmp 0x8d34
movq %rax, %rbx
jmp 0x8d75
jmp 0x8d3b
movq %rax, %rbx
jmp 0x8d5a
jmp 0x8d3b
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x8d5a
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3270
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x8d75
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3270
movq %rbx, %rdi
callq 0x3450
nop