// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movq %rdi, %rbx
leal (%rsi,%rsi), %eax
movl %eax, 0x14(%rsp)
cltq
movq %rsi, 0x48(%rsp)
leal 0x1(%rsi,%rsi), %ecx
movl %ecx, 0x44(%rsp)
movslq %ecx, %rcx
leaq 0x218(%rdi), %rdx
movq %rdx, 0x18(%rsp)
movq $0x0, 0x8(%rsp)
leaq (%rax,%rax,2), %rax
movq %rax, 0x28(%rsp)
leaq (%rcx,%rcx,2), %rax
movq %rax, 0x38(%rsp)
movq %rdi, 0x20(%rsp)
movq 0x48(%rsp), %rbp
movq 0x18(%rbx), %rax
movq 0x28(%rsp), %rdx
movq 0x8(%rax,%rdx,8), %rcx
subq (%rax,%rdx,8), %rcx
shrq $0x2, %rcx
testl %ecx, %ecx
jle 0x1140e
movq $0x0, 0x30(%rsp)
xorl %esi, %esi
movl %esi, 0x4(%rsp)
movq 0x18(%rbx), %rcx
movq 0x38(%rsp), %rdx
movq (%rcx,%rdx,8), %rax
movq 0x8(%rcx,%rdx,8), %rdx
subq %rax, %rdx
shrq $0x2, %rdx
testl %edx, %edx
jle 0x113d3
xorl %r14d, %r14d
movq 0x28(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x30(%rsp), %rdx
movslq (%rcx,%rdx,4), %r15
movq (%rbx), %rcx
leaq (%r15,%r15,4), %rdx
leaq (%rcx,%rdx,8), %r13
movslq (%rax,%r14,4), %rax
movq %rax, 0x50(%rsp)
leaq (%rax,%rax,4), %rax
leaq (%rcx,%rax,8), %rbx
movl %ebp, %esi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x1042e
movl %eax, %r12d
movl %ebp, %esi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x1042e
testb %r12b, %r12b
je 0x1134d
testb %al, %al
je 0x1134d
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
movl 0x14(%rsp), %esi
movl %r15d, %edx
movl $0x1, %ecx
callq 0x28f40
movq 0x18(%rsp), %r15
movq %r15, %rdi
movl $0x1, %esi
callq 0x299e8
movq 0x18(%rbx), %rax
movq 0x38(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax,%r14,4), %esi
movq %rbx, %rdi
callq 0x28c34
movq %r15, %rdi
movl $0x1, %esi
callq 0x29970
jmp 0x11393
testb %r12b, %r12b
je 0x11363
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
movl 0x14(%rsp), %esi
movl %r15d, %edx
jmp 0x1137a
movb $0x1, %cl
testb %al, %al
movq 0x20(%rsp), %rbx
je 0x113a7
movq %rbx, %rdi
movl 0x44(%rsp), %esi
movq 0x50(%rsp), %rdx
movl $0x1, %ecx
callq 0x28f40
movq 0x18(%rsp), %rdi
movl $0x1, %esi
callq 0x299e8
movq 0x8(%rsp), %rax
incl %eax
movq %rax, 0x8(%rsp)
movb $0x1, %al
movl %eax, 0x4(%rsp)
xorl %ecx, %ecx
testb %cl, %cl
je 0x113d3
incq %r14
movq 0x18(%rbx), %rcx
movq 0x38(%rsp), %rdx
movq (%rcx,%rdx,8), %rax
movq 0x8(%rcx,%rdx,8), %rdx
subq %rax, %rdx
shrq $0x2, %rdx
movslq %edx, %rdx
cmpq %rdx, %r14
jl 0x112a6
movl 0x4(%rsp), %esi
testb $0x1, %sil
jne 0x11410
movq 0x18(%rbx), %rax
movq 0x28(%rsp), %rdx
movq 0x8(%rax,%rdx,8), %rcx
subq (%rax,%rdx,8), %rcx
movq 0x30(%rsp), %rdx
incq %rdx
shrq $0x2, %rcx
movslq %ecx, %rax
movq %rdx, 0x30(%rsp)
cmpq %rax, %rdx
jl 0x1127e
jmp 0x11410
xorl %esi, %esi
testb $0x1, %sil
jne 0x11255
movq 0x8(%rsp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq