// File: Laakeri[P]maxpre/src/./BVE.cpp
// Function: maxPreprocessor::Preprocessor::tryBVEGE(int)
vector<int> Preprocessor::tryBVEGE(int var) {
	set<int> negBinaryClauseLits, posBinaryClauseLits;
	
	for (int c : pi.litClauses[negLit(var)]) {
		if (pi.clauses[c].lit.size() == 2) {
			if (litVariable(pi.clauses[c].lit[0]) == var) {
				negBinaryClauseLits.insert(pi.clauses[c].lit[1]);
			}
			else {
				negBinaryClauseLits.insert(pi.clauses[c].lit[0]);
			}
		}
	}
	for (int c : pi.litClauses[posLit(var)]) {
		if (pi.clauses[c].lit.size() == 2) {
			if (litVariable(pi.clauses[c].lit[0]) == var) {
				posBinaryClauseLits.insert(pi.clauses[c].lit[1]);
			}
			else {
				posBinaryClauseLits.insert(pi.clauses[c].lit[0]);
			}
		}
	}
	
	//Find the shortest definition
	vector<int> defClauses;
	int defVars = 0;
	if (defVars == 0) {
		auto tr = searchXor(var);
		if (tr.S > 0) {
			defVars = tr.S;
			defClauses = tr.F;
		}
	}
	if (defVars == 0) {
		auto tr = searchAndOr(posLit(var), defVars, negBinaryClauseLits);
		if (tr.S > 0) {
			defVars = tr.S;
			defClauses = tr.F;
		}
	}
	if (defVars == 0) {
		auto tr = searchAndOr(negLit(var), defVars, posBinaryClauseLits);
		if (tr.S > 0) {
			defVars = tr.S;
			defClauses = tr.F;
		}
	}
	if (defVars == 0) {
		auto tr = searchITE(var);
		if (tr.S > 0) {
			defVars = tr.S;
			defClauses = tr.F;
		}
	}
	if (defVars > 0) {
		return defClauses;
	}
	return vector<int>();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x1d0(%rbp)
movq %rdi, %rax
movq %rax, -0x1c8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1c0(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3dde0
leaq -0x78(%rbp), %rdi
callq 0x3dde0
movq -0x1c0(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x1b8(%rbp)
movl -0x14(%rbp), %edi
callq 0x3c5e0
movl %eax, -0x1b0(%rbp)
jmp 0x18cd6
movq -0x1b8(%rbp), %rdi
movl -0x1b0(%rbp), %eax
movslq %eax, %rsi
callq 0xaab0
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
callq 0xa800
movq %rax, -0x98(%rbp)
movq -0x80(%rbp), %rdi
callq 0xa830
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0xa860
testb $0x1, %al
jne 0x18d2b
jmp 0x18e74
leaq -0x98(%rbp), %rdi
callq 0xa8a0
movq -0x1c0(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xa4(%rbp)
movslq -0xa4(%rbp), %rsi
callq 0x3c600
movq %rax, %rdi
callq 0xf940
cmpq $0x2, %rax
jne 0x18e61
movq -0x1c0(%rbp), %rdi
movslq -0xa4(%rbp), %rsi
callq 0x3c600
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xa7c0
movl (%rax), %edi
callq 0x3c880
movl %eax, -0x1d4(%rbp)
jmp 0x18d92
movl -0x1d4(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x18e0b
movq -0x1c0(%rbp), %rdi
movslq -0xa4(%rbp), %rsi
callq 0x3c600
movq %rax, %rdi
movl $0x1, %esi
callq 0xa7c0
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x3de00
movb %dl, -0x1e1(%rbp)
movq %rax, -0x1e0(%rbp)
jmp 0x18dd8
movb -0x1e1(%rbp), %al
movq -0x1e0(%rbp), %rcx
movq %rcx, -0xb8(%rbp)
movb %al, -0xb0(%rbp)
jmp 0x18e5f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x19314
movq -0x1c0(%rbp), %rdi
movslq -0xa4(%rbp), %rsi
callq 0x3c600
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xa7c0
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x3de00
movb %dl, -0x1f1(%rbp)
movq %rax, -0x1f0(%rbp)
jmp 0x18e45
movb -0x1f1(%rbp), %al
movq -0x1f0(%rbp), %rcx
movq %rcx, -0xc8(%rbp)
movb %al, -0xc0(%rbp)
jmp 0x18e61
jmp 0x18e63
leaq -0x98(%rbp), %rdi
callq 0xa930
jmp 0x18d0f
movq -0x1c0(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x200(%rbp)
movl -0x14(%rbp), %edi
callq 0x3c5d0
movl %eax, -0x1f8(%rbp)
jmp 0x18e96
movq -0x200(%rbp), %rdi
movl -0x1f8(%rbp), %eax
movslq %eax, %rsi
callq 0xaab0
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
callq 0xa800
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rdi
callq 0xa830
movq %rax, -0xe0(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0xa860
testb $0x1, %al
jne 0x18ef4
jmp 0x19026
leaq -0xd8(%rbp), %rdi
callq 0xa8a0
movq -0x1c0(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xe4(%rbp)
movslq -0xe4(%rbp), %rsi
callq 0x3c600
movq %rax, %rdi
callq 0xf940
cmpq $0x2, %rax
jne 0x19013
movq -0x1c0(%rbp), %rdi
movslq -0xe4(%rbp), %rsi
callq 0x3c600
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xa7c0
movl (%rax), %edi
callq 0x3c880
movl %eax, -0x204(%rbp)
jmp 0x18f5b
movl -0x204(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x18fbd
movq -0x1c0(%rbp), %rdi
movslq -0xe4(%rbp), %rsi
callq 0x3c600
movq %rax, %rdi
movl $0x1, %esi
callq 0xa7c0
movq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x3de00
movb %dl, -0x211(%rbp)
movq %rax, -0x210(%rbp)
jmp 0x18fa1
movb -0x211(%rbp), %al
movq -0x210(%rbp), %rcx
movq %rcx, -0xf8(%rbp)
movb %al, -0xf0(%rbp)
jmp 0x19011
movq -0x1c0(%rbp), %rdi
movslq -0xe4(%rbp), %rsi
callq 0x3c600
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xa7c0
movq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x3de00
movb %dl, -0x221(%rbp)
movq %rax, -0x220(%rbp)
jmp 0x18ff7
movb -0x221(%rbp), %al
movq -0x220(%rbp), %rcx
movq %rcx, -0x108(%rbp)
movb %al, -0x100(%rbp)
jmp 0x19013
jmp 0x19015
leaq -0xd8(%rbp), %rdi
callq 0xa930
jmp 0x18ed8
leaq -0x120(%rbp), %rdi
callq 0xa7e0
movl $0x0, -0x124(%rbp)
cmpl $0x0, -0x124(%rbp)
jne 0x190d3
movq -0x1c0(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x148(%rbp), %rdi
callq 0x17060
jmp 0x19061
cmpl $0x0, -0x130(%rbp)
jle 0x190c7
movl -0x130(%rbp), %eax
movl %eax, -0x124(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x3de50
jmp 0x1908b
jmp 0x190c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x19308
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x3db70
jmp 0x19308
leaq -0x148(%rbp), %rdi
callq 0x3db70
cmpl $0x0, -0x124(%rbp)
jne 0x19170
movl -0x14(%rbp), %edi
callq 0x3c5d0
movl %eax, -0x228(%rbp)
jmp 0x190f0
movl -0x228(%rbp), %edx
movq -0x1c0(%rbp), %rsi
movl -0x124(%rbp), %ecx
leaq -0x168(%rbp), %rdi
leaq -0x48(%rbp), %r8
callq 0x15b60
jmp 0x19115
cmpl $0x0, -0x150(%rbp)
jle 0x19164
movl -0x150(%rbp), %eax
movl %eax, -0x124(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x3de50
jmp 0x1913f
jmp 0x19164
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x3db70
jmp 0x19308
leaq -0x168(%rbp), %rdi
callq 0x3db70
cmpl $0x0, -0x124(%rbp)
jne 0x1920d
movl -0x14(%rbp), %edi
callq 0x3c5e0
movl %eax, -0x22c(%rbp)
jmp 0x1918d
movl -0x22c(%rbp), %edx
movq -0x1c0(%rbp), %rsi
movl -0x124(%rbp), %ecx
leaq -0x188(%rbp), %rdi
leaq -0x78(%rbp), %r8
callq 0x15b60
jmp 0x191b2
cmpl $0x0, -0x170(%rbp)
jle 0x19201
movl -0x170(%rbp), %eax
movl %eax, -0x124(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x3de50
jmp 0x191dc
jmp 0x19201
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x3db70
jmp 0x19308
leaq -0x188(%rbp), %rdi
callq 0x3db70
cmpl $0x0, -0x124(%rbp)
jne 0x19289
movq -0x1c0(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x1a8(%rbp), %rdi
callq 0x16020
jmp 0x1922e
cmpl $0x0, -0x190(%rbp)
jle 0x1927d
movl -0x190(%rbp), %eax
movl %eax, -0x124(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x3de50
jmp 0x19258
jmp 0x1927d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x3db70
jmp 0x19308
leaq -0x1a8(%rbp), %rdi
callq 0x3db70
cmpl $0x0, -0x124(%rbp)
jle 0x192b1
movq -0x1d0(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x10650
movl $0x1, -0x1ac(%rbp)
jmp 0x192da
movq -0x1d0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x41e0
movq -0x1d0(%rbp), %rdi
callq 0xa7e0
movl $0x1, -0x1ac(%rbp)
leaq -0x120(%rbp), %rdi
callq 0xab00
leaq -0x78(%rbp), %rdi
callq 0x3e0a0
leaq -0x48(%rbp), %rdi
callq 0x3e0a0
movq -0x1c8(%rbp), %rax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
leaq -0x120(%rbp), %rdi
callq 0xab00
leaq -0x78(%rbp), %rdi
callq 0x3e0a0
leaq -0x48(%rbp), %rdi
callq 0x3e0a0
movq -0x88(%rbp), %rdi
callq 0x4610
nopw %cs:(%rax,%rax)