// File: /workspace/github_cpp_makefile_star2_O3/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
movq %rbx, %rdi
movl $0x6, %esi
callq 0x28b9e
movq %rbx, %rdi
movl $0x6, %esi
callq 0x29718
testb %al, %al
je 0x11cae
movq %rbx, 0x8(%rsp)
leaq 0x68(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x26da1(%rip), %rsi     # 0x3899b
leaq 0x26d9d(%rip), %rdx     # 0x3899e
leaq 0x58(%rsp), %r15
movq %r15, %rdi
callq 0x9466
leaq 0x68(%r14), %rsi
leaq 0x30(%rsp), %rdi
movq %r15, %rdx
callq 0x2f8c0
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x11c36
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32b0
movq 0x8(%rsp), %rdi
callq 0x29a46
testb %al, %al
je 0x11cd0
movq 0x30(%rsp), %r12
movq 0x38(%rsp), %r15
cmpq %r15, %r12
je 0x11cd0
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 0x1c212
cmpq $0x41, %rbx
jl 0x11cc2
leaq 0x40(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1c612
cmpq %r15, %r13
je 0x11cd0
movq %r13, %rdi
movq %r14, %rsi
callq 0x1c692
addq $0x4, %r13
jmp 0x11c98
movq %rbx, %rdi
movl $0x6, %esi
callq 0x28be0
xorl %ebx, %ebx
jmp 0x11ec7
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1c612
movq 0x30(%rsp), %rbx
movq 0x38(%rsp), %rax
movq %rax, 0x48(%rsp)
cmpq %rax, %rbx
je 0x11e86
movl $0x0, (%rsp)
movslq (%rbx), %r12
movq 0x48(%r14), %rax
cmpl $0x0, (%rax,%r12,4)
movq %rbx, 0x50(%rsp)
je 0x11e70
movq %r14, %rdi
movl %r12d, %esi
callq 0x278a0
testb %al, %al
jne 0x11e70
movq 0x8(%rsp), %rdi
movl $0x6, %esi
callq 0x29718
testb %al, %al
je 0x11e8d
movq 0x48(%r14), %rax
movl (%rax,%r12,4), %eax
leal (%r12,%r12), %ecx
movl %ecx, 0x4(%rsp)
cmpl $0x2, %eax
je 0x11d7b
cmpl $0x1, %eax
jne 0x11d97
movl 0x4(%rsp), %eax
orl $0x1, %eax
cltq
movq 0x18(%r14), %rcx
leaq (%rax,%rax,2), %rax
movq 0x8(%rcx,%rax,8), %rdx
cmpq (%rcx,%rax,8), %rdx
jne 0x11d97
movq %r14, %rdi
movl %r12d, %esi
movl $0x1, %edx
callq 0xa026
jmp 0x11e6d
movslq 0x4(%rsp), %rax
movq 0x18(%r14), %rcx
leaq (%rax,%rax,2), %rax
movq 0x8(%rcx,%rax,8), %rdx
cmpq (%rcx,%rax,8), %rdx
je 0x11e60
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x48(%r14), %rax
xorl %ecx, %ecx
cmpl $0x1, (%rax,%r12,4)
sete %cl
orl 0x4(%rsp), %ecx
movslq %ecx, %rax
leaq (%rax,%rax,2), %rsi
shlq $0x3, %rsi
addq 0x18(%r14), %rsi
leaq 0x10(%rsp), %rdi
callq 0x1ef50
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rbp
cmpq %rbp, %r13
je 0x11e3f
movslq (%r13), %rax
movq (%r14), %rcx
leaq (%rax,%rax,4), %rax
movq (%rcx,%rax,8), %rbx
movq 0x8(%rcx,%rax,8), %r15
cmpq %r15, %rbx
je 0x11e26
movl (%rbx), %edx
sarl %edx
cmpl %r12d, %edx
je 0x11e20
movslq %edx, %rax
movq 0x48(%r14), %rcx
cmpl $0x0, (%rcx,%rax,4)
je 0x11e20
movq %r14, %rdi
movl %r12d, %esi
callq 0x1186c
testl %eax, %eax
jne 0x11e33
addq $0x4, %rbx
jmp 0x11df6
addq $0x4, %r13
cmpq %rbp, %r13
jne 0x11de2
xorl %ebx, %ebx
jmp 0x11e38
incl (%rsp)
movb $0x1, %bl
movq 0x10(%rsp), %r13
jmp 0x11e41
xorl %ebx, %ebx
testq %r13, %r13
je 0x11e56
movq 0x20(%rsp), %rsi
subq %r13, %rsi
movq %r13, %rdi
callq 0x32b0
testb %bl, %bl
jne 0x11d97
jmp 0x11e70
movq %r14, %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0xa026
incl (%rsp)
movq 0x50(%rsp), %rbx
addq $0x4, %rbx
cmpq 0x48(%rsp), %rbx
jne 0x11cef
jmp 0x11e8d
movl $0x0, (%rsp)
leaq 0x26aeb(%rip), %rdx     # 0x3897f
movq %r14, %rdi
movl (%rsp), %ebx
movl %ebx, %esi
callq 0x1e844
movq 0x8(%rsp), %rdi
movl $0x6, %esi
callq 0x28be0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x11ec7
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x11f29
movq 0x68(%rsp), %rsi
incq %rsi
jmp 0x11f24
jmp 0x11ef1
movq %rax, %rbx
jmp 0x11f12
jmp 0x11ef8
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x11f12
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x11f29
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x34a0
nop