// File: /workspace/github_cpp_makefile_star2_O1/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 $0x68, %rsp
movq %rsi, %rbx
movl %edi, %r15d
movl $0xc8, %edi
callq 0x3030
movq %rax, %r14
movl $0x7a120, %edi          # imm = 0x7A120
callq 0x9d28
leaq 0x8ceb(%rip), %r13      # 0xe2f0
movq %rax, (%r13)
cmpl $0x6, %r15d
jg 0x56a1
movq 0x89be(%rip), %rbx      # 0xdfd8
leaq 0x5c2b(%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 0x5c19(%rip), %rsi      # 0xb278
movl $0x73, %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 0x8bf8(%rip), %rcx      # 0xe2c4
movl %eax, (%rcx)
cmpl $0x8, %r15d
je 0x5753
cmpl $0x7, %r15d
jne 0x57b6
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 0x5d84
movq %rax, %r15
movl (%r12), %eax
testl %eax, %eax
je 0x57be
cmpl $0x22, %eax
leaq 0x8baf(%rip), %r13      # 0xe2f0
jne 0x57cd
leaq 0x5c42(%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 0x5d90
movl (%r15), %ecx
testl %ecx, %ecx
je 0x57ee
cmpl $0x22, %ecx
leaq 0x8b48(%rip), %r13      # 0xe2f0
jne 0x57f8
leaq 0x5bdf(%rip), %rdi      # 0xb390
callq 0x3390
xorl %r15d, %r15d
jmp 0x5868
movl 0x30(%rsp), %eax
movl %eax, (%r12)
leaq 0x8b23(%rip), %r13      # 0xe2f0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5868
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3270
jmp 0x5868
movl %ebp, (%r15)
leaq 0x8af8(%rip), %r13      # 0xe2f0
movq %rax, %xmm0
punpckldq 0x586b(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x5873(%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 0x57d6(%rip), %xmm0     # 0xb018
cvttsd2si %xmm0, %r12
andq %rax, %r12
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5865
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3270
orq %r12, %r15
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x5a74(%rip), %rsi      # 0xb2ec
leaq 0x5a6f(%rip), %rdx      # 0xb2ee
movq %rsp, %rdi
callq 0x637e
movq 0x8(%rbx), %rsi
movq %rsp, %rdi
callq 0x34b0
leaq 0x5a55(%rip), %rsi      # 0xb2ef
movq %rsp, %rdi
callq 0x34b0
movq 0x10(%rbx), %rsi
movq %rsp, %rdi
callq 0x34b0
leaq 0x5a3e(%rip), %rsi      # 0xb2f3
movq %rsp, %rdi
callq 0x34b0
movq 0x18(%rbx), %rsi
movq %rsp, %rdi
callq 0x34b0
leaq 0x5a27(%rip), %rsi      # 0xb2f7
movq %rsp, %rdi
callq 0x34b0
movq 0x30(%rbx), %rsi
movq %rsp, %rdi
callq 0x34b0
leaq 0x5a10(%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 0x5921
movq (%rsp), %rcx
xorl %edx, %edx
cmpb $0x2e, (%rcx,%rdx)
jne 0x5919
movb $0x2d, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x590f
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x5943
movq (%rsp), %rcx
xorl %edx, %edx
cmpb $0x2f, (%rcx,%rdx)
jne 0x593b
movb $0x7e, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x5931
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x56b3(%rip), %rsi      # 0xb006
leaq 0x56b3(%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 0x589c(%rip), %rsi      # 0xb225
movq %rsp, %rdi
callq 0x34b0
movq (%rsp), %rdi
movq 0x8624(%rip), %rax      # 0xdfc0
movq (%rax), %rdx
leaq 0x58a0(%rip), %rsi      # 0xb246
callq 0x32a0
callq 0x9d69
movq %r15, %rdi
callq 0x9d28
movq %rax, %r15
movq 0x8616(%rip), %rdi      # 0xdfd8
leaq 0x5937(%rip), %rsi      # 0xb300
movl $0xd, %edx
callq 0x32d0
movq 0x85fe(%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 0x85c5(%rip), %rdi      # 0xdfd8
leaq 0x58f4(%rip), %rsi      # 0xb30e
movl $0xa, %edx
callq 0x32d0
movq %r14, %rdi
callq 0x30c0
movq 0x85a5(%rip), %rdi      # 0xdfd8
movq %r14, %rsi
movq %rax, %rdx
callq 0x32d0
movq 0x8593(%rip), %rdi      # 0xdfd8
leaq 0x58cd(%rip), %rsi      # 0xb319
movl $0x8, %edx
callq 0x32d0
movq 0x857b(%rip), %rdi      # 0xdfd8
movl 0x24(%rsp), %esi
callq 0x3440
movq %rax, %r12
leaq 0x58b2(%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 $0x5, %ecx
movq %r15, %rax
mulq %rcx
movq $-0x1, %rbp
cmovoq %rbp, %rax
movq %rax, %rdi
callq 0x3030
movq %rax, %r12
movq (%r13), %r13
movl $0x18, %ecx
movq %r13, %rax
mulq %rcx
seto %cl
addq $0x8, %rax
cmovbq %rbp, %rax
testb %cl, %cl
cmoveq %rax, %rbp
movq %rbp, %rdi
callq 0x3030
movq %rax, %rbp
movq %r13, (%rax)
addq $0x8, %rbp
testq %r13, %r13
je 0x5b49
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, 0x8740(%rip)      # 0xe290
leaq (%r15,%r15,4), %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 0x3ba2
callq 0x3724
callq 0x9d69
callq 0x9d69
leaq 0x28(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x91dc
movq 0x843d(%rip), %rdi      # 0xdfd8
leaq 0x5788(%rip), %rsi      # 0xb32a
movl $0x23, %edx
callq 0x32d0
movq %r15, %xmm1
punpckldq 0x54b7(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x54bf(%rip), %xmm1     # 0xb080
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x544b(%rip), %xmm0     # 0xb020
mulsd 0x544b(%rip), %xmm0     # 0xb028
movq 0x83f4(%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 0x83b8(%rip), %rdi      # 0xdfd8
leaq 0x5727(%rip), %rsi      # 0xb34e
movl $0x23, %edx
callq 0x32d0
movsd 0x53d7(%rip), %xmm1     # 0xb010
movsd 0x28(%rsp), %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
subsd 0x30(%rsp), %xmm0
movq 0x8384(%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 0x834e(%rip), %rdi      # 0xdfd8
leaq 0x56e1(%rip), %rsi      # 0xb372
movl $0x19, %edx
callq 0x32d0
movsd 0x28(%rsp), %xmm0
movsd 0x5367(%rip), %xmm1     # 0xb010
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movq 0x8320(%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 0x569a(%rip), %rdi      # 0xb38c
movq %rbx, %rsi
callq 0x3370
testl %eax, %eax
je 0x5d11
leaq 0x5689(%rip), %rdi      # 0xb38e
movq %rbx, %rsi
callq 0x3370
testl %eax, %eax
jne 0x5d27
movq 0x8578(%rip), %rcx      # 0xe290
movq %r12, %rdi
movq %r15, %rsi
movl 0x24(%rsp), %edx
callq 0x51eb
movq %r12, %rdi
callq 0x3340
movq 0x828a(%rip), %rax      # 0xdfc0
movq (%rax), %rdi
callq 0x3250
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
leaq 0x10(%rsp), %rbx
je 0x5d5f
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3270
movq (%rsp), %rdi
cmpq %rbx, %rdi
je 0x5d75
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 0x5605(%rip), %rdi      # 0xb390
callq 0x3130
leaq 0x55f9(%rip), %rdi      # 0xb390
callq 0x3130
jmp 0x5dcd
jmp 0x5dcd
movq %rax, %rbx
cmpl $0x0, (%r15)
jne 0x5dc0
movl %ebp, (%r15)
jmp 0x5dc0
movq %rax, %rbx
cmpl $0x0, (%r12)
jne 0x5dc0
movl 0x30(%rsp), %eax
movl %eax, (%r12)
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x5e03
jmp 0x5dd4
movq %rax, %rbx
jmp 0x5e15
jmp 0x5ddb
movq %rax, %rbx
jmp 0x5dfa
jmp 0x5ddb
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x5dfa
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3270
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5e15
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3270
movq %rbx, %rdi
callq 0x3450
nop