// File: /workspace/github_cpp_makefile_star2_O2/Laakeri[P]maxpre/src/./BVE.cpp
// Function: maxPreprocessor::Preprocessor::searchAndOr(int, int, std::set<int, std::less<int>, std::allocator<int>> const&) const
pair<vector<int>, int> Preprocessor::searchAndOr(int dLit, int defVars, const set<int>& binaryClauseLits) const {
	vector<int> defClauses;
	for (int c : pi.litClauses[dLit]) {
		if (pi.clauses[c].lit.size() > 2 && ((int)pi.clauses[c].lit.size() - 1 < defVars || defVars == 0)) {
			bool f = false;
			for (int lit : pi.clauses[c].lit) {
				if (lit != dLit) {
					if (binaryClauseLits.count(litNegation(lit)) == 0) {
						f = true;
						break;
					}
				}
			}
			if (!f) {
				defVars = pi.clauses[c].lit.size() - 1;
				defClauses.clear();
				defClauses.push_back(c);
				for (int cc : pi.litClauses[litNegation(dLit)]) {
					if (pi.clauses[cc].lit.size() == 2) {
						int tl;
						if (litNegation(pi.clauses[cc].lit[0]) == dLit) {
							tl = pi.clauses[cc].lit[1];
						}
						else {
							tl = pi.clauses[cc].lit[0];
						}
						for (int lit : pi.clauses[c].lit) {
							if (litNegation(lit) == tl) {
								defClauses.push_back(cc);
								break;
							}
						}
					}
				}
				assert(defClauses.size() >= pi.clauses[c].lit.size());
			}
		}
	}
	return {defClauses, defVars};
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, 0x40(%rsp)
movl %ecx, %r15d
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, 0x28(%rsp)
leaq 0x10(%rsp), %rax
andq $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movslq %edx, %rax
movq 0x18(%rsi), %rcx
imulq $0x18, %rax, %rdx
movq (%rcx,%rdx), %r13
movq 0x8(%rcx,%rdx), %rcx
movq %rcx, 0x38(%rsp)
xorl $0x1, %eax
cltq
imulq $0x18, %rax, %rax
movq %rax, 0x30(%rsp)
cmpq 0x38(%rsp), %r13
je 0xa21a
movslq (%r13), %rax
movl %eax, 0x8(%rsp)
movq (%r12), %rcx
imulq $0x28, %rax, %rax
movq (%rcx,%rax), %rbx
movq 0x8(%rcx,%rax), %r14
movq %r14, %rax
subq %rbx, %rax
sarq $0x2, %rax
cmpq $0x3, %rax
jb 0xa211
movq %r15, %rcx
testl %ecx, %ecx
je 0xa102
cmpl %eax, %ecx
jl 0xa211
jmp 0xa102
addq $0x4, %rbx
cmpq %r14, %rbx
je 0xa12d
movl (%rbx), %eax
cmpl %ebp, %eax
je 0xa0fe
xorl $0x1, %eax
movl %eax, 0xc(%rsp)
movq 0x40(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x18c86
testq %rax, %rax
jne 0xa0fe
jmp 0xa211
movslq 0x8(%rsp), %rax
movq (%r12), %rcx
imulq $0x28, %rax, %rax
movq 0x8(%rcx,%rax), %r15
subq (%rcx,%rax), %r15
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0xa154
movq %rax, 0x18(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x68a4
shrq $0x2, %r15
decl %r15d
movq 0x18(%r12), %rax
movq 0x30(%rsp), %rcx
movq (%rax,%rcx), %r14
movq 0x8(%rax,%rcx), %rbx
cmpq %rbx, %r14
je 0xa1ec
movslq (%r14), %rcx
movl %ecx, 0xc(%rsp)
movq (%r12), %rax
imulq $0x28, %rcx, %rdx
movq (%rax,%rdx), %rcx
movq 0x8(%rax,%rdx), %rdx
subq %rcx, %rdx
cmpq $0x8, %rdx
jne 0xa1e6
movl (%rcx), %edx
xorl %ebp, %edx
xorl %esi, %esi
cmpl $0x1, %edx
sete %sil
movl (%rcx,%rsi,4), %ecx
movslq 0x8(%rsp), %rdx
imulq $0x28, %rdx, %rsi
movq (%rax,%rsi), %rdx
movq 0x8(%rax,%rsi), %rax
cmpq %rax, %rdx
je 0xa1e6
movl (%rdx), %esi
xorl %ecx, %esi
addq $0x4, %rdx
cmpl $0x1, %esi
jne 0xa1c5
leaq 0x10(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x68a4
addq $0x4, %r14
jmp 0xa17d
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
movslq 0x8(%rsp), %rcx
movq (%r12), %rdx
imulq $0x28, %rcx, %rcx
movq 0x8(%rdx,%rcx), %rsi
subq (%rdx,%rcx), %rsi
cmpq %rsi, %rax
jb 0xa24c
addq $0x4, %r13
jmp 0xa0b5
leaq 0x10(%rsp), %rsi
movq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0x19284
movl %r15d, 0x18(%rbx)
leaq 0x10(%rsp), %rdi
callq 0x7512
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2524e(%rip), %rdi     # 0x2f4a1
leaq 0x25275(%rip), %rsi     # 0x2f4cf
leaq 0x25278(%rip), %rcx     # 0x2f4d9
pushq $0x2d
popq %rdx
callq 0x31c0
jmp 0xa26f
jmp 0xa26f
jmp 0xa26f
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x7512
movq %rbx, %rdi
callq 0x3490