// File: /workspace/github_cpp_makefile_star2_O2/ratulSharker[P]Havec/src/vector_with_rehash_8_hash_with_N_detection_5_bytes.cpp
// Function: main5Byte(int, char**)
void main5Byte(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);
	
	if(argc < 7){
		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;
		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 value 
	
	//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;
	}
*/


// for output to the file

	string fileName = "5_";
	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");
	
	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 khmerInfo5Byte *blockArray = new struct khmerInfo5Byte[size];
	mapPointer5Byte=new vector<struct vector_trial_5_byte>[num_of_vector];
	
	//cleaning the array
	memset( blockArray, 0, sizeof(struct khmerInfo5Byte) * size);

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

	populateBlock5Byte(blockArray, size , filename , kSize);

	show_vect_status_5_byte();
	
	currentDateTime();
	
	//rechecking ...
	//reCheckTheKhmerExistence5Byte(blockArray,size,argv[1],kSize);
	currentDateTime();
	
	double vm, rss;
	process_mem_usage(vm, rss);
	cout<<"HashTable memory allocation (GB):: "<<((double)size * 5.0 )/(1024.0 * 1024.0 * 1024.0)<<endl;
	cout<<"Vector memory allocation    (GB):: "<<(((vm)/1024.0)/1024.0) - (((double)size * 5 )/(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
		//printWholeBlockArrayAndVectorStructure(blockArray, true, size, kSize, NULL, NULL);
		print5ByteHashTableAndVectorStructure(blockArray , size, kSize,mapPointer5Byte);
	}
	
	delete [] blockArray;
	
	fclose(stdout);
	return ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %rbx
movl %edi, %ebp
andq $0x0, 0x40(%rsp)
movl $0xc8, %edi
callq 0x2030
movq %rax, %r13
movl $0x7a120, %edi          # imm = 0x7A120
callq 0x75cf
leaq 0x766e(%rip), %rcx      # 0xb2c0
movq %rax, (%rcx)
cmpl $0x6, %ebp
jg 0x3c9d
movq 0x736f(%rip), %rdi      # 0xafd0
leaq 0x45e4(%rip), %rsi      # 0x824c
callq 0x2220
movq %rax, %rdi
callq 0x20e0
leaq 0x45fc(%rip), %rsi      # 0x8278
movq %rax, %rdi
callq 0x2220
movq %rax, %rdi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20e0
movq 0x8(%rbx), %rsi
movq %r13, %rdi
callq 0x2210
movq 0x10(%rbx), %rdi
callq 0x23a0
movl %eax, 0x4(%rsp)
movq 0x18(%rbx), %rdi
callq 0x23a0
decl %eax
leaq 0x75cc(%rip), %rcx      # 0xb294
movl %eax, (%rcx)
cmpl $0x8, %ebp
je 0x3d02
cmpl $0x7, %ebp
jne 0x3d88
movq 0x30(%rbx), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x421e
leaq 0x8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
pushq $0xa
popq %rdx
callq 0x4291
movq %rax, %r12
jmp 0x3d7c
movq 0x30(%rbx), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x421e
leaq 0x8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
pushq $0xa
popq %rdx
callq 0x4291
movq %rax, %xmm0
punpckldq 0x433c(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x4344(%rip), %xmm0     # 0x8080
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x30(%rsp)
movq 0x38(%rbx), %rdi
callq 0x22f0
mulsd 0x30(%rsp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x42a7(%rip), %xmm0     # 0x8018
cvttsd2si %xmm0, %r12
andq %rcx, %r12
orq %rax, %r12
leaq 0x8(%rsp), %rdi
callq 0x20c0
jmp 0x3d8b
xorl %r12d, %r12d
leaq 0x455a(%rip), %rsi      # 0x82ec
leaq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x421e
movq 0x8(%rbx), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2440
leaq 0x4539(%rip), %rsi      # 0x82ef
leaq 0x8(%rsp), %rdi
callq 0x2440
movq 0x10(%rbx), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2440
leaq 0x451e(%rip), %rsi      # 0x82f3
leaq 0x8(%rsp), %rdi
callq 0x2440
movq 0x18(%rbx), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2440
leaq 0x4503(%rip), %rsi      # 0x82f7
leaq 0x8(%rsp), %rdi
callq 0x2440
movq 0x30(%rbx), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2440
leaq 0x44e8(%rip), %rsi      # 0x82fb
leaq 0x8(%rsp), %rdi
callq 0x2440
movq 0x38(%rbx), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2440
movq %rbx, 0x68(%rsp)
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
addq %rdi, %rsi
leaq 0x48(%rsp), %rbx
movb $0x2e, (%rbx)
leaq 0x28(%rsp), %r15
movb $0x2d, (%r15)
movq %rbx, %rdx
movq %r15, %rcx
callq 0x42ad
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
addq %rdi, %rsi
movb $0x2f, (%rbx)
movb $0x7e, (%r15)
leaq 0x48(%rsp), %rdx
leaq 0x28(%rsp), %rcx
callq 0x42ad
leaq 0x4181(%rip), %rsi      # 0x8004
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x421e
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2460
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x2100
leaq 0x4370(%rip), %rsi      # 0x8225
leaq 0x8(%rsp), %rdi
callq 0x2440
movq 0x8(%rsp), %rdi
movq 0x70ed(%rip), %rax      # 0xafb8
movq (%rax), %rdx
leaq 0x4371(%rip), %rsi      # 0x8246
callq 0x2280
callq 0x7610
movq %r12, %rdi
callq 0x75cf
movq %rax, %rbx
movq 0x70df(%rip), %rdi      # 0xafd0
leaq 0x4408(%rip), %rsi      # 0x8300
callq 0x2220
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2160
movq %rax, %rdi
callq 0x20e0
movq 0x70b9(%rip), %rdi      # 0xafd0
leaq 0x43f0(%rip), %rsi      # 0x830e
callq 0x2220
movq %rax, %rdi
movq %r13, %rsi
callq 0x2220
leaq 0x43e4(%rip), %rsi      # 0x8319
movq %rax, %rdi
callq 0x2220
movq %rax, %rdi
movl 0x4(%rsp), %esi
callq 0x23f0
leaq 0x43d2(%rip), %rsi      # 0x8322
movq %rax, %rdi
callq 0x2220
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2160
movq %rax, %rdi
callq 0x20e0
callq 0x769d
movq %r13, %r12
pushq $0x5
popq %rcx
movq %rbx, %r14
movq %rbx, %rax
mulq %rcx
movq %rax, %rbp
pushq $-0x1
popq %r15
movq %rax, %rdi
cmovoq %r15, %rdi
callq 0x2030
movq %rax, 0x30(%rsp)
leaq 0x7322(%rip), %rax      # 0xb2c0
movq (%rax), %rbx
pushq $0x18
popq %r13
movq %rbx, %rax
mulq %r13
seto %cl
addq $0x8, %rax
cmovbq %r15, %rax
testb %cl, %cl
cmoveq %rax, %r15
movq %r15, %rdi
callq 0x2030
movq %rax, %r15
movq %rbx, (%rax)
addq $0x8, %r15
testq %rbx, %rbx
je 0x3ff7
imulq $0x18, %rbx, %rcx
addq $-0x18, %rcx
movq %rcx, %rax
xorl %edx, %edx
divq %r13
subq %rdx, %rcx
addq $0x18, %rcx
movq %r15, %rdi
xorl %esi, %esi
movq %rcx, %rdx
callq 0x2120
movq %r15, 0x7262(%rip)      # 0xb260
movq 0x30(%rsp), %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x2120
callq 0x7610
movzwl 0x4(%rsp), %ecx
movq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x2a07
callq 0x266c
callq 0x7610
callq 0x7610
leaq 0x28(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x6f54
movq 0x6f81(%rip), %rdi      # 0xafd0
leaq 0x42d4(%rip), %rsi      # 0x832a
callq 0x2220
movq %r14, %xmm1
punpckldq 0x4008(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x4010(%rip), %xmm1     # 0x8080
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x3f9c(%rip), %xmm0     # 0x8020
mulsd 0x3f9c(%rip), %xmm0     # 0x8028
movq %rax, %rdi
movapd %xmm0, 0x70(%rsp)
callq 0x23c0
movq %rax, %rdi
callq 0x20e0
movq 0x6f27(%rip), %rdi      # 0xafd0
leaq 0x429e(%rip), %rsi      # 0x834e
callq 0x2220
movsd 0x3f53(%rip), %xmm1     # 0x8010
movsd 0x28(%rsp), %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
subsd 0x70(%rsp), %xmm0
movq %rax, %rdi
callq 0x23c0
movq %rax, %rdi
callq 0x20e0
movq 0x6ee8(%rip), %rdi      # 0xafd0
leaq 0x4283(%rip), %rsi      # 0x8372
callq 0x2220
movsd 0x28(%rsp), %xmm0
movsd 0x3f0e(%rip), %xmm1     # 0x8010
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x23c0
movq %rax, %rdi
callq 0x20e0
movq 0x68(%rsp), %rax
movq 0x28(%rax), %rcx
movzbl (%rcx), %eax
cmpl $0x70, %eax
jne 0x4133
cmpb $0x0, 0x1(%rcx)
jne 0x415a
jmp 0x4142
subl $0x50, %eax
jne 0x413c
movzbl 0x1(%rcx), %eax
negl %eax
testl %eax, %eax
jne 0x415a
movq 0x7117(%rip), %rcx      # 0xb260
movq 0x30(%rsp), %rdi
movq %r14, %rsi
movl 0x4(%rsp), %edx
callq 0x3891
movq 0x30(%rsp), %rdi
callq 0x2320
movq 0x6e4d(%rip), %rax      # 0xafb8
movq (%rax), %rdi
callq 0x2230
leaq 0x48(%rsp), %rdi
callq 0x20c0
leaq 0x8(%rsp), %rdi
callq 0x20c0
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x41aa
jmp 0x41aa
jmp 0x41a3
jmp 0x41a3
jmp 0x41aa
movq %rax, %rbx
jmp 0x41c8
jmp 0x41b1
movq %rax, %rbx
jmp 0x41be
jmp 0x41b1
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x20c0
leaq 0x8(%rsp), %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x2400