// File: /workspace/github_cpp_makefile_star2_O1/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
movl %r9d, 0x2c(%rsp)
movl %r8d, %r15d
movq %rcx, 0x48(%rsp)
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, %rbx
movslq %r8d, %rsi
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x8c32
movq (%r13), %rax
movq 0x8(%r13), %rcx
cmpq %rcx, %rax
je 0x27d8c
movq 0x30(%rsp), %rdx
movl (%rax), %esi
movl %esi, %edi
negl %edi
cmovsl %esi, %edi
cmpl %r15d, %edi
jg 0x27d83
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
cmpq %rcx, %rax
jne 0x27d60
testl %r15d, %r15d
jle 0x27db0
movq 0x30(%rsp), %rax
movl %r15d, %ecx
xorl %edx, %edx
cmpl $0x0, (%rax,%rdx,4)
jne 0x27da8
movl $0x1, (%rax,%rdx,4)
incq %rdx
cmpq %rdx, %rcx
jne 0x27d9b
movq %rbx, 0x50(%rsp)
movq 0x8(%r12), %rax
movq 0x10(%r12), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
testl %ecx, %ecx
jle 0x281f5
movq 0x20(%r12), %rdx
movq 0x30(%rsp), %rsi
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
leaq 0x126ef(%rip), %r12     # 0x3a4d4
movl -0x4(%rax,%rcx,4), %edi
decl %edi
cmpl $0x6, %edi
ja 0x28313
movq %rcx, %r8
decq %rcx
movslq (%r12,%rdi,4), %rdi
addq %r12, %rdi
jmpq *%rdi
leaq (%rcx,%rcx,2), %rdi
movq (%rdx,%rdi,8), %rdi
movslq (%rdi), %r9
cmpl %r15d, %r9d
jge 0x28332
cmpl $0x1, 0x4(%rdi)
jne 0x280ac
movl $0x1, (%rsi,%r9,4)
jmp 0x281eb
leaq (%rcx,%rcx,2), %rdi
movq (%rdx,%rdi,8), %r9
movl (%r9), %edi
sarl %edi
movslq %edi, %rdi
cmpl $0x0, (%rsi,%rdi,4)
jne 0x27e4b
movl $0x1, (%rsi,%rdi,4)
movl (%r9), %edi
movl 0x4(%r9), %r9d
movl %r9d, %r10d
xorl %edi, %r10d
sarl %edi
sarl %r9d
movslq %edi, %rdi
movl (%rsi,%rdi,4), %edi
movslq %r9d, %r9
testb $0x1, %r10b
jne 0x280a3
cmpl $0x1, %edi
je 0x27e21
jmp 0x280ac
leaq (%rcx,%rcx,2), %rdi
movq (%rdx,%rdi,8), %r9
movq 0x8(%rdx,%rdi,8), %r10
subq %r9, %r10
shrq $0x2, %r10
cmpl $0x2, %r10d
jl 0x28171
andl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
movl $0x1, %r11d
movl (%r9,%r11,4), %ebx
movl %ebx, %edi
sarl %edi
movslq %edi, %r14
cmpl $0x0, (%rsi,%r14,4)
jne 0x27ec0
andl $0x1, %ebx
incl %ebx
movl %ebx, (%rsi,%r14,4)
movl (%r9,%r11,4), %ebx
movl %ebx, %edi
sarl %edi
movslq %edi, %rdi
movl (%rsi,%rdi,4), %edi
testb $0x1, %bl
jne 0x27edd
cmpl $0x1, %edi
jne 0x27ee6
jmp 0x281eb
cmpl $0x2, %edi
je 0x281eb
incq %r11
cmpq %r11, %r10
jne 0x27ea5
jmp 0x28171
leaq (%rcx,%rcx,2), %rdi
movq (%rdx,%rdi,8), %r11
movq 0x8(%rdx,%rdi,8), %r14
movl (%r11), %r10d
movl 0x4(%r11), %r9d
subq %r11, %r14
shrq $0x2, %r14
cmpl $0x3, %r14d
jl 0x27f81
movq 0x30(%rsp), %r12
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
movl $0x2, %r13d
xorl %ebp, %ebp
movl (%r11,%r13,4), %ebx
cmpl $-0x1, %ebx
je 0x27f63
movl %ebx, %edi
sarl %edi
movslq %edi, %rdi
cmpl $0x0, (%r12,%rdi,4)
jne 0x27f48
andl $0x1, %ebx
incl %ebx
movl %ebx, (%r12,%rdi,4)
movl (%r11,%r13,4), %ebx
movl %ebx, %edi
sarl %edi
movslq %edi, %rdi
movl (%r12,%rdi,4), %edi
testb $0x1, %bl
jne 0x27f71
cmpl $0x1, %edi
je 0x27f76
jmp 0x27f79
testb $0x1, %bpl
je 0x281c1
xorl %ebp, %ebp
jmp 0x27f79
cmpl $0x2, %edi
jne 0x27f79
movb $0x1, %bpl
incq %r13
cmpq %r13, %r14
jne 0x27f28
movl %r10d, %edi
andl $0x1, %edi
sarl %r10d
movslq %r10d, %r10
movl $0x2, %r11d
subl %edi, %r11d
movl %r11d, (%rsi,%r10,4)
movl %r9d, %edi
sarl %edi
movslq %edi, %rdi
testb $0x1, %r9b
jne 0x281d3
movl $0x1, (%rsi,%rdi,4)
jmp 0x281e4
leaq (%rcx,%rcx,2), %rdi
movq (%rdx,%rdi,8), %r10
movq 0x8(%rdx,%rdi,8), %r11
movslq (%r10), %r9
subq %r10, %r11
shrq $0x2, %r11
cmpl $0x2, %r11d
jl 0x28042
movq 0x30(%rsp), %r14
andl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
movl $0x1, %r12d
xorl %ebp, %ebp
movl (%r10,%r12,4), %ebx
cmpl $-0x1, %ebx
je 0x28024
movl %ebx, %edi
sarl %edi
movslq %edi, %r13
cmpl $0x0, (%r14,%r13,4)
jne 0x28009
andl $0x1, %ebx
incl %ebx
movl %ebx, (%r14,%r13,4)
movl (%r10,%r12,4), %ebx
movl %ebx, %edi
sarl %edi
movslq %edi, %rdi
movl (%r14,%rdi,4), %edi
testb $0x1, %bl
jne 0x28032
cmpl $0x1, %edi
je 0x28037
jmp 0x2803a
testb $0x1, %bpl
je 0x281dc
xorl %ebp, %ebp
jmp 0x2803a
cmpl $0x2, %edi
jne 0x2803a
movb $0x1, %bpl
incq %r12
cmpq %r12, %r11
jne 0x27fe9
movl $0x1, (%rsi,%r9,4)
jmp 0x281e4
leaq (%rcx,%rcx,2), %r10
movq (%rdx,%r10,8), %r9
movl (%r9), %r11d
movl %r11d, %edi
sarl %edi
movslq %edi, %rdi
movl (%rsi,%rdi,4), %edi
testb $0x1, %r11b
jne 0x280b9
cmpl $0x1, %edi
je 0x280c2
jmp 0x281eb
leaq (%rcx,%rcx,2), %rdi
movq (%rdx,%rdi,8), %r9
movl (%r9), %r10d
movl %r10d, %edi
sarl %edi
movslq %edi, %rdi
movl (%rsi,%rdi,4), %edi
testb $0x1, %r10b
jne 0x28131
cmpl $0x2, %edi
je 0x2813a
jmp 0x281eb
cmpl $0x1, %edi
jne 0x27e21
movl $0x2, (%rsi,%r9,4)
jmp 0x281eb
cmpl $0x2, %edi
jne 0x281eb
leaq (%rdx,%r10,8), %rdi
movq 0x8(%rdi), %r10
subq %r9, %r10
shrq $0x2, %r10
cmpl $0x3, %r10d
jl 0x2812b
andl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
movl $0x2, %r11d
movl (%r9,%r11,4), %ebx
movl %ebx, %edi
sarl %edi
movslq %edi, %rdi
cmpl $0x0, (%rsi,%rdi,4)
jne 0x280fd
andl $0x1, %ebx
incl %ebx
movl %ebx, (%rsi,%rdi,4)
movl (%r9,%r11,4), %ebx
movl %ebx, %edi
sarl %edi
movslq %edi, %rdi
movl (%rsi,%rdi,4), %edi
testb $0x1, %bl
jne 0x2811a
cmpl $0x1, %edi
jne 0x28123
jmp 0x281eb
cmpl $0x2, %edi
je 0x281eb
incq %r11
cmpq %r11, %r10
jne 0x280e4
movl 0x4(%r9), %r9d
jmp 0x28174
cmpl $0x1, %edi
jne 0x281eb
movl 0x8(%r9), %r10d
movl %r10d, %edi
sarl %edi
movslq %edi, %rdi
movl (%rsi,%rdi,4), %edi
testb $0x1, %r10b
jne 0x2818b
cmpl $0x1, %edi
je 0x28190
movl 0x4(%r9), %edi
movl %edi, %r10d
andl $0x1, %r10d
sarl %edi
movslq %edi, %rdi
movl $0x2, %r11d
subl %r10d, %r11d
movl %r11d, (%rsi,%rdi,4)
movl (%r9), %r9d
movl %r9d, %edi
sarl %edi
movslq %edi, %rdi
testb $0x1, %r9b
jne 0x281b8
movl $0x1, (%rsi,%rdi,4)
jmp 0x281eb
cmpl $0x2, %edi
jne 0x28154
movl 0x4(%r9), %edi
movl %edi, %r10d
andl $0x1, %r10d
sarl %edi
movslq %edi, %rdi
incl %r10d
movl %r10d, (%rsi,%rdi,4)
movl (%r9), %r9d
movl %r9d, %edi
sarl %edi
movslq %edi, %rdi
testb $0x1, %r9b
jne 0x28182
movl $0x2, (%rsi,%rdi,4)
jmp 0x281eb
movl %r10d, %edi
sarl %edi
movslq %edi, %rdi
testb $0x1, %r10b
je 0x27fac
movl $0x2, (%rsi,%rdi,4)
jmp 0x281e4
movl $0x2, (%rsi,%r9,4)
leaq 0x122e9(%rip), %r12     # 0x3a4d4
cmpq $0x1, %r8
jg 0x27de5
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl 0x2c(%rsp), %eax
testl %eax, %eax
jle 0x282b8
movl %eax, %r13d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r14d, %r14d
leaq 0x10(%rsp), %r15
leaq 0xc(%rsp), %r12
movq 0x30(%rsp), %rax
movl (%rax,%r14,4), %eax
cmpl $0x1, %eax
je 0x2824e
cmpl $0x2, %eax
jne 0x2826f
movl %ebp, 0xc(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x2829e
movl %ebp, (%rsi)
jmp 0x28289
leal 0x1(%r14), %eax
movl %eax, 0xc(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
jne 0x28283
movq %r15, %rdi
movq %r12, %rdx
callq 0x20b8a
jmp 0x28292
leal 0x1(%r14), %eax
movl %eax, 0xc(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x282ab
leal 0x1(%r14), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
incq %r14
decl %ebp
cmpq %r14, %r13
jne 0x28227
jmp 0x282b8
movq %r15, %rdi
movq %r12, %rdx
callq 0x20b8a
jmp 0x28292
movq %r15, %rdi
movq %r12, %rdx
callq 0x20b8a
jmp 0x28292
leaq 0x10(%rsp), %rsi
movq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0x1ffa6
movq 0x48(%rsp), %rax
movq %rax, 0x18(%rbx)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x282ea
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x28301
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12933(%rip), %rdi     # 0x3ac4d
leaq 0x121f5(%rip), %rsi     # 0x3a516
leaq 0x12252(%rip), %rcx     # 0x3a57a
movl $0x10b, %edx            # imm = 0x10B
callq 0x31b0
leaq 0x1222f(%rip), %rdi     # 0x3a568
leaq 0x121d6(%rip), %rsi     # 0x3a516
leaq 0x12233(%rip), %rcx     # 0x3a57a
movl $0x68, %edx
callq 0x31b0
jmp 0x28357
jmp 0x28357
jmp 0x28357
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x28371
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x28388
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x34a0