// File: CMU-SAFARI[P]optimal-seed-solver/HashTree.cc
// Function: HashTree::generateTree(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void HashTree::generateTree(string refName) {
	refdb.loadRefFile(refName);

	//Load all databases. This only works for 1TB machine.
	checkdb = new RefDB[refdb.getNumOfChromo()];
	for (int i = 0; i < static_cast<int>(refdb.getNumOfChromo() ); i++) {
		checkdb[i].loadRefFile(refName);
		checkdb[i].loadChromo(i);
	}

	string DNA;

	for (unsigned int chromoIter = 0; chromoIter < refdb.getNumOfChromo(); chromoIter++) {
		refdb.loadChromo(chromoIter);

		for (unsigned int location = 0; location < refdb.getChromoLength() - hashLength; location++){
			DNA = refdb.getRefSeq(location, fullLength);
			if (DNA.find('N') == string::npos)
				checkDouble(DNA, chromoIter, location);
		}
	}
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rsi, 0x70(%rsp)
movq %rdi, 0x130(%rsp)
movq %rsi, 0x128(%rsp)
movq 0x130(%rsp), %rax
movq %rax, 0x78(%rsp)
addq $0xa8, %rax
movq %rax, 0x80(%rsp)
leaq 0x108(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x3140
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x10a40
jmp 0x7b83
leaq 0x108(%rsp), %rdi
callq 0x31b0
movq 0x78(%rsp), %rdi
addq $0xa8, %rdi
callq 0x11190
movl %eax, %eax
movq %rax, 0x58(%rsp)
movl $0x268, %ecx            # imm = 0x268
mulq %rcx
movq %rax, %rdi
seto %cl
addq $0x8, %rdi
setb %al
orb %al, %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, 0x50(%rsp)
callq 0x3030
movq %rax, %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x60(%rsp)
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, 0x68(%rsp)
cmpq $0x0, %rax
je 0x7c42
movq 0x68(%rsp), %rax
movq 0x58(%rsp), %rcx
imulq $0x268, %rcx, %rdx      # imm = 0x268
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, 0x40(%rsp)
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x10990
jmp 0x7c28
movq 0x40(%rsp), %rcx
movq 0x38(%rsp), %rax
addq $0x268, %rax            # imm = 0x268
cmpq %rcx, %rax
movq %rax, 0x48(%rsp)
jne 0x7c17
movq 0x78(%rsp), %rax
movq 0x68(%rsp), %rcx
movq %rcx, 0x310(%rax)
movl $0x0, 0xf8(%rsp)
movq 0x78(%rsp), %rdi
movl 0xf8(%rsp), %eax
movl %eax, 0x34(%rsp)
addq $0xa8, %rdi
callq 0x11190
movl %eax, %ecx
movl 0x34(%rsp), %eax
cmpl %ecx, %eax
jge 0x7dd0
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rax
movq 0x310(%rax), %rax
movslq 0xf8(%rsp), %rcx
imulq $0x268, %rcx, %rcx      # imm = 0x268
addq %rcx, %rax
movq %rax, 0x20(%rsp)
leaq 0xd8(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x3140
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x10a40
jmp 0x7cd3
leaq 0xd8(%rsp), %rdi
callq 0x31b0
movq 0x78(%rsp), %rax
movq 0x310(%rax), %rdi
movslq 0xf8(%rsp), %rax
imulq $0x268, %rax, %rax      # imm = 0x268
addq %rax, %rdi
movl 0xf8(%rsp), %esi
callq 0x10ec0
movl 0xf8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf8(%rsp)
jmp 0x7c5e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x31b0
jmp 0x7f68
movq 0x68(%rsp), %rcx
movq %rax, %rsi
movq 0x38(%rsp), %rax
movq %rsi, 0x100(%rsp)
movl %edx, 0xfc(%rsp)
cmpq %rax, %rcx
movq %rax, 0x18(%rsp)
je 0x7d96
movq 0x18(%rsp), %rdi
addq $-0x268, %rdi           # imm = 0xFD98
movq %rdi, 0x10(%rsp)
callq 0x109f0
movq 0x68(%rsp), %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x18(%rsp)
jne 0x7d6c
movq 0x50(%rsp), %rsi
movq 0x60(%rsp), %rdi
callq 0x35f0
jmp 0x7f68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x31b0
jmp 0x7f68
leaq 0xb8(%rsp), %rdi
callq 0x3450
movl $0x0, 0xb4(%rsp)
movq 0x78(%rsp), %rdi
movl 0xb4(%rsp), %eax
movl %eax, 0x8(%rsp)
addq $0xa8, %rdi
callq 0x11190
movl %eax, 0xc(%rsp)
jmp 0x7e0a
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
cmpl %ecx, %eax
jae 0x7f53
movq 0x78(%rsp), %rdi
addq $0xa8, %rdi
movl 0xb4(%rsp), %esi
callq 0x10ec0
jmp 0x7e34
movl $0x0, 0xb0(%rsp)
movq 0x78(%rsp), %rdi
movl 0xb0(%rsp), %eax
movl %eax, (%rsp)
addq $0xa8, %rdi
callq 0x11170
movl %eax, 0x4(%rsp)
jmp 0x7e60
movl (%rsp), %eax
movq 0x78(%rsp), %rdx
movl 0x4(%rsp), %ecx
subl (%rdx), %ecx
cmpl %ecx, %eax
jae 0x7f3b
movq 0x78(%rsp), %rax
movq %rax, %rsi
addq $0xa8, %rsi
movl 0xb0(%rsp), %edx
movl 0x4(%rax), %ecx
leaq 0x90(%rsp), %rdi
callq 0x111e0
jmp 0x7e9e
leaq 0xb8(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x3390
leaq 0x90(%rsp), %rdi
callq 0x31b0
leaq 0xb8(%rsp), %rdi
movl $0x4e, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x33f0
cmpq $-0x1, %rax
jne 0x7f23
movq 0x78(%rsp), %rdi
movl 0xb4(%rsp), %edx
movl 0xb0(%rsp), %ecx
leaq 0xb8(%rsp), %rsi
callq 0x7990
jmp 0x7efe
jmp 0x7f23
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x31b0
jmp 0x7f68
jmp 0x7f25
movl 0xb0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb0(%rsp)
jmp 0x7e3f
jmp 0x7f3d
movl 0xb4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb4(%rsp)
jmp 0x7de8
leaq 0xb8(%rsp), %rdi
callq 0x31b0
addq $0x138, %rsp            # imm = 0x138
retq
movq 0x100(%rsp), %rdi
callq 0x3590
nopw %cs:(%rax,%rax)