// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %edx, %r15d
movq %rsi, %r12
movq %rdi, %r14
movq %rdi, 0x50(%rsp)
leaq 0x90(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x60(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leal (%r15,%r15), %eax
movl %eax, 0x28(%rsp)
leal 0x1(,%r15,2), %eax
movl %eax, 0x2c(%rsp)
cltq
movq 0x18(%rsi), %rcx
imulq $0x18, %rax, %rax
movq (%rcx,%rax), %rbp
movq 0x8(%rcx,%rax), %r13
leaq 0x88(%rsp), %rbx
cmpq %r13, %rbp
je 0xb778
movslq (%rbp), %rax
movq (%r12), %rcx
imulq $0x28, %rax, %rdx
movq (%rcx,%rdx), %rax
movq 0x8(%rcx,%rdx), %rcx
subq %rax, %rcx
cmpq $0x8, %rcx
jne 0xb772
movl (%rax), %ecx
sarl %ecx
xorl %edx, %edx
cmpl %r15d, %ecx
sete %dl
leaq (%rax,%rdx,4), %rsi
movq %rbx, %rdi
callq 0x1c54e
addq $0x4, %rbp
jmp 0xb737
movslq 0x28(%rsp), %rax
movq 0x18(%r12), %rcx
imulq $0x18, %rax, %rax
movq (%rcx,%rax), %rbp
movq 0x8(%rcx,%rax), %r13
leaq 0x58(%rsp), %rbx
cmpq %r13, %rbp
je 0xb7d5
movslq (%rbp), %rax
movq (%r12), %rcx
imulq $0x28, %rax, %rdx
movq (%rcx,%rdx), %rax
movq 0x8(%rcx,%rdx), %rcx
subq %rax, %rcx
cmpq $0x8, %rcx
jne 0xb7cf
movl (%rax), %ecx
sarl %ecx
xorl %edx, %edx
cmpl %r15d, %ecx
sete %dl
leaq (%rax,%rdx,4), %rsi
movq %rbx, %rdi
callq 0x1c54e
addq $0x4, %rbp
jmp 0xb794
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
movl %r15d, %edx
callq 0xa91c
cmpl $0x0, 0x20(%rsp)
jle 0xb80e
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x18ea4
jmp 0xb8b5
leaq 0x8(%rsp), %rdi
callq 0x7512
leaq 0x8(%rsp), %rdi
leaq 0x88(%rsp), %r8
movq %r12, %rsi
movl 0x28(%rsp), %edx
xorl %ecx, %ecx
callq 0xa05e
cmpl $0x0, 0x20(%rsp)
jle 0xb84b
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x18ea4
jmp 0xb8b5
leaq 0x8(%rsp), %rdi
callq 0x7512
leaq 0x8(%rsp), %rdi
leaq 0x58(%rsp), %r8
movq %r12, %rsi
movl 0x2c(%rsp), %edx
xorl %ecx, %ecx
callq 0xa05e
cmpl $0x0, 0x20(%rsp)
jle 0xb885
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x18ea4
jmp 0xb8b5
leaq 0x8(%rsp), %rdi
callq 0x7512
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
movl %r15d, %edx
callq 0xa284
cmpl $0x0, 0x20(%rsp)
jle 0xb91a
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x18ea4
leaq 0x8(%rsp), %rdi
callq 0x7512
leaq 0x30(%rsp), %rax
movaps (%rax), %xmm0
movups %xmm0, (%r14)
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%r14)
movq %rax, %r14
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
andq $0x0, 0x10(%r14)
leaq 0x30(%rsp), %rdi
callq 0x7512
leaq 0x58(%rsp), %rdi
callq 0x19878
leaq 0x88(%rsp), %rdi
callq 0x19878
movq 0x50(%rsp), %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8(%rsp), %rdi
callq 0x7512
jmp 0xb8d6
jmp 0xb932
jmp 0xb941
jmp 0xb932
jmp 0xb941
jmp 0xb932
jmp 0xb941
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x7512
jmp 0xb944
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x7512
jmp 0xb955
jmp 0xb952
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x19878
leaq 0x88(%rsp), %rdi
callq 0x19878
movq %rbx, %rdi
callq 0x3490