// File: /workspace/github_cpp_makefile_star2_O2/Laakeri[P]maxpre/src/./SLE.cpp
// Function: maxPreprocessor::Preprocessor::doSLE()
int Preprocessor::doSLE() {
	rLog.startTechnique(Log::Technique::SLE);
	int removed = 0;
	if (!rLog.requestTime(Log::Technique::SLE)) {
		rLog.stopTechnique(Log::Technique::SLE);
		return 0;
	}
	vector<int> checkVar = pi.tl.getTouchedVariables("SLE");
	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);
	}
	for (int var : checkVar) {
		if (pi.isLabel[var] == VAR_UNDEFINED) continue;
		if (pi.isVarRemoved(var)) continue;
		if (!rLog.requestTime(Log::Technique::SLE)) break;
		
		if (pi.isLabel[var] == VAR_TRUE && pi.litClauses[negLit(var)].size() == 0){
			setVariable(var, true);
			removed++;
			continue;
		}
		if (pi.isLabel[var] == VAR_FALSE && pi.litClauses[posLit(var)].size() == 0){
			setVariable(var, false);
			removed++;
			continue;
		}
		
		bool f = true;
		while (f) {
			f = false;
			vector<int> clauses;
			if (pi.isLabel[var] == VAR_TRUE) clauses = pi.litClauses[negLit(var)];
			else clauses = pi.litClauses[posLit(var)];
			for (int c : clauses) {
				for (int l : pi.clauses[c].lit) {
					if (pi.isLabel[litVariable(l)] && litVariable(l) != var) {
						if (trySLESlow(var, litVariable(l))) {
							removed++;
							f = true;
							break;
						}
					}
				}
				if (f) break;
			}
		}
	}
	
	log(removed, " labels removed by SLE");
	rLog.stopTechnique(Log::Technique::SLE);
	return removed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %r14
leaq 0x218(%rdi), %rbx
pushq $0x6
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x21e0a
movq %rbx, %rdi
movl %ebp, %esi
callq 0x227d2
testb %al, %al
je 0xe4c9
leaq 0x214f9(%rip), %rsi     # 0x2f91b
leaq 0x58(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x6788
leaq 0x68(%r14), %rsi
leaq 0x28(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x2778e
leaq 0x58(%rsp), %rdi
callq 0x3130
movq %rbx, %rdi
callq 0x22ac8
movq %rbx, 0x8(%rsp)
testb %al, %al
je 0xe4e9
movq 0x28(%rsp), %r12
movq 0x30(%rsp), %r15
cmpq %r15, %r12
je 0xe4e9
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 0x16a34
cmpq $0x41, %rbx
jl 0xe4db
leaq 0x40(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x16dc8
cmpq %r15, %r13
je 0xe4e9
movq %r13, %rdi
movq %r14, %rsi
callq 0x16e53
addq $0x4, %r13
jmp 0xe4b3
pushq $0x6
popq %rsi
movq %rbx, %rdi
callq 0x21e46
xorl %ebp, %ebp
jmp 0xe6c8
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x16dc8
movq 0x28(%rsp), %r15
movq 0x30(%rsp), %rax
movq %rax, 0x48(%rsp)
movl $0x0, (%rsp)
movq 0x8(%rsp), %rbx
cmpq 0x48(%rsp), %r15
je 0xe69f
movslq (%r15), %r13
movq 0x48(%r14), %rax
cmpl $0x0, (%rax,%r13,4)
je 0xe696
movq %r14, %rdi
movl %r13d, %esi
callq 0x20fae
testb %al, %al
jne 0xe696
movq %rbx, %rdi
pushq $0x6
popq %rsi
callq 0x227d2
testb %al, %al
je 0xe69f
movq 0x48(%r14), %rax
movl (%rax,%r13,4), %eax
leal (,%r13,2), %ecx
movl %ecx, 0x4(%rsp)
cmpl $0x2, %eax
je 0xe599
cmpl $0x1, %eax
jne 0xe5b5
movl 0x4(%rsp), %eax
orl $0x1, %eax
cltq
movq 0x18(%r14), %rcx
imulq $0x18, %rax, %rax
movq 0x8(%rcx,%rax), %rdx
cmpq (%rcx,%rax), %rdx
jne 0xe5b5
movq %r14, %rdi
movl %r13d, %esi
pushq $0x1
popq %rdx
callq 0x7c98
movq 0x8(%rsp), %rbx
jmp 0xe693
movslq 0x4(%rsp), %rax
movq 0x18(%r14), %rcx
imulq $0x18, %rax, %rax
movq 0x8(%rcx,%rax), %rdx
cmpq (%rcx,%rax), %rdx
je 0xe681
movq %r15, 0x40(%rsp)
movb $0x1, %r15b
testb $0x1, %r15b
je 0xe675
andq $0x0, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0x48(%r14), %rax
xorl %ecx, %ecx
cmpl $0x1, (%rax,%r13,4)
sete %cl
orl 0x4(%rsp), %ecx
movslq %ecx, %rax
imulq $0x18, %rax, %rsi
addq 0x18(%r14), %rsi
leaq 0x10(%rsp), %rdi
callq 0x18ea4
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %rax
movq %rax, 0x50(%rsp)
cmpq %rax, %r12
setne %r15b
je 0xe666
movslq (%r12), %rax
movq (%r14), %rcx
imulq $0x28, %rax, %rax
movq (%rcx,%rax), %rbx
movq 0x8(%rcx,%rax), %rbp
cmpq %rbp, %rbx
je 0xe658
movl (%rbx), %edx
sarl %edx
cmpl %r13d, %edx
je 0xe652
movslq %edx, %rax
movq 0x48(%r14), %rcx
cmpl $0x0, (%rcx,%rax,4)
je 0xe652
movq %r14, %rdi
movl %r13d, %esi
callq 0xe166
testl %eax, %eax
jne 0xe663
addq $0x4, %rbx
jmp 0xe628
addq $0x4, %r12
movq 0x50(%rsp), %rax
jmp 0xe60b
incl (%rsp)
leaq 0x10(%rsp), %rdi
callq 0x7512
jmp 0xe5bd
movq 0x8(%rsp), %rbx
movq 0x40(%rsp), %r15
jmp 0xe696
movq %r14, %rdi
movl %r13d, %esi
xorl %edx, %edx
callq 0x7c98
movq 0x8(%rsp), %rbx
incl (%rsp)
addq $0x4, %r15
jmp 0xe504
leaq 0x21259(%rip), %rdx     # 0x2f8ff
movq %r14, %rdi
movl (%rsp), %ebp
movl %ebp, %esi
callq 0x189d8
pushq $0x6
popq %rsi
movq %rbx, %rdi
callq 0x21e46
leaq 0x28(%rsp), %rdi
callq 0x7512
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x3130
jmp 0xe70d
movq %rax, %rbx
jmp 0xe70d
jmp 0xe6ef
movq %rax, %rbx
jmp 0xe703
jmp 0xe6f6
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x7512
leaq 0x28(%rsp), %rdi
callq 0x7512
movq %rbx, %rdi
callq 0x3490
nop