// File: 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
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x10(%rbp)
movb $0x1, -0x11(%rbp)
testb $0x1, -0x11(%rbp)
je 0x1da77
movb $0x0, -0x11(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x40(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, -0x44(%rbp)
addq $0x18, %rax
movq %rax, -0x50(%rbp)
movl -0xc(%rbp), %edi
callq 0x3c5d0
movq -0x50(%rbp), %rdi
movslq %eax, %rsi
callq 0xaab0
movq %rax, %rdi
callq 0xf940
movq %rax, %rcx
movl -0x44(%rbp), %eax
cmpl %ecx, %eax
jge 0x1da72
movl $0x0, -0x1c(%rbp)
movq -0x40(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, -0x54(%rbp)
addq $0x18, %rax
movq %rax, -0x60(%rbp)
movl -0xc(%rbp), %edi
callq 0x3c5e0
movq -0x60(%rbp), %rdi
movslq %eax, %rsi
callq 0xaab0
movq %rax, %rdi
callq 0xf940
movq %rax, %rcx
movl -0x54(%rbp), %eax
cmpl %ecx, %eax
jge 0x1da5a
movq -0x40(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x70(%rbp)
movl -0xc(%rbp), %edi
callq 0x3c5d0
movq -0x70(%rbp), %rdi
movslq %eax, %rsi
callq 0xaab0
movq %rax, %rdi
movslq -0x18(%rbp), %rsi
callq 0xa7c0
movq -0x40(%rbp), %rdi
movslq (%rax), %rsi
callq 0x3c600
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, -0x28(%rbp)
addq $0x18, %rax
movq %rax, -0x68(%rbp)
movl -0xc(%rbp), %edi
callq 0x3c5e0
movq -0x68(%rbp), %rdi
movslq %eax, %rsi
callq 0xaab0
movq %rax, %rdi
movslq -0x1c(%rbp), %rsi
callq 0xa7c0
movq -0x40(%rbp), %rdi
movslq (%rax), %rsi
callq 0x3c600
movq -0x40(%rbp), %rdi
movq %rax, -0x30(%rbp)
movl -0xc(%rbp), %esi
movq -0x30(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x1bbf0
movq -0x40(%rbp), %rdi
andb $0x1, %al
movb %al, -0x31(%rbp)
movl -0xc(%rbp), %esi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x1bbf0
andb $0x1, %al
movb %al, -0x32(%rbp)
testb $0x1, -0x31(%rbp)
je 0x1d93f
testb $0x1, -0x32(%rbp)
je 0x1d93f
movl -0xc(%rbp), %edi
callq 0x3c5d0
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, -0x7c(%rbp)
addq $0x18, %rax
movq %rax, -0x88(%rbp)
movl -0xc(%rbp), %edi
callq 0x3c5d0
movq -0x88(%rbp), %rdi
movslq %eax, %rsi
callq 0xaab0
movq %rax, %rdi
movslq -0x18(%rbp), %rsi
callq 0xa7c0
movl -0x7c(%rbp), %esi
movq -0x40(%rbp), %rdi
movl (%rax), %edx
movl $0x1, %ecx
callq 0x5fb90
movq -0x40(%rbp), %rdi
addq $0x218, %rdi            # imm = 0x218
movl $0x1, %esi
callq 0x61510
movq -0x40(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x78(%rbp)
movl -0xc(%rbp), %edi
callq 0x3c5e0
movq -0x78(%rbp), %rdi
movslq %eax, %rsi
callq 0xaab0
movq %rax, %rdi
movslq -0x1c(%rbp), %rsi
callq 0xa7c0
movq -0x40(%rbp), %rdi
movl (%rax), %esi
callq 0x5f7f0
movq -0x40(%rbp), %rdi
addq $0x218, %rdi            # imm = 0x218
movl $0x1, %esi
callq 0x61410
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movb $0x1, -0x11(%rbp)
jmp 0x1da5a
testb $0x1, -0x31(%rbp)
je 0x1d9c4
movl -0xc(%rbp), %edi
callq 0x3c5d0
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, -0x8c(%rbp)
addq $0x18, %rax
movq %rax, -0x98(%rbp)
movl -0xc(%rbp), %edi
callq 0x3c5d0
movq -0x98(%rbp), %rdi
movslq %eax, %rsi
callq 0xaab0
movq %rax, %rdi
movslq -0x18(%rbp), %rsi
callq 0xa7c0
movl -0x8c(%rbp), %esi
movq -0x40(%rbp), %rdi
movl (%rax), %edx
movl $0x1, %ecx
callq 0x5fb90
movq -0x40(%rbp), %rdi
addq $0x218, %rdi            # imm = 0x218
movl $0x1, %esi
callq 0x61510
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movb $0x1, -0x11(%rbp)
jmp 0x1da5a
testb $0x1, -0x32(%rbp)
je 0x1da46
movl -0xc(%rbp), %edi
callq 0x3c5e0
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, -0x9c(%rbp)
addq $0x18, %rax
movq %rax, -0xa8(%rbp)
movl -0xc(%rbp), %edi
callq 0x3c5e0
movq -0xa8(%rbp), %rdi
movslq %eax, %rsi
callq 0xaab0
movq %rax, %rdi
movslq -0x1c(%rbp), %rsi
callq 0xa7c0
movl -0x9c(%rbp), %esi
movq -0x40(%rbp), %rdi
movl (%rax), %edx
movl $0x1, %ecx
callq 0x5fb90
movq -0x40(%rbp), %rdi
addq $0x218, %rdi            # imm = 0x218
movl $0x1, %esi
callq 0x61510
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movb $0x1, -0x11(%rbp)
jmp 0x1da5a
jmp 0x1da48
jmp 0x1da4a
jmp 0x1da4c
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1d77d
testb $0x1, -0x11(%rbp)
je 0x1da62
jmp 0x1da72
jmp 0x1da64
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1d73a
jmp 0x1d725
movl -0x10(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)