// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebp
movl %edx, %r15d
movl %esi, %r14d
movq %rdi, %rbx
movq 0x358(%rdi), %rdi
testq %rdi, %rdi
je 0x4701
callq 0x3330
movq $0x0, 0x358(%rbx)
movq 0x378(%rbx), %rdi
testq %rdi, %rdi
je 0x471d
callq 0x3330
movq $0x0, 0x378(%rbx)
movq 0x360(%rbx), %rdi
testq %rdi, %rdi
je 0x4739
callq 0x3330
movq $0x0, 0x360(%rbx)
movq 0x380(%rbx), %rdi
testq %rdi, %rdi
je 0x4755
callq 0x3330
movq $0x0, 0x380(%rbx)
movl %r14d, 0x368(%rbx)
movl %r15d, 0x36c(%rbx)
movl %ebp, 0x370(%rbx)
movl %ebp, %eax
imull %r15d, %eax
negl %eax
leal (%r14,%rax), %r13d
incl %r13d
movl %r13d, 0x388(%rbx)
subl %ebp, %r14d
movq %r14, 0x10(%rsp)
movslq %r14d, %rax
leaq 0x4(,%rax,4), %r12
cmpl $-0x1, %eax
movq $-0x1, %rax
cmovlq %rax, %r12
movq %r12, %rdi
callq 0x3030
movq %rax, 0x358(%rbx)
movq %r12, %rdi
callq 0x3030
movq %rax, 0x378(%rbx)
movslq %r15d, %r14
leaq 0x1(%r14), %rbp
movslq %ebp, %rdi
shlq $0x3, %rdi
cmpl $-0x1, %r14d
movq $-0x1, %rax
cmovlq %rax, %rdi
callq 0x3030
movq %rax, %r12
movq %rax, 0x360(%rbx)
movl %r13d, 0xc(%rsp)
movl %r13d, %eax
imull %ebp, %eax
cltq
leaq (,%rax,4), %r13
testl %eax, %eax
movq $-0x1, %rax
cmovsq %rax, %r13
movq %r13, %rdi
callq 0x3030
movq %rax, (%r12)
movq %r13, %rdi
callq 0x3030
movq %rax, 0x380(%rbx)
testl %r14d, %r14d
jle 0x4858
movslq 0xc(%rsp), %rax
incl %r15d
movl $0x1, %ecx
shlq $0x2, %rax
movq 0x360(%rbx), %rdx
movq -0x8(%rdx,%rcx,8), %rsi
addq %rax, %rsi
movq %rsi, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %r15
jne 0x483d
movq 0x10(%rsp), %rdx
testl %edx, %edx
js 0x4875
movq 0x378(%rbx), %rdi
incl %edx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x3160
movl 0x388(%rbx), %eax
imull %ebp, %eax
testl %eax, %eax
jle 0x48a5
movq 0x380(%rbx), %rax
xorl %ecx, %ecx
movl $0x0, (%rax,%rcx,4)
incq %rcx
movslq 0x388(%rbx), %rdx
imulq %rbp, %rdx
cmpq %rdx, %rcx
jl 0x488b
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq