// File: /workspace/github_cpp_makefile_star2_O3/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 0x4711
callq 0x3330
movq $0x0, 0x358(%rbx)
movq 0x378(%rbx), %rdi
testq %rdi, %rdi
je 0x472d
callq 0x3330
movq $0x0, 0x378(%rbx)
movq 0x360(%rbx), %rdi
testq %rdi, %rdi
je 0x4749
callq 0x3330
movq $0x0, 0x360(%rbx)
movq 0x380(%rbx), %rdi
testq %rdi, %rdi
je 0x4765
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)
movq %r14, 0x8(%rsp)
movl %ebp, 0x4(%rsp)
subl %ebp, %r14d
leal 0x1(%r14), %r12d
shlq $0x2, %r12
cmpl $-0x1, %r14d
movq $-0x1, %rax
cmovlq %rax, %r12
movq %r12, %rdi
callq 0x3030
movq %rax, 0x358(%rbx)
movq %r12, %rdi
callq 0x3030
movq %rax, 0x378(%rbx)
leal 0x1(%r15), %ebp
leaq (,%rbp,8), %rdi
cmpl $-0x1, %r15d
movq $-0x1, %rax
cmovlq %rax, %rdi
callq 0x3030
movq %rax, %r12
movq %rax, 0x360(%rbx)
movq %r15, 0x10(%rsp)
movl %ebp, %r15d
movl %r13d, (%rsp)
imull %r13d, %r15d
leaq (,%r15,4), %r13
testl %r15d, %r15d
movq $-0x1, %rax
cmovsq %rax, %r13
movq %r13, %rdi
callq 0x3030
movq %rax, (%r12)
movq %r13, %rdi
callq 0x3030
movq %rax, 0x380(%rbx)
cmpl $0x0, 0x10(%rsp)
jle 0x486a
movslq (%rsp), %rax
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, %rbp
jne 0x484f
testl %r14d, %r14d
js 0x4897
movq 0x8(%rsp), %rdx
incl %edx
movq 0x378(%rbx), %rdi
subl 0x4(%rsp), %edx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x3160
movl 0x388(%rbx), %r15d
imull %ebp, %r15d
testl %r15d, %r15d
jle 0x48c2
movq 0x380(%rbx), %rax
xorl %ecx, %ecx
movslq %ebp, %rdx
movl $0x0, (%rax,%rcx,4)
incq %rcx
movslq 0x388(%rbx), %rsi
imulq %rdx, %rsi
cmpq %rsi, %rcx
jl 0x48a8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop