// File: Laakeri[P]maxpre/src/preprocessor.cpp
// Function: maxPreprocessor::Preprocessor::createLabels()
void Preprocessor::createLabels() {
	int added = 0;
	
	// Create labels for every soft clause that does not have a label yet
	for (unsigned i = 0; i < pi.clauses.size(); i++) {
		if (!pi.clauses[i].isHard() && !pi.isClauseRemoved(i)) {
			bool f = false;
			for (int lit : pi.clauses[i].lit) {
				if (pi.isLabel[litVariable(lit)]) {
					f = true;
					break;
				}
			}
			if (!f) {
				int nv = pi.addVar();
				pi.addLiteralToClause(posLit(nv), i);
				pi.addClause({negLit(nv)}, pi.clauses[i].weight);
				pi.isLabel[nv] = VAR_FALSE;
				pi.clauses[i].weight = HARDWEIGHT;
				added++;
			}
		}
	}
	
	log(added, " labels added");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x80(%rbp), %rdi
movl -0x10(%rbp), %eax
movq %rax, -0x88(%rbp)
callq 0x3c4b0
movq %rax, %rcx
movq -0x88(%rbp), %rax
cmpq %rcx, %rax
jae 0x129b4
movq -0x80(%rbp), %rdi
movl -0x10(%rbp), %eax
movl %eax, %esi
callq 0x3c600
movq %rax, %rdi
callq 0x60e90
testb $0x1, %al
jne 0x129a4
movq -0x80(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x5eb70
testb $0x1, %al
jne 0x129a4
movq -0x80(%rbp), %rdi
movb $0x0, -0x11(%rbp)
movl -0x10(%rbp), %eax
movl %eax, %esi
callq 0x3c600
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 0x12830
jmp 0x1287f
leaq -0x28(%rbp), %rdi
callq 0xa8a0
movq %rax, %rcx
movq -0x80(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x34(%rbp)
addq $0x48, %rax
movq %rax, -0x90(%rbp)
movl -0x34(%rbp), %edi
callq 0x3c880
movq -0x90(%rbp), %rdi
movslq %eax, %rsi
callq 0xa7c0
cmpl $0x0, (%rax)
je 0x12872
movb $0x1, -0x11(%rbp)
jmp 0x1287f
jmp 0x12874
leaq -0x28(%rbp), %rdi
callq 0xa930
jmp 0x1281d
testb $0x1, -0x11(%rbp)
jne 0x129a2
movq -0x80(%rbp), %rdi
callq 0x5f970
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %edi
callq 0x3c5d0
movq -0x80(%rbp), %rdi
movl %eax, %esi
movl -0x10(%rbp), %edx
movl $0x1, %ecx
callq 0x5fa80
movq -0x80(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl -0x38(%rbp), %edi
callq 0x3c5e0
movl %eax, -0x64(%rbp)
leaq -0x64(%rbp), %rax
movq %rax, -0x60(%rbp)
movq $0x1, -0x58(%rbp)
leaq -0x65(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0xa710
movq -0x98(%rbp), %rcx
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
leaq -0x50(%rbp), %rdi
callq 0x3c9b0
jmp 0x12900
movq -0x80(%rbp), %rdi
movl -0x10(%rbp), %eax
movl %eax, %esi
callq 0x3c600
movq -0xa0(%rbp), %rdi
movq 0x18(%rax), %rdx
leaq -0x50(%rbp), %rsi
callq 0x5f880
jmp 0x12924
leaq -0x50(%rbp), %rdi
callq 0xab00
leaq -0x65(%rbp), %rdi
callq 0xa7a0
movq -0x80(%rbp), %rdi
addq $0x48, %rdi
movslq -0x38(%rbp), %rsi
callq 0xa7c0
movq -0x80(%rbp), %rdi
movl $0x2, (%rax)
movl -0x10(%rbp), %eax
movl %eax, %esi
callq 0x3c600
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
movq %rcx, 0x18(%rax)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x129a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x12997
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xab00
leaq -0x65(%rbp), %rdi
callq 0xa7a0
jmp 0x129d0
jmp 0x129a4
jmp 0x129a6
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x12795
movq -0x80(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x73995(%rip), %rdx     # 0x86357
callq 0x3c620
addq $0xa0, %rsp
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x4610
nopl (%rax)