// File: /workspace/github_cpp_makefile_star2_O2/Laakeri[P]maxpre/src/trace.cpp
// Function: maxPreprocessor::Trace::getSolution(std::vector<int, std::allocator<int>> const&, unsigned long, int, int)
pair<vector<int>, uint64_t> Trace::getSolution(const vector<int>& trueLits, uint64_t weight, int vars, int originalVars) {
	vector<int> value(vars);
	for (int lit : trueLits) {
		if (abs(lit) <= vars) {
			if (lit < 0) value[(-lit) - 1] = VAR_FALSE;
			else value[lit - 1] = VAR_TRUE;
		}
	}
	
	for (int i = 0; i < vars; i++) {
		if (value[i] == VAR_UNDEFINED) {
			value[i] = VAR_TRUE;
		}
	}
	
	for (int i = (int)operations.size() -1; i >= 0; i--) {
		if (operations[i] == 1) {
			assert(data[i][0] < vars);
			
			if (data[i][1] == true) {
				value[data[i][0]] = VAR_TRUE;
			}
			else {
				value[data[i][0]] = VAR_FALSE;
			}
		}
		else if(operations[i] == 2) {
			int var = data[i][0];
			bool f = false;
			bool ff = false;
			for (int j = 1; j < (int)data[i].size(); j++) {
				if (data[i][j] == -1) {
					if (!f) {
						value[var] = VAR_FALSE;
						ff = true;
						break;
					}
					f = false;
				}
				else {
					if (value[litVariable(data[i][j])] == VAR_UNDEFINED) {
						if (litValue(data[i][j]) == true) value[litVariable(data[i][j])] = VAR_TRUE;
						else value[litVariable(data[i][j])] = VAR_FALSE;
					}
					if ((litValue(data[i][j]) == true && value[litVariable(data[i][j])] == VAR_TRUE) || 
						(litValue(data[i][j]) == false && value[litVariable(data[i][j])] == VAR_FALSE)) {
						f = true;
					}
				}
			}
			if (!ff) value[var] = VAR_TRUE;
		}
		else if(operations[i] == 3) {
			bool sat = false;
			for (int j = 1; j < (int)data[i].size(); j++) {
				if (value[litVariable(data[i][j])] == VAR_UNDEFINED) {
					if (litValue(data[i][j]) == true) value[litVariable(data[i][j])] = VAR_TRUE;
					else value[litVariable(data[i][j])] = VAR_FALSE;
				}
				if ((litValue(data[i][j]) == true && value[litVariable(data[i][j])] == VAR_TRUE) || 
					(litValue(data[i][j]) == false && value[litVariable(data[i][j])] == VAR_FALSE)) {
					sat = true;
					break;
				}
			}
			if (!sat) {
				if (litValue(data[i][0]) == false) value[litVariable(data[i][0])] = VAR_FALSE;
				else value[litVariable(data[i][0])] = VAR_TRUE;
			}
		}
		else if(operations[i] == 4) {
			bool f = false;
			bool ff = false;
			int lbl1 = data[i][0];
			int lbl2 = data[i][1];
			for (int j = 2; j < (int)data[i].size(); j++) {
				if (data[i][j] == -1) {
					if (!f) {
						if (litValue(lbl1) == true) value[litVariable(lbl1)] = VAR_TRUE;
						else value[litVariable(lbl1)] = VAR_FALSE;
						ff = true;
						break;
					}
					f = false;
				}
				else {
					if (value[litVariable(data[i][j])] == VAR_UNDEFINED) {
						if (litValue(data[i][j]) == true) value[litVariable(data[i][j])] = VAR_TRUE;
						else value[litVariable(data[i][j])] = VAR_FALSE;
					}
					if ((litValue(data[i][j]) == true && value[litVariable(data[i][j])] == VAR_TRUE) || 
						(litValue(data[i][j]) == false && value[litVariable(data[i][j])] == VAR_FALSE)) {
						f = true;
					}
				}
			}
			if (!ff) {
				if (litValue(lbl1) == true) value[litVariable(lbl1)] = VAR_FALSE;
				else value[litVariable(lbl1)] = VAR_TRUE;
				if (litValue(lbl2)== true) value[litVariable(lbl2)] = VAR_TRUE;
				else value[litVariable(lbl2)] = VAR_FALSE;
			}
		}
		else if(operations[i] == 5) {
			if (value[litVariable(data[i][0])] == VAR_UNDEFINED) {
				value[litVariable(data[i][0])] = VAR_TRUE;
			}
			if (litValue(data[i][0]) != litValue(data[i][1])) {
				if (value[litVariable(data[i][0])] == VAR_TRUE) {
					value[litVariable(data[i][1])] = VAR_FALSE;
				}
				else {
					value[litVariable(data[i][1])] = VAR_TRUE;
				}
			}
			else {
				if (value[litVariable(data[i][0])] == VAR_TRUE) {
					value[litVariable(data[i][1])] = VAR_TRUE;
				}
				else {
					value[litVariable(data[i][1])] = VAR_FALSE;
				}
			}
		}
		else if(operations[i] == 6) {
			if ((litValue(data[i][0]) == true && value[litVariable(data[i][0])] == VAR_TRUE) ||
				(litValue(data[i][0]) == false && value[litVariable(data[i][0])] == VAR_FALSE)) {
				bool sat = false;
				for (int j = 2; j < (int)data[i].size(); j++) {
					if (value[litVariable(data[i][j])] == VAR_UNDEFINED) {
						if (litValue(data[i][j]) == true) value[litVariable(data[i][j])] = VAR_TRUE;
						else value[litVariable(data[i][j])] = VAR_FALSE;
					}
					if ((litValue(data[i][j]) == true && value[litVariable(data[i][j])] == VAR_TRUE) || 
						(litValue(data[i][j]) == false && value[litVariable(data[i][j])] == VAR_FALSE)) {
						sat = true;
						break;
					}
				}
				if (!sat) {
					if (litValue(data[i][1]) == false) value[litVariable(data[i][1])] = VAR_FALSE;
					else value[litVariable(data[i][1])] = VAR_TRUE;
				}
			}
		}
		else if(operations[i] == 7) {
			if ((litValue(data[i][0]) == true && value[litVariable(data[i][0])] == VAR_FALSE) ||
				(litValue(data[i][0]) == false && value[litVariable(data[i][0])] == VAR_TRUE)) {
				if ((litValue(data[i][2]) == true && value[litVariable(data[i][2])] == VAR_TRUE) ||
				(litValue(data[i][2]) == false && value[litVariable(data[i][2])] == VAR_FALSE)) {
					if (litValue(data[i][1]) == false) {
						value[litVariable(data[i][1])] = VAR_FALSE;
					}
					else {
						value[litVariable(data[i][1])] = VAR_TRUE;
					}
					if (litValue(data[i][0]) == false) {
						value[litVariable(data[i][0])] = VAR_TRUE;
					}
					else {
						value[litVariable(data[i][0])] = VAR_FALSE;
					}
				}
				else {
					if (litValue(data[i][1]) == false) {
						value[litVariable(data[i][1])] = VAR_TRUE;
					}
					else {
						value[litVariable(data[i][1])] = VAR_FALSE;
					}
					if (litValue(data[i][0]) == false) {
						value[litVariable(data[i][0])] = VAR_FALSE;
					}
					else {
						value[litVariable(data[i][0])] = VAR_TRUE;
					}
				}
			}
		}
		else {
			assert(0);
		}
	}
	
	vector<int> retLit;
	for (int i = 0; i < originalVars; i++) {
		if (value[i] == VAR_FALSE) {
			retLit.push_back(-(i + 1));
		}
		else if(value[i] == VAR_TRUE) {
			retLit.push_back(i + 1);
		}
		else {
			retLit.push_back(i + 1);
		}
	}
	return {retLit, weight};
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, 0x38(%rsp)
movl %r8d, %ebp
movq %rcx, 0x28(%rsp)
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, 0x30(%rsp)
movslq %r8d, %rsi
leaq 0x10(%rsp), %r14
leaq 0x40(%rsp), %rdx
movq %r14, %rdi
callq 0x6852
movq (%r13), %rax
movq 0x8(%r13), %rcx
movq (%r14), %rdx
cmpq %rcx, %rax
je 0x2085f
movl (%rax), %esi
movl %esi, %edi
negl %edi
cmovsl %esi, %edi
cmpl %ebp, %edi
jg 0x20859
movl %esi, %edi
sarl $0x1f, %edi
xorl %esi, %edi
shrl $0x1f, %esi
leaq (%rdx,%rsi,4), %r8
incl %esi
movl %esi, -0x4(%r8,%rdi,4)
addq $0x4, %rax
jmp 0x20832
movq 0x10(%rsp), %rax
xorl %ecx, %ecx
testl %ebp, %ebp
movl $0x0, %edx
cmovgl %ebp, %edx
cmpq %rcx, %rdx
je 0x20887
cmpl $0x0, (%rax,%rcx,4)
jne 0x20882
movl $0x1, (%rax,%rcx,4)
incq %rcx
jmp 0x20870
movq 0x8(%r12), %rax
movq 0x10(%r12), %rsi
subq %rax, %rsi
shrq $0x2, %rsi
movq 0x20(%r12), %rcx
movq 0x10(%rsp), %rdx
movl %esi, %esi
leaq 0xfc49(%rip), %rdi      # 0x304f4
testl %esi, %esi
jle 0x20ced
movl -0x4(%rax,%rsi,4), %r8d
decl %r8d
cmpl $0x6, %r8d
ja 0x20daf
decq %rsi
movslq (%rdi,%r8,4), %r8
addq %rdi, %r8
jmpq *%r8
imulq $0x18, %rsi, %r8
movq (%rcx,%r8), %r9
movslq (%r9), %r8
cmpl %ebp, %r8d
jge 0x20dce
cmpl $0x1, 0x4(%r9)
je 0x20caa
movl $0x2, (%rdx,%r8,4)
jmp 0x208ab
imulq $0x18, %rsi, %r8
movq (%rcx,%r8), %r8
movl (%r8), %r9d
movl %r9d, %r10d
sarl %r10d
movslq %r10d, %r10
cmpl $0x0, (%rdx,%r10,4)
jne 0x20921
movl $0x1, (%rdx,%r10,4)
movl (%r8), %r9d
movl 0x4(%r8), %r10d
movl %r10d, %r11d
xorl %r9d, %r11d
sarl %r9d
sarl %r10d
movslq %r9d, %r8
movl (%rdx,%r8,4), %r8d
movslq %r10d, %r9
testb $0x1, %r11b
jne 0x20b96
cmpl $0x1, %r8d
jne 0x20ba0
movl $0x1, (%rdx,%r9,4)
jmp 0x208ab
imulq $0x18, %rsi, %r8
movq (%rcx,%r8), %r9
movq 0x8(%rcx,%r8), %r8
subq %r9, %r8
movq 0x10(%rsp), %r10
shrq $0x2, %r8
movslq %r8d, %r11
pushq $0x1
popq %rbx
cmpq %r11, %rbx
jge 0x20c6c
movl (%r9,%rbx,4), %r8d
movl %r8d, %r14d
sarl %r14d
movslq %r14d, %r14
cmpl $0x0, (%r10,%r14,4)
jne 0x209a3
andl $0x1, %r8d
incl %r8d
movl %r8d, (%r10,%r14,4)
movl (%r9,%rbx,4), %r14d
movl %r14d, %r8d
sarl %r8d
movslq %r8d, %r8
movl (%r10,%r8,4), %r8d
testb $0x1, %r14b
jne 0x209c5
cmpl $0x1, %r8d
jne 0x209cf
jmp 0x208ab
cmpl $0x2, %r8d
je 0x208ab
incq %rbx
jmp 0x2097b
imulq $0x18, %rsi, %r8
movq (%rcx,%r8), %r12
movq 0x8(%rcx,%r8), %r8
movl (%r12), %r14d
movl 0x4(%r12), %r11d
subq %r12, %r8
movq 0x10(%rsp), %r13
shrq $0x2, %r8
movslq %r8d, %r10
xorl %ebx, %ebx
pushq $0x2
popq %r9
cmpq %r10, %r9
jge 0x20b59
movl (%r12,%r9,4), %r8d
cmpl $-0x1, %r8d
je 0x20a4f
movl %r8d, %r15d
sarl %r15d
movslq %r15d, %r15
cmpl $0x0, (%r13,%r15,4)
jne 0x20a2f
andl $0x1, %r8d
incl %r8d
movl %r8d, (%r13,%r15,4)
movl (%r12,%r9,4), %r15d
movl %r15d, %r8d
sarl %r8d
movslq %r8d, %r8
movl (%r13,%r8,4), %r8d
testb $0x1, %r15b
jne 0x20a5c
cmpl $0x1, %r8d
je 0x20a62
jmp 0x20a64
testb $0x1, %bl
je 0x20c71
xorl %ebx, %ebx
jmp 0x20a64
cmpl $0x2, %r8d
jne 0x20a64
movb $0x1, %bl
incq %r9
jmp 0x209ff
imulq $0x18, %rsi, %r8
movq (%rcx,%r8), %r14
movq 0x8(%rcx,%r8), %r8
movslq (%r14), %r11
subq %r14, %r8
movq 0x10(%rsp), %r12
shrq $0x2, %r8
movslq %r8d, %r13
xorl %r9d, %r9d
pushq $0x1
popq %r10
cmpq %r13, %r10
jge 0x20b89
movl (%r14,%r10,4), %r8d
cmpl $-0x1, %r8d
je 0x20ada
movl %r8d, %ebx
sarl %ebx
movslq %ebx, %rbx
cmpl $0x0, (%r12,%rbx,4)
jne 0x20abc
andl $0x1, %r8d
incl %r8d
movl %r8d, (%r12,%rbx,4)
movl (%r14,%r10,4), %ebx
movl %ebx, %r8d
sarl %r8d
movslq %r8d, %r8
movl (%r12,%r8,4), %r8d
testb $0x1, %bl
jne 0x20ae9
cmpl $0x1, %r8d
je 0x20aef
jmp 0x20af2
testb $0x1, %r9b
je 0x20c86
xorl %r9d, %r9d
jmp 0x20af2
cmpl $0x2, %r8d
jne 0x20af2
movb $0x1, %r9b
incq %r10
jmp 0x20a8f
imulq $0x18, %rsi, %r9
movq (%rcx,%r9), %r11
movl (%r11), %r10d
movl %r10d, %r8d
sarl %r8d
movslq %r8d, %r8
movl (%rdx,%r8,4), %r8d
testb $0x1, %r10b
jne 0x20bad
cmpl $0x1, %r8d
jne 0x208ab
jmp 0x20bb7
imulq $0x18, %rsi, %r8
movq (%rcx,%r8), %r9
movl (%r9), %r10d
movl %r10d, %r8d
sarl %r8d
movslq %r8d, %r8
movl (%rdx,%r8,4), %r8d
testb $0x1, %r10b
jne 0x20c29
cmpl $0x2, %r8d
jne 0x208ab
jmp 0x20c33
movl %r14d, %r8d
andl $0x1, %r8d
sarl %r14d
movslq %r14d, %r9
pushq $0x2
popq %r10
subl %r8d, %r10d
movl %r10d, (%rdx,%r9,4)
movl %r11d, %r8d
sarl %r8d
movslq %r8d, %r8
testb $0x1, %r11b
jne 0x208f1
jmp 0x20caa
movl $0x1, (%rdx,%r11,4)
jmp 0x208ab
cmpl $0x1, %r8d
jne 0x2094f
movl $0x2, (%rdx,%r9,4)
jmp 0x208ab
cmpl $0x2, %r8d
jne 0x208ab
addq %rcx, %r9
movq 0x8(%r9), %r8
subq %r11, %r8
movq 0x10(%rsp), %r9
shrq $0x2, %r8
movslq %r8d, %r10
pushq $0x2
popq %rbx
cmpq %r10, %rbx
jge 0x20c93
movl (%r11,%rbx,4), %r8d
movl %r8d, %r14d
sarl %r14d
movslq %r14d, %r14
cmpl $0x0, (%r9,%r14,4)
jne 0x20bf8
andl $0x1, %r8d
incl %r8d
movl %r8d, (%r9,%r14,4)
movl (%r11,%rbx,4), %r14d
movl %r14d, %r8d
sarl %r8d
movslq %r8d, %r8
movl (%r9,%r8,4), %r8d
testb $0x1, %r14b
jne 0x20c1a
cmpl $0x1, %r8d
jne 0x20c24
jmp 0x208ab
cmpl $0x2, %r8d
je 0x208ab
incq %rbx
jmp 0x20bd0
cmpl $0x1, %r8d
jne 0x208ab
movl 0x8(%r9), %r10d
movl %r10d, %r8d
sarl %r8d
movslq %r8d, %r8
movl (%rdx,%r8,4), %r8d
testb $0x1, %r10b
jne 0x20cb7
cmpl $0x1, %r8d
je 0x20cbd
movl 0x4(%r9), %r8d
movl %r8d, %r10d
andl $0x1, %r10d
sarl %r8d
movslq %r8d, %r8
pushq $0x2
popq %r11
subl %r10d, %r11d
movl %r11d, (%rdx,%r8,4)
movl (%r9), %r9d
jmp 0x20c97
movl %r14d, %r8d
sarl %r8d
movslq %r8d, %r8
testb $0x1, %r14b
jne 0x208f1
jmp 0x20caa
movl $0x2, (%rdx,%r11,4)
jmp 0x208ab
movl 0x4(%r11), %r9d
movl %r9d, %r8d
sarl %r8d
movslq %r8d, %r8
testb $0x1, %r9b
jne 0x208f1
movl $0x1, (%rdx,%r8,4)
jmp 0x208ab
cmpl $0x2, %r8d
jne 0x20c50
movl 0x4(%r9), %r8d
movl %r8d, %r10d
andl $0x1, %r10d
sarl %r8d
movslq %r8d, %r8
incl %r10d
movl %r10d, (%rdx,%r8,4)
movl (%r9), %r9d
movl %r9d, %r8d
sarl %r8d
movslq %r8d, %r8
testb $0x1, %r9b
je 0x208f1
jmp 0x20caa
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %r12
movaps %xmm0, (%r12)
andq $0x0, 0x10(%r12)
xorl %r14d, %r14d
movq 0x38(%rsp), %rbx
testl %ebx, %ebx
cmovlel %r14d, %ebx
leaq 0xc(%rsp), %r13
cmpq %rbx, %r14
je 0x20d6e
movq 0x10(%rsp), %rax
movl (%rax,%r14,4), %eax
cmpl $0x1, %eax
je 0x20d44
cmpl $0x2, %eax
jne 0x20d59
movl %r14d, %eax
notl %eax
movl %eax, 0xc(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x19ed4
incq %r14
jmp 0x20d13
incq %r14
movl %r14d, 0xc(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x19ed4
jmp 0x20d13
incq %r14
movl %r14d, 0xc(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x19ed4
jmp 0x20d13
leaq 0x40(%rsp), %rsi
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
callq 0x19284
movq 0x28(%rsp), %rax
movq %rax, 0x18(%rbx)
leaq 0x40(%rsp), %rdi
callq 0x7512
leaq 0x10(%rsp), %rdi
callq 0x7512
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xff0f(%rip), %rdi      # 0x30cc5
leaq 0xf779(%rip), %rsi      # 0x30536
leaq 0xf7d6(%rip), %rcx      # 0x3059a
movl $0x10b, %edx            # imm = 0x10B
callq 0x31c0
leaq 0xf7b3(%rip), %rdi      # 0x30588
leaq 0xf75a(%rip), %rsi      # 0x30536
leaq 0xf7b7(%rip), %rcx      # 0x3059a
pushq $0x68
popq %rdx
callq 0x31c0
jmp 0x20df1
jmp 0x20df1
jmp 0x20df1
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x7512
leaq 0x10(%rsp), %rdi
callq 0x7512
movq %rbx, %rdi
callq 0x3490