// File: /workspace/github_cpp_makefile_star2_O2/Laakeri[P]maxpre/src/preprocessor.cpp
// Function: maxPreprocessor::Preprocessor::getPreprocessedInstance()
PreprocessedInstance Preprocessor::getPreprocessedInstance() {
	PreprocessedInstance ret;
	for (unsigned i = 0; i < pi.clauses.size(); i++) {
		if (!pi.isClauseRemoved(i) && pi.clauses[i].isHard()) {
			ret.clauses.push_back(pi.clauses[i].lit);
			ret.weights.push_back(pi.clauses[i].weight);
		}
	}
	for (int var = 0; var < pi.vars; var++) {
		if (pi.isLabel[var] == VAR_TRUE && !pi.isVarRemoved(var)) {
			assert(pi.litClauses[posLit(var)].size() == 1);
		}
		if (pi.isLabel[var] == VAR_FALSE && !pi.isVarRemoved(var)) {
			assert(pi.litClauses[negLit(var)].size() == 1);
		}
		if (pi.litClauses[posLit(var)].size() > 0 || pi.litClauses[negLit(var)].size() > 0) {
			if (pi.isLabel[var] == VAR_TRUE) {
				if (pi.litClauses[negLit(var)].size() == 0) {
					trace.setVar(var, true);
				}
				else {
					assert(pi.litClauses[posLit(var)].size() == 1);
					assert(pi.clauses[pi.litClauses[posLit(var)][0]].lit.size() == 1);
					assert(!pi.clauses[pi.litClauses[posLit(var)][0]].isHard());
					ret.labels.push_back({posLit(var), pi.clauses[pi.litClauses[posLit(var)][0]].weight});
				}
			}
			else if(pi.isLabel[var] == VAR_FALSE) {
				if (pi.litClauses[posLit(var)].size() == 0) {
					trace.setVar(var, false);
				}
				else {
					assert(pi.litClauses[negLit(var)].size() == 1);
					assert(pi.clauses[pi.litClauses[negLit(var)][0]].lit.size() == 1);
					assert(!pi.clauses[pi.litClauses[negLit(var)][0]].isHard());
					ret.labels.push_back({negLit(var), pi.clauses[pi.litClauses[negLit(var)][0]].weight});
				}
			}
		}
	}
	if (trace.removedWeight > 0) {
		int nVar = pi.getExcessVar();
		ret.labels.push_back({negLit(nVar), trace.removedWeight});
		ret.clauses.push_back({posLit(nVar)});
		ret.weights.push_back(HARDWEIGHT);
	}
	auto cmp = [&](pair<int, uint64_t> a, pair<int, uint64_t> b) {
		if (litVariable(a.F) >= pi.vars || litVariable(b.F) >= pi.vars) return a.F > b.F;
		return pi.litClauses[a.F].size() + pi.litClauses[litNegation(a.F)].size() > pi.litClauses[b.F].size() + pi.litClauses[litNegation(b.F)].size();
	};
	sort(ret.labels.begin(), ret.labels.end(), cmp);
	for (int i = 0; i < (int)ret.labels.size(); i++) {
		ret.clauses.push_back({ret.labels[i].F});
		ret.weights.push_back(ret.labels[i].S);
	}
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
andq $0x0, 0x40(%rdi)
movups %xmm0, (%rdi)
movq %rdi, 0x8(%rsp)
leaq 0x18(%rdi), %rax
movq %rax, 0x40(%rsp)
xorl %r12d, %r12d
pushq $0x28
popq %r14
movl %r12d, %r12d
movq 0x8(%r15), %rax
subq (%r15), %rax
cqto
idivq %r14
cmpq %r12, %rax
jbe 0x1461d
movq %r15, %rdi
movl %r12d, %esi
callq 0x20f14
testb %al, %al
jne 0x14618
imulq $0x28, %r12, %rbx
movq (%r15), %rdi
addq %rbx, %rdi
callq 0x21bac
testb %al, %al
je 0x14618
movq (%r15), %rsi
addq %rbx, %rsi
movq 0x8(%rsp), %rdi
callq 0x18f96
movq (%r15), %rax
leaq (%rax,%rbx), %rsi
addq $0x18, %rsi
movq 0x40(%rsp), %rdi
callq 0x193d8
incl %r12d
jmp 0x145bd
movq 0x8(%rsp), %rax
addq $0x30, %rax
movq %rax, 0x18(%rsp)
leaq 0x2f0(%r15), %rax
movq %rax, 0x38(%rsp)
pushq $0x1
popq %r14
xorl %r13d, %r13d
xorl %ebp, %ebp
movslq 0x60(%r15), %rax
cmpq %rax, %rbp
jge 0x14845
movq 0x48(%r15), %rax
cmpl $0x1, (%rax,%rbp,4)
jne 0x14686
movq %r15, %rdi
movl %ebp, %esi
callq 0x20fae
testb %al, %al
jne 0x14686
leal -0x1(%r14), %eax
cltq
movq 0x18(%r15), %rcx
imulq $0x18, %rax, %rax
movq 0x8(%rcx,%rax), %rdx
subq (%rcx,%rax), %rdx
cmpq $0x4, %rdx
jne 0x149da
movq 0x48(%r15), %rax
cmpl $0x2, (%rax,%rbp,4)
movslq %r14d, %r12
jne 0x146bd
movq %r15, %rdi
movl %ebp, %esi
callq 0x20fae
movq 0x18(%r15), %rcx
testb %al, %al
jne 0x146c1
imulq $0x18, %r12, %rax
movq 0x8(%rcx,%rax), %rdx
subq (%rcx,%rax), %rdx
cmpq $0x4, %rdx
je 0x146c1
jmp 0x149f9
movq 0x18(%r15), %rcx
movq %r13, %rsi
sarq $0x20, %rsi
imulq $0x18, %rsi, %rbx
movq (%rcx,%rbx), %rax
movq 0x8(%rcx,%rbx), %rdi
movq %rdi, %rdx
subq %rax, %rdx
jne 0x146f7
movq %rsi, %r8
orq $0x1, %r8
imulq $0x18, %r8, %r8
movq 0x8(%rcx,%r8), %r9
cmpq (%rcx,%r8), %r9
je 0x1482c
movq 0x48(%r15), %r8
movl (%r8,%rbp,4), %r8d
cmpl $0x2, %r8d
je 0x14799
cmpl $0x1, %r8d
jne 0x1482c
orq $0x1, %rsi
imulq $0x18, %rsi, %rsi
movq 0x8(%rcx,%rsi), %rdi
cmpq (%rcx,%rsi), %rdi
je 0x14817
cmpq $0x4, %rdx
jne 0x14a75
movslq (%rax), %rax
movq (%r15), %rdi
imulq $0x28, %rax, %rax
movq 0x8(%rdi,%rax), %rcx
subq (%rdi,%rax), %rcx
cmpq $0x4, %rcx
jne 0x14a94
addq %rax, %rdi
callq 0x21bac
testb %al, %al
jne 0x14ab3
leal -0x1(%r14), %eax
movq (%r15), %rcx
movq 0x18(%r15), %rdx
movq (%rdx,%rbx), %rdx
movslq (%rdx), %rdx
imulq $0x28, %rdx, %rdx
movl %eax, 0x20(%rsp)
movq 0x18(%rcx,%rdx), %rax
movq %rax, 0x28(%rsp)
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x1aa0a
jmp 0x1482c
cmpq %rax, %rdi
je 0x1481b
imulq $0x18, %r12, %rbx
movq (%rcx,%rbx), %rax
movq 0x8(%rcx,%rbx), %rcx
subq %rax, %rcx
cmpq $0x4, %rcx
jne 0x14a37
movslq (%rax), %rax
movq (%r15), %rdi
imulq $0x28, %rax, %rax
movq 0x8(%rdi,%rax), %rcx
subq (%rdi,%rax), %rcx
cmpq $0x4, %rcx
jne 0x14a18
addq %rax, %rdi
callq 0x21bac
testb %al, %al
jne 0x14a56
movq (%r15), %rax
movq 0x18(%r15), %rcx
movq (%rcx,%rbx), %rcx
movslq (%rcx), %rcx
imulq $0x28, %rcx, %rcx
movl %r14d, 0x20(%rsp)
movq 0x18(%rax,%rcx), %rax
movq %rax, 0x28(%rsp)
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x1aa0a
jmp 0x1482c
movb $0x1, %al
jmp 0x1481d
xorl %eax, %eax
movzbl %al, %edx
movq 0x38(%rsp), %rdi
movl %ebp, %esi
callq 0x202d0
incq %rbp
movabsq $0x200000000, %rax      # imm = 0x200000000
addq %rax, %r13
addl $0x2, %r14d
jmp 0x14640
movq 0x38(%rsp), %rax
cmpq $0x0, (%rax)
je 0x148c7
movq %r15, %rdi
callq 0x2178c
movl %eax, %r14d
leal 0x1(,%r14,2), %eax
leaq 0x20(%rsp), %rsi
movl %eax, (%rsi)
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsi)
movq 0x18(%rsp), %rdi
callq 0x1aa0a
addl %r14d, %r14d
leaq 0x14(%rsp), %rsi
movl %r14d, (%rsi)
leaq 0x20(%rsp), %rdi
pushq $0x1
popq %rdx
leaq 0x7(%rsp), %rcx
callq 0x18af6
leaq 0x20(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x1cb40
leaq 0x20(%rsp), %rdi
callq 0x7512
leaq 0x1aa6b(%rip), %rsi     # 0x2f328
movq 0x40(%rsp), %rdi
callq 0x193d8
movq 0x8(%rsp), %rax
movq 0x30(%rax), %r13
movq 0x38(%rax), %r14
cmpq %r14, %r13
je 0x14945
movq %r14, %rbx
subq %r13, %rbx
movq %rbx, %rax
sarq $0x4, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rcx
callq 0x1846e
cmpq $0x101, %rbx            # imm = 0x101
jl 0x14937
leaq 0x100(%r13), %rbp
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x188b8
jmp 0x14930
movq %rbp, %rdi
movq %r15, %rsi
callq 0x1893f
addq $0x10, %rbp
cmpq %r14, %rbp
jne 0x14921
jmp 0x14945
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x188b8
pushq $0x8
popq %r12
xorl %ebx, %ebx
leaq 0x20(%rsp), %r15
leaq 0x14(%rsp), %r13
pushq $0x1
popq %rbp
leaq 0x7(%rsp), %r14
movq 0x8(%rsp), %rcx
movq 0x30(%rcx), %rax
movq 0x38(%rcx), %rcx
subq %rax, %rcx
shrq $0x4, %rcx
movslq %ecx, %rcx
cmpq %rcx, %rbx
jge 0x149c6
movl -0x8(%rax,%r12), %eax
movl %eax, 0x14(%rsp)
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x18af6
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x1cb40
movq %r15, %rdi
callq 0x7512
movq 0x18(%rsp), %rax
movq (%rax), %rsi
addq %r12, %rsi
movq 0x40(%rsp), %rdi
callq 0x193d8
incq %rbx
addq $0x10, %r12
jmp 0x1495d
movq 0x8(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1afdd(%rip), %rdi     # 0x2f9be
leaq 0x1a97f(%rip), %rsi     # 0x2f367
leaq 0x1b657(%rip), %rcx     # 0x30046
movl $0x1ae, %edx            # imm = 0x1AE
callq 0x31c0
leaq 0x1b010(%rip), %rdi     # 0x2fa10
leaq 0x1a960(%rip), %rsi     # 0x2f367
leaq 0x1b638(%rip), %rcx     # 0x30046
movl $0x1b1, %edx            # imm = 0x1B1
callq 0x31c0
leaq 0x1b6e3(%rip), %rdi     # 0x30102
leaq 0x1a941(%rip), %rsi     # 0x2f367
leaq 0x1b619(%rip), %rcx     # 0x30046
movl $0x1c5, %edx            # imm = 0x1C5
callq 0x31c0
leaq 0x1afd2(%rip), %rdi     # 0x2fa10
leaq 0x1a922(%rip), %rsi     # 0x2f367
leaq 0x1b5fa(%rip), %rcx     # 0x30046
movl $0x1c4, %edx            # imm = 0x1C4
callq 0x31c0
leaq 0x1b6df(%rip), %rdi     # 0x3013c
leaq 0x1a903(%rip), %rsi     # 0x2f367
leaq 0x1b5db(%rip), %rcx     # 0x30046
movl $0x1c6, %edx            # imm = 0x1C6
callq 0x31c0
leaq 0x1af42(%rip), %rdi     # 0x2f9be
leaq 0x1a8e4(%rip), %rsi     # 0x2f367
leaq 0x1b5bc(%rip), %rcx     # 0x30046
movl $0x1b9, %edx            # imm = 0x1B9
callq 0x31c0
leaq 0x1b5f9(%rip), %rdi     # 0x30094
leaq 0x1a8c5(%rip), %rsi     # 0x2f367
leaq 0x1b59d(%rip), %rcx     # 0x30046
movl $0x1ba, %edx            # imm = 0x1BA
callq 0x31c0
leaq 0x1b614(%rip), %rdi     # 0x300ce
leaq 0x1a8a6(%rip), %rsi     # 0x2f367
leaq 0x1b57e(%rip), %rcx     # 0x30046
movl $0x1bb, %edx            # imm = 0x1BB
callq 0x31c0
jmp 0x14af5
jmp 0x14ae2
jmp 0x14af5
jmp 0x14af5
jmp 0x14af5
jmp 0x14af5
jmp 0x14af5
jmp 0x14af5
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x7512
jmp 0x14af8
jmp 0x14af5
jmp 0x14af5
movq %rax, %r14
movq 0x8(%rsp), %rdi
callq 0x6b26
movq %r14, %rdi
callq 0x3490