// File: /workspace/github_cpp_makefile_star2_O3/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, 0x50(%rsp)
movslq %r8d, %rsi
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x8c20
movq (%r13), %rax
movq 0x8(%r13), %rcx
cmpq %rcx, %rax
je 0x270b2
movq 0x30(%rsp), %rdx
movl (%rax), %esi
movl %esi, %edi
negl %edi
cmovsl %esi, %edi
cmpl %r15d, %edi
jg 0x270a9
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 0x27086
testl %r15d, %r15d
jle 0x270d6
movq 0x30(%rsp), %rax
movl %r15d, %ecx
xorl %edx, %edx
cmpl $0x0, (%rax,%rdx,4)
jne 0x270ce
movl $0x1, (%rax,%rdx,4)
incq %rdx
cmpq %rdx, %rcx
jne 0x270c1
movq 0x8(%r12), %rax
movq 0x10(%r12), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
testl %ecx, %ecx
jle 0x2751d
movq 0x20(%r12), %rdx
movq 0x30(%rsp), %rsi
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
leaq 0x1246e(%rip), %r12     # 0x39574
movl -0x4(%rax,%rcx,4), %edi
decl %edi
cmpl $0x6, %edi
ja 0x2763b
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 0x2765a
cmpl $0x1, 0x4(%rdi)
jne 0x273d4
movl $0x1, (%rsi,%r9,4)
jmp 0x27513
leaq (%rcx,%rcx,2), %rdi
movq (%rdx,%rdi,8), %r10
movl (%r10), %r9d
movl %r9d, %edi
sarl %edi
movslq %edi, %rdi
cmpl $0x0, (%rsi,%rdi,4)
jne 0x27172
movl $0x1, (%rsi,%rdi,4)
movl (%r10), %r9d
movl 0x4(%r10), %r10d
movl %r10d, %r11d
xorl %r9d, %r11d
sarl %r9d
sarl %r10d
movslq %r9d, %rdi
movl (%rsi,%rdi,4), %edi
movslq %r10d, %r9
testb $0x1, %r11b
jne 0x273cb
cmpl $0x1, %edi
je 0x27142
jmp 0x273d4
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 0x27499
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 0x271e5
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 0x27202
cmpl $0x1, %edi
jne 0x2720b
jmp 0x27513
cmpl $0x2, %edi
je 0x27513
incq %r11
cmpq %r11, %r10
jne 0x271ca
jmp 0x27499
leaq (%rcx,%rcx,2), %rdi
movq (%rdx,%rdi,8), %r11
movq 0x8(%rdx,%rdi,8), %r12
movl (%r11), %r10d
movl 0x4(%r11), %r9d
subq %r11, %r12
shrq $0x2, %r12
cmpl $0x3, %r12d
jl 0x272a9
movq 0x30(%rsp), %r13
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
movl $0x2, %r14d
xorl %ebp, %ebp
movl (%r11,%r14,4), %ebx
cmpl $-0x1, %ebx
je 0x2728b
movl %ebx, %edi
sarl %edi
movslq %edi, %rdi
cmpl $0x0, (%r13,%rdi,4)
jne 0x2726f
andl $0x1, %ebx
incl %ebx
movl %ebx, (%r13,%rdi,4)
movl (%r11,%r14,4), %ebx
movl %ebx, %edi
sarl %edi
movslq %edi, %rdi
movl (%r13,%rdi,4), %edi
testb $0x1, %bl
jne 0x27299
cmpl $0x1, %edi
je 0x2729e
jmp 0x272a1
testb $0x1, %bpl
je 0x274e9
xorl %ebp, %ebp
jmp 0x272a1
cmpl $0x2, %edi
jne 0x272a1
movb $0x1, %bpl
incq %r14
cmpq %r14, %r12
jne 0x2724d
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 0x274fb
movl $0x1, (%rsi,%rdi,4)
jmp 0x2750c
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 0x2736a
movq 0x30(%rsp), %r12
andl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
movl $0x1, %r13d
xorl %ebp, %ebp
movl (%r10,%r13,4), %ebx
cmpl $-0x1, %ebx
je 0x2734c
movl %ebx, %edi
sarl %edi
movslq %edi, %r14
cmpl $0x0, (%r12,%r14,4)
jne 0x27331
andl $0x1, %ebx
incl %ebx
movl %ebx, (%r12,%r14,4)
movl (%r10,%r13,4), %ebx
movl %ebx, %edi
sarl %edi
movslq %edi, %rdi
movl (%r12,%rdi,4), %edi
testb $0x1, %bl
jne 0x2735a
cmpl $0x1, %edi
je 0x2735f
jmp 0x27362
testb $0x1, %bpl
je 0x27504
xorl %ebp, %ebp
jmp 0x27362
cmpl $0x2, %edi
jne 0x27362
movb $0x1, %bpl
incq %r13
cmpq %r13, %r11
jne 0x27311
movl $0x1, (%rsi,%r9,4)
jmp 0x2750c
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 0x273e1
cmpl $0x1, %edi
je 0x273ea
jmp 0x27513
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 0x27459
cmpl $0x2, %edi
je 0x27462
jmp 0x27513
cmpl $0x1, %edi
jne 0x27142
movl $0x2, (%rsi,%r9,4)
jmp 0x27513
cmpl $0x2, %edi
jne 0x27513
leaq (%rdx,%r10,8), %rdi
movq 0x8(%rdi), %r10
subq %r9, %r10
shrq $0x2, %r10
cmpl $0x3, %r10d
jl 0x27453
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 0x27425
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 0x27442
cmpl $0x1, %edi
jne 0x2744b
jmp 0x27513
cmpl $0x2, %edi
je 0x27513
incq %r11
cmpq %r11, %r10
jne 0x2740c
movl 0x4(%r9), %r9d
jmp 0x2749c
cmpl $0x1, %edi
jne 0x27513
movl 0x8(%r9), %r10d
movl %r10d, %edi
sarl %edi
movslq %edi, %rdi
movl (%rsi,%rdi,4), %edi
testb $0x1, %r10b
jne 0x274b3
cmpl $0x1, %edi
je 0x274b8
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 0x274e0
movl $0x1, (%rsi,%rdi,4)
jmp 0x27513
cmpl $0x2, %edi
jne 0x2747c
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 0x274aa
movl $0x2, (%rsi,%rdi,4)
jmp 0x27513
movl %r10d, %edi
sarl %edi
movslq %edi, %rdi
testb $0x1, %r10b
je 0x272d4
movl $0x2, (%rsi,%rdi,4)
jmp 0x2750c
movl $0x2, (%rsi,%r9,4)
leaq 0x12061(%rip), %r12     # 0x39574
cmpq $0x1, %r8
jg 0x27106
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl 0x2c(%rsp), %eax
testl %eax, %eax
jle 0x275e0
movl %eax, %r13d
xorl %ebp, %ebp
leaq 0x10(%rsp), %r15
leaq 0xc(%rsp), %r12
movq 0x30(%rsp), %rax
movl (%rax,%rbp,4), %eax
cmpl $0x1, %eax
je 0x2757c
cmpl $0x2, %eax
jne 0x2759c
movl %ebp, %eax
notl %eax
movl %eax, 0xc(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x275bc
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x275c7
incq %rbp
movl %ebp, 0xc(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
jne 0x275af
movq %r15, %rdi
movq %r12, %rdx
callq 0x1ffb8
jmp 0x275d7
incq %rbp
movl %ebp, 0xc(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x275cc
movl %ebp, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x275d7
movq %r15, %rdi
movq %r12, %rdx
callq 0x1ffb8
incq %rbp
jmp 0x275d7
movq %r15, %rdi
movq %r12, %rdx
callq 0x1ffb8
cmpq %r13, %rbp
jne 0x27549
leaq 0x10(%rsp), %rsi
movq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0x1f3de
movq 0x48(%rsp), %rax
movq %rax, 0x18(%rbx)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x27612
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x27629
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 0x1271f(%rip), %rdi     # 0x39d61
leaq 0x11f6d(%rip), %rsi     # 0x395b6
leaq 0x11fca(%rip), %rcx     # 0x3961a
movl $0x10b, %edx            # imm = 0x10B
callq 0x31b0
leaq 0x11fa7(%rip), %rdi     # 0x39608
leaq 0x11f4e(%rip), %rsi     # 0x395b6
leaq 0x11fab(%rip), %rcx     # 0x3961a
movl $0x68, %edx
callq 0x31b0
jmp 0x2767f
jmp 0x2767f
jmp 0x2767f
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x27699
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x276b0
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x34a0