// File: /workspace/github_cpp_makefile_star2_O1/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 $0x68, %rsp
movq %rdi, %r14
leaq 0x218(%rdi), %rbx
movq %rbx, %rdi
movl $0x4, %esi
callq 0x298e6
movq %rbx, %rdi
movl $0x4, %esi
callq 0x2a464
testb %al, %al
je 0xc9d6
leaq 0x58(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2cb52(%rip), %rsi     # 0x39465
leaq 0x2cb4d(%rip), %rdx     # 0x39467
leaq 0x48(%rsp), %r15
movq %r15, %rdi
callq 0x945c
leaq 0x68(%r14), %rsi
leaq 0x8(%rsp), %rdi
movq %r15, %rdx
callq 0x304cc
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0xc94f
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x2a792
testb %al, %al
movq %rbx, (%rsp)
je 0xc9fc
movq 0x8(%rsp), %r12
movq 0x10(%rsp), %r15
cmpq %r15, %r12
je 0xc9fc
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 0x1b3b7
cmpq $0x41, %rbx
jl 0xc9ea
leaq 0x40(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b6c4
cmpq %r15, %r13
movq (%rsp), %rbx
je 0xc9fc
movq %r13, %rdi
movq %r14, %rsi
callq 0x1b75f
addq $0x4, %r13
cmpq %r15, %r13
jne 0xc9c0
jmp 0xc9fc
movq %rbx, %rdi
movl $0x4, %esi
callq 0x29928
xorl %ebp, %ebp
jmp 0xcbb1
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1b6c4
movq (%rsp), %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movl 0x468(%r14), %eax
testl %eax, %eax
jle 0xcab9
movq 0x10(%rsp), %rcx
subq 0x8(%rsp), %rcx
shrq $0x2, %rcx
shll $0x2, %eax
cmpl %ecx, %eax
jg 0xcab9
cmpl $0x0, 0x468(%r14)
jle 0xcaad
leaq 0x470(%r14), %r15
xorl %ebp, %ebp
leaq 0x40(%rsp), %r12
leaq 0x20(%rsp), %r13
movq %rbx, %rdi
movl $0x4, %esi
callq 0x2a464
testb %al, %al
je 0xcaad
movq 0x10(%rsp), %rax
subq 0x8(%rsp), %rax
shrq $0x2, %rax
decl %eax
movl $0x0, 0x40(%rsp)
movl %eax, 0x44(%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2152e
cltq
movq 0x8(%rsp), %rcx
movl (%rcx,%rax,4), %esi
movq %r14, %rdi
movq %r13, %rdx
callq 0xc836
incl %ebp
cmpl 0x468(%r14), %ebp
jl 0xca52
movq 0x28(%rsp), %rax
cmpq 0x20(%rsp), %rax
je 0xcb08
movq 0x8(%rsp), %r13
movq 0x10(%rsp), %rbx
cmpq %rbx, %r13
je 0xcb17
addq $0x4, %r13
leaq 0x20(%rsp), %r15
movl -0x4(%r13), %r12d
movq (%rsp), %rdi
movl $0x4, %esi
callq 0x2a464
movl %eax, %ebp
testb %al, %al
je 0xcb17
movq %r14, %rdi
movl %r12d, %esi
movq %r15, %rdx
callq 0xc836
cmpq %rbx, %r13
setne %al
addq $0x4, %r13
testb %al, %bpl
jne 0xcad1
jmp 0xcb17
leaq 0x2c937(%rip), %rsi     # 0x39446
movq %r14, %rdi
callq 0x1f6a2
movq 0x20(%rsp), %r12
movq 0x28(%rsp), %r13
xorl %ebp, %ebp
cmpq %r13, %r12
je 0xcb57
movq (%rsp), %rbx
movl (%r12), %r15d
movq %r14, %rdi
movl %r15d, %esi
callq 0x284dc
testb %al, %al
jne 0xcb4c
movq %r14, %rdi
movl %r15d, %esi
callq 0x28c34
incl %ebp
addq $0x4, %r12
cmpq %r13, %r12
jne 0xcb2c
jmp 0xcb5b
movq (%rsp), %rbx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x29970
leaq 0x2c8e5(%rip), %rdx     # 0x39451
movq %r14, %rdi
movl %ebp, %esi
callq 0x1f426
movq %rbx, %rdi
movl $0x4, %esi
callq 0x29928
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xcb9a
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xcbb1
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xcbe8
movq %rax, %rbx
jmp 0xcc02
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0xcc19
movq 0x58(%rsp), %rsi
incq %rsi
jmp 0xcc14
jmp 0xcbe8
jmp 0xcbe8
jmp 0xcbe8
jmp 0xcbe8
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xcc02
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xcc19
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x34a0
nop