// File: /workspace/github_cpp_makefile_star2_O1/Laakeri[P]maxpre/src/./GSLE.cpp
// Function: maxPreprocessor::Preprocessor::doGSLE()
int Preprocessor::doGSLE() {
	rLog.startTechnique(Log::Technique::GSLE);
	int removed = 0;
	if (!rLog.requestTime(Log::Technique::GSLE)) {
		rLog.stopTechnique(Log::Technique::GSLE);
		return 0;
	}
	vector<int> checkVar = pi.tl.getTouchedVariables("GSLE");
	if (rLog.isTimeLimit()) {
		auto cmp = [&](int var1, int var2) {
			return pi.litClauses[negLit(var1)].size() + pi.litClauses[posLit(var1)].size() < pi.litClauses[negLit(var2)].size() + pi.litClauses[posLit(var2)].size();
		};
		sort(checkVar.begin(), checkVar.end(), cmp);
	}
	bool skip = false;
	if (skipTechnique > 0 && (int)checkVar.size() >= skipTechnique * 4) { // magic constant
		for (int tc = 0; tc < skipTechnique; tc++) {
			if (!rLog.requestTime(Log::Technique::GSLE)) break;
			int var = checkVar[getRand(0, (int)checkVar.size() - 1)];
			if (pi.isLabel[var] == VAR_UNDEFINED) continue;
			if (pi.isVarRemoved(var)) continue;
			if (pi.isLabel[var] == VAR_TRUE && pi.litClauses[negLit(var)].size() == 0){
				setVariable(var, true);
				removed++;
				continue;
			}
			if (pi.isLabel[var] == VAR_FALSE && pi.litClauses[posLit(var)].size() == 0){
				setVariable(var, false);
				removed++;
				continue;
			}
			
			if (pi.isLabel[var] == VAR_TRUE) {
				removed += tryGSLE(negLit(var));
			}
			else {
				removed += tryGSLE(posLit(var));
			}
		}
		if (removed == 0) {
			skip = true;
			log("GSLE skipped");
		}
	}
	if (!skip) {
		for (int var : checkVar) {
			if (pi.isLabel[var] == VAR_UNDEFINED) continue;
			if (pi.isVarRemoved(var)) continue;
			if (!rLog.requestTime(Log::Technique::GSLE)) break;
			
			if (pi.isLabel[var] == VAR_TRUE && pi.litClauses[negLit(var)].size() == 0){
				setVariable(var, true);
				removed++;
				continue;
			}
			if (pi.isLabel[var] == VAR_FALSE && pi.litClauses[posLit(var)].size() == 0){
				setVariable(var, false);
				removed++;
				continue;
			}
			
			if (pi.isLabel[var] == VAR_TRUE) {
				removed += tryGSLE(negLit(var));
			}
			else {
				removed += tryGSLE(posLit(var));
			}
		}
	}
	
	log(removed, " labels removed by GSLE");
	rLog.stopTechnique(Log::Technique::GSLE);
	return removed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r14
leaq 0x218(%rdi), %rbx
movq %rbx, %rdi
movl $0xb, %esi
callq 0x298e6
movq %rbx, %rdi
movl $0xb, %esi
callq 0x2a464
testb %al, %al
je 0x18bcb
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2141a(%rip), %rsi     # 0x39f33
leaq 0x21417(%rip), %rdx     # 0x39f37
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x945c
leaq 0x68(%r14), %rsi
leaq 0x8(%rsp), %rdi
movq %r15, %rdx
callq 0x307c8
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x18b55
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x2a792
testb %al, %al
je 0x18bed
movq 0x8(%rsp), %r12
movq 0x10(%rsp), %r15
cmpq %r15, %r12
je 0x18bed
movq %r15, %r13
subq %r12, %r13
movq %r13, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rcx
callq 0x1e7cf
cmpq $0x41, %r13
jl 0x18bdf
leaq 0x40(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1ec07
cmpq %r15, %r13
je 0x18bed
movq %r13, %rdi
movq %r14, %rsi
callq 0x1ec97
addq $0x4, %r13
jmp 0x18bb5
movq %rbx, %rdi
movl $0xb, %esi
callq 0x29928
xorl %ebp, %ebp
jmp 0x18db8
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1ec07
movl 0x468(%r14), %eax
testl %eax, %eax
jle 0x18d4a
movq 0x10(%rsp), %rcx
subq 0x8(%rsp), %rcx
shrq $0x2, %rcx
shll $0x2, %eax
xorl %ebp, %ebp
movl $0x0, %edx
cmpl %ecx, %eax
jg 0x18d76
cmpl $0x0, 0x468(%r14)
jle 0x18d50
leaq 0x470(%r14), %r15
movl $0x0, 0x4(%rsp)
leaq 0x20(%rsp), %rbp
xorl %r12d, %r12d
movq %rbx, %rdi
movl $0xb, %esi
callq 0x2a464
testb %al, %al
je 0x18d58
movq 0x10(%rsp), %rax
subq 0x8(%rsp), %rax
shrq $0x2, %rax
decl %eax
movl $0x0, 0x20(%rsp)
movl %eax, 0x24(%rsp)
movq %rbp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x2152e
cltq
movq 0x8(%rsp), %rcx
movslq (%rcx,%rax,4), %r13
movq 0x48(%r14), %rax
cmpl $0x0, (%rax,%r13,4)
je 0x18d38
movq %r14, %rdi
movl %r13d, %esi
callq 0x2859c
testb %al, %al
jne 0x18d38
movq 0x48(%r14), %rax
movl (%rax,%r13,4), %eax
cmpl $0x1, %eax
jne 0x18cd8
leal 0x1(,%r13,2), %ecx
movslq %ecx, %rcx
movq 0x18(%r14), %rdx
leaq (%rcx,%rcx,2), %rcx
movq 0x8(%rdx,%rcx,8), %rsi
cmpq (%rdx,%rcx,8), %rsi
je 0x18d15
cmpl $0x2, %eax
jne 0x18cfb
leal (,%r13,2), %ecx
movslq %ecx, %rcx
movq 0x18(%r14), %rdx
leaq (%rcx,%rcx,2), %rcx
movq 0x8(%rdx,%rcx,8), %rsi
cmpq (%rdx,%rcx,8), %rsi
je 0x18d27
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
leal (%rcx,%r13,2), %esi
movq %r14, %rdi
callq 0x18214
addl %eax, 0x4(%rsp)
jmp 0x18d38
movq %r14, %rdi
movl %r13d, %esi
movl $0x1, %edx
callq 0xa016
jmp 0x18d34
movq %r14, %rdi
movl %r13d, %esi
xorl %edx, %edx
callq 0xa016
incl 0x4(%rsp)
incl %r12d
cmpl 0x468(%r14), %r12d
jl 0x18c41
jmp 0x18d58
xorl %ebp, %ebp
xorl %edx, %edx
jmp 0x18d76
movl $0x0, 0x4(%rsp)
xorl %ebp, %ebp
movl 0x4(%rsp), %edx
testl %edx, %edx
jne 0x18d76
movb $0x1, %bpl
leaq 0x2119d(%rip), %rsi     # 0x39f09
movq %r14, %rdi
callq 0x1f6a2
xorl %edx, %edx
movl %edx, 0x4(%rsp)
testb %bpl, %bpl
je 0x18dc9
leaq 0x21190(%rip), %rdx     # 0x39f16
movq %r14, %rdi
movl 0x4(%rsp), %ebp
movl %ebp, %esi
callq 0x1f426
movq %rbx, %rdi
movl $0xb, %esi
callq 0x29928
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x18db8
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %r12
movq 0x10(%rsp), %r13
cmpq %r13, %r12
je 0x18d7f
movslq (%r12), %r15
movq 0x48(%r14), %rax
movl $0x6, %ebp
cmpl $0x0, (%rax,%r15,4)
je 0x18ea4
movq %r14, %rdi
movl %r15d, %esi
callq 0x2859c
testb %al, %al
jne 0x18ea4
movq %rbx, %rdi
movl $0xb, %esi
callq 0x2a464
testb %al, %al
je 0x18e7a
movq 0x48(%r14), %rax
movl (%rax,%r15,4), %eax
cmpl $0x1, %eax
jne 0x18e3f
leal 0x1(,%r15,2), %ecx
movslq %ecx, %rcx
movq 0x18(%r14), %rdx
leaq (%rcx,%rcx,2), %rcx
movq 0x8(%rdx,%rcx,8), %rsi
cmpq (%rdx,%rcx,8), %rsi
je 0x18e81
cmpl $0x2, %eax
jne 0x18e5e
leal (%r15,%r15), %ecx
movslq %ecx, %rcx
movq 0x18(%r14), %rdx
leaq (%rcx,%rcx,2), %rcx
movq 0x8(%rdx,%rcx,8), %rsi
cmpq (%rdx,%rcx,8), %rsi
je 0x18e93
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
leal (%rcx,%r15,2), %esi
movq %r14, %rdi
callq 0x18214
addl %eax, 0x4(%rsp)
xorl %ebp, %ebp
jmp 0x18ea4
movl $0x5, %ebp
jmp 0x18ea4
movq %r14, %rdi
movl %r15d, %esi
movl $0x1, %edx
callq 0xa016
jmp 0x18ea0
movq %r14, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0xa016
incl 0x4(%rsp)
cmpl $0x6, %ebp
je 0x18eb1
testl %ebp, %ebp
jne 0x18d7f
addq $0x4, %r12
jmp 0x18dd3
jmp 0x18ed9
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x18ef3
movq 0x38(%rsp), %rsi
incq %rsi
jmp 0x18eee
jmp 0x18ed9
jmp 0x18ed9
jmp 0x18ed9
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x18ef3
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x34a0
nop