// File: Laakeri[P]maxpre/src/./SSR.cpp
// Function: maxPreprocessor::Preprocessor::trySSRgen(int)
int Preprocessor::trySSRgen(int var) {
	int eliminated = 0;
	if (pi.isLabel[var] == 0 && pi.litClauses[posLit(var)].size() > 0 && pi.litClauses[negLit(var)].size() > 0) {
		uint64_t n = (uint64_t)pi.litClauses[posLit(var)].size()*(uint64_t)pi.litClauses[negLit(var)].size();
		if (n <= 50000) { // magic constant
			eliminated += trySSR2(var);
		}
		else {
			int avg = 0;
			for (int c : pi.litClauses[posLit(var)]) {
				avg += pi.clauses[c].lit.size();
			}
			for (int c : pi.litClauses[negLit(var)]) {
				avg += pi.clauses[c].lit.size();
			}
			avg /= (int)(pi.litClauses[posLit(var)].size() + pi.litClauses[negLit(var)].size());
			
			if (avg <= 4) { // magic constant
				eliminated += trySSRHash(var);
			}
			else if (avg >= 8) { // magic constant
				eliminated += trySSRAmsLex(var);
			}
			else {
				if (avg * (int)(pi.litClauses[posLit(var)].size() + pi.litClauses[negLit(var)].size()) > 10000) { // magic constant
					eliminated += trySSRAmsLex(var);
				}
				else {
					eliminated += trySSRHash(var);
				}
			}
		}
	}
	return eliminated;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x68(%rbp)
movl $0x0, -0x10(%rbp)
addq $0x48, %rdi
movslq -0xc(%rbp), %rsi
callq 0xa7c0
cmpl $0x0, (%rax)
jne 0x1de5b
movq -0x68(%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
callq 0xf940
cmpq $0x0, %rax
jbe 0x1de5b
movq -0x68(%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
callq 0xf940
cmpq $0x0, %rax
jbe 0x1de5b
movq -0x68(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x90(%rbp)
movl -0xc(%rbp), %edi
callq 0x3c5d0
movq -0x90(%rbp), %rdi
movslq %eax, %rsi
callq 0xaab0
movq %rax, %rdi
callq 0xf940
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, -0x80(%rbp)
addq $0x18, %rax
movq %rax, -0x88(%rbp)
movl -0xc(%rbp), %edi
callq 0x3c5e0
movq -0x88(%rbp), %rdi
movslq %eax, %rsi
callq 0xaab0
movq %rax, %rdi
callq 0xf940
movq %rax, %rcx
movq -0x80(%rbp), %rax
imulq %rcx, %rax
movq %rax, -0x18(%rbp)
cmpq $0xc350, -0x18(%rbp)    # imm = 0xC350
ja 0x1dbbe
movq -0x68(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x1d4b0
addl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
jmp 0x1de59
movq -0x68(%rbp), %rax
movl $0x0, -0x1c(%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, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0xa800
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0xa830
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0xa860
testb $0x1, %al
jne 0x1dc1c
jmp 0x1dc57
leaq -0x30(%rbp), %rdi
callq 0xa8a0
movq -0x68(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movslq -0x3c(%rbp), %rsi
callq 0x3c600
movq %rax, %rdi
callq 0xf940
movq %rax, %rcx
movslq -0x1c(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x1c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xa930
jmp 0x1dc09
movq -0x68(%rbp), %rax
addq $0x18, %rax
movq %rax, -0xa0(%rbp)
movl -0xc(%rbp), %edi
callq 0x3c5e0
movq -0xa0(%rbp), %rdi
movslq %eax, %rsi
callq 0xaab0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0xa800
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
callq 0xa830
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0xa860
testb $0x1, %al
jne 0x1dcae
jmp 0x1dce9
leaq -0x50(%rbp), %rdi
callq 0xa8a0
movq -0x68(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x5c(%rbp)
movslq -0x5c(%rbp), %rsi
callq 0x3c600
movq %rax, %rdi
callq 0xf940
movq %rax, %rcx
movslq -0x1c(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x1c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xa930
jmp 0x1dc9b
movq -0x68(%rbp), %rax
addq $0x18, %rax
movq %rax, -0xb8(%rbp)
movl -0xc(%rbp), %edi
callq 0x3c5d0
movq -0xb8(%rbp), %rdi
movslq %eax, %rsi
callq 0xaab0
movq %rax, %rdi
callq 0xf940
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, -0xa8(%rbp)
addq $0x18, %rax
movq %rax, -0xb0(%rbp)
movl -0xc(%rbp), %edi
callq 0x3c5e0
movq -0xb0(%rbp), %rdi
movslq %eax, %rsi
callq 0xaab0
movq %rax, %rdi
callq 0xf940
movq %rax, %rcx
movq -0xa8(%rbp), %rax
addq %rcx, %rax
movl %eax, %ecx
movl -0x1c(%rbp), %eax
cltd
idivl %ecx
movl %eax, -0x1c(%rbp)
cmpl $0x4, -0x1c(%rbp)
jg 0x1dd84
movq -0x68(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x1c640
addl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
jmp 0x1de57
cmpl $0x8, -0x1c(%rbp)
jl 0x1dda1
movq -0x68(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x1bfe0
addl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
jmp 0x1de55
movq -0x68(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, -0xbc(%rbp)
addq $0x18, %rax
movq %rax, -0xd8(%rbp)
movl -0xc(%rbp), %edi
callq 0x3c5d0
movq -0xd8(%rbp), %rdi
movslq %eax, %rsi
callq 0xaab0
movq %rax, %rdi
callq 0xf940
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, -0xc8(%rbp)
addq $0x18, %rax
movq %rax, -0xd0(%rbp)
movl -0xc(%rbp), %edi
callq 0x3c5e0
movq -0xd0(%rbp), %rdi
movslq %eax, %rsi
callq 0xaab0
movq %rax, %rdi
callq 0xf940
movq -0xc8(%rbp), %rcx
movq %rax, %rdx
movl -0xbc(%rbp), %eax
addq %rdx, %rcx
imull %ecx, %eax
cmpl $0x2710, %eax           # imm = 0x2710
jle 0x1de41
movq -0x68(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x1bfe0
addl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
jmp 0x1de53
movq -0x68(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x1c640
addl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
jmp 0x1de55
jmp 0x1de57
jmp 0x1de59
jmp 0x1de5b
movl -0x10(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nopw (%rax,%rax)