// File: /workspace/github_cpp_makefile_star2_O2/Laakeri[P]maxpre/src/./BVE.cpp
// Function: maxPreprocessor::Preprocessor::doBVE()
int Preprocessor::doBVE() {
	rLog.startTechnique(Log::Technique::BVE);
	if (!rLog.requestTime(Log::Technique::BVE)) {
		rLog.stopTechnique(Log::Technique::BVE);
		return 0;
	}
	int eliminated = 0;
	vector<int> checkVar = pi.tl.getTouchedVariables("BVE");
	if (rLog.isTimeLimit()) {
		auto cmp = [&](int var1, int var2) {
			return pi.litClauses[negLit(var1)].size() + pi.litClauses[posLit(var1)].size() < pi.litClauses[negLit(var2)].size() + pi.litClauses[posLit(var2)].size();
		};
		sort(checkVar.begin(), checkVar.end(), cmp);
	}
  if (BVEsortMaxFirst) {
    auto cmp = [&](int var1, int var2) {
      return pi.litClauses[negLit(var1)].size() + pi.litClauses[posLit(var1)].size() > pi.litClauses[negLit(var2)].size() + pi.litClauses[posLit(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::BVE)) break;
			int var = checkVar[getRand(0, (int)checkVar.size() - 1)];
			if (pi.isLabel[var] == 0 && (pi.litClauses[posLit(var)].size() > 0 || pi.litClauses[negLit(var)].size() > 0)) {
				eliminated += tryBVE2(var);
			}
		}
		if (eliminated == 0) {
			skip = true;
			log("BVE skipped");
		}
	}
	if (!skip) {
		for (int var : checkVar) {
			if (!rLog.requestTime(Log::Technique::BVE)) break;
			if (pi.isLabel[var] == 0 && (pi.litClauses[posLit(var)].size() > 0 || pi.litClauses[negLit(var)].size() > 0)) {
				eliminated += tryBVE2(var);
			}
		}
	}
	log(eliminated, " eliminated by BVE");
	rLog.stopTechnique(Log::Technique::BVE);
	return eliminated;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r14
leaq 0x218(%rdi), %rbx
pushq $0x3
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x21e0a
movq %rbx, %rdi
movl %ebp, %esi
callq 0x227d2
testb %al, %al
je 0xc8bd
leaq 0x226d7(%rip), %rsi     # 0x2eeed
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 0xc8dd
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %r15
cmpq %r15, %r12
je 0xc8dd
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 0x158c2
cmpq $0x41, %rbx
jl 0xc8cf
leaq 0x40(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x15c56
cmpq %r15, %r13
je 0xc8dd
movq %r13, %rdi
movq %r14, %rsi
callq 0x15ce1
addq $0x4, %r13
jmp 0xc8a7
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x21e46
xorl %ebp, %ebp
jmp 0xcad0
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x15c56
cmpb $0x1, 0x3a1(%r14)
jne 0xc95b
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %r15
cmpq %r15, %r12
je 0xc95b
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 0x15d1e
cmpq $0x41, %rbx
jl 0xc94d
leaq 0x40(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x160b2
cmpq %r15, %r13
je 0xc95b
movq %r13, %rdi
movq %r14, %rsi
callq 0x1613d
addq $0x4, %r13
jmp 0xc937
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x160b2
movl 0x468(%r14), %eax
xorl %ebp, %ebp
movq 0x10(%rsp), %r13
testl %eax, %eax
jle 0xca35
movq 0x18(%rsp), %rcx
subq %r13, %rcx
shrq $0x2, %rcx
leal (,%rax,4), %edx
cmpl %ecx, %edx
jg 0xca35
xorl %r12d, %r12d
pushq $0x3
popq %r15
xorl %ebp, %ebp
movq 0x8(%rsp), %rbx
cmpl %eax, %r12d
jge 0xca28
movq %rbx, %rdi
movl %r15d, %esi
callq 0x227d2
testb %al, %al
je 0xca28
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), %rsi
movq 0x48(%r14), %rax
cmpl $0x0, (%rax,%rsi,4)
jne 0xca19
leal (%rsi,%rsi), %ecx
movslq %ecx, %rdx
movq 0x18(%r14), %rax
imulq $0x18, %rdx, %rdx
movq 0x8(%rax,%rdx), %rdi
cmpq (%rax,%rdx), %rdi
jne 0xca0f
orl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
movq 0x8(%rax,%rcx), %rdx
cmpq (%rax,%rcx), %rdx
je 0xca19
movq %r14, %rdi
callq 0xb974
addl %eax, %ebp
incl %r12d
movl 0x468(%r14), %eax
jmp 0xc99a
testl %ebp, %ebp
je 0xcae1
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rbx
pushq $0x3
popq %r15
cmpq %rbx, %r13
je 0xcaa5
movslq (%r13), %r12
movq 0x8(%rsp), %rdi
movl %r15d, %esi
callq 0x227d2
testb %al, %al
je 0xcaa5
movq 0x48(%r14), %rax
cmpl $0x0, (%rax,%r12,4)
jne 0xca9f
leal (%r12,%r12), %ecx
movslq %ecx, %rdx
movq 0x18(%r14), %rax
imulq $0x18, %rdx, %rdx
movq 0x8(%rax,%rdx), %rsi
cmpq (%rax,%rdx), %rsi
jne 0xca92
orl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
movq 0x8(%rax,%rcx), %rdx
cmpq (%rax,%rcx), %rdx
je 0xca9f
movq %r14, %rdi
movl %r12d, %esi
callq 0xb974
addl %eax, %ebp
addq $0x4, %r13
jmp 0xca3e
movq 0x8(%rsp), %rbx
leaq 0x22d18(%rip), %rdx     # 0x2f7c9
movq %r14, %rdi
movl %ebp, %esi
callq 0x189d8
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x21e46
leaq 0x10(%rsp), %rdi
callq 0x7512
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
leaq 0x22cd3(%rip), %rsi     # 0x2f7bd
movq %r14, %rdi
callq 0x18be4
jmp 0xcaaa
jmp 0xcb10
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3130
jmp 0xcb1d
movq %rax, %rbx
jmp 0xcb1d
jmp 0xcb10
jmp 0xcb10
jmp 0xcb10
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x7512
movq %rbx, %rdi
callq 0x3490
nop