// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movq %rdi, %r14
leaq 0x218(%rdi), %rbx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x298e6
movq %rbx, %rdi
movl $0x1, %esi
callq 0x2a464
testb %al, %al
je 0x11bc4
leaq 0x48(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x27cea(%rip), %rsi     # 0x397f7
leaq 0x27ce6(%rip), %rdx     # 0x397fa
leaq 0x38(%rsp), %r15
movq %r15, %rdi
callq 0x945c
leaq 0x68(%r14), %rsi
leaq 0x10(%rsp), %rdi
movq %r15, %rdx
callq 0x307c8
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x11b49
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x2a792
testb %al, %al
movq %rbx, 0x28(%rsp)
je 0x11be6
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %r15
cmpq %r15, %r12
je 0x11be6
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 0x1c78a
cmpq $0x41, %rbx
jl 0x11bd8
leaq 0x40(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1cbc1
cmpq %r15, %r13
je 0x11be6
movq %r13, %rdi
movq %r14, %rsi
callq 0x1cc51
addq $0x4, %r13
jmp 0x11bae
movq %rbx, %rdi
movl $0x1, %esi
callq 0x29928
xorl %ebx, %ebx
jmp 0x11dac
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1cbc1
movl 0x468(%r14), %eax
testl %eax, %eax
jle 0x11ccd
movq 0x18(%rsp), %rcx
subq 0x10(%rsp), %rcx
shrq $0x2, %rcx
shll $0x2, %eax
xorl %ebx, %ebx
movl $0x0, %edx
cmpl %ecx, %eax
jg 0x11cf8
cmpl $0x0, 0x468(%r14)
jle 0x11cd3
leaq 0x470(%r14), %r15
movl $0x0, 0xc(%rsp)
xorl %r12d, %r12d
movq 0x28(%rsp), %rbx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x2a464
testb %al, %al
je 0x11cdb
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
shrq $0x2, %rax
decl %eax
movl $0x0, 0x30(%rsp)
movl %eax, 0x34(%rsp)
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movq %rdi, %rdx
callq 0x2152e
cltq
movq 0x10(%rsp), %rcx
movslq (%rcx,%rax,4), %r13
movq 0x48(%r14), %rax
cmpl $0x0, (%rax,%r13,4)
jne 0x11cbb
leal 0x1(,%r13,2), %esi
movq %r14, %rdi
callq 0x1187c
movl %eax, %ebp
addl %r13d, %r13d
movq %r14, %rdi
movl %r13d, %esi
callq 0x1187c
addl 0xc(%rsp), %ebp
addl %eax, %ebp
movl %ebp, 0xc(%rsp)
incl %r12d
cmpl 0x468(%r14), %r12d
jl 0x11c3a
jmp 0x11cdb
xorl %ebx, %ebx
xorl %edx, %edx
jmp 0x11cf8
movl $0x0, 0xc(%rsp)
xorl %ebx, %ebx
movl 0xc(%rsp), %edx
testl %edx, %edx
jne 0x11cf8
movb $0x1, %bl
leaq 0x27af1(%rip), %rsi     # 0x397df
movq %r14, %rdi
callq 0x1f6a2
xorl %edx, %edx
testb %bl, %bl
movl %edx, 0xc(%rsp)
jne 0x11d71
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rbx
cmpq %rbx, %r13
je 0x11d71
addq $0x4, %r13
movslq -0x4(%r13), %r12
movq 0x28(%rsp), %rdi
movl $0x1, %esi
callq 0x2a464
movl %eax, %r15d
testb %al, %al
je 0x11d62
movq 0x48(%r14), %rax
cmpl $0x0, (%rax,%r12,4)
jne 0x11d62
leal 0x1(,%r12,2), %esi
movq %r14, %rdi
callq 0x1187c
movl %eax, %ebp
addl %r12d, %r12d
movq %r14, %rdi
movl %r12d, %esi
callq 0x1187c
addl 0xc(%rsp), %ebp
addl %eax, %ebp
movl %ebp, 0xc(%rsp)
cmpq %rbx, %r13
setne %al
addq $0x4, %r13
testb %al, %r15b
jne 0x11d13
leaq 0x27a73(%rip), %rdx     # 0x397eb
movq %r14, %rdi
movl 0xc(%rsp), %ebx
movl %ebx, %esi
callq 0x1f426
movq 0x28(%rsp), %rdi
movl $0x1, %esi
callq 0x29928
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x11dac
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x11ddc
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x11df6
movq 0x48(%rsp), %rsi
incq %rsi
jmp 0x11df1
jmp 0x11ddc
jmp 0x11ddc
jmp 0x11ddc
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x11df6
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x34a0