// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movslq 0x368(%rdi), %rax
cmpq %rax, 0x8(%rsi)
jne 0x4672
movq %rsi, %r14
movq %rdi, %rbx
callq 0x43be
xorl %r15d, %r15d
leaq 0x28(%rsp), %r12
leaq 0x8(%rsp), %r13
movq 0x9b78(%rip), %rbp      # 0xdfc8
movslq 0x368(%rbx), %rax
movslq 0x370(%rbx), %rcx
subq %rcx, %rax
cmpq %rax, %r15
jg 0x44ce
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x3250
movq %r13, %rdi
movq %r12, %rsi
callq 0x3340
movq %rbx, %rdi
movq %r13, %rsi
pushq $0x1
popq %rdx
callq 0x550a
movq %r13, %rdi
callq 0x3110
movq %rbx, %rdi
callq 0x5654
movq 0x358(%rbx), %rcx
movl %eax, (%rcx,%r15,4)
movq %rbp, %rdi
movl %eax, %esi
callq 0x3410
movq %rbp, %rdi
leaq 0x4ef2(%rip), %rsi      # 0x93ae
callq 0x3220
movq %r12, %rdi
callq 0x3110
incq %r15
jmp 0x4450
movq 0x9af3(%rip), %rdi      # 0xdfc8
leaq 0x4b8a(%rip), %rsi      # 0x9066
callq 0x3220
movq 0x358(%rbx), %rax
movq 0x360(%rbx), %rcx
pushq $0x1
popq %rdx
movslq 0x36c(%rbx), %rsi
cmpq %rsi, %rdx
jg 0x4523
leaq -0x1(%rdx), %rsi
movslq 0x370(%rbx), %rdi
imulq %rsi, %rdi
movq -0x8(%rcx,%rdx,8), %rsi
movq (%rcx,%rdx,8), %r8
movl (%rsi), %esi
addl (%rax,%rdi,4), %esi
movl %esi, (%r8)
incq %rdx
jmp 0x44f2
movq 0x9a9e(%rip), %r14      # 0xdfc8
leaq 0x4b35(%rip), %r15      # 0x9066
movq %r14, %rdi
movq %r15, %rsi
callq 0x3220
movq %r14, %rdi
movq %r15, %rsi
callq 0x3220
pushq $0x1
popq %r13
xorl %ecx, %ecx
leaq 0x4e5a(%rip), %r12      # 0x93ae
movslq 0x36c(%rbx), %rax
cmpq %rax, %r13
jg 0x45fd
movl %ecx, 0x4(%rsp)
movslq %ecx, %r15
pushq $0x1
popq %rbp
movslq 0x388(%rbx), %rax
cmpq %rax, %rbp
jge 0x45c9
movslq 0x370(%rbx), %rax
imulq %r15, %rax
movq 0x358(%rbx), %rcx
movq 0x360(%rbx), %rdx
addq %rbp, %rax
movl (%rcx,%rax,4), %eax
movq -0x8(%rdx,%r13,8), %rcx
movq (%rdx,%r13,8), %rdx
addl (%rcx,%rbp,4), %eax
movl -0x4(%rdx,%rbp,4), %esi
cmpl %eax, %esi
cmovll %esi, %eax
movl %eax, (%rdx,%rbp,4)
movq %r14, %rdi
callq 0x3410
movq %r14, %rdi
movq %r12, %rsi
callq 0x3220
incq %rbp
jmp 0x456e
movq 0x360(%rbx), %rcx
movq (%rcx,%r13,8), %rcx
movl -0x4(%rcx,%rax,4), %esi
movq %r14, %rdi
callq 0x3410
movq %r14, %rdi
leaq 0x4a7c(%rip), %rsi      # 0x9066
callq 0x3220
incq %r13
movl 0x4(%rsp), %ecx
incl %ecx
jmp 0x4554
movq 0x99c4(%rip), %r14      # 0xdfc8
leaq 0x4a5b(%rip), %r15      # 0x9066
movq %r14, %rdi
movq %r15, %rsi
callq 0x3220
movq 0x360(%rbx), %rax
movslq 0x36c(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x388(%rbx), %rcx
movl -0x4(%rax,%rcx,4), %esi
movq %r14, %rdi
callq 0x3410
movq %r14, %rdi
movq %r15, %rsi
callq 0x3220
movq 0x360(%rbx), %rax
movslq 0x36c(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x388(%rbx), %rcx
movl -0x4(%rax,%rcx,4), %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4a3c(%rip), %rdi      # 0x90b5
leaq 0x4a50(%rip), %rsi      # 0x90d0
leaq 0x4a59(%rip), %rcx      # 0x90e0
pushq $0x5c
popq %rdx
callq 0x3170
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3110
jmp 0x46a1
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3110
movq %rbx, %rdi
callq 0x3430
nop