// File: /workspace/github_cpp_makefile_star2_O1/Laakeri[P]maxpre/src/./GSLE.cpp
// Function: maxPreprocessor::Preprocessor::tryGSLE(int)
int Preprocessor::tryGSLE(int lb) {
	uint64_t lw = pi.labelWeight(litVariable(lb));
	for (int c : pi.litClauses[lb]) {
		bool f = false;
		for (int l : pi.clauses[c].lit) {
			if (l != lb && pi.isLabel[litVariable(l)] && pi.labelWeight(litVariable(l)) <= lw) {
				f = true;
				break;
			}
		}
		if (!f) {
			return 0;
		}
	}
	vector<vector<int> > hs;
	set<int> sel;
	uint64_t selW = 0;
	for (int c : pi.litClauses[lb]) {
		vector<int> s;
		for (int l : pi.clauses[c].lit) {
			if (l != lb && pi.isLabel[litVariable(l)] && pi.labelWeight(litVariable(l)) <= lw) {
				s.push_back(litVariable(l));
			}
		}
		hs.push_back(s);
	}
	for (auto& s : hs) {
		if (s.size() == 1) {
			if (sel.count(s[0]) == 0) {
				sel.insert(s[0]);
				selW += pi.labelWeight(s[0]);
			}
		}
	}
	if (selW > lw) return 0;
	vector<vector<int> > hss;
	uint64_t hsl = 0;
	for (auto& s : hs) {
		if (s.size() > 1) {
			bool f = false;
			for (int l : s) {
				if (sel.count(l) > 0) {
					f = true;
					break;
				}
			}
			if (!f) {
				hss.push_back(s);
				hsl += (uint64_t)(int)s.size();
			}
		}
	}
	auto cmp = [](const vector<int>& a, const vector<int>& b) {
		return a.size() < b.size();
	};
	sort(hss.begin(), hss.end(), cmp);
	// Do coordinate compression
	vector<int> cc;
	for (auto& se : hss) {
		for (int l : se) {
			cc.push_back(l);
		}
	}
	sort(cc.begin(), cc.end());
	cc.erase(unique(cc.begin(), cc.end()), cc.end());
	vector<uint64_t> laWeights(cc.size());
	for (int i = 0; i < (int)cc.size(); i++) {
		laWeights[i] = pi.labelWeight(cc[i]);
	}
	for (auto& se : hss) {
		for (int& l : se) {
			l = lower_bound(cc.begin(), cc.end(), l) - cc.begin();
		}
	}
	vector<int> cnt(cc.size());
	for (int i = (int)hss.size() - 1; i >= 0; i--) {
		for (int l : hss[i]) {
			cnt[l]++;
		}
		auto cmp2 = [&](int a, int b) {// the log-approximation heuristic
			return (double)laWeights[a]/(double)cnt[a] < (double)laWeights[b]/(double)cnt[b];
		};
		sort(hss[i].begin(), hss[i].end(), cmp2);
	}
	bool ok = false;
	hsl = min(hsl, (uint64_t)hss.size()*10); // magic constant
	if (GSLEtryBackTrack(hss, laWeights, lw - selW, hsl)) {
		ok = true;
	}
	if (ok) {
		int rmClauses = 0;
		if (pi.isLabel[litVariable(lb)] == VAR_TRUE) {
			rmClauses = setVariable(litVariable(lb), true);
		}
		else {
			rmClauses = setVariable(litVariable(lb), false);
		}
		assert(pi.isVarRemoved(litVariable(lb)));
		rLog.removeClause(rmClauses);
		rLog.removeLabel(1);
		return 1;
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movl %esi, %r15d
movq %rdi, %rbx
sarl %esi
movl %esi, 0x64(%rsp)
callq 0x285da
movq %rax, 0x68(%rsp)
movslq %r15d, %rax
movq %rbx, 0x8(%rsp)
movq 0x18(%rbx), %rcx
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %r14
movq %rax, 0x58(%rsp)
movq 0x8(%rcx,%rax,8), %r13
cmpq %r13, %r14
je 0x182e5
movslq (%r14), %rax
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rax,%rax,4), %rax
movq (%rcx,%rax,8), %rbp
movq 0x8(%rcx,%rax,8), %rbx
cmpq %rbx, %rbp
je 0x18562
addq $0x4, %rbp
xorl %r12d, %r12d
movl -0x4(%rbp), %esi
cmpl %r15d, %esi
je 0x182bb
sarl %esi
movslq %esi, %rax
movq 0x8(%rsp), %rcx
movq 0x48(%rcx), %rcx
cmpl $0x0, (%rcx,%rax,4)
je 0x182bb
movq 0x8(%rsp), %rdi
callq 0x285da
movb $0x1, %cl
movb $0x1, %dl
cmpq 0x68(%rsp), %rax
jbe 0x182c0
xorl %edx, %edx
movl %r12d, %ecx
testb %dl, %dl
jne 0x182d3
leaq 0x4(%rbp), %rax
movl %ecx, %r12d
cmpq %rbx, %rbp
movq %rax, %rbp
jne 0x1828a
testb $0x1, %cl
je 0x18562
addq $0x4, %r14
jmp 0x18259
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
xorl %eax, %eax
movq %rax, 0xa0(%rsp)
leaq 0xd0(%rsp), %r14
movl $0x0, (%r14)
movq %rax, 0x8(%r14)
movq %r14, 0x10(%r14)
movq %r14, 0x18(%r14)
movq %rax, 0x20(%r14)
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x58(%rsp), %rcx
movq (%rax,%rcx,8), %rbp
movq 0x8(%rax,%rcx,8), %rax
movq %rax, 0x58(%rsp)
cmpq %rax, %rbp
je 0x1840b
movslq (%rbp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rax,%rax,4), %rax
movq (%rcx,%rax,8), %r13
movq 0x8(%rcx,%rax,8), %rbx
cmpq %rbx, %r13
je 0x183d3
movl (%r13), %r12d
cmpl %r15d, %r12d
je 0x183cd
sarl %r12d
movslq %r12d, %rax
movq 0x8(%rsp), %rcx
movq 0x48(%rcx), %rcx
cmpl $0x0, (%rcx,%rax,4)
je 0x183cd
movq 0x8(%rsp), %rdi
movl %r12d, %esi
callq 0x285da
cmpq 0x68(%rsp), %rax
ja 0x183cd
movl %r12d, 0x30(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x183be
movl %r12d, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x183cd
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x20b8a
addq $0x4, %r13
jmp 0x18368
leaq 0x90(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1fc42
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x183fc
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
addq $0x4, %rbp
cmpq 0x58(%rsp), %rbp
jne 0x1833e
movq 0x90(%rsp), %r13
movq 0x98(%rsp), %rbp
xorl %ebx, %ebx
xorl %r15d, %r15d
cmpq %rbp, %r13
je 0x18473
leaq 0xc8(%rsp), %r12
movq (%r13), %rsi
movq 0x8(%r13), %rax
subq %rsi, %rax
cmpq $0x4, %rax
jne 0x1846a
movq %r12, %rdi
callq 0x1f80e
testq %rax, %rax
jne 0x1846a
movq (%r13), %rsi
movq %r12, %rdi
callq 0x22d60
movq (%r13), %rax
movl (%rax), %esi
movq 0x8(%rsp), %rdi
callq 0x285da
addq %rax, %r15
addq $0x18, %r13
cmpq %rbp, %r13
jne 0x1842d
subq %r15, 0x68(%rsp)
jb 0x189c6
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x90(%rsp), %r15
movq 0x98(%rsp), %r13
cmpq %r13, %r15
je 0x18569
movq $0x0, 0x70(%rsp)
leaq 0x10(%rsp), %r12
movl $0x1, %ebp
movq (%r15), %rax
movq 0x8(%r15), %rcx
movq %rcx, %rdx
subq %rax, %rdx
cmpq $0x5, %rdx
jb 0x18553
cmpq %rcx, %rax
je 0x18536
movq 0xd8(%rsp), %rsi
xorl %edx, %edx
movl (%rax), %edi
movq %r14, %r8
testq %rsi, %rsi
je 0x1850a
movq %rsi, %r9
movq %r14, %r8
xorl %r10d, %r10d
cmpl %edi, 0x20(%r9)
setl %r10b
cmovgeq %r9, %r8
movq 0x10(%r9,%r10,8), %r9
testq %r9, %r9
jne 0x184f1
movq %r14, %r9
cmpq %r14, %r8
je 0x1851d
cmpl 0x20(%r8), %edi
cmovlq %r14, %r8
movq %r8, %r9
movzbl %dl, %edx
cmpq %r14, %r9
cmovnel %ebp, %edx
jne 0x18531
addq $0x4, %rax
cmpq %rcx, %rax
jne 0x184e1
testb $0x1, %dl
jne 0x18553
movq %r12, %rdi
movq %r15, %rsi
callq 0x1fc42
movq 0x8(%r15), %rax
subq (%r15), %rax
shrq $0x2, %rax
cltq
addq %rax, 0x70(%rsp)
addq $0x18, %r15
cmpq %r13, %r15
jne 0x184bb
jmp 0x18572
xorl %ebx, %ebx
jmp 0x189e0
movq $0x0, 0x70(%rsp)
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %r15
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
cmpq %r15, %r12
je 0x185ee
movq %r15, %rbx
subq %r12, %rbx
movq %rbx, %rax
sarq $0x3, %rax
imulq %rcx, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x1db5c
cmpq $0x181, %rbx            # imm = 0x181
jl 0x185e3
leaq 0x180(%r12), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x1dff9
cmpq %r15, %r14
je 0x185ee
movq %r14, %rdi
callq 0x1e104
addq $0x18, %r14
jmp 0x185d0
movq %r12, %rdi
movq %r15, %rsi
callq 0x1dff9
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r14
cmpq %r14, %rbx
je 0x1865e
leaq 0x30(%rsp), %r15
leaq 0x78(%rsp), %r12
movq (%rbx), %rbp
movq 0x8(%rbx), %r13
cmpq %r13, %rbp
je 0x18655
movl (%rbp), %eax
movl %eax, 0x78(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x18644
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x1864f
movq %r15, %rdi
movq %r12, %rdx
callq 0x98e8
addq $0x4, %rbp
jmp 0x1861f
addq $0x18, %rbx
cmpq %r14, %rbx
jne 0x18618
movq 0x30(%rsp), %r15
movq 0x38(%rsp), %r12
cmpq %r12, %r15
je 0x1869a
movq %r12, %rax
subq %r15, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x22eaf
movq %r15, %rdi
movq %r12, %rsi
callq 0x22f92
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x2352e
movq 0x38(%rsp), %rcx
cmpq %rcx, %rax
je 0x186cb
movq 0x38(%rsp), %rdx
movq %rdx, %rsi
subq %rcx, %rsi
addq %rsi, %rax
cmpq %rax, %rdx
je 0x186cb
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rsi
subq 0x30(%rsp), %rsi
sarq $0x2, %rsi
leaq 0x78(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
callq 0x1f784
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rsi
subq %rax, %rsi
sarq $0x2, %rsi
testl %esi, %esi
jle 0x18745
xorl %ebx, %ebx
movl (%rax,%rbx,4), %esi
movq 0x8(%rsp), %rdi
callq 0x285da
movq 0x78(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
incq %rbx
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rsi
subq %rax, %rsi
movq %rsi, %rcx
shrq $0x2, %rcx
movslq %ecx, %rcx
cmpq %rcx, %rbx
jl 0x1870c
sarq $0x2, %rsi
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rdx
cmpq %rdx, %rcx
je 0x187b2
movq (%rcx), %rdi
movq 0x8(%rcx), %r8
cmpq %r8, %rdi
je 0x187ac
movq %rax, %r9
testq %rsi, %rsi
jle 0x1879c
movl (%rdi), %r10d
movq %rsi, %r11
movq %rax, %r9
movq %r11, %rbx
shrq %rbx
movq %rbx, %r14
notq %r14
addq %r11, %r14
leaq (%r9,%rbx,4), %r11
addq $0x4, %r11
cmpl %r10d, -0x4(%r11)
cmovlq %r11, %r9
cmovgeq %rbx, %r14
movq %r14, %r11
testq %r14, %r14
jg 0x18771
subq %rax, %r9
shrq $0x2, %r9
movl %r9d, (%rdi)
addq $0x4, %rdi
jmp 0x1875b
addq $0x18, %rcx
jmp 0x1874f
leaq 0xb0(%rsp), %rdi
leaq 0x57(%rsp), %rdx
callq 0x8c32
movq 0x18(%rsp), %rbx
subq 0x10(%rsp), %rbx
sarq $0x3, %rbx
imulq %r15, %rbx
testl %ebx, %ebx
jle 0x188cc
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
leaq 0x78(%rsp), %r15
leaq 0xb0(%rsp), %r12
movq %rbx, 0x58(%rsp)
decq %rbx
movq 0x10(%rsp), %rax
leaq (%rbx,%rbx,2), %rcx
movq (%rax,%rcx,8), %rbp
movq 0x8(%rax,%rcx,8), %r13
cmpq %r13, %rbp
je 0x1882a
movq 0xb0(%rsp), %rax
movq %rbp, %rcx
movslq (%rcx), %rdx
incl (%rax,%rdx,4)
addq $0x4, %rcx
cmpq %r13, %rcx
jne 0x1881b
cmpq %r13, %rbp
je 0x188c0
movq %rbx, 0xa8(%rsp)
movq %r13, %rbx
subq %rbp, %rbx
movq %rbx, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbp, %rdi
movq %r13, %rsi
movq %r15, %rcx
movq %r12, %r8
callq 0x1e1a2
cmpq $0x41, %rbx
jl 0x188a7
leaq 0x40(%rbp), %r14
movq %rbp, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x1e624
cmpq %r13, %r14
movq 0xa8(%rsp), %rbx
je 0x188c0
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1e70d
addq $0x4, %r14
cmpq %r13, %r14
jne 0x1888e
jmp 0x188c0
movq %rbp, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x1e624
movq 0xa8(%rsp), %rbx
cmpq $0x1, 0x58(%rsp)
jg 0x187f1
leaq 0x10(%rsp), %rsi
movq 0x8(%rsi), %rax
subq (%rsi), %rax
sarq $0x3, %rax
movabsq $-0x5555555555555552, %r8 # imm = 0xAAAAAAAAAAAAAAAE
imulq %rax, %r8
movq 0x70(%rsp), %rax
cmpq %rax, %r8
cmovaeq %rax, %r8
leaq 0x78(%rsp), %rdx
movq 0x8(%rsp), %rdi
movq 0x68(%rsp), %rcx
callq 0x180d2
xorl %ebx, %ebx
testb %al, %al
je 0x1896e
movl 0x64(%rsp), %esi
movslq %esi, %rax
movq 0x8(%rsp), %rdi
movq 0x48(%rdi), %rcx
xorl %edx, %edx
cmpl $0x1, (%rcx,%rax,4)
sete %dl
callq 0xa016
movl %eax, %ebp
movq 0x8(%rsp), %rdi
movl 0x64(%rsp), %esi
callq 0x2859c
testb %al, %al
je 0x189f4
movq 0x8(%rsp), %rdi
addq $0x218, %rdi            # imm = 0x218
movq %rdi, %rbx
movl %ebp, %esi
callq 0x29970
movq %rbx, %rdi
movl $0x1, %ebx
movl $0x1, %esi
callq 0x29a24
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x1898b
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x189a5
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x189bc
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
leaq 0x10(%rsp), %rdi
callq 0x8f6e
leaq 0xc8(%rsp), %rdi
callq 0x2062a
leaq 0x90(%rsp), %rdi
callq 0x8f6e
movl %ebx, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x214b2(%rip), %rdi     # 0x39ead
leaq 0x214cc(%rip), %rsi     # 0x39ece
leaq 0x214d0(%rip), %rcx     # 0x39ed9
movl $0x92, %edx
callq 0x31b0
jmp 0x18a1d
jmp 0x18a44
jmp 0x18a6c
jmp 0x18a6c
jmp 0x18a6c
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x18a47
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
jmp 0x18a47
movq %rax, %rbx
jmp 0x18a86
movq %rax, %rbx
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x18a6f
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
jmp 0x18a6f
movq %rax, %rbx
jmp 0x18aac
jmp 0x18a92
jmp 0x18a92
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x18a86
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
leaq 0x10(%rsp), %rdi
callq 0x8f6e
jmp 0x18aac
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x18aac
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
leaq 0xc8(%rsp), %rdi
callq 0x2062a
leaq 0x90(%rsp), %rdi
callq 0x8f6e
movq %rbx, %rdi
callq 0x34a0