// File: /workspace/github_cpp_makefile_star2_O2/Laakeri[P]maxpre/src/./SSR.cpp
// Function: maxPreprocessor::Preprocessor::trySSR(int)
int Preprocessor::trySSR(int var) {
	int removed = 0;
	bool f = true;
	while (f) {
		f = false;
		for (int i = 0; i < (int)pi.litClauses[posLit(var)].size(); i++) {
			for (int ii = 0; ii < (int)pi.litClauses[negLit(var)].size(); ii++) {
				Clause& cp = pi.clauses[pi.litClauses[posLit(var)][i]];
				Clause& cn = pi.clauses[pi.litClauses[negLit(var)][ii]];
				
				bool canP = canSSR(var, cn, cp);
				bool canN = canSSR(var, cp, cn);
				
				if (canP && canN) {
					pi.removeLiteralFromClause(posLit(var), pi.litClauses[posLit(var)][i]);
					rLog.removeLiteral(1);
					pi.removeClause(pi.litClauses[negLit(var)][ii]);
					rLog.removeClause(1);
					removed++;
					f = true;
					break;
				}
				else if (canP) {
					pi.removeLiteralFromClause(posLit(var), pi.litClauses[posLit(var)][i]);
					rLog.removeLiteral(1);
					removed++;
					f = true;
					break;
				}
				else if (canN) {
					pi.removeLiteralFromClause(negLit(var), pi.litClauses[negLit(var)][ii]);
					rLog.removeLiteral(1);
					removed++;
					f = true;
					break;
				}
			}
			if (f) break;
		}
	}
	return removed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
leal (%rsi,%rsi), %eax
movl %eax, 0xc(%rsp)
movslq %eax, %rcx
movq %rsi, 0x60(%rsp)
leal 0x1(%rsi,%rsi), %eax
movl %eax, 0x2c(%rsp)
movslq %eax, %rdx
movq %rdi, 0x10(%rsp)
leaq 0x218(%rdi), %rax
movq %rax, 0x18(%rsp)
movb $0x1, %al
imulq $0x18, %rcx, %rcx
movq %rcx, 0x40(%rsp)
imulq $0x18, %rdx, %rcx
movq %rcx, 0x30(%rsp)
movl $0x0, 0x8(%rsp)
testb $0x1, %al
je 0xd8e0
movq 0x10(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x70(%rsp)
movq 0x18(%rax), %rcx
movq 0x40(%rsp), %rax
movq (%rcx,%rax), %rdx
movq 0x8(%rcx,%rax), %rax
movq %rdx, 0x68(%rsp)
subq %rdx, %rax
shrq $0x2, %rax
addq 0x30(%rsp), %rcx
cltq
testl %eax, %eax
movl $0x0, %edx
movq %rax, 0x58(%rsp)
cmovgl %eax, %edx
xorl %r14d, %r14d
movq %rcx, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
cmpq %rdx, %r14
je 0xd8d3
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movq %rax, 0x78(%rsp)
subq %rax, %rcx
shrq $0x2, %rcx
testl %ecx, %ecx
movl $0x0, %eax
cmovlel %eax, %ecx
movq %rcx, 0x80(%rsp)
xorl %ebx, %ebx
movq %r14, 0x20(%rsp)
cmpq %rbx, 0x80(%rsp)
je 0xd81e
movq 0x68(%rsp), %rax
movslq (%rax,%r14,4), %rax
movq %rax, 0x38(%rsp)
imulq $0x28, %rax, %r15
movq 0x70(%rsp), %rax
addq %rax, %r15
movq 0x78(%rsp), %rcx
movslq (%rcx,%rbx,4), %r13
imulq $0x28, %r13, %r14
addq %rax, %r14
movq 0x60(%rsp), %rbp
movl %ebp, %esi
movq %r14, %rdx
movq %r15, %rcx
callq 0xcbc2
movl %eax, %r12d
movl %ebp, %esi
movq %r15, %rdx
movq %r14, %rcx
callq 0xcbc2
testb %r12b, %r12b
je 0xd808
testb %al, %al
jne 0xd830
testb %r12b, %r12b
jne 0xd87e
incq %rbx
testb %al, %al
movq 0x20(%rsp), %r14
je 0xd7a9
jmp 0xd8ad
incq %r14
movq 0x50(%rsp), %rcx
movq 0x48(%rsp), %rdx
jmp 0xd774
movq 0x10(%rsp), %r14
movq %r14, %rdi
movl 0xc(%rsp), %esi
movq 0x38(%rsp), %rdx
pushq $0x1
popq %rbp
movl %ebp, %ecx
callq 0x216d0
movq 0x18(%rsp), %r15
movq %r15, %rdi
movl %ebp, %esi
callq 0x21ef8
movq 0x18(%r14), %rax
movq 0x30(%rsp), %rcx
movq (%rax,%rcx), %rax
movl (%rax,%rbx,4), %esi
movq %r14, %rdi
callq 0x21490
movq %r15, %rdi
movl %ebp, %esi
callq 0x21e84
jmp 0xd8a2
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
movq 0x38(%rsp), %rdx
pushq $0x1
popq %rbx
movl %ebx, %ecx
callq 0x216d0
movq 0x18(%rsp), %rdi
movl %ebx, %esi
callq 0x21ef8
incl 0x8(%rsp)
movq 0x20(%rsp), %r14
jmp 0xd8d3
movq 0x10(%rsp), %rdi
movl 0x2c(%rsp), %esi
movl %r13d, %edx
pushq $0x1
popq %rbx
movl %ebx, %ecx
callq 0x216d0
movq 0x18(%rsp), %rdi
movl %ebx, %esi
callq 0x21ef8
incl 0x8(%rsp)
cmpq 0x58(%rsp), %r14
setl %al
jmp 0xd71e
movl 0x8(%rsp), %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq