// File: CMU-SAFARI[P]optimal-seed-solver/hobbesSolver.cc
// Function: HobbesSolver::init(int, int, int)
void HobbesSolver::init(int readLength, int seedNum, int seedLength) {
	//Initialize the matrix
	if  (invertedList != NULL) {
		delete [] invertedList;
		invertedList = NULL;
	}
	if  (defaultInvertedList != NULL) {
		delete [] defaultInvertedList;
		defaultInvertedList = NULL;
	}
		if  (dynamicMatrix != NULL) {
		delete [] dynamicMatrix;
		dynamicMatrix = NULL;
	}
	if  (defaultDynamicMatrix != NULL) {
		delete [] defaultDynamicMatrix;
		defaultDynamicMatrix = NULL;
	}

	this->readLength = readLength;
	this->seedNum = seedNum;
	this->seedLength = seedLength;
	dynamicMatrixWidth = readLength + 1 - seedNum * seedLength;

	invertedList = new int [readLength - seedLength + 1];
	defaultInvertedList = new int [readLength - seedLength + 1];

	dynamicMatrix = new int* [seedNum + 1];
	dynamicMatrix[0] = new int [dynamicMatrixWidth * (seedNum + 1)];
	defaultDynamicMatrix = new int [dynamicMatrixWidth * (seedNum + 1)];

	for (int i = 1; i <= seedNum; i++)
		dynamicMatrix[i] = dynamicMatrix[i-1] + dynamicMatrixWidth;

	for (int i = 0; i < readLength - seedLength + 1; i++)
		defaultInvertedList[i] = 0;
	
	for (int i = 0; i < dynamicMatrixWidth * (seedNum + 1); i++)
		defaultDynamicMatrix[i] = 0;

}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movl %esi, 0x3c(%rsp)
movl %edx, 0x38(%rsp)
movl %ecx, 0x34(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x358(%rax)
je 0x614a
movq 0x20(%rsp), %rax
movq 0x358(%rax), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x613a
movq 0x18(%rsp), %rdi
callq 0x33f0
movq 0x20(%rsp), %rax
movq $0x0, 0x358(%rax)
movq 0x20(%rsp), %rax
cmpq $0x0, 0x378(%rax)
je 0x618a
movq 0x20(%rsp), %rax
movq 0x378(%rax), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
je 0x617a
movq 0x10(%rsp), %rdi
callq 0x33f0
movq 0x20(%rsp), %rax
movq $0x0, 0x378(%rax)
movq 0x20(%rsp), %rax
cmpq $0x0, 0x360(%rax)
je 0x61ca
movq 0x20(%rsp), %rax
movq 0x360(%rax), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x61ba
movq 0x8(%rsp), %rdi
callq 0x33f0
movq 0x20(%rsp), %rax
movq $0x0, 0x360(%rax)
movq 0x20(%rsp), %rax
cmpq $0x0, 0x380(%rax)
je 0x6208
movq 0x20(%rsp), %rax
movq 0x380(%rax), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x61f8
movq (%rsp), %rdi
callq 0x33f0
movq 0x20(%rsp), %rax
movq $0x0, 0x380(%rax)
movq 0x20(%rsp), %rax
movl 0x3c(%rsp), %ecx
movl %ecx, 0x368(%rax)
movl 0x38(%rsp), %ecx
movl %ecx, 0x36c(%rax)
movl 0x34(%rsp), %ecx
movl %ecx, 0x370(%rax)
movl 0x3c(%rsp), %ecx
addl $0x1, %ecx
movl 0x38(%rsp), %edx
imull 0x34(%rsp), %edx
subl %edx, %ecx
movl %ecx, 0x388(%rax)
movl 0x3c(%rsp), %eax
subl 0x34(%rsp), %eax
addl $0x1, %eax
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x358(%rax)
movl 0x3c(%rsp), %eax
subl 0x34(%rsp), %eax
addl $0x1, %eax
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x378(%rax)
movl 0x38(%rsp), %eax
addl $0x1, %eax
cltq
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x360(%rax)
movl 0x388(%rax), %eax
movl 0x38(%rsp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rdx
movq 0x20(%rsp), %rax
movq 0x360(%rax), %rcx
movq %rdx, (%rcx)
movl 0x388(%rax), %eax
movl 0x38(%rsp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x380(%rax)
movl $0x1, 0x30(%rsp)
movl 0x30(%rsp), %eax
cmpl 0x38(%rsp), %eax
jg 0x63d4
movq 0x20(%rsp), %rax
movq 0x360(%rax), %rcx
movl 0x30(%rsp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rdx
movslq 0x388(%rax), %rcx
shlq $0x2, %rcx
addq %rcx, %rdx
movq 0x360(%rax), %rax
movslq 0x30(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x6385
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
movl 0x3c(%rsp), %ecx
subl 0x34(%rsp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x6414
movq 0x20(%rsp), %rax
movq 0x378(%rax), %rax
movslq 0x2c(%rsp), %rcx
movl $0x0, (%rax,%rcx,4)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x63dc
movl $0x0, 0x28(%rsp)
movq 0x20(%rsp), %rcx
movl 0x28(%rsp), %eax
movl 0x388(%rcx), %ecx
movl 0x38(%rsp), %edx
addl $0x1, %edx
imull %edx, %ecx
cmpl %ecx, %eax
jge 0x645e
movq 0x20(%rsp), %rax
movq 0x380(%rax), %rax
movslq 0x28(%rsp), %rcx
movl $0x0, (%rax,%rcx,4)
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x641c
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)