// File: /workspace/github_cpp_makefile_star2_O2/Laakeri[P]maxpre/src/./SSR.cpp
// Function: maxPreprocessor::Preprocessor::doSSR()
int Preprocessor::doSSR() {
	rLog.startTechnique(Log::Technique::SSR);
	if (!rLog.requestTime(Log::Technique::SSR)) {
		rLog.stopTechnique(Log::Technique::SSR);
		return 0;
	}
	int eliminated = 0;
	vector<int> checkVar = pi.tl.getModVariables("SSR");
	if (rLog.isTimeLimit()) {
		auto cmp = [&](int var1, int var2) {
			return pi.litClauses[negLit(var1)].size() + pi.litClauses[posLit(var1)].size() < pi.litClauses[negLit(var2)].size() + pi.litClauses[posLit(var2)].size();
		};
		sort(checkVar.begin(), checkVar.end(), cmp);
	}
	bool skip = false;
	if (skipTechnique > 0 && (int)checkVar.size() >= skipTechnique * 4) { // magic constant
		for (int tc = 0; tc < skipTechnique; tc++) {
			if (!rLog.requestTime(Log::Technique::SSR)) break;
			int var = checkVar[getRand(0, (int)checkVar.size() -1)];
			eliminated += trySSRgen(var);
		}
		if (eliminated == 0) {
			skip = true;
			log("SSR skipped");
		}
	}
	if (!skip) {
		for (int var : checkVar) {
			if (!rLog.requestTime(Log::Technique::SSR)) break;
			eliminated += trySSRgen(var);
		}
	}
	log(eliminated, " eliminated by SSR");
	rLog.stopTechnique(Log::Technique::SSR);
	return eliminated;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r14
leaq 0x218(%rdi), %rbx
pushq $0x5
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x21e0a
movq %rbx, %rdi
movl %ebp, %esi
callq 0x227d2
testb %al, %al
je 0xdaba
movq %rbx, 0x8(%rsp)
leaq 0x21dee(%rip), %rsi     # 0x2f801
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6788
leaq 0x68(%r14), %rsi
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x275ce
movq 0x8(%rsp), %rbx
leaq 0x28(%rsp), %rdi
callq 0x3130
movq %rbx, %rdi
callq 0x22ac8
testb %al, %al
je 0xdada
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %r15
cmpq %r15, %r12
je 0xdada
movq %r15, %rbx
subq %r12, %rbx
movq %rbx, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rcx
callq 0x1617a
cmpq $0x41, %rbx
jl 0xdacc
leaq 0x40(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1650e
cmpq %r15, %r13
je 0xdada
movq %r13, %rdi
movq %r14, %rsi
callq 0x16599
addq $0x4, %r13
jmp 0xdaa4
pushq $0x5
popq %rsi
movq %rbx, %rdi
callq 0x21e46
xorl %ebp, %ebp
jmp 0xdbd4
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1650e
movl 0x468(%r14), %eax
xorl %ebp, %ebp
movq 0x10(%rsp), %r13
testl %eax, %eax
jle 0xdb65
movq 0x18(%rsp), %rcx
subq %r13, %rcx
shrq $0x2, %rcx
leal (,%rax,4), %edx
cmpl %ecx, %edx
jg 0xdb65
xorl %r12d, %r12d
pushq $0x5
popq %r15
xorl %ebp, %ebp
cmpl %eax, %r12d
jge 0xdb5c
movq 0x8(%rsp), %rdi
movl %r15d, %esi
callq 0x227d2
testb %al, %al
je 0xdb5c
movq 0x18(%rsp), %rdx
subq 0x10(%rsp), %rdx
shrq $0x2, %rdx
decl %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x18bca
cltq
movq 0x10(%rsp), %rcx
movl (%rcx,%rax,4), %esi
movq %r14, %rdi
callq 0xd8f6
addl %eax, %ebp
incl %r12d
movl 0x468(%r14), %eax
jmp 0xdb0c
testl %ebp, %ebp
je 0xdb9b
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rbx
pushq $0x5
popq %r15
cmpq %rbx, %r13
je 0xdbac
movl (%r13), %r12d
movq 0x8(%rsp), %rdi
movl %r15d, %esi
callq 0x227d2
testb %al, %al
je 0xdbac
movq %r14, %rdi
movl %r12d, %esi
callq 0xd8f6
addl %eax, %ebp
addq $0x4, %r13
jmp 0xdb6e
xorl %ebp, %ebp
leaq 0x21c42(%rip), %rsi     # 0x2f7e6
movq %r14, %rdi
callq 0x18be4
leaq 0x21c3f(%rip), %rdx     # 0x2f7f2
movq %r14, %rdi
movl %ebp, %esi
callq 0x189d8
pushq $0x5
popq %rsi
movq 0x8(%rsp), %rdi
callq 0x21e46
leaq 0x10(%rsp), %rdi
callq 0x7512
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xdc01
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3130
jmp 0xdc0e
movq %rax, %rbx
jmp 0xdc0e
jmp 0xdc01
jmp 0xdc01
jmp 0xdc01
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x7512
movq %rbx, %rdi
callq 0x3490