// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rbx, %rdi
movl $0x5, %esi
callq 0x298e6
movq %rbx, %rdi
movl $0x5, %esi
callq 0x2a464
testb %al, %al
je 0x11615
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x28270(%rip), %rsi     # 0x397d1
leaq 0x2826c(%rip), %rdx     # 0x397d4
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x945c
leaq 0x68(%r14), %rsi
movq %rsp, %rdi
movq %r15, %rdx
callq 0x305c8
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x1159b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x2a792
testb %al, %al
movq %rbx, 0x18(%rsp)
je 0x11637
movq (%rsp), %r12
movq 0x8(%rsp), %r15
cmpq %r15, %r12
je 0x11637
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 0x1c23e
cmpq $0x41, %rbx
jl 0x11629
leaq 0x40(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1c675
cmpq %r15, %r13
je 0x11637
movq %r13, %rdi
movq %r14, %rsi
callq 0x1c705
addq $0x4, %r13
jmp 0x115ff
movq %rbx, %rdi
movl $0x5, %esi
callq 0x29928
xorl %ebp, %ebp
jmp 0x11783
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1c675
movl 0x468(%r14), %eax
testl %eax, %eax
jle 0x116e0
movq 0x8(%rsp), %rcx
subq (%rsp), %rcx
shrq $0x2, %rcx
shll $0x2, %eax
xorl %ebx, %ebx
movl $0x0, %ebp
cmpl %ecx, %eax
jg 0x11701
cmpl $0x0, 0x468(%r14)
jle 0x116e6
leaq 0x470(%r14), %r15
xorl %ebp, %ebp
leaq 0x20(%rsp), %r12
xorl %r13d, %r13d
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
movl $0x5, %esi
callq 0x2a464
testb %al, %al
je 0x116e8
movq 0x8(%rsp), %rax
subq (%rsp), %rax
shrq $0x2, %rax
decl %eax
movl $0x0, 0x20(%rsp)
movl %eax, 0x24(%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2152e
cltq
movq (%rsp), %rcx
movl (%rcx,%rax,4), %esi
movq %r14, %rdi
callq 0x1142e
addl %eax, %ebp
incl %r13d
cmpl 0x468(%r14), %r13d
jl 0x11685
jmp 0x116e8
xorl %ebx, %ebx
xorl %ebp, %ebp
jmp 0x11701
xorl %ebp, %ebp
xorl %ebx, %ebx
testl %ebp, %ebp
jne 0x11701
movb $0x1, %bl
leaq 0x280bf(%rip), %rsi     # 0x397b6
movq %r14, %rdi
callq 0x1f6a2
xorl %ebp, %ebp
testb %bl, %bl
jne 0x1174d
movq (%rsp), %r13
movq 0x8(%rsp), %rbx
cmpq %rbx, %r13
je 0x1174d
addq $0x4, %r13
movl -0x4(%r13), %r12d
movq 0x18(%rsp), %rdi
movl $0x5, %esi
callq 0x2a464
movl %eax, %r15d
testb %al, %al
je 0x1173e
movq %r14, %rdi
movl %r12d, %esi
callq 0x1142e
addl %eax, %ebp
cmpq %rbx, %r13
setne %al
addq $0x4, %r13
testb %al, %r15b
jne 0x11717
leaq 0x2806e(%rip), %rdx     # 0x397c2
movq %r14, %rdi
movl %ebp, %esi
callq 0x1f426
movq 0x18(%rsp), %rdi
movl $0x5, %esi
callq 0x29928
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x11783
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x117b3
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x117cc
movq 0x38(%rsp), %rsi
incq %rsi
jmp 0x117c7
jmp 0x117b3
jmp 0x117b3
jmp 0x117b3
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x117cc
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x34a0