// File: /workspace/github_cpp_makefile_star2_O3/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 0x94c4(%rip), %r15      # 0x13d80
leaq 0x1b8(%rsp), %rdi
movq %r15, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
leaq 0x2707(%rip), %r14      # 0xcfdc
movq %r14, 0x18(%rdi)
movl $0x2, %esi
callq 0xb8f2
leaq 0x158(%rsp), %rdi
movq %r15, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
movq %r14, 0x18(%rdi)
movl $0x2, %esi
callq 0xb8f2
leaq 0x3d04(%rip), %rcx      # 0xe60e
leaq 0x178(%rsp), %rdi
movl %ebp, %esi
movq %rbx, %rdx
xorl %r8d, %r8d
callq 0x7d7c
leaq 0x3cee(%rip), %rsi      # 0xe614
leaq 0x178(%rsp), %rdi
movl $0x1, %edx
callq 0x8784
leaq 0x178(%rsp), %rdi
movl $0x68, %esi
callq 0x8ab0
testq %rax, %rax
jne 0xa968
leaq 0x3d2c(%rip), %rsi      # 0xe682
leaq 0x178(%rsp), %rdi
callq 0x8a54
testq %rax, %rax
je 0xa976
leaq 0x3ca5(%rip), %rdi      # 0xe614
xorl %eax, %eax
callq 0x2470
leaq 0x178(%rsp), %rdi
movl $0x6e, %esi
callq 0x8ab0
leaq 0x1d8(%rsp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x4bec
leaq 0x1d8(%rsp), %rdi
callq 0x4aea
testb %al, %al
jne 0xa9df
leaq 0x1d8(%rsp), %rdi
movl $0xa, %esi
callq 0x7a3c
movl %eax, 0x9882(%rip)      # 0x14248
testl %eax, %eax
jg 0xa9df
leaq 0x3cb6(%rip), %rdi      # 0xe687
leaq 0x3c3c(%rip), %rsi      # 0xe614
xorl %eax, %eax
callq 0x286c
leaq 0x178(%rsp), %rdi
movl $0x51, %esi
callq 0x8ab0
testq %rax, %rax
setne 0x9866(%rip)            # 0x14261
leaq 0x178(%rsp), %rdi
movl $0x43, %esi
callq 0x8ab0
testq %rax, %rax
setne 0x984b(%rip)            # 0x14262
leaq 0x178(%rsp), %rdi
callq 0x8b7e
testl %eax, %eax
je 0xaa9d
leaq 0x178(%rsp), %rbx
leaq 0x3849(%rip), %r14      # 0xe280
leaq 0x158(%rsp), %r12
leaq 0x1b8(%rsp), %r13
movq %rbx, %rdi
callq 0x8b8a
movq %rax, %r15
testq %rax, %rax
je 0xab07
movq %r15, %rdi
movq %r14, %rsi
callq 0x22d0
movq %rax, %rbp
testq %rax, %rax
jne 0xaa7f
leaq 0x3c46(%rip), %rdi      # 0xe6bb
movq %r15, %rsi
xorl %eax, %eax
callq 0x286c
movl 0x97c3(%rip), %ecx      # 0x14248
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x90b4
movq %rbp, %rdi
callq 0x2230
jmp 0xaa47
leaq 0x3c05(%rip), %rdi      # 0xe6a9
leaq 0x37d5(%rip), %rsi      # 0xe280
callq 0x22d0
movq %rax, %rbx
testq %rax, %rax
jne 0xaacd
leaq 0x3bfc(%rip), %rdi      # 0xe6bb
leaq 0x3be3(%rip), %rsi      # 0xe6a9
xorl %eax, %eax
callq 0x286c
movl 0x9775(%rip), %esi      # 0x14248
leaq 0x3c02(%rip), %rdi      # 0xe6dc
xorl %eax, %eax
callq 0x2470
movl 0x9761(%rip), %ecx      # 0x14248
leaq 0x158(%rsp), %rsi
leaq 0x1b8(%rsp), %rdx
movq %rbx, %rdi
callq 0x90b4
movq %rbx, %rdi
callq 0x2230
leaq 0x200(%rsp), %rdi
movw $0x0, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
leaq 0x3bdb(%rip), %rdx      # 0xe6fd
leaq 0x158(%rsp), %rsi
callq 0x9501
leaq 0x200(%rsp), %rsi
movl $0x2b, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x9394
leaq 0x3bbf(%rip), %rdx      # 0xe70d
leaq 0x200(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x9865
leaq 0x200(%rsp), %rsi
movl $0x2b, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x9394
leaq 0x3b9c(%rip), %rdx      # 0xe71e
leaq 0x200(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x9be2
leaq 0x200(%rsp), %rsi
movl $0x2b, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x9394
leaq 0x3b83(%rip), %rdx      # 0xe739
leaq 0x200(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0xa048
leaq 0x200(%rsp), %rsi
movl $0x2b, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x9394
leaq 0x1d8(%rsp), %rdi
callq 0x4d60
leaq 0x178(%rsp), %rdi
callq 0x8900
leaq 0x158(%rsp), %rdi
leaq 0x9174(%rip), %rbx      # 0x13d80
movq %rbx, (%rdi)
callq 0xd026
leaq 0x1b8(%rsp), %rdi
movq %rbx, (%rdi)
callq 0xd026
xorl %eax, %eax
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xac5f
jmp 0xac5f
jmp 0xac3e
movq %rax, %rdi
callq 0x8c7a
jmp 0xac5f
movq %rax, %rbx
jmp 0xac7c
movq %rax, %rbx
jmp 0xac89
jmp 0xac54
movq %rax, %rbx
jmp 0xac6f
jmp 0xac5f
jmp 0xac5f
jmp 0xac5f
movq %rax, %rbx
leaq 0x1d8(%rsp), %rdi
callq 0x4d60
leaq 0x178(%rsp), %rdi
callq 0x8900
leaq 0x158(%rsp), %rdi
callq 0xb8b6
leaq 0x1b8(%rsp), %rdi
callq 0xb8b6
movq %rbx, %rdi
callq 0x2400