// File: /workspace/github_cpp_makefile_star2_O1/Laakeri[P]maxpre/src/./BCR.cpp
// Function: maxPreprocessor::Preprocessor::doBCR()
int Preprocessor::doBCR() {
	rLog.startTechnique(Log::Technique::BCR);
	int removed = 0;
	if (!rLog.requestTime(Log::Technique::BCR)) {
		rLog.stopTechnique(Log::Technique::BCR);
		return 0;
	}
	vector<int> checkVar = pi.tl.getTouchedVariables("BCR");
	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);
	}
	for (int var : checkVar) {
		if (pi.isLabel[var] == VAR_UNDEFINED) continue;
		if (pi.isVarRemoved(var)) continue;
		if (!rLog.requestTime(Log::Technique::BCR)) break;
		if (pi.isLabel[var] == VAR_TRUE) {
			assert(pi.litClauses[posLit(var)].size() == 1);
			for (int c : pi.litClauses[negLit(var)]) {
				if (pi.clauses[c].lit.size() == 2) {
					if (pi.isLabel[litVariable(pi.clauses[c].lit[0])] && pi.isLabel[litVariable(pi.clauses[c].lit[1])]) {
						if (pi.labelWeight(litVariable(pi.clauses[c].lit[0])) == pi.labelWeight(litVariable(pi.clauses[c].lit[1]))) {
							if (tryBCR(c, negLit(var))) {
								removed++;
								break;
							}
						}
					}
				}
			}
		}
		else if(pi.isLabel[var] == VAR_FALSE) {
			assert(pi.litClauses[negLit(var)].size() == 1);
			for (int c : pi.litClauses[posLit(var)]) {
				if (pi.clauses[c].lit.size() == 2) {
					if (pi.isLabel[litVariable(pi.clauses[c].lit[0])] && pi.isLabel[litVariable(pi.clauses[c].lit[1])]) {
						if (pi.labelWeight(litVariable(pi.clauses[c].lit[0])) == pi.labelWeight(litVariable(pi.clauses[c].lit[1]))) {
							if (tryBCR(c, posLit(var))) {
								removed++;
								break;
							}
						}
					}
				}
			}
		}
		else{
			assert(0);
		}
	}
	rLog.stopTechnique(Log::Technique::BCR);
	log(removed, " labels removed by BCR");
	return removed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
leaq 0x218(%rdi), %r12
movq %r12, %rdi
movl $0x7, %esi
callq 0x298e6
movq %r12, %rdi
movl $0x7, %esi
callq 0x2a464
testb %al, %al
je 0x12ff6
leaq 0x58(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x26ade(%rip), %rsi     # 0x39a1a
leaq 0x26ada(%rip), %rdx     # 0x39a1d
leaq 0x48(%rsp), %r15
movq %r15, %rdi
callq 0x945c
leaq 0x68(%rbx), %rsi
leaq 0x28(%rsp), %rdi
movq %r15, %rdx
callq 0x307c8
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x12f78
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x32b0
movq %r12, 0x20(%rsp)
movq %r12, %rdi
callq 0x2a792
testb %al, %al
movq %rbx, %r14
je 0x13018
movq 0x28(%rsp), %r12
movq 0x30(%rsp), %r15
cmpq %r15, %r12
je 0x13018
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 0x1d222
cmpq $0x41, %rbx
jl 0x1300a
leaq 0x40(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1d659
cmpq %r15, %r13
je 0x13018
movq %r13, %rdi
movq %r14, %rsi
callq 0x1d6e9
addq $0x4, %r13
jmp 0x12fe0
movq %r12, %rdi
movl $0x7, %esi
callq 0x29928
xorl %ebx, %ebx
jmp 0x132e8
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1d659
movq %r14, 0x8(%rsp)
movq 0x28(%rsp), %r14
movq 0x30(%rsp), %rax
movq %rax, 0x40(%rsp)
cmpq %rax, %r14
je 0x132a0
movl $0x0, 0x4(%rsp)
movq 0x8(%rsp), %r13
movslq (%r14), %rbx
movq 0x48(%r13), %rax
movl $0x3, %ebp
cmpl $0x0, (%rax,%rbx,4)
je 0x13286
movq %r13, %rdi
movl %ebx, %esi
callq 0x2859c
testb %al, %al
jne 0x13286
movq 0x20(%rsp), %rdi
movl $0x7, %esi
callq 0x2a464
movl $0x2, %ebp
testb %al, %al
je 0x13286
movq 0x48(%r13), %rax
movl (%rax,%rbx,4), %eax
cmpl $0x2, %eax
je 0x13193
cmpl $0x1, %eax
jne 0x132f9
addl %ebx, %ebx
movslq %ebx, %rcx
movq 0x18(%r13), %rax
leaq (%rcx,%rcx,2), %rcx
movq 0x8(%rax,%rcx,8), %rdx
subq (%rax,%rcx,8), %rdx
cmpq $0x4, %rdx
jne 0x13318
orl $0x1, %ebx
movq %rbx, 0x10(%rsp)
movslq %ebx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %r15
movq 0x8(%rax,%rcx,8), %rax
movq %rax, 0x18(%rsp)
cmpq %rax, %r15
je 0x13284
addq $0x4, %r15
movslq -0x4(%r15), %r12
movq (%r13), %rcx
leaq (%r12,%r12,4), %rbx
movq (%rcx,%rbx,8), %rax
movq 0x8(%rcx,%rbx,8), %rcx
subq %rax, %rcx
xorl %ebp, %ebp
cmpq $0x8, %rcx
jne 0x13169
movl (%rax), %esi
sarl %esi
movslq %esi, %rdx
movq 0x48(%r13), %rcx
cmpl $0x0, (%rcx,%rdx,4)
je 0x13169
movl 0x4(%rax), %eax
sarl %eax
cltq
cmpl $0x0, (%rcx,%rax,4)
je 0x13169
movq %r13, %rdi
callq 0x285da
movq %r13, %rdi
movq %rax, %r13
movq (%rdi), %rax
movq (%rax,%rbx,8), %rax
movl 0x4(%rax), %esi
sarl %esi
callq 0x285da
cmpq %rax, %r13
jne 0x1318a
movq 0x8(%rsp), %r13
movq %r13, %rdi
movl %r12d, %esi
movq 0x10(%rsp), %rdx
callq 0x127d4
movzbl %al, %ecx
addl %ecx, 0x4(%rsp)
jmp 0x1316b
xorl %eax, %eax
testb %al, %al
jne 0x13286
leaq 0x4(%r15), %rax
cmpq 0x18(%rsp), %r15
movq %rax, %r15
jne 0x130e9
jmp 0x13286
xorl %eax, %eax
movq 0x8(%rsp), %r13
jmp 0x1316b
leal 0x1(,%rbx,2), %eax
movslq %eax, %rcx
movq 0x18(%r13), %rax
leaq (%rcx,%rcx,2), %rcx
movq 0x8(%rax,%rcx,8), %rdx
subq (%rax,%rcx,8), %rdx
cmpq $0x4, %rdx
jne 0x13337
addl %ebx, %ebx
movq %rbx, 0x10(%rsp)
movslq %ebx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %r15
movq 0x8(%rax,%rcx,8), %rax
movq %rax, 0x18(%rsp)
cmpq %rax, %r15
je 0x13284
addq $0x4, %r15
movslq -0x4(%r15), %r12
movq (%r13), %rcx
leaq (%r12,%r12,4), %rbx
movq (%rcx,%rbx,8), %rax
movq 0x8(%rcx,%rbx,8), %rcx
subq %rax, %rcx
xorl %ebp, %ebp
cmpq $0x8, %rcx
jne 0x13261
movl (%rax), %esi
sarl %esi
movslq %esi, %rdx
movq 0x48(%r13), %rcx
cmpl $0x0, (%rcx,%rdx,4)
je 0x13261
movl 0x4(%rax), %eax
sarl %eax
cltq
cmpl $0x0, (%rcx,%rax,4)
je 0x13261
movq %r13, %rdi
callq 0x285da
movq %r13, %rdi
movq %rax, %r13
movq (%rdi), %rax
movq (%rax,%rbx,8), %rax
movl 0x4(%rax), %esi
sarl %esi
callq 0x285da
cmpq %rax, %r13
jne 0x1327b
movq 0x8(%rsp), %r13
movq %r13, %rdi
movl %r12d, %esi
movq 0x10(%rsp), %rdx
callq 0x127d4
movzbl %al, %ecx
addl %ecx, 0x4(%rsp)
jmp 0x13263
xorl %eax, %eax
testb %al, %al
jne 0x13286
leaq 0x4(%r15), %rax
cmpq 0x18(%rsp), %r15
movq %rax, %r15
jne 0x131e1
jmp 0x13286
xorl %eax, %eax
movq 0x8(%rsp), %r13
jmp 0x13263
xorl %ebp, %ebp
cmpl $0x3, %ebp
je 0x1328f
testl %ebp, %ebp
jne 0x132ad
addq $0x4, %r14
cmpq 0x40(%rsp), %r14
jne 0x13042
jmp 0x132ad
movl $0x0, 0x4(%rsp)
movq 0x8(%rsp), %r13
movq 0x20(%rsp), %rdi
movl $0x7, %esi
callq 0x29928
movl 0x4(%rsp), %ebx
leaq 0x26740(%rip), %rdx     # 0x39a07
movq %r13, %rdi
movl %ebx, %esi
callq 0x1f426
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x132e8
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2794d(%rip), %rdi     # 0x3ac4d
leaq 0x265f2(%rip), %rsi     # 0x398f9
leaq 0x266a7(%rip), %rcx     # 0x399b5
movl $0x7f, %edx
callq 0x31b0
leaq 0x2666f(%rip), %rdi     # 0x3998e
leaq 0x265d3(%rip), %rsi     # 0x398f9
leaq 0x26688(%rip), %rcx     # 0x399b5
movl $0x61, %edx
callq 0x31b0
leaq 0x266a2(%rip), %rdi     # 0x399e0
leaq 0x265b4(%rip), %rsi     # 0x398f9
leaq 0x26669(%rip), %rcx     # 0x399b5
movl $0x70, %edx
callq 0x31b0
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x1338d
movq 0x58(%rsp), %rsi
incq %rsi
jmp 0x13388
jmp 0x13373
jmp 0x13373
jmp 0x13373
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x1338d
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x34a0
nop