// File: /workspace/github_cpp_makefile_star2_O2/Laakeri[P]maxpre/src/./SE.cpp
// Function: maxPreprocessor::Preprocessor::doSE()
int Preprocessor::doSE() {
	rLog.startTechnique(Log::Technique::SE);
	if (!rLog.requestTime(Log::Technique::SE)) {
		rLog.stopTechnique(Log::Technique::SE);
		return 0;
	}
	
	vector<int> checkLit = pi.tl.getModLiterals("SE");
	if (rLog.isTimeLimit()) {
		auto cmp = [&](int lit1, int lit2) {
			return pi.litClauses[lit1].size() < pi.litClauses[lit2].size();
		};
		sort(checkLit.begin(), checkLit.end(), cmp);
	}
	bool skip = false;
	vector<int> toRemove;
	if (skipTechnique > 0 && (int)checkLit.size() >= skipTechnique*4) { // magic constant
		for (int tc = 0; tc < skipTechnique; tc++) {
			if (!rLog.requestTime(Log::Technique::SE)) break;
			int lit = checkLit[getRand(0, (int)checkLit.size() - 1)];
			trySEgen(lit, toRemove);
		}
		if (toRemove.size() == 0) {
			skip = true;
			log("SE skipped");
		}
	}
	if (!skip) {
		for (int lit : checkLit) {
			if (!rLog.requestTime(Log::Technique::SE)) break;
			trySEgen(lit, toRemove);
		}
	}
	int removed = 0;
	for (int c : toRemove) {
		if (!pi.isClauseRemoved(c)) {
			pi.removeClause(c);
			removed++;
		}
	}
	rLog.removeClause(removed);
	log(removed, " clauses removed by SE");
	rLog.stopTechnique(Log::Technique::SE);
	return removed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r14
leaq 0x218(%rdi), %rbx
pushq $0x4
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x21e0a
movq %rbx, %rdi
movl %ebp, %esi
callq 0x227d2
testb %al, %al
je 0x9da2
leaq 0x25799(%rip), %rsi     # 0x2f495
leaq 0x38(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x6788
leaq 0x68(%r14), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x274f2
leaq 0x38(%rsp), %rdi
callq 0x3130
movq %rbx, (%rsp)
movq %rbx, %rdi
callq 0x22ac8
testb %al, %al
je 0x9dc2
movq 0x8(%rsp), %r12
movq 0x10(%rsp), %r15
cmpq %r15, %r12
je 0x9dc2
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 0x154ad
cmpq $0x41, %rbx
jl 0x9db4
leaq 0x40(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x157fa
cmpq %r15, %r13
je 0x9dc2
movq %r13, %rdi
movq %r14, %rsi
callq 0x15885
addq $0x4, %r13
jmp 0x9d8c
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x21e46
xorl %ebp, %ebp
jmp 0x9f26
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x157fa
xorps %xmm0, %xmm0
andq $0x0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movl 0x468(%r14), %eax
movq 0x8(%rsp), %r13
testl %eax, %eax
jle 0x9e69
movq 0x10(%rsp), %rcx
subq %r13, %rcx
shrq $0x2, %rcx
leal (,%rax,4), %edx
cmpl %ecx, %edx
jg 0x9e69
xorl %r12d, %r12d
pushq $0x4
popq %rbp
leaq 0x20(%rsp), %r15
movq (%rsp), %rbx
cmpl %eax, %r12d
jge 0x9e58
movq %rbx, %rdi
movl %ebp, %esi
callq 0x227d2
testb %al, %al
je 0x9e58
movq 0x10(%rsp), %rdx
subq 0x8(%rsp), %rdx
shrq $0x2, %rdx
decl %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x18bca
cltq
movq 0x8(%rsp), %rcx
movl (%rcx,%rax,4), %esi
movq %r14, %rdi
movq %r15, %rdx
callq 0x9c32
incl %r12d
movl 0x468(%r14), %eax
jmp 0x9e0a
movq 0x28(%rsp), %rax
cmpq 0x20(%rsp), %rax
je 0x9ea2
movq 0x8(%rsp), %r13
movq 0x10(%rsp), %rbx
pushq $0x4
popq %rbp
leaq 0x20(%rsp), %r15
cmpq %rbx, %r13
je 0x9eb1
movl (%r13), %r12d
movq (%rsp), %rdi
movl %ebp, %esi
callq 0x227d2
testb %al, %al
je 0x9eb1
movq %r14, %rdi
movl %r12d, %esi
movq %r15, %rdx
callq 0x9c32
addq $0x4, %r13
jmp 0x9e76
leaq 0x255cd(%rip), %rsi     # 0x2f476
movq %r14, %rdi
callq 0x18be4
movq 0x20(%rsp), %r12
movq 0x28(%rsp), %r13
xorl %ebp, %ebp
cmpq %r13, %r12
je 0x9ee8
movl (%r12), %r15d
movq %r14, %rdi
movl %r15d, %esi
callq 0x20f14
testb %al, %al
jne 0x9ee2
movq %r14, %rdi
movl %r15d, %esi
callq 0x21490
incl %ebp
addq $0x4, %r12
jmp 0x9ebd
movq (%rsp), %rbx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x21e84
leaq 0x25584(%rip), %rdx     # 0x2f481
movq %r14, %rdi
movl %ebp, %esi
callq 0x189d8
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x21e46
leaq 0x20(%rsp), %rdi
callq 0x7512
leaq 0x8(%rsp), %rdi
callq 0x7512
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9f5a
movq %rax, %rbx
jmp 0x9f67
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x3130
jmp 0x9f71
movq %rax, %rbx
jmp 0x9f71
jmp 0x9f5a
jmp 0x9f5a
jmp 0x9f5a
jmp 0x9f5a
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x7512
leaq 0x8(%rsp), %rdi
callq 0x7512
movq %rbx, %rdi
callq 0x3490
nop