// File: CMU-SAFARI[P]optimal-seed-solver/optimalSolverLN.cc
// Function: OptimalSolverLN::backtrack()
void OptimalSolverLN::backtrack() {
	if (seedNum > 1) {
		int seedIdx = seedNum - 1;
		int level0lv = readLength - seedNum * minLength - finalDiv;
		int level0pos = finalDiv + (seedNum - 1) * minLength;
		seeds[seedIdx].start = level0[level0lv][level0pos].start;
		seeds[seedIdx].end = level0[level0lv][level0pos].end;
		seeds[seedIdx].frequency = level0[level0lv][level0pos].frequency;
	
		int opt_div = finalDiv;
	
		for (seedIdx = seedNum - 2; seedIdx >= 0; seedIdx--) {
			seeds[seedIdx].start = level[seedIdx][opt_div].rstart;
			seeds[seedIdx].end = level[seedIdx][opt_div].rend;
			seeds[seedIdx].frequency = level[seedIdx][opt_div].rfreq;
			opt_div = level[seedIdx][opt_div].lend + 1 - seedIdx * minLength;
		}
	}
	else {
		seeds[0].start = level0[readLength - minLength][0].start;
		seeds[0].end = level0[readLength - minLength][0].end;
		seeds[0].frequency = level0[readLength - minLength][0].frequency;
	}
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpl $0x1, 0x364(%rax)
jle 0x9dab
movq 0x28(%rsp), %rdi
movl 0x364(%rdi), %eax
subl $0x1, %eax
movl %eax, 0x3c(%rsp)
movl 0x360(%rdi), %eax
movl 0x364(%rdi), %ecx
imull 0x368(%rdi), %ecx
subl %ecx, %eax
subl 0x3e0(%rdi), %eax
movl %eax, 0x38(%rsp)
movl 0x3e0(%rdi), %eax
movl 0x364(%rdi), %ecx
subl $0x1, %ecx
imull 0x368(%rdi), %ecx
addl %ecx, %eax
movl %eax, 0x34(%rsp)
addq $0x398, %rdi            # imm = 0x398
movslq 0x38(%rsp), %rsi
callq 0xa600
movq 0x28(%rsp), %rdi
movq (%rax), %rax
movslq 0x34(%rsp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, 0x1c(%rsp)
addq $0x3c8, %rdi            # imm = 0x3C8
movslq 0x3c(%rsp), %rsi
callq 0xa7c0
movl 0x1c(%rsp), %ecx
movq 0x28(%rsp), %rdi
movl %ecx, (%rax)
addq $0x398, %rdi            # imm = 0x398
movslq 0x38(%rsp), %rsi
callq 0xa600
movq 0x28(%rsp), %rdi
movq (%rax), %rax
movslq 0x34(%rsp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, 0x20(%rsp)
addq $0x3c8, %rdi            # imm = 0x3C8
movslq 0x3c(%rsp), %rsi
callq 0xa7c0
movl 0x20(%rsp), %ecx
movq 0x28(%rsp), %rdi
movl %ecx, 0x4(%rax)
addq $0x398, %rdi            # imm = 0x398
movslq 0x38(%rsp), %rsi
callq 0xa600
movq 0x28(%rsp), %rdi
movq (%rax), %rax
movslq 0x34(%rsp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, 0x24(%rsp)
addq $0x3c8, %rdi            # imm = 0x3C8
movslq 0x3c(%rsp), %rsi
callq 0xa7c0
movl 0x24(%rsp), %edx
movq %rax, %rcx
movq 0x28(%rsp), %rax
movl %edx, 0xc(%rcx)
movl 0x3e0(%rax), %ecx
movl %ecx, 0x30(%rsp)
movl 0x364(%rax), %eax
subl $0x2, %eax
movl %eax, 0x3c(%rsp)
cmpl $0x0, 0x3c(%rsp)
jl 0x9da6
movq 0x28(%rsp), %rdi
addq $0x380, %rdi            # imm = 0x380
movslq 0x3c(%rsp), %rsi
callq 0xa600
movq 0x28(%rsp), %rdi
movq (%rax), %rax
movslq 0x30(%rsp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x1c(%rax), %eax
movl %eax, 0x10(%rsp)
addq $0x3c8, %rdi            # imm = 0x3C8
movslq 0x3c(%rsp), %rsi
callq 0xa7c0
movl 0x10(%rsp), %ecx
movq 0x28(%rsp), %rdi
movl %ecx, (%rax)
addq $0x380, %rdi            # imm = 0x380
movslq 0x3c(%rsp), %rsi
callq 0xa600
movq 0x28(%rsp), %rdi
movq (%rax), %rax
movslq 0x30(%rsp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
movl %eax, 0x14(%rsp)
addq $0x3c8, %rdi            # imm = 0x3C8
movslq 0x3c(%rsp), %rsi
callq 0xa7c0
movl 0x14(%rsp), %ecx
movq 0x28(%rsp), %rdi
movl %ecx, 0x4(%rax)
addq $0x380, %rdi            # imm = 0x380
movslq 0x3c(%rsp), %rsi
callq 0xa600
movq 0x28(%rsp), %rdi
movq (%rax), %rax
movslq 0x30(%rsp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x24(%rax), %eax
movl %eax, 0x18(%rsp)
addq $0x3c8, %rdi            # imm = 0x3C8
movslq 0x3c(%rsp), %rsi
callq 0xa7c0
movl 0x18(%rsp), %ecx
movq 0x28(%rsp), %rdi
movl %ecx, 0xc(%rax)
addq $0x380, %rdi            # imm = 0x380
movslq 0x3c(%rsp), %rsi
callq 0xa600
movq 0x28(%rsp), %rdx
movq (%rax), %rax
movslq 0x30(%rsp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
addl $0x1, %eax
movl 0x3c(%rsp), %ecx
imull 0x368(%rdx), %ecx
subl %ecx, %eax
movl %eax, 0x30(%rsp)
movl 0x3c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x9c70
jmp 0x9e84
movq 0x28(%rsp), %rcx
movq %rcx, %rdi
addq $0x398, %rdi            # imm = 0x398
movl 0x360(%rcx), %eax
subl 0x368(%rcx), %eax
movslq %eax, %rsi
callq 0xa600
movq 0x28(%rsp), %rdi
movq (%rax), %rax
movl (%rax), %eax
movl %eax, 0x4(%rsp)
addq $0x3c8, %rdi            # imm = 0x3C8
xorl %eax, %eax
movl %eax, %esi
callq 0xa7c0
movl 0x4(%rsp), %edx
movq 0x28(%rsp), %rcx
movl %edx, (%rax)
movq %rcx, %rdi
addq $0x398, %rdi            # imm = 0x398
movl 0x360(%rcx), %eax
subl 0x368(%rcx), %eax
movslq %eax, %rsi
callq 0xa600
movq 0x28(%rsp), %rdi
movq (%rax), %rax
movl 0x4(%rax), %eax
movl %eax, 0x8(%rsp)
addq $0x3c8, %rdi            # imm = 0x3C8
xorl %eax, %eax
movl %eax, %esi
callq 0xa7c0
movl 0x8(%rsp), %edx
movq 0x28(%rsp), %rcx
movl %edx, 0x4(%rax)
movq %rcx, %rdi
addq $0x398, %rdi            # imm = 0x398
movl 0x360(%rcx), %eax
subl 0x368(%rcx), %eax
movslq %eax, %rsi
callq 0xa600
movq 0x28(%rsp), %rdi
movq (%rax), %rax
movl 0xc(%rax), %eax
movl %eax, 0xc(%rsp)
addq $0x3c8, %rdi            # imm = 0x3C8
xorl %eax, %eax
movl %eax, %esi
callq 0xa7c0
movl 0xc(%rsp), %ecx
movl %ecx, 0xc(%rax)
addq $0x48, %rsp
retq
nopl (%rax)