// File: /workspace/github_cpp_makefile_star2_O2/Laakeri[P]maxpre/src/./BCE.cpp
// Function: maxPreprocessor::Preprocessor::doBCE()
int Preprocessor::doBCE() {
	rLog.startTechnique(Log::Technique::BCE);
	if (!rLog.requestTime(Log::Technique::BCE)) {
		rLog.stopTechnique(Log::Technique::BCE);
		return 0;
	}
	int removed = 0;
	vector<int> checkVar = pi.tl.getTouchedVariables("BCE");
	if (rLog.isTimeLimit()) {
		auto cmp = [&](int var1, int var2) {
			return pi.litClauses[posLit(var1)].size() + pi.litClauses[negLit(var1)].size() < pi.litClauses[posLit(var2)].size() + pi.litClauses[negLit(var2)].size();
		};
		sort(checkVar.begin(), checkVar.end(), cmp);
	}
	bool skip = false;
	if (skipTechnique > 0 && (int)checkVar.size() >= skipTechnique * 4) {
		for (int tc = 0; tc < skipTechnique; tc++) {
			if (!rLog.requestTime(Log::Technique::BCE)) break;
			int var = checkVar[getRand(0, (int)checkVar.size() - 1)];
			if (pi.isLabel[var] == 0) {
				removed += tryBCE(negLit(var));
				removed += tryBCE(posLit(var));
			}
		}
		if (removed == 0) {
			log("BCE skipped");
			skip = true;
		}
	}
	if (!skip) {
		for (int var : checkVar) {
			if (!rLog.requestTime(Log::Technique::BCE)) break;
			if (pi.isLabel[var] == 0) {
				removed += tryBCE(negLit(var));
				removed += tryBCE(posLit(var));
			}
		}
	}
	log(removed, " removed by BCE");
	rLog.stopTechnique(Log::Technique::BCE);
	return removed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r14
leaq 0x218(%rdi), %rbx
pushq $0x1
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x21e0a
movq %rbx, %rdi
movl %ebp, %esi
callq 0x227d2
testb %al, %al
je 0xdf0b
leaq 0x219c3(%rip), %rsi     # 0x2f827
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6788
leaq 0x68(%r14), %rsi
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x2778e
leaq 0x28(%rsp), %rdi
callq 0x3130
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
callq 0x22ac8
testb %al, %al
je 0xdf2c
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %r15
cmpq %r15, %r12
je 0xdf2c
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 0x165d6
cmpq $0x41, %rbx
jl 0xdf1e
leaq 0x40(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1696c
cmpq %r15, %r13
je 0xdf2c
movq %r13, %rdi
movq %r14, %rsi
callq 0x169f7
addq $0x4, %r13
jmp 0xdef5
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x21e46
xorl %r15d, %r15d
jmp 0xe076
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1696c
movl 0x468(%r14), %eax
xorl %ebp, %ebp
movq 0x10(%rsp), %rbx
testl %eax, %eax
jle 0xdfee
movq 0x18(%rsp), %rcx
subq %rbx, %rcx
shrq $0x2, %rcx
leal (,%rax,4), %edx
cmpl %ecx, %edx
jg 0xdfee
xorl %r15d, %r15d
xorl %ebp, %ebp
movq 0x8(%rsp), %rbx
cmpl %eax, %r15d
jge 0xdfe1
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0x227d2
testb %al, %al
je 0xdfe1
movq 0x18(%rsp), %rdx
subq 0x10(%rsp), %rdx
shrq $0x2, %rdx
decl %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x18bca
cltq
movq 0x10(%rsp), %rcx
movslq (%rcx,%rax,4), %r12
movq 0x48(%r14), %rax
cmpl $0x0, (%rax,%r12,4)
jne 0xdfd5
leal 0x1(,%r12,2), %esi
movq %r14, %rdi
callq 0xdcb2
movl %eax, %r13d
addl %r12d, %r12d
movq %r14, %rdi
movl %r12d, %esi
callq 0xdcb2
addl %ebp, %r13d
addl %eax, %r13d
movl %r13d, %ebp
incl %r15d
movl 0x468(%r14), %eax
jmp 0xdf67
testl %ebp, %ebp
je 0xe088
movq 0x10(%rsp), %rbx
movl %ebp, %r15d
movq 0x18(%rsp), %rbp
cmpq %rbp, %rbx
je 0xe04a
movslq (%rbx), %r12
movq 0x8(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x227d2
testb %al, %al
je 0xe04a
movq 0x48(%r14), %rax
cmpl $0x0, (%rax,%r12,4)
jne 0xe044
leal 0x1(,%r12,2), %esi
movq %r14, %rdi
callq 0xdcb2
movl %eax, %r13d
addl %r12d, %r12d
movq %r14, %rdi
movl %r12d, %esi
callq 0xdcb2
addl %r15d, %r13d
addl %eax, %r13d
movl %r13d, %r15d
addq $0x4, %rbx
jmp 0xdff6
movq 0x8(%rsp), %rbx
leaq 0x217c5(%rip), %rdx     # 0x2f81b
movq %r14, %rdi
movl %r15d, %esi
callq 0x189d8
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x21e46
leaq 0x10(%rsp), %rdi
callq 0x7512
movl %r15d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
leaq 0x2177d(%rip), %rsi     # 0x2f80f
movq %r14, %rdi
callq 0x18be4
jmp 0xe04f
jmp 0xe0b8
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3130
jmp 0xe0c5
movq %rax, %rbx
jmp 0xe0c5
jmp 0xe0b8
jmp 0xe0b8
jmp 0xe0b8
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x7512
movq %rbx, %rdi
callq 0x3490
nop