// File: /workspace/github_cpp_makefile_star2_O3/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
movq %rbx, %rdi
movl $0x1, %esi
callq 0x28b9e
movq %rbx, %rdi
movl $0x1, %esi
callq 0x29718
testb %al, %al
je 0x115cb
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2738e(%rip), %rsi     # 0x388a7
leaq 0x2738a(%rip), %rdx     # 0x388aa
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x9466
leaq 0x68(%r14), %rsi
leaq 0x8(%rsp), %rdi
movq %r15, %rdx
callq 0x2f8c0
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x11555
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x29a46
testb %al, %al
je 0x115ed
movq 0x8(%rsp), %r12
movq 0x10(%rsp), %r15
cmpq %r15, %r12
je 0x115ed
movq %r15, %r13
subq %r12, %r13
movq %r13, %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 0x1bd0d
cmpq $0x41, %r13
jl 0x115df
leaq 0x40(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1c10d
cmpq %r15, %r13
je 0x115ed
movq %r13, %rdi
movq %r14, %rsi
callq 0x1c18d
addq $0x4, %r13
jmp 0x115b5
movq %rbx, %rdi
movl $0x1, %esi
callq 0x28be0
xorl %eax, %eax
jmp 0x1176d
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1c10d
movl 0x468(%r14), %eax
xorl %r12d, %r12d
movq 0x8(%rsp), %r13
testl %eax, %eax
jle 0x116c2
movq 0x10(%rsp), %rcx
subq %r13, %rcx
shrq $0x2, %rcx
shll $0x2, %eax
cmpl %ecx, %eax
jg 0x116c2
leaq 0x470(%r14), %rax
movq %rax, (%rsp)
xorl %r12d, %r12d
xorl %r15d, %r15d
movq %rbx, %rdi
movl $0x1, %esi
callq 0x29718
testb %al, %al
je 0x116b8
movq 0x10(%rsp), %rax
subq 0x8(%rsp), %rax
shrq $0x2, %rax
decl %eax
movl $0x0, 0x20(%rsp)
movl %eax, 0x24(%rsp)
leaq 0x20(%rsp), %rdi
movq (%rsp), %rsi
movq %rdi, %rdx
callq 0x2096e
cltq
movq 0x8(%rsp), %rcx
movslq (%rcx,%rax,4), %r13
movq 0x48(%r14), %rax
cmpl $0x0, (%rax,%r13,4)
jne 0x116a8
leal 0x1(,%r13,2), %esi
movq %r14, %rdi
callq 0x112e6
movl %eax, %ebp
addl %r13d, %r13d
movq %r14, %rdi
movl %r13d, %esi
callq 0x112e6
addl %r12d, %ebp
addl %eax, %ebp
movl %ebp, %r12d
incl %r15d
cmpl 0x468(%r14), %r15d
jl 0x1162c
testl %r12d, %r12d
je 0x1171e
movq 0x8(%rsp), %r13
movl %r12d, (%rsp)
movq 0x10(%rsp), %r12
cmpq %r12, %r13
je 0x11734
movslq (%r13), %r15
movq %rbx, %rdi
movl $0x1, %esi
callq 0x29718
testb %al, %al
je 0x11734
movq 0x48(%r14), %rax
cmpl $0x0, (%rax,%r15,4)
jne 0x11718
leal 0x1(,%r15,2), %esi
movq %r14, %rdi
callq 0x112e6
movl %eax, %ebp
addl %r15d, %r15d
movq %r14, %rdi
movl %r15d, %esi
callq 0x112e6
addl (%rsp), %ebp
addl %eax, %ebp
movl %ebp, (%rsp)
addq $0x4, %r13
jmp 0x116cb
movl $0x0, (%rsp)
leaq 0x27163(%rip), %rsi     # 0x3888f
movq %r14, %rdi
callq 0x1eac0
leaq 0x27160(%rip), %rdx     # 0x3889b
movq %r14, %rdi
movl (%rsp), %esi
callq 0x1e844
movq %rbx, %rdi
movl $0x1, %esi
callq 0x28be0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1176a
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movl (%rsp), %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1179b
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x117b5
movq 0x38(%rsp), %rsi
incq %rsi
jmp 0x117b0
jmp 0x1179b
jmp 0x1179b
jmp 0x1179b
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x117b5
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x34a0
nop