// File: /workspace/github_cpp_makefile_star2_O2/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
pushq $0xa
popq %rsi
pushq $0x1e
popq %rdx
callq 0x403c
leaq 0x18(%rsp), %rdi
callq 0x7b18
leal -0x4(%r14), %eax
cmpl $-0x3, %eax
ja 0x36a2
movq 0x99a0(%rip), %rdi      # 0xcff0
leaq 0x49ad(%rip), %rsi      # 0x8004
callq 0x3200
movq %rax, %rdi
callq 0x3120
movq 0x9985(%rip), %rdi      # 0xcff0
leaq 0x4998(%rip), %rsi      # 0x800a
callq 0x3200
movq %rax, %rdi
callq 0x3120
movq 0x996a(%rip), %rdi      # 0xcff0
leaq 0x49d2(%rip), %rsi      # 0x805f
callq 0x3200
movq %rax, %rdi
callq 0x3120
pushq $0x1
popq %rdi
callq 0x3280
movq 0x8(%rbx), %rsi
cmpl $0x3, %r14d
jne 0x3716
leaq 0x80(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x3c9a
leaq 0x160(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x49a0
leaq 0x80(%rsp), %rdi
callq 0x3110
movq 0x10(%rbx), %rsi
leaq 0x60(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x3c9a
leaq 0x160(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x5bb6
leaq 0x60(%rsp), %rdi
callq 0x3110
xorl %edi, %edi
callq 0x3280
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x3c9a
leaq 0x160(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x5dbc
leaq 0x40(%rsp), %rdi
callq 0x3110
leaq 0x160(%rsp), %rdi
callq 0x4bba
leaq 0x18(%rsp), %rdi
movl %eax, %esi
callq 0x7bac
movq 0x9867(%rip), %rbx      # 0xcfc8
movq 0x9870(%rip), %r15      # 0xcfd8
leaq 0xb(%rsp), %r12
leaq 0x160(%rsp), %r13
leaq 0x20(%rsp), %rbp
movq %rbx, %rdi
leaq 0x4919(%rip), %rsi      # 0x809d
callq 0x3200
movq %rax, %rdi
callq 0x3120
movq %r15, %rdi
movq %r12, %rsi
callq 0x3310
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
andq $0x0, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
movzbl 0xb(%rsp), %eax
cmpl $0x61, %eax
je 0x3b27
cmpl $0x66, %eax
je 0x392d
cmpl $0x73, %eax
je 0x3a15
cmpl $0x74, %eax
jne 0x3bb9
movq %rbx, %rdi
leaq 0x49f1(%rip), %rsi      # 0x81d5
callq 0x3200
movq %rax, %rdi
callq 0x3120
movq %rbx, %rdi
leaq 0x49f4(%rip), %rsi      # 0x81ef
callq 0x3200
movq %rax, %rdi
callq 0x3120
movq %r13, %rdi
callq 0x4f06
movq %rbx, %rdi
leaq 0x49e8(%rip), %rsi      # 0x8202
callq 0x3200
movq %rax, %rdi
callq 0x3120
leaq 0x140(%rsp), %r14
movq %r14, %rdi
leaq 0x49d9(%rip), %rsi      # 0x8212
leaq 0xa(%rsp), %rdx
callq 0x3c9a
movq %r13, %rdi
movq %r14, %rsi
callq 0x4ff2
movq %r14, %rdi
callq 0x3110
movq %rbx, %rdi
leaq 0x49bc(%rip), %rsi      # 0x821c
callq 0x3200
movq %rax, %rdi
callq 0x3120
leaq 0x120(%rsp), %r14
movq %r14, %rdi
leaq 0x49ac(%rip), %rsi      # 0x822b
leaq 0xa(%rsp), %rdx
callq 0x3c9a
movq %r13, %rdi
movq %r14, %rsi
callq 0x5118
movq %r14, %rdi
callq 0x3110
movq %rbx, %rdi
leaq 0x498e(%rip), %rsi      # 0x8234
callq 0x3200
movq %rax, %rdi
callq 0x3120
leaq 0x100(%rsp), %r14
movq %r14, %rdi
leaq 0x4966(%rip), %rsi      # 0x822b
leaq 0xa(%rsp), %rdx
callq 0x3c9a
movq %r13, %rdi
movq %r14, %rsi
callq 0x5238
movq %r14, %rdi
callq 0x3110
movq %rbx, %rdi
leaq 0x4957(%rip), %rsi      # 0x8243
callq 0x3200
movq %rax, %rdi
callq 0x3120
leaq 0xe0(%rsp), %r14
movq %r14, %rdi
leaq 0x4948(%rip), %rsi      # 0x8253
leaq 0xa(%rsp), %rdx
callq 0x3c9a
movq %r13, %rdi
movq %r14, %rsi
callq 0x4ff2
movq %r14, %rdi
callq 0x3110
jmp 0x3bd0
movq %rbx, %rdi
leaq 0x47bd(%rip), %rsi      # 0x80f4
callq 0x3200
movq %rax, %rdi
callq 0x3120
movq %r15, %rdi
movq %rbp, %rsi
callq 0x32c0
movq %rbx, %rdi
leaq 0x47b5(%rip), %rsi      # 0x810e
callq 0x3200
movq %rax, %rdi
callq 0x3120
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
callq 0x3150
movq %r13, %rdi
callq 0x4bba
leaq 0x18(%rsp), %rdi
movq %rbp, %rsi
movl %eax, %edx
callq 0x7b2e
movl %eax, %r14d
movq %rbx, %rdi
leaq 0x47a7(%rip), %rsi      # 0x813e
callq 0x3200
movl %r14d, %esi
movq %rax, %rdi
callq 0x3180
movq %rax, %rdi
callq 0x3120
movl 0xc(%rsp), %edx
movq %r13, %rdi
movl %r14d, %esi
callq 0x4d28
movl %eax, %r14d
movq %rbx, %rdi
leaq 0x477e(%rip), %rsi      # 0x8149
callq 0x3200
movl 0xc(%rsp), %esi
movq %rax, %rdi
callq 0x3400
movq %rax, %rdi
leaq 0x478a(%rip), %rsi      # 0x8170
callq 0x3200
movq %rax, %rdi
movq %rbp, %rsi
callq 0x31e0
movq %rax, %rdi
leaq 0x4783(%rip), %rsi      # 0x8183
callq 0x3200
movl %r14d, %esi
movq %rax, %rdi
callq 0x3180
jmp 0x3bc8
movq %rbx, %rdi
leaq 0x46d5(%rip), %rsi      # 0x80f4
callq 0x3200
movq %rax, %rdi
callq 0x3120
movq %r15, %rdi
movq %rbp, %rsi
callq 0x32c0
movq %rbx, %rdi
leaq 0x46cd(%rip), %rsi      # 0x810e
callq 0x3200
movq %rax, %rdi
callq 0x3120
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
callq 0x3150
leaq 0xc0(%rsp), %rdi
movq %rbp, %rsi
callq 0x3340
movq %r13, %rdi
leaq 0xc0(%rsp), %r14
movq %r14, %rsi
callq 0x57a0
movq %r14, %rdi
callq 0x3110
leaq 0xa0(%rsp), %rdi
movq %rbp, %rsi
callq 0x3340
movl 0xc(%rsp), %edx
movq %r13, %rdi
leaq 0xa0(%rsp), %r14
movq %r14, %rsi
callq 0x4bc2
movq %r14, %rdi
callq 0x3110
movq %rbx, %rdi
leaq 0x4668(%rip), %rsi      # 0x8127
callq 0x3200
movq %rax, %r14
movq %r13, %rdi
callq 0x4d04
movl %eax, %esi
movq %r14, %rdi
callq 0x3180
movq %rax, %rdi
leaq 0x49a2(%rip), %rsi      # 0x8485
callq 0x3200
movq %rax, %r14
movq %r13, %rdi
callq 0x4d0c
movl %eax, %esi
movq %r14, %rdi
callq 0x3180
movq %rax, %rdi
leaq 0x462d(%rip), %rsi      # 0x8134
callq 0x3200
movq %rax, %r14
movq %r13, %rdi
callq 0x4d20
movzbl %al, %esi
movq %r14, %rdi
callq 0x33d0
jmp 0x3bc8
movq %rbx, %rdi
leaq 0x4657(%rip), %rsi      # 0x8188
callq 0x3200
movq %rax, %rdi
callq 0x3120
movq %r15, %rdi
leaq 0x14(%rsp), %rsi
callq 0x3150
movq %rbx, %rdi
leaq 0x4646(%rip), %rsi      # 0x819b
callq 0x3200
movq %rax, %rdi
callq 0x3120
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
callq 0x3150
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
movq %r13, %rdi
callq 0x4e1e
movl %eax, %r14d
movq %rbx, %rdi
leaq 0x4624(%rip), %rsi      # 0x81b0
callq 0x3200
movl 0x10(%rsp), %esi
movq %rax, %rdi
callq 0x3400
movq %rax, %rdi
leaq 0x45dc(%rip), %rsi      # 0x8183
callq 0x3200
movq %rax, %rdi
movl %r14d, %esi
callq 0x3400
jmp 0x3bc8
movq %rbx, %rdi
leaq 0x469b(%rip), %rsi      # 0x825e
callq 0x3200
movq %rax, %rdi
callq 0x3120
movq %rbp, %rdi
callq 0x3110
jmp 0x377a
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
jmp 0x3c2f
jmp 0x3c3c
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
jmp 0x3c2f
jmp 0x3c3c
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
jmp 0x3c2f
jmp 0x3c3c
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
jmp 0x3c2f
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
jmp 0x3c2f
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x3110
jmp 0x3c3f
jmp 0x3c3c
jmp 0x3c72
jmp 0x3c72
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
jmp 0x3c67
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x3c67
jmp 0x3c72
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
jmp 0x3c67
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x3110
jmp 0x3c75
jmp 0x3c72
jmp 0x3c72
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x7ba2
jmp 0x3c84
movq %rax, %rbx
leaq 0x160(%rsp), %rdi
callq 0x4180
movq %rbx, %rdi
callq 0x3420
nop