// File: /workspace/github_cpp_makefile_star2_O2/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 0x1b8(%rsp), %rdi
pushq $0x2
popq %r14
pushq $0x1
popq %r15
movl %r14d, %esi
movl %r15d, %edx
callq 0xa57e
leaq 0x158(%rsp), %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0xa57e
leaq 0x2f93(%rip), %rcx      # 0xc5be
leaq 0x178(%rsp), %rdi
movl %ebp, %esi
movq %rbx, %rdx
xorl %r8d, %r8d
callq 0x766c
leaq 0x2f7d(%rip), %rsi      # 0xc5c4
leaq 0x178(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0x7e98
leaq 0x178(%rsp), %rdi
pushq $0x68
popq %rsi
callq 0x812e
testq %rax, %rax
jne 0x9685
leaq 0x2fbf(%rip), %rsi      # 0xc632
leaq 0x178(%rsp), %rdi
callq 0x80da
testq %rax, %rax
je 0x9693
leaq 0x2f38(%rip), %rdi      # 0xc5c4
xorl %eax, %eax
callq 0x2662
leaq 0x178(%rsp), %rdi
pushq $0x6e
popq %rsi
callq 0x812e
leaq 0x1d8(%rsp), %rdi
pushq $0x8
popq %rdx
movq %rax, %rsi
callq 0x4844
leaq 0x1d8(%rsp), %rdi
callq 0x4748
testb %al, %al
jne 0x96f6
leaq 0x1d8(%rsp), %rdi
pushq $0xa
popq %rsi
callq 0x739c
movl %eax, 0x8b6b(%rip)      # 0x12248
testl %eax, %eax
jg 0x96f6
leaq 0x2f4f(%rip), %rdi      # 0xc637
leaq 0x2ed5(%rip), %rsi      # 0xc5c4
xorl %eax, %eax
callq 0x25ca
leaq 0x178(%rsp), %rdi
pushq $0x51
popq %rsi
callq 0x812e
testq %rax, %rax
setne 0x8b51(%rip)            # 0x12261
leaq 0x178(%rsp), %rdi
pushq $0x43
popq %rsi
callq 0x812e
testq %rax, %rax
setne 0x8b38(%rip)            # 0x12262
leaq 0x178(%rsp), %rdi
callq 0x81ec
testl %eax, %eax
je 0x97b0
leaq 0x178(%rsp), %rbx
leaq 0x2994(%rip), %r14      # 0xc0de
leaq 0x158(%rsp), %r12
leaq 0x1b8(%rsp), %r13
movq %rbx, %rdi
callq 0x81f4
movq %rax, %r15
testq %rax, %rax
je 0x981a
movq %r15, %rdi
movq %r14, %rsi
callq 0x22d0
movq %rax, %rbp
testq %rax, %rax
jne 0x9792
leaq 0x2ee3(%rip), %rdi      # 0xc66b
movq %r15, %rsi
xorl %eax, %eax
callq 0x25ca
movl 0x8ab0(%rip), %ecx      # 0x12248
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x86c0
movq %rbp, %rdi
callq 0x2230
jmp 0x975a
leaq 0x2ea2(%rip), %rdi      # 0xc659
leaq 0x2920(%rip), %rsi      # 0xc0de
callq 0x22d0
movq %rax, %rbx
testq %rax, %rax
jne 0x97e0
leaq 0x2e99(%rip), %rdi      # 0xc66b
leaq 0x2e80(%rip), %rsi      # 0xc659
xorl %eax, %eax
callq 0x25ca
movl 0x8a62(%rip), %esi      # 0x12248
leaq 0x2e9f(%rip), %rdi      # 0xc68c
xorl %eax, %eax
callq 0x2662
movl 0x8a4e(%rip), %ecx      # 0x12248
leaq 0x158(%rsp), %rsi
leaq 0x1b8(%rsp), %rdx
movq %rbx, %rdi
callq 0x86c0
movq %rbx, %rdi
callq 0x2230
leaq 0x200(%rsp), %rdi
andw $0x0, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
leaq 0x2e79(%rip), %rdx      # 0xc6ad
leaq 0x158(%rsp), %rsi
callq 0x8a2f
pushq $0x2b
popq %rcx
leaq 0x200(%rsp), %rsi
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x88df
leaq 0x2e5f(%rip), %rdx      # 0xc6bd
leaq 0x200(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x8cb2
pushq $0x2b
popq %rcx
leaq 0x200(%rsp), %rsi
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x88df
leaq 0x2e3e(%rip), %rdx      # 0xc6ce
leaq 0x200(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x8f01
pushq $0x2b
popq %rcx
leaq 0x200(%rsp), %rsi
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x88df
leaq 0x2e27(%rip), %rdx      # 0xc6e9
leaq 0x200(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x914d
pushq $0x2b
popq %rcx
leaq 0x200(%rsp), %rsi
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x88df
leaq 0x1d8(%rsp), %rdi
callq 0x49aa
leaq 0x178(%rsp), %rdi
callq 0x801c
leaq 0x158(%rsp), %rdi
callq 0xa5ac
leaq 0x1b8(%rsp), %rdi
callq 0xa5ac
xorl %eax, %eax
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9952
jmp 0x9952
jmp 0x9952
movq %rax, %rbx
jmp 0x996f
movq %rax, %rbx
jmp 0x997c
jmp 0x9947
movq %rax, %rbx
jmp 0x9962
jmp 0x9952
jmp 0x9952
jmp 0x9952
movq %rax, %rbx
leaq 0x1d8(%rsp), %rdi
callq 0x49aa
leaq 0x178(%rsp), %rdi
callq 0x801c
leaq 0x158(%rsp), %rdi
callq 0xa5ac
leaq 0x1b8(%rsp), %rdi
callq 0xa5ac
movq %rbx, %rdi
callq 0x2400