// File: /workspace/github_cpp_makefile_star2_O3/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
movq %rdi, %r14
leal (%rsi,%rsi), %eax
movl %eax, 0xc(%rsp)
movslq %eax, %rcx
movq 0x18(%rdi), %rdx
leaq (%rcx,%rcx,2), %rcx
movq (%rdx,%rcx,8), %rax
movq %rcx, 0x58(%rsp)
movq 0x8(%rdx,%rcx,8), %rdi
movq %rax, 0x48(%rsp)
subq %rax, %rdi
shrq $0x2, %rdi
testl %edi, %edi
jle 0x10ec0
movq %rsi, 0x78(%rsp)
leal 0x1(,%rsi,2), %eax
movl %eax, 0x2c(%rsp)
movslq %eax, %rcx
leaq 0x218(%r14), %rax
movq %rax, 0x10(%rsp)
xorl %eax, %eax
leaq (%rcx,%rcx,2), %rcx
movq %rcx, 0x30(%rsp)
movq %r14, 0x18(%rsp)
movq 0x78(%rsp), %r12
movq %rax, 0x40(%rsp)
movq 0x30(%rsp), %rax
movq (%rdx,%rax,8), %rcx
movq 0x8(%rdx,%rax,8), %rdx
movq %rcx, 0x80(%rsp)
subq %rcx, %rdx
shrq $0x2, %rdx
movq (%r14), %rax
movq %rax, 0x50(%rsp)
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, %rdi
movq %rdx, %rcx
andq %rax, %rcx
movq %rcx, 0x70(%rsp)
movq $0x0, 0x20(%rsp)
movq %rdi, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
testl %edx, %edx
jle 0x10ddd
movq 0x48(%rsp), %rax
movq 0x20(%rsp), %rcx
movslq (%rax,%rcx,4), %rax
movq %rax, 0x38(%rsp)
leaq (%rax,%rax,4), %rax
movq 0x50(%rsp), %rcx
leaq (%rcx,%rax,8), %rbp
xorl %ebx, %ebx
movq 0x80(%rsp), %rax
movslq (%rax,%rbx,4), %r13
leaq (,%r13,4), %rax
addq %r13, %rax
movq 0x50(%rsp), %rcx
leaq (%rcx,%rax,8), %r15
movl %r12d, %esi
movq %r15, %rdx
movq %rbp, %rcx
callq 0xff38
movl %eax, %r14d
movl %r12d, %esi
movq %rbp, %rdx
movq %r15, %rcx
callq 0xff38
testb %r14b, %r14b
je 0x10dc2
testb %al, %al
jne 0x10e02
testb %r14b, %r14b
jne 0x10e56
testb %al, %al
jne 0x10e69
incq %rbx
cmpq %rbx, 0x70(%rsp)
jne 0x10d7a
movq 0x20(%rsp), %rcx
incq %rcx
movq 0x68(%rsp), %rdi
movq %rcx, 0x20(%rsp)
cmpq %rdi, %rcx
movq 0x60(%rsp), %rdx
jne 0x10d50
jmp 0x10ec4
movq 0x18(%rsp), %r14
movq %r14, %rdi
movl 0xc(%rsp), %esi
movq 0x38(%rsp), %rdx
movl $0x1, %ecx
callq 0x28218
movq 0x10(%rsp), %r15
movq %r15, %rdi
movl $0x1, %esi
callq 0x28ca0
movq 0x18(%r14), %rax
movq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax,%rbx,4), %esi
movq %r14, %rdi
callq 0x27f28
movq %r15, %rdi
movl $0x1, %esi
callq 0x28c28
jmp 0x10e91
movq 0x18(%rsp), %r14
movq %r14, %rdi
movl 0xc(%rsp), %esi
movq 0x38(%rsp), %rdx
jmp 0x10e78
movq 0x18(%rsp), %r14
movq %r14, %rdi
movl 0x2c(%rsp), %esi
movl %r13d, %edx
movl $0x1, %ecx
callq 0x28218
movq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0x28ca0
movq 0x40(%rsp), %rax
incl %eax
movq 0x18(%r14), %rdx
movq 0x58(%rsp), %rcx
movq (%rdx,%rcx,8), %rsi
movq 0x8(%rdx,%rcx,8), %rdi
movq %rsi, 0x48(%rsp)
subq %rsi, %rdi
shrq $0x2, %rdi
testl %edi, %edi
jg 0x10d00
jmp 0x10ec9
xorl %eax, %eax
jmp 0x10ec9
movq 0x40(%rsp), %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop