// File: /workspace/github_cpp_makefile_star2_O3/Laakeri[P]maxpre/src/./SSR.cpp
// Function: maxPreprocessor::Preprocessor::trySSRHash(int)
int Preprocessor::trySSRHash(int var) {
	uint64_t bmP = ((uint64_t)1 << (uint64_t)(posLit(var)&63));
	uint64_t bmN = ((uint64_t)1 << (uint64_t)(negLit(var)&63));
	
	vector<int>& pc = pi.litClauses[posLit(var)];
	vector<int>& nc = pi.litClauses[negLit(var)];
	uint64_t k = 1;
	while ((1<<k) < max((int)pc.size(), (int)nc.size())) k++;
	
	vector<vector<pair<int, uint64_t> > > hp(1<<k);
	vector<vector<pair<int, uint64_t> > > hn(1<<k);
	
	for (int c : pc) {
		// do UP to avoid special case
		if (pi.clauses[c].lit.size() == 1){
			return setVariable(var, true);
		}
		uint64_t h = 0;
		for (int l : pi.clauses[c].lit) {
			if (litVariable(l) != var) h |= ((uint64_t)1 << (uint64_t)(l%k));
		}
		hp[h].push_back({c, pi.clauses[c].hash});
	}
	
	for (int c : nc) {
		// do UP to avoid special case
		if (pi.clauses[c].lit.size() == 1){
			return setVariable(var, false);
		}
		uint64_t h = 0;
		for (int l : pi.clauses[c].lit) {
			if (litVariable(l) != var) h |= ((uint64_t)1 << (uint64_t)(l%k));
		}
		hn[h].push_back({c, pi.clauses[c].hash});
	}
	
	int removed = 0;
	bool f  = true;
	while (f) {
		f = false;
		for (int c1 : pi.litClauses[posLit(var)]) {
			int64_t h = 0;
			for (int l : pi.clauses[c1].lit) {
				if (litVariable(l) != var) h |= ((int64_t)1 << (int64_t)(l%k));
			}
			for (int64_t sub = 0; (sub = (sub - h) & h);) {
				for (auto c2 : hn[sub]) {
					if ((((pi.clauses[c1].hash ^ bmP) | c2.S) != c2.S) && (((c2.S ^ bmN) | pi.clauses[c1].hash) != pi.clauses[c1].hash)) continue;
					if ((c2.S & bmN) == 0) continue;
					if (pi.isClauseRemoved(c2.F)) continue;
					if (!binary_search(pi.clauses[c2.F].lit.begin(), pi.clauses[c2.F].lit.end(), negLit(var))) continue;
					if (SSRC(c1, c2.F, var)) {
						f = true;
						removed++;
						break;
					}
				}
				if (f) break;
			}
			if (f) break;
		}
	}
	f = true;
	while (f) {
		f = false;
		for (int c2 : pi.litClauses[negLit(var)]) {
			int64_t h = 0;
			for (int l : pi.clauses[c2].lit) {
				if (litVariable(l) != var) h |= ((int64_t)1 << (int64_t)(l%k));
			}
			for (int64_t sub = 0; (sub = (sub - h) & h);) {
				for (auto c1 : hp[sub]) {
					if ((((c1.S ^ bmP) | pi.clauses[c2].hash) != pi.clauses[c2].hash) && (((pi.clauses[c2].hash ^ bmN) | c1.S) != c1.S)) continue;
					if ((c1.S & bmP) == 0) continue;
					if (pi.isClauseRemoved(c1.F)) continue;
					if (!binary_search(pi.clauses[c1.F].lit.begin(), pi.clauses[c1.F].lit.end(), posLit(var))) continue;
					if (SSRC(c1.F, c2, var)) {
						f = true;
						removed++;
						break;
					}
				}
				if (f) break;
			}
			if (f) break;
		}
	}
	return removed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %r14
leal (%rsi,%rsi), %r12d
movl %r12d, %eax
andl $0x3e, %eax
movq %rsi, (%rsp)
leal 0x1(,%rsi,2), %edi
movl %edi, %edx
andl $0x3f, %edx
movslq %r12d, %rcx
movq 0x18(%r14), %rsi
leaq (%rcx,%rcx,2), %rcx
movq %rcx, 0x68(%rsp)
leaq (%rsi,%rcx,8), %r13
movl %edi, 0x50(%rsp)
movslq %edi, %rcx
leaq (%rcx,%rcx,2), %rcx
movq %rcx, 0x60(%rsp)
leaq (%rsi,%rcx,8), %rbx
movq 0x8(%r13), %rcx
subq (%r13), %rcx
shrq $0x2, %rcx
movq 0x8(%rbx), %rsi
subq (%rbx), %rsi
shrq $0x2, %rsi
cmpl %esi, %ecx
cmovgl %ecx, %esi
xorl %ecx, %ecx
incq %rcx
movl $0x1, %edi
shll %cl, %edi
cmpl %esi, %edi
jl 0x1054a
movq %rcx, 0x18(%rsp)
movl $0x1, %esi
movl $0x1, %r8d
movl %eax, %ecx
shlq %cl, %r8
movq %r8, 0x58(%rsp)
movl %edx, %ecx
shlq %cl, %rsi
movq %rsi, 0x20(%rsp)
movslq %edi, %rbp
leaq 0x90(%rsp), %rdi
leaq 0x78(%rsp), %rdx
movq %rbp, %rsi
callq 0x1e9ee
leaq 0x78(%rsp), %rdi
leaq 0x28(%rsp), %rdx
movq %rbp, %rsi
callq 0x1e9ee
movq (%r13), %r15
movq 0x8(%r13), %r13
cmpq %r13, %r15
je 0x10653
leaq 0x28(%rsp), %rbp
movslq (%r15), %rcx
movq (%r14), %rsi
leaq (%rcx,%rcx,4), %rdi
movq (%rsi,%rdi,8), %r8
movq 0x8(%rsi,%rdi,8), %r9
movq %r9, %rax
subq %r8, %rax
cmpq $0x4, %rax
je 0x108d6
xorl %r10d, %r10d
cmpq %r9, %r8
je 0x10604
movslq (%r8), %rax
movl %eax, %edx
sarl %edx
cmpl (%rsp), %edx
je 0x105fe
xorl %edx, %edx
divq 0x18(%rsp)
btsq %rdx, %r10
addq $0x4, %r8
jmp 0x105e2
leaq (%rsi,%rdi,8), %rax
movq 0x90(%rsp), %rdx
leaq (%r10,%r10,2), %rsi
leaq (%rdx,%rsi,8), %rdi
movl %ecx, 0x28(%rsp)
movq 0x20(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x1063e
movups 0x28(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x8(%rdi)
jmp 0x10646
movq %rbp, %rdx
callq 0x2082e
addq $0x4, %r15
cmpq %r13, %r15
jne 0x105bc
movq (%rbx), %r15
movq 0x8(%rbx), %rbx
cmpq %rbx, %r15
movq (%rsp), %r13
je 0x10700
leaq 0x28(%rsp), %rbp
movslq (%r15), %rcx
movq (%r14), %rsi
leaq (%rcx,%rcx,4), %rdi
movq (%rsi,%rdi,8), %r8
movq 0x8(%rsi,%rdi,8), %r9
movq %r9, %rax
subq %r8, %rax
cmpq $0x4, %rax
je 0x108f1
xorl %r10d, %r10d
cmpq %r9, %r8
je 0x106b4
movslq (%r8), %rax
movl %eax, %edx
sarl %edx
cmpl %r13d, %edx
je 0x106ae
xorl %edx, %edx
divq 0x18(%rsp)
btsq %rdx, %r10
addq $0x4, %r8
jmp 0x10692
leaq (%rsi,%rdi,8), %rax
movq 0x78(%rsp), %rdx
leaq (%r10,%r10,2), %rsi
leaq (%rdx,%rsi,8), %rdi
movl %ecx, 0x28(%rsp)
movq 0x20(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x106eb
movups 0x28(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x8(%rdi)
jmp 0x106f3
movq %rbp, %rdx
callq 0x2082e
addq $0x4, %r15
cmpq %rbx, %r15
jne 0x1066c
movq 0x18(%r14), %rax
movq 0x68(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
movq 0x8(%rax,%rcx,8), %rax
movq %rax, 0x70(%rsp)
cmpq %rax, %rdx
je 0x10908
movq $0x0, 0x8(%rsp)
movslq (%rdx), %rcx
movq (%r14), %rax
movq %rcx, 0x40(%rsp)
leaq (%rcx,%rcx,4), %rbx
movq (%rax,%rbx,8), %rcx
movq 0x8(%rax,%rbx,8), %rsi
cmpq %rsi, %rcx
movq %rdx, 0x10(%rsp)
je 0x1076f
xorl %edi, %edi
movslq (%rcx), %rax
movl %eax, %edx
sarl %edx
cmpl %r13d, %edx
je 0x10764
xorl %edx, %edx
divq 0x18(%rsp)
btsq %rdx, %rdi
addq $0x4, %rcx
cmpq %rsi, %rcx
jne 0x1074d
jmp 0x10771
xorl %edi, %edi
movq %rdi, %rcx
negq %rcx
andq %rdi, %rcx
movq %rdi, 0x38(%rsp)
je 0x10894
movq 0x78(%rsp), %rax
movq %rcx, 0x48(%rsp)
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %r15
movq 0x8(%rax,%rcx,8), %r13
cmpq %r13, %r15
je 0x1087e
movslq (%r15), %rbp
movq 0x8(%r15), %rax
movq (%r14), %rcx
movq 0x20(%rcx,%rbx,8), %rcx
movq %rcx, %rdx
xorq 0x58(%rsp), %rdx
movq %rax, %rsi
notq %rsi
testq %rdx, %rsi
jne 0x107d3
testq %rax, 0x20(%rsp)
jne 0x107f2
jmp 0x10875
movq %rax, %rdx
xorq 0x20(%rsp), %rdx
notq %rcx
testq %rdx, %rcx
jne 0x10875
andq 0x20(%rsp), %rax
je 0x10875
movq %r14, %rdi
movl %ebp, %esi
callq 0x27804
testb %al, %al
jne 0x10875
movq (%r14), %rcx
leaq (,%rbp,4), %rdx
addq %rbp, %rdx
movq (%rcx,%rdx,8), %rax
movq 0x8(%rcx,%rdx,8), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x2, %rdx
testq %rdx, %rdx
jle 0x10851
movq %rdx, %rsi
shrq %rsi
movq %rsi, %rdi
notq %rdi
addq %rdx, %rdi
leaq (%rax,%rsi,4), %rdx
addq $0x4, %rdx
cmpl %r12d, -0x4(%rdx)
cmovleq %rdx, %rax
cmovgq %rsi, %rdi
movq %rdi, %rdx
testq %rdi, %rdi
jg 0x10826
cmpq %rcx, %rax
je 0x10875
movl 0x50(%rsp), %ecx
cmpl (%rax), %ecx
jl 0x10875
movq %r14, %rdi
movq 0x40(%rsp), %rsi
movl %ebp, %edx
movq (%rsp), %rcx
callq 0xfff2
testb %al, %al
jne 0x108a4
addq $0x10, %r15
jmp 0x1079c
movq 0x38(%rsp), %rdi
movq 0x48(%rsp), %rcx
subq %rdi, %rcx
andq %rdi, %rcx
jne 0x10785
movq 0x10(%rsp), %rdx
addq $0x4, %rdx
cmpq 0x70(%rsp), %rdx
jmp 0x108ca
movq 0x8(%rsp), %rax
incl %eax
movq %rax, 0x8(%rsp)
movq 0x18(%r14), %rax
movq 0x68(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
movq 0x8(%rax,%rcx,8), %rax
movq %rax, 0x70(%rsp)
cmpq %rax, %rdx
movq (%rsp), %r13
jne 0x10729
jmp 0x10911
movq %r14, %rdi
movq (%rsp), %rsi
movl $0x1, %edx
callq 0xa026
movq %rax, 0x8(%rsp)
jmp 0x10add
movq %r14, %rdi
movl %r13d, %esi
xorl %edx, %edx
callq 0xa026
movq %rax, 0x8(%rsp)
jmp 0x10add
movq $0x0, 0x8(%rsp)
movq 0x18(%r14), %rax
movq 0x60(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
movq 0x8(%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
cmpq %rax, %rdx
je 0x10add
movslq (%rdx), %rcx
movq (%r14), %rax
movq %rcx, 0x48(%rsp)
leaq (%rcx,%rcx,4), %rbx
movq (%rax,%rbx,8), %rcx
movq 0x8(%rax,%rbx,8), %rsi
cmpq %rsi, %rcx
movq %rdx, 0x38(%rsp)
je 0x10977
xorl %edi, %edi
movslq (%rcx), %rax
movl %eax, %edx
sarl %edx
cmpl %r13d, %edx
je 0x1096c
xorl %edx, %edx
divq 0x18(%rsp)
btsq %rdx, %rdi
addq $0x4, %rcx
cmpq %rsi, %rcx
jne 0x10955
jmp 0x10979
xorl %edi, %edi
movq %rdi, %rcx
negq %rcx
andq %rdi, %rcx
movq %rdi, 0x40(%rsp)
je 0x10a9d
movq 0x90(%rsp), %rax
movq %rcx, 0x50(%rsp)
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %r15
movq 0x8(%rax,%rcx,8), %r13
cmpq %r13, %r15
je 0x10a87
movslq (%r15), %rbp
movq 0x8(%r15), %rax
movq %rax, %rdx
movq 0x58(%rsp), %rdi
xorq %rdi, %rdx
movq (%r14), %rcx
movq 0x20(%rcx,%rbx,8), %rcx
movq %rcx, %rsi
notq %rsi
testq %rdx, %rsi
jne 0x109df
testq %rdi, %rax
jne 0x109fe
jmp 0x10a7e
xorq 0x20(%rsp), %rcx
movq %rax, %rdx
notq %rdx
testq %rcx, %rdx
jne 0x10a7e
andq 0x58(%rsp), %rax
je 0x10a7e
movq %r14, %rdi
movl %ebp, %esi
callq 0x27804
testb %al, %al
jne 0x10a7e
movq (%r14), %rcx
leaq (,%rbp,4), %rdx
addq %rbp, %rdx
movq (%rcx,%rdx,8), %rax
movq 0x8(%rcx,%rdx,8), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x2, %rdx
testq %rdx, %rdx
jle 0x10a5d
movq %rdx, %rsi
shrq %rsi
movq %rsi, %rdi
notq %rdi
addq %rdx, %rdi
leaq (%rax,%rsi,4), %rdx
addq $0x4, %rdx
cmpl %r12d, -0x4(%rdx)
cmovlq %rdx, %rax
cmovgeq %rsi, %rdi
movq %rdi, %rdx
testq %rdi, %rdi
jg 0x10a32
cmpq %rcx, %rax
je 0x10a7e
cmpl (%rax), %r12d
jl 0x10a7e
movq %r14, %rdi
movl %ebp, %esi
movq 0x48(%rsp), %rdx
movq (%rsp), %rcx
callq 0xfff2
testb %al, %al
jne 0x10aad
addq $0x10, %r15
jmp 0x109a7
movq 0x40(%rsp), %rdi
movq 0x50(%rsp), %rcx
subq %rdi, %rcx
andq %rdi, %rcx
jne 0x1098d
movq 0x38(%rsp), %rdx
addq $0x4, %rdx
cmpq 0x10(%rsp), %rdx
jmp 0x10ad3
movq 0x8(%rsp), %rax
incl %eax
movq %rax, 0x8(%rsp)
movq 0x18(%r14), %rax
movq 0x60(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
movq 0x8(%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
cmpq %rax, %rdx
movq (%rsp), %r13
jne 0x10931
leaq 0x78(%rsp), %rdi
callq 0x1ea6c
leaq 0x90(%rsp), %rdi
callq 0x1ea6c
movq 0x8(%rsp), %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x10b1a
jmp 0x10b1a
movq %rax, %rbx
jmp 0x10b27
jmp 0x10b1a
jmp 0x10b1a
jmp 0x10b1a
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x1ea6c
leaq 0x90(%rsp), %rdi
callq 0x1ea6c
movq %rbx, %rdi
callq 0x34a0