// File: /workspace/github_cpp_makefile_star2_O3/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 $0xe8, %rsp
movl %esi, %r15d
movq %rdi, %rbx
sarl %esi
movl %esi, 0x54(%rsp)
callq 0x278de
movq %rax, 0x58(%rsp)
movslq %r15d, %rcx
movq 0x18(%rbx), %rax
leaq (%rcx,%rcx,2), %r13
movq (%rax,%r13,8), %r14
movq 0x8(%rax,%r13,8), %rdx
cmpq %rdx, %r14
je 0x17ae8
movq %rdx, 0x20(%rsp)
movslq (%r14), %rax
movq (%rbx), %rcx
leaq (%rax,%rax,4), %rax
movq (%rcx,%rax,8), %r12
movq 0x8(%rcx,%rax,8), %rbp
cmpq %rbp, %r12
je 0x17c60
movl (%r12), %esi
cmpl %r15d, %esi
je 0x17ad0
sarl %esi
movslq %esi, %rax
movq 0x48(%rbx), %rcx
cmpl $0x0, (%rcx,%rax,4)
je 0x17ad0
movq %rbx, %rdi
callq 0x278de
cmpq 0x58(%rsp), %rax
jbe 0x17ad6
addq $0x4, %r12
jmp 0x17aa0
addq $0x4, %r14
movq 0x20(%rsp), %rdx
cmpq %rdx, %r14
jne 0x17a8d
movq 0x18(%rbx), %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
xorl %ecx, %ecx
movq %rcx, 0xa0(%rsp)
leaq 0xc0(%rsp), %rdx
movl $0x0, (%rdx)
movq %rcx, 0x8(%rdx)
movq %rdx, 0x10(%rdx)
movq %rdx, 0x18(%rdx)
movq %rcx, 0x20(%rdx)
movq (%rax,%r13,8), %rbp
movq 0x8(%rax,%r13,8), %rax
movq %rax, 0x20(%rsp)
cmpq %rax, %rbp
je 0x17c67
movslq (%rbp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq (%rbx), %rcx
leaq (%rax,%rax,4), %rax
movq (%rcx,%rax,8), %r13
movq 0x8(%rcx,%rax,8), %r14
cmpq %r14, %r13
je 0x17bb8
movl (%r13), %r12d
cmpl %r15d, %r12d
je 0x17bb2
sarl %r12d
movslq %r12d, %rax
movq 0x48(%rbx), %rcx
cmpl $0x0, (%rcx,%rax,4)
je 0x17bb2
movq %rbx, %rdi
movl %r12d, %esi
callq 0x278de
cmpq 0x58(%rsp), %rax
ja 0x17bb2
movl %r12d, 0x30(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x17ba5
movl %r12d, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x17bb2
movq %rsp, %rdi
leaq 0x30(%rsp), %rdx
callq 0x1ffb8
addq $0x4, %r13
jmp 0x17b56
leaq 0x90(%rsp), %rdi
movq %rsp, %rsi
callq 0x1f07e
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x17bde
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
addq $0x4, %rbp
cmpq 0x20(%rsp), %rbp
jne 0x17b32
movq 0x90(%rsp), %r12
movq 0x98(%rsp), %r13
cmpq %r13, %r12
je 0x17c67
xorl %r14d, %r14d
leaq 0xb8(%rsp), %r15
movq (%r12), %rsi
movq 0x8(%r12), %rax
subq %rsi, %rax
cmpq $0x4, %rax
jne 0x17c49
movq %r15, %rdi
callq 0x1ec30
testq %rax, %rax
jne 0x17c49
movq (%r12), %rsi
movq %r15, %rdi
callq 0x22126
movq (%r12), %rax
movl (%rax), %esi
movq %rbx, %rdi
callq 0x278de
addq %rax, %r14
addq $0x18, %r12
cmpq %r13, %r12
jne 0x17c0d
xorl %ebp, %ebp
cmpq 0x58(%rsp), %r14
jbe 0x17c6a
jmp 0x181ea
xorl %ebp, %ebp
jmp 0x18204
xorl %r14d, %r14d
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq 0x90(%rsp), %r12
movq 0x98(%rsp), %r15
cmpq %r15, %r12
movq %r14, 0xb0(%rsp)
je 0x17dba
xorl %ebp, %ebp
movq %rsp, %r13
movq (%r12), %rax
movq 0x8(%r12), %rcx
movq %rcx, %rdx
subq %rax, %rdx
cmpq $0x5, %rdx
jb 0x17d3d
cmpq %rcx, %rax
je 0x17d20
movq 0xc8(%rsp), %rdx
testq %rdx, %rdx
je 0x17d17
movl (%rax), %esi
movq %rdx, %r11
leaq 0xc0(%rsp), %r10
movq %r10, %rdi
movq %r11, %r8
movl 0x20(%r11), %r9d
xorl %r11d, %r11d
cmpl %esi, %r9d
setl %r11b
movq %r8, %r10
cmovlq %rdi, %r10
movq 0x10(%r8,%r11,8), %r11
testq %r11, %r11
jne 0x17cd8
leaq 0xc0(%rsp), %r11
cmpq %r11, %r10
je 0x17d17
cmpl %esi, %r9d
cmovlq %rdi, %r8
cmpl 0x20(%r8), %esi
jge 0x17d3d
addq $0x4, %rax
cmpq %rcx, %rax
jne 0x17cc6
movq %r13, %rdi
movq %r12, %rsi
callq 0x1f07e
movq 0x8(%r12), %rax
subq (%r12), %rax
shrq $0x2, %rax
cltq
addq %rax, %rbp
addq $0x18, %r12
cmpq %r15, %r12
jne 0x17ca0
movq (%rsp), %r12
movq 0x8(%rsp), %r15
cmpq %r15, %r12
je 0x17dc9
movq %r15, %r14
subq %r12, %r14
movq %r14, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x1cff2
cmpq $0x181, %r14            # imm = 0x181
jl 0x17dbe
leaq 0x180(%r12), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x1d483
cmpq %r15, %r14
je 0x17dc9
movq %r14, %rdi
callq 0x1d59c
addq $0x18, %r14
jmp 0x17da7
xorl %ebp, %ebp
jmp 0x17dc9
movq %r12, %rdi
movq %r15, %rsi
callq 0x1d483
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq (%rsp), %r14
movq 0x8(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq %rax, %r14
movq %rbp, 0xa8(%rsp)
je 0x17ecc
leaq 0x30(%rsp), %r15
leaq 0x78(%rsp), %r12
movq (%r14), %rbp
movq 0x8(%r14), %r13
cmpq %r13, %rbp
je 0x17e40
movl (%rbp), %eax
movl %eax, 0x78(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x17e2f
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x17e3a
movq %r15, %rdi
movq %r12, %rdx
callq 0x98f8
addq $0x4, %rbp
jmp 0x17e0a
addq $0x18, %r14
cmpq 0x20(%rsp), %r14
jne 0x17e03
movq 0x30(%rsp), %r12
movq 0x38(%rsp), %r13
cmpq %r13, %r12
je 0x17e91
movq %r13, %rax
subq %r12, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x2226b
movq %r12, %rdi
movq %r13, %rsi
callq 0x2234e
movq 0x30(%rsp), %r12
movq 0x38(%rsp), %r13
cmpq %r13, %r12
je 0x17ee5
leaq 0x4(%r12), %rax
cmpq %r13, %rax
je 0x17ee5
movl -0x4(%rax), %ecx
leaq 0x4(%rax), %rdx
cmpl (%rax), %ecx
movq %rdx, %rax
jne 0x17e9b
leaq -0x8(%rdx), %rax
cmpq %r13, %rdx
je 0x17ed4
movl %ecx, %esi
movl (%rdx), %ecx
cmpl %ecx, %esi
je 0x17ec6
movl %ecx, 0x4(%rax)
addq $0x4, %rax
addq $0x4, %rdx
jmp 0x17eb2
xorl %r12d, %r12d
xorl %r13d, %r13d
jmp 0x17ee5
addq $0x4, %rax
cmpq %r13, %rax
je 0x17ee5
movq %rax, 0x38(%rsp)
movq %rax, %r13
subq %r12, %r13
sarq $0x2, %r13
leaq 0x78(%rsp), %rdi
leaq 0x60(%rsp), %rdx
movq %r13, %rsi
callq 0x1eba2
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rsi
subq %rax, %rsi
sarq $0x2, %rsi
testl %esi, %esi
jle 0x17f4e
xorl %r14d, %r14d
movl (%rax,%r14,4), %esi
movq %rbx, %rdi
callq 0x278de
movq 0x78(%rsp), %rcx
movq %rax, (%rcx,%r14,8)
incq %r14
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rsi
subq %rax, %rsi
movq %rsi, %rcx
shrq $0x2, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r14
jl 0x17f16
sarq $0x2, %rsi
movq (%rsp), %rcx
movq 0x8(%rsp), %rdx
cmpq %rdx, %rcx
je 0x17fba
movq (%rcx), %rdi
movq 0x8(%rcx), %r8
cmpq %r8, %rdi
je 0x17fb4
movq %rax, %r9
testq %rsi, %rsi
jle 0x17fa4
movl (%rdi), %r10d
movq %rsi, %r11
movq %rax, %r9
movq %r11, %r14
shrq %r14
movq %r14, %r15
notq %r15
addq %r11, %r15
leaq (%r9,%r14,4), %r11
addq $0x4, %r11
cmpl %r10d, -0x4(%r11)
cmovlq %r11, %r9
cmovgeq %r14, %r15
movq %r15, %r11
testq %r15, %r15
jg 0x17f79
subq %rax, %r9
shrq $0x2, %r9
movl %r9d, (%rdi)
addq $0x4, %rdi
jmp 0x17f63
addq $0x18, %rcx
jmp 0x17f57
leaq 0x60(%rsp), %rdi
leaq 0x2f(%rsp), %rdx
callq 0x8c20
movq 0x8(%rsp), %r13
subq (%rsp), %r13
sarq $0x3, %r13
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r13
testl %r13d, %r13d
jle 0x18105
movq %rbx, 0x20(%rsp)
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
leaq 0x78(%rsp), %rbx
leaq 0x60(%rsp), %r9
movq %r13, %r12
decq %r13
movq (%rsp), %rax
leaq (,%r13,2), %rcx
addq %r13, %rcx
movq (%rax,%rcx,8), %r15
movq 0x8(%rax,%rcx,8), %rbp
cmpq %rbp, %r15
je 0x180db
movq 0x60(%rsp), %rax
movq %r15, %rcx
movslq (%rcx), %rdx
incl (%rax,%rdx,4)
addq $0x4, %rcx
cmpq %rbp, %rcx
jne 0x18032
cmpq %rbp, %r15
je 0x180db
movq %rbp, %r14
subq %r15, %r14
movq %r14, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %rbp, %rsi
movq %rbx, %rcx
movq %r9, %r8
callq 0x1d63c
cmpq $0x41, %r14
jl 0x180c2
leaq 0x40(%r15), %r14
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
leaq 0x60(%rsp), %r15
movq %r15, %rcx
callq 0x1dacc
cmpq %rbp, %r14
movq %r15, %r9
je 0x180db
movq %r14, %rdi
movq %rbx, %rsi
movq %r9, %rdx
movq %rbx, %r15
movq %r9, %rbx
callq 0x1dbb5
movq %rbx, %r9
movq %r15, %rbx
addq $0x4, %r14
cmpq %rbp, %r14
jne 0x1809d
jmp 0x180db
movq %r15, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
leaq 0x60(%rsp), %r14
movq %r14, %rcx
callq 0x1dacc
movq %r14, %r9
cmpq $0x1, %r12
jg 0x18003
movq 0x8(%rsp), %r13
subq (%rsp), %r13
sarq $0x3, %r13
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r13
movq 0x20(%rsp), %rbx
addq %r13, %r13
leaq (,%r13,4), %rax
addq %r13, %rax
movq 0xa8(%rsp), %r8
cmpq %r8, %rax
cmovbq %rax, %r8
movq 0x58(%rsp), %rcx
subq 0xb0(%rsp), %rcx
movq %rsp, %rsi
leaq 0x78(%rsp), %rdx
movq %rbx, %rdi
callq 0x17920
xorl %ebp, %ebp
testb %al, %al
je 0x1819a
movl 0x54(%rsp), %esi
movslq %esi, %rax
movq 0x48(%rbx), %rcx
xorl %edx, %edx
cmpl $0x1, (%rcx,%rax,4)
sete %dl
movq %rbx, %rdi
callq 0xa026
movl %eax, %ebp
movq %rbx, %rdi
movl 0x54(%rsp), %esi
callq 0x278a0
testb %al, %al
je 0x18218
addq $0x218, %rbx            # imm = 0x218
movq %rbx, %rdi
movl %ebp, %esi
callq 0x28c28
movl $0x1, %ebp
movq %rbx, %rdi
movl $0x1, %esi
callq 0x28cdc
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x181b1
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x181cb
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x181e2
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq %rsp, %rdi
callq 0x8f5e
leaq 0xb8(%rsp), %rdi
callq 0x1fa58
leaq 0x90(%rsp), %rdi
callq 0x8f5e
movl %ebp, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20d3e(%rip), %rdi     # 0x38f5d
leaq 0x20d58(%rip), %rsi     # 0x38f7e
leaq 0x20d5c(%rip), %rcx     # 0x38f89
movl $0x92, %edx
callq 0x31b0
jmp 0x18288
jmp 0x1823f
jmp 0x18265
jmp 0x18288
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x18268
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
jmp 0x18268
movq %rax, %rbx
jmp 0x182a2
movq %rax, %rbx
jmp 0x182c5
movq %rax, %rbx
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x1828b
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
jmp 0x1828b
jmp 0x182ac
jmp 0x182ac
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x182a2
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq %rsp, %rdi
callq 0x8f5e
jmp 0x182c5
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x182c5
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
leaq 0xb8(%rsp), %rdi
callq 0x1fa58
leaq 0x90(%rsp), %rdi
callq 0x8f5e
movq %rbx, %rdi
callq 0x34a0
nop