// File: CMU-SAFARI[P]optimal-seed-solver/HashTree.cc
// Function: HashTree::test(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void HashTree::test(string DNA) {
	hashVal = hashgen.calculateHash(DNA, hashLength);

	queryCursor = root[hashVal];

	if (queryCursor == NULL) {
		cout << "NULL pointer detected" << endl;
		cout << "DNA: " << DNA << endl;
		cout << "hashLength: " << hashLength << endl;

	}

	TreeNode* nextCursor = queryCursor;

	int i;
	//The depth depends on the length of the string: DNA
	for (i = hashLength; i < DNA.length(); i++) {
		cout << "TreeNode: " << DNA.substr(0, i)
			<< " of frequency: " << queryCursor->getLocNum()
			<< " from chromosome: " << queryCursor->getChrNum()
			<< " at location: " << queryCursor->getLocation()
			<< " isLeaf: " << queryCursor->isLeaf() << endl;

		if (!queryCursor->isLeaf() ) {
			switch (DNA[i]) {
				case 'A':
					nextCursor = queryCursor->getA();
					break;
				case 'C':
					nextCursor = queryCursor->getC();
					break;
				case 'G':
					nextCursor = queryCursor->getG();
					break;
				case 'T':
					nextCursor = queryCursor->getT();
					break;
				default:
					cerr << "unrecognized character: " << DNA[i] << endl;
					break;
			}
		}

		queryCursor = nextCursor;

		if (queryCursor == NULL || queryCursor->isLeaf() )
			break;
	}

	cout << "LastNode: " << DNA.substr(0, i);
		if (queryCursor != NULL)
			cout << " of frequency: " << queryCursor->getLocNum()
				<< " from chromosome: " << queryCursor->getChrNum()
				<< " at location: " << queryCursor->getLocation()
				<< " isLeaf: " << queryCursor->isLeaf() << endl;
		else
			cout << " is NULL." << endl;
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rsi, 0xb8(%rsp)
movq %rdi, 0x130(%rsp)
movq %rsi, 0x128(%rsp)
movq 0x130(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq %rax, %rdi
addq $0x318, %rdi            # imm = 0x318
movl (%rax), %edx
callq 0x126e0
movl %eax, %ecx
movq 0xc0(%rsp), %rax
movl %ecx, 0x340(%rax)
movq 0x320(%rax), %rcx
movl 0x340(%rax), %edx
movq (%rcx,%rdx,8), %rcx
movq %rcx, 0x348(%rax)
cmpq $0x0, 0x348(%rax)
jne 0x987e
movq 0x117cb(%rip), %rdi     # 0x1afc8
leaq 0x9cc6(%rip), %rsi      # 0x134ca
callq 0x32a0
movq %rax, %rdi
movq 0x117a5(%rip), %rsi     # 0x1afb8
callq 0x32f0
movq 0x117a9(%rip), %rdi     # 0x1afc8
leaq 0x9cba(%rip), %rsi      # 0x134e0
callq 0x32a0
movq 0xb8(%rsp), %rsi
movq %rax, %rdi
callq 0x3260
movq %rax, %rdi
movq 0x11773(%rip), %rsi     # 0x1afb8
callq 0x32f0
movq 0x11777(%rip), %rdi     # 0x1afc8
leaq 0x9c8e(%rip), %rsi      # 0x134e6
callq 0x32a0
movq %rax, %rdi
movq 0xc0(%rsp), %rax
movl (%rax), %esi
callq 0x3420
movq %rax, %rdi
movq 0x1173f(%rip), %rsi     # 0x1afb8
callq 0x32f0
movq 0xc0(%rsp), %rax
movq 0x348(%rax), %rcx
movq %rcx, 0x120(%rsp)
movl (%rax), %eax
movl %eax, 0x11c(%rsp)
movq 0xb8(%rsp), %rdi
movslq 0x11c(%rsp), %rax
movq %rax, 0xb0(%rsp)
callq 0x34a0
movq %rax, %rcx
movq 0xb0(%rsp), %rax
cmpq %rcx, %rax
jae 0x9c2f
movq 0x116f2(%rip), %rdi     # 0x1afc8
leaq 0x9c16(%rip), %rsi      # 0x134f3
callq 0x32a0
movq 0xb8(%rsp), %rsi
movq %rax, 0x98(%rsp)
movslq 0x11c(%rsp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq 0xf8(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0x32d0
movq 0x98(%rsp), %rdi
movq 0xa0(%rsp), %rsi
callq 0x3260
movq %rax, 0xa8(%rsp)
jmp 0x9932
movq 0xa8(%rsp), %rdi
leaq 0x9bbd(%rip), %rsi      # 0x134fe
callq 0x32a0
movq %rax, 0x90(%rsp)
jmp 0x9950
movq 0xc0(%rsp), %rax
movq 0x348(%rax), %rdi
callq 0x6690
movq 0x90(%rsp), %rdi
movl %eax, %esi
callq 0x3420
movq %rax, 0x88(%rsp)
jmp 0x997d
movq 0x88(%rsp), %rdi
leaq 0x9b82(%rip), %rsi      # 0x1350e
callq 0x32a0
movq %rax, 0x80(%rsp)
jmp 0x999b
movq 0xc0(%rsp), %rax
movq 0x348(%rax), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, 0x7c(%rsp)
jmp 0x99b9
movl 0x7c(%rsp), %esi
movq 0x80(%rsp), %rdi
callq 0x3420
movq %rax, 0x70(%rsp)
jmp 0x99d1
movq 0x70(%rsp), %rdi
leaq 0x9b44(%rip), %rsi      # 0x13521
callq 0x32a0
movq %rax, 0x68(%rsp)
jmp 0x99e9
movq 0xc0(%rsp), %rax
movq 0x348(%rax), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movl %eax, 0x64(%rsp)
jmp 0x9a07
movl 0x64(%rsp), %esi
movq 0x68(%rsp), %rdi
callq 0x3420
movq %rax, 0x58(%rsp)
jmp 0x9a1c
movq 0x58(%rsp), %rdi
leaq 0x9b08(%rip), %rsi      # 0x13530
callq 0x32a0
movq %rax, 0x50(%rsp)
jmp 0x9a34
movq 0xc0(%rsp), %rax
movq 0x348(%rax), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
callq *%rax
movb %al, 0x4f(%rsp)
jmp 0x9a52
movq 0x50(%rsp), %rdi
movb 0x4f(%rsp), %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x35b0
movq %rax, 0x40(%rsp)
jmp 0x9a6d
movq 0x40(%rsp), %rdi
movq 0x1153f(%rip), %rsi     # 0x1afb8
callq 0x32f0
jmp 0x9a80
leaq 0xf8(%rsp), %rdi
callq 0x31b0
movq 0xc0(%rsp), %rax
movq 0x348(%rax), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
testb $0x1, %al
jne 0x9bd9
movq 0xb8(%rsp), %rdi
movslq 0x11c(%rsp), %rsi
callq 0x3620
movsbl (%rax), %eax
addl $-0x41, %eax
movl %eax, %ecx
movq %rcx, 0x38(%rsp)
subl $0x13, %eax
ja 0x9b8e
movq 0x38(%rsp), %rax
leaq 0x97bf(%rip), %rcx      # 0x132a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x31b0
jmp 0x9de4
movq 0xc0(%rsp), %rax
movq 0x348(%rax), %rdi
callq 0x66a0
movq %rax, 0x120(%rsp)
jmp 0x9bd7
movq 0xc0(%rsp), %rax
movq 0x348(%rax), %rdi
callq 0x66b0
movq %rax, 0x120(%rsp)
jmp 0x9bd7
movq 0xc0(%rsp), %rax
movq 0x348(%rax), %rdi
callq 0x66c0
movq %rax, 0x120(%rsp)
jmp 0x9bd7
movq 0xc0(%rsp), %rax
movq 0x348(%rax), %rdi
callq 0x66d0
movq %rax, 0x120(%rsp)
jmp 0x9bd7
movq 0x1145b(%rip), %rdi     # 0x1aff0
leaq 0x983a(%rip), %rsi      # 0x133d6
callq 0x32a0
movq 0xb8(%rsp), %rdi
movq %rax, 0x30(%rsp)
movslq 0x11c(%rsp), %rsi
callq 0x3620
movq 0x30(%rsp), %rdi
movsbl (%rax), %esi
callq 0x3370
movq %rax, %rdi
movq 0x113e6(%rip), %rsi     # 0x1afb8
callq 0x32f0
jmp 0x9bd9
movq 0xc0(%rsp), %rax
movq 0x120(%rsp), %rcx
movq %rcx, 0x348(%rax)
cmpq $0x0, 0x348(%rax)
je 0x9c15
movq 0xc0(%rsp), %rax
movq 0x348(%rax), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
testb $0x1, %al
jne 0x9c15
jmp 0x9c17
jmp 0x9c2f
jmp 0x9c19
movl 0x11c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x11c(%rsp)
jmp 0x989e
movq 0x11392(%rip), %rdi     # 0x1afc8
leaq 0x98fd(%rip), %rsi      # 0x1353a
callq 0x32a0
movq 0xb8(%rsp), %rsi
movq %rax, 0x20(%rsp)
movslq 0x11c(%rsp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq 0xc8(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x32d0
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x3260
jmp 0x9c7e
leaq 0xc8(%rsp), %rdi
callq 0x31b0
movq 0xc0(%rsp), %rax
cmpq $0x0, 0x348(%rax)
je 0x9dba
movq 0x11320(%rip), %rdi     # 0x1afc8
leaq 0x984f(%rip), %rsi      # 0x134fe
callq 0x32a0
movq %rax, %rcx
movq 0xc0(%rsp), %rax
movq %rcx, (%rsp)
movq 0x348(%rax), %rdi
callq 0x6690
movq (%rsp), %rdi
movl %eax, %esi
callq 0x3420
movq %rax, %rdi
leaq 0x982a(%rip), %rsi      # 0x1350e
callq 0x32a0
movq %rax, %rcx
movq 0xc0(%rsp), %rax
movq %rcx, 0x8(%rsp)
movq 0x348(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x8(%rsp), %rdi
movl %eax, %esi
callq 0x3420
movq %rax, %rdi
leaq 0x9805(%rip), %rsi      # 0x13521
callq 0x32a0
movq %rax, %rcx
movq 0xc0(%rsp), %rax
movq %rcx, 0x10(%rsp)
movq 0x348(%rax), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x10(%rsp), %rdi
movl %eax, %esi
callq 0x3420
movq %rax, %rdi
leaq 0x97dc(%rip), %rsi      # 0x13530
callq 0x32a0
movq %rax, %rcx
movq 0xc0(%rsp), %rax
movq %rcx, 0x18(%rsp)
movq 0x348(%rax), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
movq 0x18(%rsp), %rdi
movzbl %al, %esi
andl $0x1, %esi
callq 0x35b0
movq %rax, %rdi
movq 0x11228(%rip), %rsi     # 0x1afb8
callq 0x32f0
jmp 0x9ddc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x31b0
jmp 0x9de4
movq 0x11207(%rip), %rdi     # 0x1afc8
leaq 0x977d(%rip), %rsi      # 0x13545
callq 0x32a0
movq %rax, %rdi
movq 0x111e1(%rip), %rsi     # 0x1afb8
callq 0x32f0
addq $0x138, %rsp            # imm = 0x138
retq
movq 0xf0(%rsp), %rdi
callq 0x3590
nopw %cs:(%rax,%rax)