// File: Laakeri[P]maxpre/src/preprocessor.cpp
// Function: maxPreprocessor::Preprocessor::identifyLabels()
void Preprocessor::identifyLabels() {
	int found = 0;
	
	// Find literals that occur in only 1 clause and their negation occurs only in hard clauses
	for (int lit = 0; lit < pi.vars*2; lit++) {
		if (pi.litClauses[lit].size() == 1 && !pi.clauses[pi.litClauses[lit][0]].isHard() && pi.clauses[pi.litClauses[lit][0]].lit.size() == 1) {
			bool f = false;
			for (int c : pi.litClauses[litNegation(lit)]) {
				if (!pi.clauses[c].isHard()) {
					f = true;
					break;
				}
			}
			if (!f) {
				if (litValue(lit) == true) {
					pi.isLabel[litVariable(lit)] = VAR_TRUE;
				}
				else {
					pi.isLabel[litVariable(lit)] = VAR_FALSE;
				}
				found++;
			}
		}
	}
	
	log(found, " labels identified");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x40(%rbp), %rcx
movl -0x10(%rbp), %eax
movl 0x60(%rcx), %ecx
shll %ecx
cmpl %ecx, %eax
jge 0x12748
movq -0x40(%rbp), %rdi
addq $0x18, %rdi
movslq -0x10(%rbp), %rsi
callq 0xaab0
movq %rax, %rdi
callq 0xf940
cmpq $0x1, %rax
jne 0x12738
movq -0x40(%rbp), %rdi
addq $0x18, %rdi
movslq -0x10(%rbp), %rsi
callq 0xaab0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xa7c0
movq -0x40(%rbp), %rdi
movslq (%rax), %rsi
callq 0x3c600
movq %rax, %rdi
callq 0x60e90
testb $0x1, %al
jne 0x12738
movq -0x40(%rbp), %rdi
addq $0x18, %rdi
movslq -0x10(%rbp), %rsi
callq 0xaab0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xa7c0
movq -0x40(%rbp), %rdi
movslq (%rax), %rsi
callq 0x3c600
movq %rax, %rdi
callq 0xf940
cmpq $0x1, %rax
jne 0x12738
movq -0x40(%rbp), %rax
movb $0x0, -0x11(%rbp)
addq $0x18, %rax
movq %rax, -0x48(%rbp)
movl -0x10(%rbp), %edi
callq 0x3c5a0
movq -0x48(%rbp), %rdi
movslq %eax, %rsi
callq 0xaab0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0xa800
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0xa830
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xa860
testb $0x1, %al
jne 0x12692
jmp 0x126cc
leaq -0x28(%rbp), %rdi
callq 0xa8a0
movq -0x40(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x34(%rbp)
movslq -0x34(%rbp), %rsi
callq 0x3c600
movq %rax, %rdi
callq 0x60e90
testb $0x1, %al
jne 0x126bf
movb $0x1, -0x11(%rbp)
jmp 0x126cc
jmp 0x126c1
leaq -0x28(%rbp), %rdi
callq 0xa930
jmp 0x1267f
testb $0x1, -0x11(%rbp)
jne 0x12736
movl -0x10(%rbp), %edi
callq 0x3c890
cmpl $0x1, %eax
jne 0x12707
movq -0x40(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x50(%rbp)
movl -0x10(%rbp), %edi
callq 0x3c880
movq -0x50(%rbp), %rdi
movslq %eax, %rsi
callq 0xa7c0
movl $0x1, (%rax)
jmp 0x1272d
movq -0x40(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x58(%rbp)
movl -0x10(%rbp), %edi
callq 0x3c880
movq -0x58(%rbp), %rdi
movslq %eax, %rsi
callq 0xa7c0
movl $0x2, (%rax)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x12738
jmp 0x1273a
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x12592
movq -0x40(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x73bee(%rip), %rdx     # 0x86344
callq 0x3c620
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)