// File: /workspace/github_cpp_makefile_star2_O1/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 $0x88, %rsp
movq %rdi, %r14
leaq 0x218(%rdi), %rbx
movq %rbx, %rdi
movl $0x6, %esi
callq 0x298e6
movq %rbx, %rdi
movl $0x6, %esi
callq 0x2a464
testb %al, %al
je 0x12389
leaq 0x78(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x27619(%rip), %rsi     # 0x398eb
leaq 0x27615(%rip), %rdx     # 0x398ee
leaq 0x68(%rsp), %r15
movq %r15, %rdi
callq 0x945c
leaq 0x68(%r14), %rsi
leaq 0x38(%rsp), %rdi
movq %r15, %rdx
callq 0x307c8
movq 0x68(%rsp), %rdi
cmpq %r12, %rdi
je 0x1230e
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x2a792
testb %al, %al
movq %rbx, 0x30(%rsp)
je 0x123ab
movq 0x38(%rsp), %r12
movq 0x40(%rsp), %r15
cmpq %r15, %r12
je 0x123ab
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 0x1ccd6
cmpq $0x41, %rbx
jl 0x1239d
leaq 0x40(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1d10d
cmpq %r15, %r13
je 0x123ab
movq %r13, %rdi
movq %r14, %rsi
callq 0x1d19d
addq $0x4, %r13
jmp 0x12373
movq %rbx, %rdi
movl $0x6, %esi
callq 0x29928
xorl %ebx, %ebx
jmp 0x125f0
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1d10d
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rcx
movq %rcx, 0x50(%rsp)
cmpq %rcx, %rax
je 0x125ad
movl $0x0, 0x4(%rsp)
movq %rax, 0x58(%rsp)
movslq (%rax), %r12
movq 0x48(%r14), %rax
movl $0x3, %ebx
cmpl $0x0, (%rax,%r12,4)
je 0x1258e
movq %r14, %rdi
movl %r12d, %esi
callq 0x2859c
testb %al, %al
jne 0x1258e
movq 0x30(%rsp), %rdi
movl $0x6, %esi
callq 0x2a464
testb %al, %al
je 0x12564
movq 0x48(%r14), %rax
movl (%rax,%r12,4), %eax
cmpl $0x2, %eax
je 0x1244a
cmpl $0x1, %eax
jne 0x12467
leal 0x1(,%r12,2), %ecx
movslq %ecx, %rcx
movq 0x18(%r14), %rdx
leaq (%rcx,%rcx,2), %rcx
movq 0x8(%rdx,%rcx,8), %rsi
cmpq (%rdx,%rcx,8), %rsi
je 0x1257a
cmpl $0x2, %eax
jne 0x12467
leal (%r12,%r12), %eax
cltq
movq 0x18(%r14), %rcx
leaq (%rax,%rax,2), %rax
movq 0x8(%rcx,%rax,8), %rdx
cmpq (%rcx,%rax,8), %rdx
je 0x1256b
leal (%r12,%r12), %eax
movl %eax, 0xc(%rsp)
leal 0x1(,%r12,2), %eax
movl %eax, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x48(%r14), %rax
cmpl $0x1, (%rax,%r12,4)
movl 0xc(%rsp), %eax
cmovel 0x8(%rsp), %eax
cltq
leaq (%rax,%rax,2), %rsi
shlq $0x3, %rsi
addq 0x18(%r14), %rsi
leaq 0x10(%rsp), %rdi
callq 0x1fb22
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %rax
movq %rax, 0x60(%rsp)
xorl %r15d, %r15d
cmpq %rax, %rbx
je 0x1253f
movslq (%rbx), %rax
movq (%r14), %rcx
leaq (%rax,%rax,4), %rax
movq (%rcx,%rax,8), %rbp
movq 0x8(%rcx,%rax,8), %r13
cmpq %r13, %rbp
je 0x1252e
addq $0x4, %rbp
movl -0x4(%rbp), %edx
sarl %edx
xorl %eax, %eax
cmpl %r12d, %edx
je 0x1251e
movslq %edx, %rcx
movq 0x48(%r14), %rsi
cmpl $0x0, (%rsi,%rcx,4)
je 0x1251e
movq %r14, %rdi
movl %r12d, %esi
callq 0x11ece
testl %eax, %eax
je 0x1251c
incl 0x4(%rsp)
movb $0x1, %r15b
movb $0x1, %al
jmp 0x1251e
xorl %eax, %eax
testb %al, %al
jne 0x1252e
leaq 0x4(%rbp), %rax
cmpq %r13, %rbp
movq %rax, %rbp
jne 0x124e9
testb $0x1, %r15b
jne 0x1253f
addq $0x4, %rbx
cmpq 0x60(%rsp), %rbx
jne 0x124cd
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x12556
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
testb $0x1, %r15b
jne 0x1247b
xorl %ebx, %ebx
jmp 0x1258e
movl $0x2, %ebx
jmp 0x1258e
movq %r14, %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0xa016
jmp 0x1258a
movq %r14, %rdi
movl %r12d, %esi
movl $0x1, %edx
callq 0xa016
incl 0x4(%rsp)
cmpl $0x3, %ebx
je 0x12597
testl %ebx, %ebx
jne 0x125b5
movq 0x58(%rsp), %rax
addq $0x4, %rax
cmpq 0x50(%rsp), %rax
jne 0x123cb
jmp 0x125b5
movl $0x0, 0x4(%rsp)
leaq 0x27313(%rip), %rdx     # 0x398cf
movq %r14, %rdi
movl 0x4(%rsp), %ebx
movl %ebx, %esi
callq 0x1f426
movq 0x30(%rsp), %rdi
movl $0x6, %esi
callq 0x29928
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x125f0
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movl %ebx, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r12, %rdi
je 0x12655
movq 0x78(%rsp), %rsi
incq %rsi
jmp 0x12650
jmp 0x1261d
movq %rax, %rbx
jmp 0x1263e
jmp 0x12624
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1263e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x12655
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x34a0
nop