// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]optimal-seed-solver/testHashTree.cc
// Function: main
int main(int argc, const char* argv[]) {
	HashTree tree;
	KmerHash hash;
	unsigned int DNAHash;
	unsigned int estLength;


	if (argc != 2 && argc != 3) {
		cerr << "Help:" << endl;
		cerr << "To generate the tree, please run: $ ./testHashTree referenceName.fasta treeName.tree" << endl;
		cerr << "To query the tree, please run: $ ./testHashTree treeName.tree" << endl;
		exit(1);
	}

	if (argc == 3) {
		tree.generateTree(argv[1]);
		tree.storeTree(argv[2]);
		exit(0);
	}
	tree.loadTree(argv[1]);
	hash.setKmerSize(tree.getHashLength() );

	while (1) {
		cout << "Please input mode: (f) frequency test; (s) seed test (a) average test (t) table test: " << endl;
		char option;
		cin >> option;
		string DNA;
		int threshold;
		int depth;
		int avgfreq;
		int index;
		switch (option) {
			case 's':

				cout << "please input DNA string: " << endl;
				cin >> DNA;

				cout << "please input threshold: " << endl;
				cin >> threshold;

				tree.test(DNA);
				tree.query(DNA, threshold);
				cout << "eff length: " << tree.effectiveLength() << " frequency: " << tree.frequency() << " isLeaf: " << tree.isLeaf() << endl;
				break;

			case 'f':

				cout << "please input DNA string: " << endl;
				cin >> DNA;

				cout << "please input threshold: " << endl;
				cin >> threshold;

				DNAHash = hash.calculateHash(DNA, tree.getHashLength() );
				cout << "DNA Hash: " << DNAHash << endl;
				estLength = tree.estimateFreqLength(DNAHash, threshold/*, DNA*/);
				cout << "Estimated extension length to achieve " << threshold << " locations of DNA " << DNA << " is " << estLength << endl;
				break;

			case 'a':
				cout << "please tree hash: " << endl;
				cin >> index;

				cout << "please input depth: " << endl;
				cin >> depth;

				avgfreq = tree.averageFreqDepth(index, depth);
				cout << "Average weighted frequency at depth " << depth << " is " << avgfreq << endl;
				break;

			case 't':
				cout << "Testing table generation." << endl;

				cout << "Calculating table." << endl;
				tree.calculateLenToFreqTable();

				cout << "Printing Table." << endl;
				tree.printHashLenTable("table.txt");

				cout << "Storing table." << endl;
				tree.storeHashLenTable("table.tb");

				cout << "Loading table." << endl;
				tree.readHashLenTable("table.tb");

				cout << "Printing table." << endl;
				tree.printHashLenTable("table2.txt");
				break;

			default:
				cout << "Unrecognized option" << endl;
				break;
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4b8, %rsp            # imm = 0x4B8
movq %rsi, %rbx
movl %edi, %r14d
leaq 0x160(%rsp), %rdi
movl $0xa, %esi
movl $0x1e, %edx
callq 0x46d0
leaq 0x38(%rsp), %rdi
callq 0x87d8
leal -0x4(%r14), %eax
cmpl $-0x3, %eax
ja 0x377b
movq 0x9928(%rip), %rbx      # 0xcff0
leaq 0x5935(%rip), %rsi      # 0x9004
movl $0x5, %edx
movq %rbx, %rdi
callq 0x32c0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq 0x98f6(%rip), %rdi      # 0xcff0
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq 0x98e2(%rip), %rbx      # 0xcff0
leaq 0x58f5(%rip), %rsi      # 0x900a
movl $0x54, %edx
movq %rbx, %rdi
callq 0x32c0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq 0x98b0(%rip), %rdi      # 0xcff0
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq 0x989c(%rip), %rdi      # 0xcff0
leaq 0x5904(%rip), %rsi      # 0x905f
movl $0x3d, %edx
callq 0x32c0
movq 0x9884(%rip), %rdi      # 0xcff0
callq 0x3140
movl $0x1, %edi
callq 0x32e0
movq 0x8(%rbx), %rsi
cmpl $0x3, %r14d
jne 0x3810
leaq 0x120(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x4238
leaq 0x160(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x518c
leaq 0x130(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x37d1
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x3270
movq 0x10(%rbx), %rsi
leaq 0x140(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x4238
leaq 0x160(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x676e
leaq 0x140(%rsp), %rdi
callq 0x3130
xorl %edi, %edi
callq 0x32e0
leaq 0x100(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x4238
leaq 0x160(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x69ba
leaq 0x110(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3858
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x3270
leaq 0x160(%rsp), %rdi
callq 0x5466
leaq 0x38(%rsp), %rdi
movl %eax, %esi
callq 0x887e
leaq 0x20(%rsp), %r12
movq 0x974b(%rip), %rbp      # 0xcfc8
movq 0x9754(%rip), %r15      # 0xcfd8
leaq 0x160(%rsp), %r13
movl $0x56, %edx
movq %rbp, %rdi
leaq 0x5802(%rip), %rsi      # 0x909d
callq 0x32c0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq %r15, %rdi
leaq 0x7(%rsp), %rsi
callq 0x3360
movq %r12, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
movzbl 0x7(%rsp), %eax
cmpl $0x72, %eax
jg 0x3a93
cmpl $0x61, %eax
je 0x3dc7
cmpl $0x66, %eax
jne 0x3d96
movl $0x19, %edx
movq %rbp, %rdi
leaq 0x57dd(%rip), %rsi      # 0x90f4
callq 0x32c0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
callq 0x3320
movl $0x18, %edx
movq %rbp, %rdi
leaq 0x57ae(%rip), %rsi      # 0x910e
callq 0x32c0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0x3180
movq %r13, %rdi
callq 0x5466
leaq 0x38(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl %eax, %edx
callq 0x87f2
movl %eax, %ebx
movl $0xa, %edx
movq %rbp, %rdi
leaq 0x577a(%rip), %rsi      # 0x913e
callq 0x32c0
movl %ebx, %esi
movq %rbp, %rdi
callq 0x31b0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movl 0x8(%rsp), %edx
movq %r13, %rdi
movl %ebx, %esi
callq 0x5628
movl %eax, %ebx
movl $0x26, %edx
movq %rbp, %rdi
leaq 0x572d(%rip), %rsi      # 0x9149
callq 0x32c0
movl 0x8(%rsp), %esi
movq %rbp, %rdi
callq 0x3430
movq %rax, %r14
movl $0x12, %edx
movq %rax, %rdi
leaq 0x5731(%rip), %rsi      # 0x9170
callq 0x32c0
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r14, %rdi
callq 0x32c0
movq %rax, %r14
movl $0x4, %edx
movq %rax, %rdi
leaq 0x571b(%rip), %rsi      # 0x9183
callq 0x32c0
movl %ebx, %esi
movq %r14, %rdi
callq 0x31b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3240
jmp 0x4082
cmpl $0x73, %eax
je 0x3ec8
cmpl $0x74, %eax
jne 0x3d96
movl $0x19, %edx
movq %rbp, %rdi
leaq 0x5721(%rip), %rsi      # 0x91d5
callq 0x32c0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movl $0x12, %edx
movq %rbp, %rdi
leaq 0x56ff(%rip), %rsi      # 0x91ef
callq 0x32c0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq %r13, %rdi
callq 0x5802
movl $0xf, %edx
movq %rbp, %rdi
leaq 0x56ce(%rip), %rsi      # 0x9202
callq 0x32c0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
leaq 0xf0(%rsp), %rax
movq %rax, 0xe0(%rsp)
leaq 0xe0(%rsp), %rbx
movq %rbx, %rdi
leaq 0x568f(%rip), %rsi      # 0x9212
leaq 0x5691(%rip), %rdx      # 0x921b
callq 0x4306
movq %r13, %rdi
movq %rbx, %rsi
callq 0x5910
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x3bbf
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x3270
movl $0xe, %edx
movq %rbp, %rdi
leaq 0x564e(%rip), %rsi      # 0x921c
callq 0x32c0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
leaq 0xd0(%rsp), %rax
movq %rax, 0xc0(%rsp)
leaq 0xc0(%rsp), %rbx
movq %rbx, %rdi
leaq 0x560e(%rip), %rsi      # 0x922b
leaq 0x560f(%rip), %rdx      # 0x9233
callq 0x4306
movq %r13, %rdi
movq %rbx, %rsi
callq 0x5a74
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x3c59
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x3270
movl $0xe, %edx
movq %rbp, %rdi
leaq 0x55cc(%rip), %rsi      # 0x9234
callq 0x32c0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
leaq 0xb0(%rsp), %rax
movq %rax, 0xa0(%rsp)
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
leaq 0x5574(%rip), %rsi      # 0x922b
leaq 0x5575(%rip), %rdx      # 0x9233
callq 0x4306
movq %r13, %rdi
movq %rbx, %rsi
callq 0x5bd2
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x3cf3
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x3270
movl $0xf, %edx
movq %rbp, %rdi
leaq 0x5541(%rip), %rsi      # 0x9243
callq 0x32c0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
leaq 0x5502(%rip), %rsi      # 0x9253
leaq 0x5505(%rip), %rdx      # 0x925d
callq 0x4306
movq %r13, %rdi
movq %rbx, %rsi
callq 0x5910
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x4095
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3270
jmp 0x4095
movl $0x13, %edx
movq %rbp, %rdi
leaq 0x54b9(%rip), %rsi      # 0x925e
callq 0x32c0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3240
movq %rbp, %rbx
jmp 0x4082
movl $0x12, %edx
movq %rbp, %rdi
leaq 0x53b2(%rip), %rsi      # 0x9188
callq 0x32c0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq %r15, %rdi
leaq 0x34(%rsp), %rsi
callq 0x3180
movl $0x14, %edx
movq %rbp, %rdi
leaq 0x537c(%rip), %rsi      # 0x919b
callq 0x32c0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
callq 0x3180
movl 0x34(%rsp), %esi
movl 0xc(%rsp), %edx
movq %r13, %rdi
callq 0x571a
movl %eax, %ebx
movl $0x24, %edx
movq %rbp, %rdi
leaq 0x5336(%rip), %rsi      # 0x91b0
callq 0x32c0
movl 0xc(%rsp), %esi
movq %rbp, %rdi
callq 0x3430
movq %rax, %r14
movl $0x4, %edx
movq %rax, %rdi
leaq 0x52e6(%rip), %rsi      # 0x9183
callq 0x32c0
movq %r14, %rdi
movl %ebx, %esi
callq 0x3430
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3240
jmp 0x4082
movl $0x19, %edx
movq %rbp, %rdi
leaq 0x521d(%rip), %rsi      # 0x90f4
callq 0x32c0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
callq 0x3320
movl $0x18, %edx
movq %rbp, %rdi
leaq 0x51ee(%rip), %rsi      # 0x910e
callq 0x32c0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0x3180
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x60(%rsp), %rdi
callq 0x4276
movq %r13, %rdi
leaq 0x60(%rsp), %rsi
callq 0x61be
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x3fa4
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3270
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %rdi
callq 0x4276
movl 0x8(%rsp), %edx
movq %r13, %rdi
leaq 0x40(%rsp), %rsi
callq 0x546e
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x3ff2
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3270
movl $0xc, %edx
movq %rbp, %rdi
leaq 0x5126(%rip), %rsi      # 0x9127
callq 0x32c0
movq %r13, %rdi
callq 0x5604
movl %eax, %esi
movq %rbp, %rdi
callq 0x31b0
movq %rax, %rbx
movl $0xc, %edx
movq %rax, %rdi
leaq 0x546b(%rip), %rsi      # 0x9495
callq 0x32c0
movq %r13, %rdi
callq 0x560c
movl %eax, %esi
movq %rbx, %rdi
callq 0x31b0
movq %rax, %rbx
movl $0x9, %edx
movq %rax, %rdi
leaq 0x50e1(%rip), %rsi      # 0x9134
callq 0x32c0
movq %r13, %rdi
callq 0x5620
movzbl %al, %esi
movq %rbx, %rdi
callq 0x3400
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x388c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3270
jmp 0x388c
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x4197
movq 0x90(%rsp), %rsi
jmp 0x4186
jmp 0x4194
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x4197
movq 0xb0(%rsp), %rsi
jmp 0x4186
jmp 0x4194
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x4197
movq 0xd0(%rsp), %rsi
jmp 0x4186
jmp 0x4194
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x4197
movq 0xf0(%rsp), %rsi
jmp 0x4186
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x4197
movq 0x50(%rsp), %rsi
jmp 0x4186
jmp 0x4194
movq %rax, %rbx
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x4197
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3270
jmp 0x4197
jmp 0x4210
jmp 0x4210
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x4213
movq 0x20(%rsp), %rsi
jmp 0x4202
movq %rax, %rbx
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4213
movq 0x150(%rsp), %rsi
jmp 0x4202
jmp 0x4210
movq %rax, %rbx
leaq 0x110(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4213
movq 0x110(%rsp), %rsi
jmp 0x4202
movq %rax, %rbx
leaq 0x130(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4213
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x3270
jmp 0x4213
jmp 0x4210
jmp 0x4210
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x8874
jmp 0x4222
movq %rax, %rbx
leaq 0x160(%rsp), %rdi
callq 0x4818
movq %rbx, %rdi
callq 0x3450
nop