// File: CMU-SAFARI[P]optimal-seed-solver/hobbesSolver.cc
// Function: HobbesSolver::solveDNA(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
unsigned int HobbesSolver::solveDNA(string DNA) {
	assert(DNA.length() == readLength);
	reset();

	for (int i = 0; i < readLength - seedLength + 1; i++)
	{
		string seed = DNA.substr(i, seedLength);
		tree.query(seed);
		invertedList[i] = tree.frequency();
		cout << invertedList[i];
		cout << " ";
	}

	cout << "\n";

	for (int counter = 1; counter < seedNum + 1; counter++)
	{
		dynamicMatrix[counter][0] = invertedList[(counter-1) * this->seedLength] + dynamicMatrix[counter - 1][0];
		//cout << dynamicMatrix[counter][0];
		//cout << " ";
	}
	cout << "\n";
	cout << "\n";
	for (int heightCount = 1; heightCount < seedNum + 1; heightCount++)
	{
		for (int widthCount = 1; widthCount < dynamicMatrixWidth; widthCount++)
		{
			int indexNum = (heightCount - 1) * seedLength + widthCount;
			dynamicMatrix[heightCount][widthCount] = dynamicMatrix[heightCount-1][widthCount] + invertedList[indexNum];
			if (dynamicMatrix[heightCount][widthCount-1] < dynamicMatrix[heightCount][widthCount])
				dynamicMatrix[heightCount][widthCount] = dynamicMatrix[heightCount][widthCount-1];
			cout << dynamicMatrix[heightCount][widthCount-1];
			cout << " ";			
		}
		cout << dynamicMatrix[heightCount][dynamicMatrixWidth-1];
		cout << "\n";
	}
	cout << "\n";
	cout << dynamicMatrix[seedNum][dynamicMatrixWidth-1];
	cout << "\n";
	return dynamicMatrix[seedNum][dynamicMatrixWidth-1];
}

// Assembly:
subq $0xa8, %rsp
movq %rsi, 0x18(%rsp)
movq %rdi, %rax
movq 0x18(%rsp), %rdi
movq %rdi, 0x20(%rsp)
movq %rax, 0xa0(%rsp)
movq %rdi, 0x98(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x28(%rsp)
callq 0x34b0
movq 0x28(%rsp), %rcx
movslq 0x368(%rcx), %rcx
cmpq %rcx, %rax
jne 0x652e
jmp 0x654d
leaq 0xdb80(%rip), %rdi      # 0x140b5
leaq 0xdb94(%rip), %rsi      # 0x140d0
movl $0x5c, %edx
leaq 0xdb98(%rip), %rcx      # 0x140e0
callq 0x31d0
movq 0x28(%rsp), %rdi
callq 0x6470
movl $0x0, 0x94(%rsp)
movq 0x28(%rsp), %rdx
movl 0x94(%rsp), %eax
movl 0x368(%rdx), %ecx
subl 0x370(%rdx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x669f
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rsi
movslq 0x94(%rsp), %rdx
movslq 0x370(%rax), %rcx
leaq 0x70(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x32e0
movq 0x28(%rsp), %rax
movq 0x8(%rsp), %rsi
movq %rax, 0x10(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x3140
jmp 0x65c8
movq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movl $0x1, %edx
callq 0x8830
jmp 0x65de
leaq 0x50(%rsp), %rdi
callq 0x31b0
movq 0x28(%rsp), %rdi
callq 0x8a90
movl %eax, 0x4(%rsp)
jmp 0x65f8
movq 0x28(%rsp), %rax
movl 0x4(%rsp), %esi
movq 0x358(%rax), %rcx
movslq 0x94(%rsp), %rdx
movl %esi, (%rcx,%rdx,4)
movq 0x358(%rax), %rax
movslq 0x94(%rsp), %rcx
movl (%rax,%rcx,4), %esi
movq 0x1599c(%rip), %rdi     # 0x1bfc8
callq 0x3580
jmp 0x6633
movq 0x1598e(%rip), %rdi     # 0x1bfc8
leaq 0xde77(%rip), %rsi      # 0x144b8
callq 0x32b0
jmp 0x6648
leaq 0x70(%rsp), %rdi
callq 0x31b0
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0x6562
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x48(%rsp)
movl %eax, 0x44(%rsp)
jmp 0x6690
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x48(%rsp)
movl %eax, 0x44(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x31b0
leaq 0x70(%rsp), %rdi
callq 0x31b0
jmp 0x6985
movq 0x15922(%rip), %rdi     # 0x1bfc8
leaq 0xd9b9(%rip), %rsi      # 0x14066
callq 0x32b0
movl $0x1, 0x40(%rsp)
movq 0x28(%rsp), %rcx
movl 0x40(%rsp), %eax
movl 0x36c(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x6726
movq 0x28(%rsp), %rax
movq 0x358(%rax), %rcx
movl 0x40(%rsp), %edx
subl $0x1, %edx
imull 0x370(%rax), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movq 0x360(%rax), %rdx
movl 0x40(%rsp), %esi
subl $0x1, %esi
movslq %esi, %rsi
movq (%rdx,%rsi,8), %rdx
addl (%rdx), %ecx
movq 0x360(%rax), %rax
movslq 0x40(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, (%rax)
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0x66ba
movq 0x1589b(%rip), %rdi     # 0x1bfc8
leaq 0xd932(%rip), %rsi      # 0x14066
callq 0x32b0
movq 0x15888(%rip), %rdi     # 0x1bfc8
leaq 0xd91f(%rip), %rsi      # 0x14066
callq 0x32b0
movl $0x1, 0x3c(%rsp)
movq 0x28(%rsp), %rcx
movl 0x3c(%rsp), %eax
movl 0x36c(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x68ff
movl $0x1, 0x38(%rsp)
movq 0x28(%rsp), %rcx
movl 0x38(%rsp), %eax
cmpl 0x388(%rcx), %eax
jge 0x68ac
movq 0x28(%rsp), %rcx
movl 0x3c(%rsp), %eax
subl $0x1, %eax
imull 0x370(%rcx), %eax
addl 0x38(%rsp), %eax
movl %eax, 0x34(%rsp)
movq 0x360(%rcx), %rax
movl 0x3c(%rsp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movslq 0x38(%rsp), %rdx
movl (%rax,%rdx,4), %esi
movq 0x358(%rcx), %rax
movslq 0x34(%rsp), %rdx
addl (%rax,%rdx,4), %esi
movq 0x360(%rcx), %rax
movslq 0x3c(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movslq 0x38(%rsp), %rdx
movl %esi, (%rax,%rdx,4)
movq 0x360(%rcx), %rax
movslq 0x3c(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movl 0x38(%rsp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movl (%rax,%rdx,4), %eax
movq 0x360(%rcx), %rcx
movslq 0x3c(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x38(%rsp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x685b
movq 0x28(%rsp), %rax
movq 0x360(%rax), %rcx
movslq 0x3c(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movl 0x38(%rsp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %edx
movq 0x360(%rax), %rax
movslq 0x3c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x38(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x28(%rsp), %rax
movq 0x360(%rax), %rax
movslq 0x3c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x38(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %esi
movq 0x15744(%rip), %rdi     # 0x1bfc8
callq 0x3580
movq 0x15738(%rip), %rdi     # 0x1bfc8
leaq 0xdc21(%rip), %rsi      # 0x144b8
callq 0x32b0
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0x6776
movq 0x28(%rsp), %rcx
movq 0x360(%rcx), %rax
movslq 0x3c(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movl 0x388(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %esi
movq 0x156f1(%rip), %rdi     # 0x1bfc8
callq 0x3580
movq 0x156e5(%rip), %rdi     # 0x1bfc8
leaq 0xd77c(%rip), %rsi      # 0x14066
callq 0x32b0
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x6754
movq 0x156c2(%rip), %rdi     # 0x1bfc8
leaq 0xd759(%rip), %rsi      # 0x14066
callq 0x32b0
movq 0x28(%rsp), %rcx
movq 0x360(%rcx), %rax
movslq 0x36c(%rcx), %rdx
movq (%rax,%rdx,8), %rax
movl 0x388(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %esi
movq 0x15689(%rip), %rdi     # 0x1bfc8
callq 0x3580
movq 0x1567d(%rip), %rdi     # 0x1bfc8
leaq 0xd714(%rip), %rsi      # 0x14066
callq 0x32b0
movq 0x28(%rsp), %rcx
movq 0x360(%rcx), %rax
movslq 0x36c(%rcx), %rdx
movq (%rax,%rdx,8), %rax
movl 0x388(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
addq $0xa8, %rsp
retq
movq 0x48(%rsp), %rdi
callq 0x35a0
nop