// File: Laakeri[P]maxpre/src/./BVA.cpp
// Function: maxPreprocessor::Preprocessor::doBVA()
int Preprocessor::doBVA() {
	rLog.startTechnique(Log::Technique::BVA);
	if (!rLog.requestTime(Log::Technique::BVA)) {
		rLog.stopTechnique(Log::Technique::BVA);
		return 0;
	}
	int removed = 0;
	vector<int> checkLit = pi.tl.getTouchedLiterals("BVA");
	vector<int> hClauses = pi.tl.getModClauses("BVAhash");
	for (int c : hClauses) {
		if (!rLog.requestTime(Log::Technique::BVA)) break;
		if (!pi.isClauseRemoved(c)) {
			addBVAHash(pi.clauses[c].lit, BVAHashTable);
		}
	}
	if (rLog.isTimeLimit()) {
		// The best literals to consider should be the ones that occur most
		// (at least the paper had this heuristic)
		auto cmp = [&](int lit1, int lit2) {
			return pi.litClauses[lit1].size() > pi.litClauses[lit2].size();
		};
		sort(checkLit.begin(), checkLit.end(), cmp);
	}
	for (int lit : checkLit) {
		if (!rLog.requestTime(Log::Technique::BVA)) break;
		if (pi.litClauses[lit].size() < 2) continue;
		removed += tryBVA(lit, BVAHashTable);
	}
	pi.tl.setItr("BVAhash");
	log(removed, " clauses removed by BVA");
	rLog.stopTechnique(Log::Technique::BVA);
	return removed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x138(%rbp)
addq $0x218, %rdi            # imm = 0x218
movl $0xa, %esi
callq 0x61320
movq -0x138(%rbp), %rdi
addq $0x218, %rdi            # imm = 0x218
movl $0xa, %esi
callq 0x62450
testb $0x1, %al
jne 0x297cb
movq -0x138(%rbp), %rdi
addq $0x218, %rdi            # imm = 0x218
movl $0xa, %esi
callq 0x61390
movl $0x0, -0x4(%rbp)
jmp 0x29ca1
movq -0x138(%rbp), %rax
movl $0x0, -0x14(%rbp)
addq $0x68, %rax
movq %rax, -0x148(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x4620
movq -0x140(%rbp), %rdx
leaq 0x5d62d(%rip), %rsi     # 0x86e2f
leaq -0x50(%rbp), %rdi
callq 0xa430
jmp 0x2980d
movq -0x148(%rbp), %rsi
leaq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x73500
jmp 0x29823
leaq -0x50(%rbp), %rdi
callq 0x4240
leaq -0x51(%rbp), %rdi
callq 0x43f0
movq -0x138(%rbp), %rax
addq $0x68, %rax
movq %rax, -0x158(%rbp)
leaq -0xa1(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x4620
movq -0x150(%rbp), %rdx
leaq 0x5d5ab(%rip), %rsi     # 0x86e13
leaq -0xa0(%rbp), %rdi
callq 0xa430
jmp 0x29876
movq -0x158(%rbp), %rsi
leaq -0x80(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
callq 0x73c70
jmp 0x2988f
leaq -0xa0(%rbp), %rdi
callq 0x4240
leaq -0xa1(%rbp), %rdi
callq 0x43f0
leaq -0x80(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
callq 0xa800
movq %rax, -0xb8(%rbp)
movq -0xb0(%rbp), %rdi
callq 0xa830
movq %rax, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0xa860
testb $0x1, %al
jne 0x298f4
jmp 0x29a1f
leaq -0xb8(%rbp), %rdi
callq 0xa8a0
movq -0x138(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xc4(%rbp)
addq $0x218, %rdi            # imm = 0x218
movl $0xa, %esi
callq 0x62450
movb %al, -0x159(%rbp)
jmp 0x29928
movb -0x159(%rbp), %al
testb $0x1, %al
jne 0x299b6
jmp 0x29938
jmp 0x29a1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x29960
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4240
leaq -0x51(%rbp), %rdi
callq 0x43f0
jmp 0x29cad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x29994
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x4240
leaq -0xa1(%rbp), %rdi
callq 0x43f0
jmp 0x29c96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x29c8d
movq -0x138(%rbp), %rdi
movl -0xc4(%rbp), %esi
callq 0x5eb70
movb %al, -0x15a(%rbp)
jmp 0x299d0
movb -0x15a(%rbp), %al
testb $0x1, %al
jne 0x29a0c
jmp 0x299dc
movq -0x138(%rbp), %rdi
movslq -0xc4(%rbp), %rsi
callq 0x3c600
movq -0x138(%rbp), %rdi
movq %rax, %rsi
movq %rdi, %rdx
addq $0x430, %rdx            # imm = 0x430
callq 0x27190
jmp 0x29a0a
jmp 0x29a0c
jmp 0x29a0e
leaq -0xb8(%rbp), %rdi
callq 0xa930
jmp 0x298d8
movq -0x138(%rbp), %rdi
addq $0x218, %rdi            # imm = 0x218
callq 0x62aa0
movb %al, -0x15b(%rbp)
jmp 0x29a3a
movb -0x15b(%rbp), %al
testb $0x1, %al
jne 0x29a46
jmp 0x29aaa
movq -0x138(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0xa800
movq -0x168(%rbp), %rdi
movq %rax, -0xd8(%rbp)
callq 0xa830
movq %rax, -0xe0(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
callq 0x29cc0
jmp 0x29aa8
jmp 0x29aaa
leaq -0x30(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rdi
callq 0xa800
movq %rax, -0xf8(%rbp)
movq -0xf0(%rbp), %rdi
callq 0xa830
movq %rax, -0x100(%rbp)
leaq -0xf8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0xa860
testb $0x1, %al
jne 0x29af7
jmp 0x29ba1
leaq -0xf8(%rbp), %rdi
callq 0xa8a0
movq -0x138(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x104(%rbp)
addq $0x218, %rdi            # imm = 0x218
movl $0xa, %esi
callq 0x62450
movb %al, -0x169(%rbp)
jmp 0x29b2b
movb -0x169(%rbp), %al
testb $0x1, %al
jne 0x29b39
jmp 0x29b37
jmp 0x29ba1
movq -0x138(%rbp), %rdi
addq $0x18, %rdi
movslq -0x104(%rbp), %rsi
callq 0xaab0
movq %rax, %rdi
callq 0xf940
cmpq $0x2, %rax
jae 0x29b60
jmp 0x29b90
movq -0x138(%rbp), %rdi
movl -0x104(%rbp), %esi
movq %rdi, %rdx
addq $0x430, %rdx            # imm = 0x430
callq 0x27860
movl %eax, -0x170(%rbp)
jmp 0x29b84
movl -0x170(%rbp), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0xa930
jmp 0x29adb
movq -0x138(%rbp), %rax
addq $0x68, %rax
movq %rax, -0x180(%rbp)
leaq -0x129(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x4620
movq -0x178(%rbp), %rdx
leaq 0x5d23f(%rip), %rsi     # 0x86e13
leaq -0x128(%rbp), %rdi
callq 0xa430
jmp 0x29be2
movq -0x180(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x74020
jmp 0x29bf7
leaq -0x128(%rbp), %rdi
callq 0x4240
leaq -0x129(%rbp), %rdi
callq 0x43f0
movq -0x138(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq 0x5d1fb(%rip), %rdx     # 0x86e1b
callq 0x3c620
jmp 0x29c27
movq -0x138(%rbp), %rdi
addq $0x218, %rdi            # imm = 0x218
movl $0xa, %esi
callq 0x61390
jmp 0x29c41
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xab00
leaq -0x30(%rbp), %rdi
callq 0xab00
jmp 0x29ca1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x29c81
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x4240
leaq -0x129(%rbp), %rdi
callq 0x43f0
leaq -0x80(%rbp), %rdi
callq 0xab00
leaq -0x30(%rbp), %rdi
callq 0xab00
jmp 0x29cad
movl -0x4(%rbp), %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x4610
nopw %cs:(%rax,%rax)