// File: /workspace/github_cpp_makefile_star2_O1/gpertea[P]gclib/htest.cpp
// Function: main
int main(int argc, char* argv[]) {
 GPVec<HStrData> strs;
 GPVec<HStrData> sufstrs;
 //GArgs args(argc, argv, "hg:c:s:t:o:p:help;genomic-fasta=COV=PID=seq=out=disable-flag;test=");
 GArgs args(argc, argv, "hQCn:");
 //fprintf(stderr, "Command line was:\n");
 //args.printCmdLine(stderr);
 args.printError(USAGE, true);
 if (args.getOpt('h') || args.getOpt("help")) GMessage(USAGE);
 GStr s=args.getOpt('n');
 if (!s.is_empty()) {
	 numClusters=s.asInt();
	 if (numClusters<=0)
		 GError("%s\nError: invalid value for -n !\n", USAGE);
 }
 qryMode=(args.getOpt('Q'));
 checkRM=(args.getOpt('C'));
 int numargs=args.startNonOpt();
 const char* a=NULL;
 FILE* f=NULL;
 int total=0;
//==== quick test area
 /*
 std::unordered_map<SObj*, int > umap;
 GHash<int> gh;
 GPVec<SObj> ptrs(false);
 GQHash<int, SObj*> ihash(false);
 GQHash<SObj*, int> phash;
 GQStrHash<SObj*> shash;
 const char* tstrs[6] = {"twelve", "five", "nine", "eleven", "three", "nope"};
 int  vals[6]     = { 12,  5, 9, 11, 3, 777 };
 char buf[20];
 for (int i=0;i<5;i++) {
   SObj* o=new SObj(tstrs[i], vals[i]*10);
   ptrs.Add(o);
   sprintf(buf, "%lx", o);
   GMessage("SObj (%s, %d) pointer added: %s\n",tstrs[i], o->val, buf);
   gh.Add(buf, new int(vals[i]));
   shash.Add(tstrs[i], o);
   ihash.Add(vals[i], o);
   phash.Add(o, vals[i]);
   umap[o]=vals[i];
 }
 ptrs.Sort();
 GMessage("shash has now %d entries.\n", shash.Count());
 //enumerate shash entries:
 {
   shash.startIterate();
   SObj* iv=NULL;
   while (const char* k=shash.Next(iv)) {
	   GMessage("Enumerating shash entry: (%s => %lx)\n",
			    k, iv);
   }
 }
 //qry:
 for (int i=0;i<ptrs.Count();i++) {
   SObj* o=ptrs[i];
   //test tset
   SObj* v=shash.Find(o->atr.chars());
   if (v==NULL)
	   GMessage("key <%s> not found in shash!\n", o->atr.chars());
   int* iv=phash.Find(o);
   if (iv==NULL)
	   GMessage("key <%lx> not found in phash!\n", o);
   //if (!oset[*o])
//   GMessage("struct {%s, %d} not found in oset!\n", o->atr.chars(), o->val);

   //sprintf(buf, "%lx", o);
   //int* hv=gh[buf];
   //GMessage("Item {%s, %d} : GHash retrieved flag = %d, umap retrieved flag = %d\n",
   //  o->atr.chars(), o->val, *hv, umap[o]);
 }
//SObj* n=new SObj("test", 10);
//if (!pset[n])
//	   GMessage("key <%lx> not found in pset!\n", n);

 for (int i=0;i<6;i++) {
	SObj* o=shash[tstrs[i]];
	if (o==NULL) GMessage("key <%s> not found in shash!\n", tstrs[i]);
	if (o && i<5) {
		if (o->atr!=tstrs[i])
			GMessage("shash value does not match key <%s!\n", tstrs[i]);
	}
 }

 //delete n;
 //int v=umap[n];
 //GMessage("Non-existing test entry returned value %d\n", v);
  */
 /*
 auto found=umap.find(n);
 if (found!=umap.end()) {
   GMessage("Found flags %d for entry {\"%s\", %d}\n", found->second,
         n->atr.chars(), found->first->val );
 } else  GMessage("New test obj not found !\n");

 return(0);
*/
//==== quick test area end
 if (numargs==0) {
	 //a="htest_data.lst";
	 a="htest_over500.lst";
	 f=fopen(a, "r");
	 if (f==NULL) GError("Error: could not open file %s !\n", a);
	 GMessage("loading %d clusters from file..\n", numClusters);
	 int num=loadStrings(f, sufstrs, strs, numClusters);
	 total+=num;
	 fclose(f);
 }
 else {
	   while ((a=args.nextNonOpt())) {
		   f=fopen(a, "r");
		   if (f==NULL) GError("Error: could not open file %s !\n", a);
		   int num=loadStrings(f, sufstrs, strs, numClusters);
		   total+=num;
		   fclose(f);
	   }
  }
   GResUsage swatch;


   run_GHash(swatch, sufstrs, "GHash w/ suffix");
   showTimings(swatch);
   //run_GHash(swatch, strs, "GHash no suffix");
   //showTimings(swatch);

/*
   run_Hopscotch(swatch, sufstrs, "hopscotch w/ suffix");
   showTimings(swatch);
   run_Hopscotch(swatch, strs, "hopscotch no suffix");
   showTimings(swatch);
*/
/*
   run_Robin(swatch, sufstrs, "robin w/ suffix");
   showTimings(swatch);
   run_Robin(swatch, strs, "robin no suffix");
   showTimings(swatch);
*/

   run_Khashl(swatch, sufstrs, "khashl w/ suffix");
   showTimings(swatch);
/*
   run_Khashl(swatch, strs, "khashl no suffix");
   showTimings(swatch);
*/
   run_GHashMap(swatch, sufstrs, "GHashMap default w/ suffix");
   showTimings(swatch);

   run_GxxHashMap(swatch, sufstrs, "GHashMap xxHash32 w/ suffix");
   showTimings(swatch);

   //run_GHashMap(swatch, strs, "GHashMap no suffix");
   //showTimings(swatch);

   //run_GHashMapShk(swatch, sufstrs, "GHashSetShk w/ suffix");
   //showTimings(swatch);
   //run_GHashMapShk(swatch, strs, "GHashSetShk no suffix");
   //showTimings(swatch);

/*
   run_Bytell(swatch, sufstrs, "bytell w/ suffix");
   showTimings(swatch);
   run_Bytell(swatch, strs, "bytell no suffix");
   showTimings(swatch);
*/

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x358, %rsp            # imm = 0x358
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x927e(%rip), %r15      # 0x13d80
leaq 0x1b8(%rsp), %rdi
movq %r15, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
leaq 0x25c1(%rip), %r14      # 0xd0dc
movq %r14, 0x18(%rdi)
movl $0x2, %esi
callq 0xbb0c
leaq 0x158(%rsp), %rdi
movq %r15, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
movq %r14, 0x18(%rdi)
movl $0x2, %esi
callq 0xbb0c
leaq 0x39ee(%rip), %rcx      # 0xe53e
leaq 0x178(%rsp), %rdi
movl %ebp, %esi
movq %rbx, %rdx
xorl %r8d, %r8d
callq 0x7f6c
leaq 0x39d8(%rip), %rsi      # 0xe544
leaq 0x178(%rsp), %rdi
movl $0x1, %edx
callq 0x89aa
leaq 0x178(%rsp), %rdi
movl $0x68, %esi
callq 0x8cea
testq %rax, %rax
jne 0xabae
leaq 0x3a16(%rip), %rsi      # 0xe5b2
leaq 0x178(%rsp), %rdi
callq 0x8c8e
testq %rax, %rax
je 0xabbc
leaq 0x398f(%rip), %rdi      # 0xe544
xorl %eax, %eax
callq 0x2470
leaq 0x178(%rsp), %rdi
movl $0x6e, %esi
callq 0x8cea
leaq 0x1d8(%rsp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x4cb6
leaq 0x1d8(%rsp), %rdi
callq 0x4bb4
testb %al, %al
jne 0xac25
leaq 0x1d8(%rsp), %rdi
movl $0xa, %esi
callq 0x7c0e
movl %eax, 0x963c(%rip)      # 0x14248
testl %eax, %eax
jg 0xac25
leaq 0x39a0(%rip), %rdi      # 0xe5b7
leaq 0x3926(%rip), %rsi      # 0xe544
xorl %eax, %eax
callq 0x289c
leaq 0x178(%rsp), %rdi
movl $0x51, %esi
callq 0x8cea
testq %rax, %rax
setne 0x9620(%rip)            # 0x14261
leaq 0x178(%rsp), %rdi
movl $0x43, %esi
callq 0x8cea
testq %rax, %rax
setne 0x9605(%rip)            # 0x14262
leaq 0x178(%rsp), %rdi
callq 0x8db8
testl %eax, %eax
je 0xace3
leaq 0x178(%rsp), %rbx
leaq 0x35f1(%rip), %r14      # 0xe26e
leaq 0x158(%rsp), %r12
leaq 0x1b8(%rsp), %r13
movq %rbx, %rdi
callq 0x8dc4
movq %rax, %r15
testq %rax, %rax
je 0xad4d
movq %r15, %rdi
movq %r14, %rsi
callq 0x22d0
movq %rax, %rbp
testq %rax, %rax
jne 0xacc5
leaq 0x3930(%rip), %rdi      # 0xe5eb
movq %r15, %rsi
xorl %eax, %eax
callq 0x289c
movl 0x957d(%rip), %ecx      # 0x14248
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x92f0
movq %rbp, %rdi
callq 0x2230
jmp 0xac8d
leaq 0x38ef(%rip), %rdi      # 0xe5d9
leaq 0x357d(%rip), %rsi      # 0xe26e
callq 0x22d0
movq %rax, %rbx
testq %rax, %rax
jne 0xad13
leaq 0x38e6(%rip), %rdi      # 0xe5eb
leaq 0x38cd(%rip), %rsi      # 0xe5d9
xorl %eax, %eax
callq 0x289c
movl 0x952f(%rip), %esi      # 0x14248
leaq 0x38ec(%rip), %rdi      # 0xe60c
xorl %eax, %eax
callq 0x2470
movl 0x951b(%rip), %ecx      # 0x14248
leaq 0x158(%rsp), %rsi
leaq 0x1b8(%rsp), %rdx
movq %rbx, %rdi
callq 0x92f0
movq %rbx, %rdi
callq 0x2230
leaq 0x200(%rsp), %rdi
movw $0x0, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
leaq 0x38c5(%rip), %rdx      # 0xe62d
leaq 0x158(%rsp), %rsi
callq 0x9751
leaq 0x200(%rsp), %rsi
movl $0x2b, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x95e4
leaq 0x38a9(%rip), %rdx      # 0xe63d
leaq 0x200(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x9abe
leaq 0x200(%rsp), %rsi
movl $0x2b, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x95e4
leaq 0x3886(%rip), %rdx      # 0xe64e
leaq 0x200(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x9e3d
leaq 0x200(%rsp), %rsi
movl $0x2b, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x95e4
leaq 0x386d(%rip), %rdx      # 0xe669
leaq 0x200(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0xa29c
leaq 0x200(%rsp), %rsi
movl $0x2b, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x95e4
leaq 0x1d8(%rsp), %rdi
callq 0x4e2a
leaq 0x178(%rsp), %rdi
callq 0x8b3a
leaq 0x158(%rsp), %rdi
leaq 0x8f2e(%rip), %rbx      # 0x13d80
movq %rbx, (%rdi)
callq 0xd128
leaq 0x1b8(%rsp), %rdi
movq %rbx, (%rdi)
callq 0xd128
xorl %eax, %eax
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xaea5
jmp 0xaea5
jmp 0xae84
movq %rax, %rdi
callq 0x8eb0
jmp 0xaea5
movq %rax, %rbx
jmp 0xaec2
movq %rax, %rbx
jmp 0xaecf
jmp 0xae9a
movq %rax, %rbx
jmp 0xaeb5
jmp 0xaea5
jmp 0xaea5
jmp 0xaea5
movq %rax, %rbx
leaq 0x1d8(%rsp), %rdi
callq 0x4e2a
leaq 0x178(%rsp), %rdi
callq 0x8b3a
leaq 0x158(%rsp), %rdi
callq 0xbaca
leaq 0x1b8(%rsp), %rdi
callq 0xbaca
movq %rbx, %rdi
callq 0x2400