// File: /workspace/github_cpp_makefile_star2_O2/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 $0xb8, %rsp
movq %rdi, %r14
leal (%rsi,%rsi), %ecx
movl %ecx, %eax
andl $0x3e, %eax
movq %rsi, 0x8(%rsp)
leal 0x1(,%rsi,2), %esi
movl %esi, %edx
andl $0x3f, %edx
movl %ecx, 0x6c(%rsp)
movslq %ecx, %rcx
movq 0x18(%rdi), %rdi
imulq $0x18, %rcx, %r9
leaq (%rdi,%r9), %r15
movl %esi, 0x60(%rsp)
movslq %esi, %rcx
imulq $0x18, %rcx, %r8
leaq (%rdi,%r8), %rbp
movq 0x8(%rdi,%r9), %rcx
movq %r9, 0x78(%rsp)
subq (%rdi,%r9), %rcx
shrq $0x2, %rcx
movq 0x8(%rdi,%r8), %rsi
movq %r8, 0x70(%rsp)
subq (%rdi,%r8), %rsi
shrq $0x2, %rsi
cmpl %esi, %ecx
cmovgl %ecx, %esi
xorl %ecx, %ecx
pushq $0x1
popq %r8
incq %rcx
movl %r8d, %edi
shll %cl, %edi
cmpl %esi, %edi
jl 0xd0ba
movq %rcx, 0x28(%rsp)
pushq $0x1
popq %rsi
movq %rsi, %r13
movl %eax, %ecx
shlq %cl, %r13
movl %edx, %ecx
shlq %cl, %rsi
movq %rsi, 0x30(%rsp)
movslq %edi, %r12
leaq 0xa0(%rsp), %rdi
leaq 0x88(%rsp), %rdx
movq %r12, %rsi
callq 0x18b56
leaq 0x88(%rsp), %rdi
leaq 0x18(%rsp), %rdx
movq %r12, %rsi
callq 0x18b56
movq (%r15), %rbx
movq 0x8(%r15), %r15
leaq 0x18(%rsp), %r12
cmpq %r15, %rbx
je 0xd194
movslq (%rbx), %rsi
movq (%r14), %rcx
imulq $0x28, %rsi, %rax
movq (%rcx,%rax), %rdi
movq 0x8(%rcx,%rax), %r8
movq %r8, %rdx
subq %rdi, %rdx
cmpq $0x4, %rdx
je 0xd21d
addq %rax, %rcx
xorl %r9d, %r9d
cmpq %r8, %rdi
je 0xd16d
movslq (%rdi), %rax
movl %eax, %edx
sarl %edx
cmpl 0x8(%rsp), %edx
je 0xd167
xorl %edx, %edx
divq 0x28(%rsp)
btsq %rdx, %r9
addq $0x4, %rdi
jmp 0xd14a
imulq $0x18, %r9, %rdi
addq 0xa0(%rsp), %rdi
movl %esi, 0x18(%rsp)
movq 0x20(%rcx), %rax
movq %rax, 0x20(%rsp)
movq %r12, %rsi
callq 0x1aa0a
addq $0x4, %rbx
jmp 0xd11c
movq (%rbp), %rbx
movq 0x8(%rbp), %r15
leaq 0x18(%rsp), %r12
cmpq %r15, %rbx
je 0xd232
movslq (%rbx), %rsi
movq (%r14), %rcx
imulq $0x28, %rsi, %rax
movq (%rcx,%rax), %rdi
movq 0x8(%rcx,%rax), %r8
movq %r8, %rdx
subq %rdi, %rdx
cmpq $0x4, %rdx
je 0xd52a
addq %rax, %rcx
xorl %r9d, %r9d
cmpq %r8, %rdi
je 0xd1f6
movslq (%rdi), %rax
movl %eax, %edx
sarl %edx
cmpl 0x8(%rsp), %edx
je 0xd1f0
xorl %edx, %edx
divq 0x28(%rsp)
btsq %rdx, %r9
addq $0x4, %rdi
jmp 0xd1d3
imulq $0x18, %r9, %rdi
addq 0x88(%rsp), %rdi
movl %esi, 0x18(%rsp)
movq 0x20(%rcx), %rax
movq %rax, 0x20(%rsp)
movq %r12, %rsi
callq 0x1aa0a
addq $0x4, %rbx
jmp 0xd1a1
pushq $0x1
popq %rdx
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0x7c98
jmp 0xd539
movq $0x0, 0x10(%rsp)
movb $0x1, %al
testb $0x1, %al
je 0xd3b4
movq 0x18(%r14), %rax
movq 0x78(%rsp), %rcx
movq (%rax,%rcx), %rdx
movq 0x8(%rax,%rcx), %rcx
movq %rcx, 0x80(%rsp)
cmpq %rcx, %rdx
setne %al
je 0xd23d
movb %al, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
movslq (%rdx), %rcx
movq (%r14), %rax
movq %rcx, 0x58(%rsp)
imulq $0x28, %rcx, %rbp
movq (%rax,%rbp), %rcx
movq 0x8(%rax,%rbp), %rsi
xorl %edi, %edi
cmpq %rsi, %rcx
je 0xd2ad
movslq (%rcx), %rax
movl %eax, %edx
sarl %edx
cmpl 0x8(%rsp), %edx
je 0xd2a7
xorl %edx, %edx
divq 0x28(%rsp)
btsq %rdx, %rdi
addq $0x4, %rcx
jmp 0xd28a
xorl %ecx, %ecx
movq %rdi, 0x48(%rsp)
subq %rdi, %rcx
andq %rdi, %rcx
je 0xd389
movq 0x88(%rsp), %rax
movq %rcx, 0x50(%rsp)
imulq $0x18, %rcx, %rcx
movq (%rax,%rcx), %r15
movq 0x8(%rax,%rcx), %rbx
cmpq %rbx, %r15
je 0xd37a
movslq (%r15), %r12
movq 0x8(%r15), %rax
movq (%r14), %rcx
movq 0x20(%rcx,%rbp), %rcx
movq %rcx, %rdx
xorq %r13, %rdx
movq %rax, %rsi
notq %rsi
testq %rdx, %rsi
jne 0xd30c
testq %rax, 0x30(%rsp)
jne 0xd323
jmp 0xd371
movq %rax, %rdx
xorq 0x30(%rsp), %rdx
notq %rcx
testq %rdx, %rcx
jne 0xd371
andq 0x30(%rsp), %rax
je 0xd371
movq %r14, %rdi
movl %r12d, %esi
callq 0x20f14
testb %al, %al
jne 0xd371
movq (%r14), %rax
imulq $0x28, %r12, %rcx
movq (%rax,%rcx), %rdi
movq 0x8(%rax,%rcx), %rsi
movl 0x60(%rsp), %eax
movl %eax, 0x18(%rsp)
leaq 0x18(%rsp), %rdx
callq 0x18f6e
testb %al, %al
je 0xd371
movq %r14, %rdi
movq 0x58(%rsp), %rsi
movl %r12d, %edx
movq 0x8(%rsp), %rcx
callq 0xcc58
testb %al, %al
jne 0xd39f
addq $0x10, %r15
jmp 0xd2da
movq 0x48(%rsp), %rdi
movq 0x50(%rsp), %rcx
jmp 0xd2b4
movq 0x38(%rsp), %rdx
addq $0x4, %rdx
movq 0x80(%rsp), %rcx
jmp 0xd25f
movq 0x10(%rsp), %rax
incl %eax
movq %rax, 0x10(%rsp)
movb 0x40(%rsp), %al
jmp 0xd23d
movb $0x1, %al
testb $0x1, %al
je 0xd523
movq 0x18(%r14), %rax
movq 0x70(%rsp), %rcx
movq (%rax,%rcx), %rdx
movq 0x8(%rax,%rcx), %rcx
movq %rcx, 0x38(%rsp)
cmpq %rcx, %rdx
setne %al
je 0xd3b6
movb %al, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movslq (%rdx), %rcx
movq (%r14), %rax
movq %rcx, 0x60(%rsp)
imulq $0x28, %rcx, %rbp
movq (%rax,%rbp), %rcx
movq 0x8(%rax,%rbp), %rsi
xorl %edi, %edi
cmpq %rsi, %rcx
je 0xd423
movslq (%rcx), %rax
movl %eax, %edx
sarl %edx
cmpl 0x8(%rsp), %edx
je 0xd41d
xorl %edx, %edx
divq 0x28(%rsp)
btsq %rdx, %rdi
addq $0x4, %rcx
jmp 0xd400
xorl %ecx, %ecx
movq %rdi, 0x50(%rsp)
subq %rdi, %rcx
andq %rdi, %rcx
je 0xd4fb
movq 0xa0(%rsp), %rax
movq %rcx, 0x58(%rsp)
imulq $0x18, %rcx, %rcx
movq (%rax,%rcx), %r15
movq 0x8(%rax,%rcx), %rbx
cmpq %rbx, %r15
je 0xd4ec
movslq (%r15), %r12
movq 0x8(%r15), %rax
movq %rax, %rdx
xorq %r13, %rdx
movq (%r14), %rcx
movq 0x20(%rcx,%rbp), %rcx
movq %rcx, %rsi
notq %rsi
testq %rdx, %rsi
jne 0xd480
testq %r13, %rax
jne 0xd495
jmp 0xd4e3
xorq 0x30(%rsp), %rcx
movq %rax, %rdx
notq %rdx
testq %rcx, %rdx
jne 0xd4e3
andq %r13, %rax
je 0xd4e3
movq %r14, %rdi
movl %r12d, %esi
callq 0x20f14
testb %al, %al
jne 0xd4e3
movq (%r14), %rax
imulq $0x28, %r12, %rcx
movq (%rax,%rcx), %rdi
movq 0x8(%rax,%rcx), %rsi
movl 0x6c(%rsp), %eax
movl %eax, 0x18(%rsp)
leaq 0x18(%rsp), %rdx
callq 0x18f6e
testb %al, %al
je 0xd4e3
movq %r14, %rdi
movl %r12d, %esi
movq 0x60(%rsp), %rdx
movq 0x8(%rsp), %rcx
callq 0xcc58
testb %al, %al
jne 0xd50e
addq $0x10, %r15
jmp 0xd450
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rcx
jmp 0xd42a
movq 0x40(%rsp), %rdx
addq $0x4, %rdx
movq 0x38(%rsp), %rcx
jmp 0xd3d5
movq 0x10(%rsp), %rax
incl %eax
movq %rax, 0x10(%rsp)
movb 0x48(%rsp), %al
jmp 0xd3b6
movq 0x10(%rsp), %rbx
jmp 0xd53b
movq %r14, %rdi
movq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x7c98
movl %eax, %ebx
leaq 0x88(%rsp), %rdi
callq 0x18ba8
leaq 0xa0(%rsp), %rdi
callq 0x18ba8
movl %ebx, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xd57c
jmp 0xd57c
movq %rax, %rbx
jmp 0xd58c
jmp 0xd57c
jmp 0xd57c
jmp 0xd57c
jmp 0xd57c
jmp 0xd57c
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x18ba8
leaq 0xa0(%rsp), %rdi
callq 0x18ba8
movq %rbx, %rdi
callq 0x3490
nop