// File: akinanop[P]mvl-solver/src/Formula.cc
// Function: Formula::satisfyClauses(int, bool, int)
inline void Formula::satisfyClauses ( int var, bool equals, int val ) {

	int lit_var = -1;
	bool lit_equal = false;
	int lit_val = -1;

	vector<int>::iterator current;
	vector<int>::iterator end;

	// Get clauses where the literal appears:
	if ( equals ) current = VARLIST[var] -> ATOMRECPOS[val].begin();
	else current = VARLIST[var] -> ATOMRECNEG[val].begin();
	if ( equals ) end = VARLIST[var] -> ATOMRECPOS[val].end();
	else end = VARLIST[var] -> ATOMRECNEG[val].end();

	while ( current != end ) {

		// For every clause that contains this literal, satisfy it

		if ( CLAUSELIST[*current] -> LEVEL == -1 ) {

			CLAUSELIST[*current]->LEVEL = LEVEL;
			CLAUSELIST[*current]->NumUnAss = 0;

			// and update the counts for other unassigned literals in the clause (corresponds to deleting the clause from the theory)

			if (heuristic==Heuristic::BK) {
				for (int i = 0; i < CLAUSELIST[*current]->ATOM_LIST.size(); i++) {

					lit_var = CLAUSELIST[*current]->ATOM_LIST[i].VAR;
					lit_equal = CLAUSELIST[*current]->ATOM_LIST[i].EQUAL;
					lit_val = CLAUSELIST[*current]->ATOM_LIST[i].VAL;

					if (VARLIST[lit_var]->ATOMASSIGN[lit_val] == 0) {

						if (lit_equal)
							VARLIST[lit_var]->ATOMCNTPOS[lit_val]--;
						else
							VARLIST[lit_var]->ATOMCNTNEG[lit_val]--;

					}
				}
			}
		}
		++current;
	}
}

// Assembly:
subq $0xa8, %rsp
movb %dl, %al
movq %rdi, 0xa0(%rsp)
movl %esi, 0x9c(%rsp)
andb $0x1, %al
movb %al, 0x9b(%rsp)
movl %ecx, 0x94(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x48(%rsp)
movl $0xffffffff, 0x90(%rsp) # imm = 0xFFFFFFFF
movb $0x0, 0x8f(%rsp)
movl $0xffffffff, 0x88(%rsp) # imm = 0xFFFFFFFF
leaq 0x80(%rsp), %rdi
callq 0x14580
leaq 0x78(%rsp), %rdi
callq 0x14580
testb $0x1, 0x9b(%rsp)
je 0x13095
movq 0x48(%rsp), %rdi
movslq 0x9c(%rsp), %rsi
callq 0xaab0
movq (%rax), %rax
movq 0x60(%rax), %rdi
movslq 0x94(%rsp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x79c0
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x80(%rsp)
jmp 0x130d4
movq 0x48(%rsp), %rdi
movslq 0x9c(%rsp), %rsi
callq 0xaab0
movq (%rax), %rax
movq 0x68(%rax), %rdi
movslq 0x94(%rsp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x79c0
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x80(%rsp)
testb $0x1, 0x9b(%rsp)
je 0x1311c
movq 0x48(%rsp), %rdi
movslq 0x9c(%rsp), %rsi
callq 0xaab0
movq (%rax), %rax
movq 0x60(%rax), %rdi
movslq 0x94(%rsp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x7840
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x78(%rsp)
jmp 0x13158
movq 0x48(%rsp), %rdi
movslq 0x9c(%rsp), %rsi
callq 0xaab0
movq (%rax), %rax
movq 0x68(%rax), %rdi
movslq 0x94(%rsp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x7840
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x78(%rsp)
jmp 0x1315a
leaq 0x80(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x145a0
testb $0x1, %al
jne 0x13175
jmp 0x133f4
movq 0x48(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x40(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x145e0
movq 0x40(%rsp), %rdi
movslq (%rax), %rsi
callq 0x12f20
movq (%rax), %rax
cmpl $-0x1, 0x1c(%rax)
jne 0x133e2
movq 0x48(%rsp), %rax
movl 0x48(%rax), %ecx
movl %ecx, 0x34(%rsp)
addq $0x18, %rax
movq %rax, 0x28(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x145e0
movq 0x28(%rsp), %rdi
movslq (%rax), %rsi
callq 0x12f20
movl 0x34(%rsp), %edx
movq %rax, %rcx
movq 0x48(%rsp), %rax
movq (%rcx), %rcx
movl %edx, 0x1c(%rcx)
addq $0x18, %rax
movq %rax, 0x38(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x145e0
movq 0x38(%rsp), %rdi
movslq (%rax), %rsi
callq 0x12f20
movq %rax, %rcx
movq 0x48(%rsp), %rax
movq (%rcx), %rcx
movl $0x0, 0x18(%rcx)
cmpl $0x0, 0xa8(%rax)
jne 0x133e0
movl $0x0, 0x54(%rsp)
movq 0x48(%rsp), %rax
movslq 0x54(%rsp), %rcx
movq %rcx, 0x20(%rsp)
addq $0x18, %rax
movq %rax, 0x18(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x145e0
movq 0x18(%rsp), %rdi
movslq (%rax), %rsi
callq 0x12f20
movq (%rax), %rdi
callq 0xb890
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0x133de
movq 0x48(%rsp), %rax
addq $0x18, %rax
movq %rax, (%rsp)
leaq 0x80(%rsp), %rdi
callq 0x145e0
movq (%rsp), %rdi
movslq (%rax), %rsi
callq 0x12f20
movq (%rax), %rdi
movslq 0x54(%rsp), %rsi
callq 0xb8b0
movq %rax, %rcx
movq 0x48(%rsp), %rax
movl (%rcx), %ecx
movl %ecx, 0x90(%rsp)
addq $0x18, %rax
movq %rax, 0x8(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x145e0
movq 0x8(%rsp), %rdi
movslq (%rax), %rsi
callq 0x12f20
movq (%rax), %rdi
movslq 0x54(%rsp), %rsi
callq 0xb8b0
movq %rax, %rcx
movq 0x48(%rsp), %rax
movb 0x8(%rcx), %cl
andb $0x1, %cl
movb %cl, 0x8f(%rsp)
addq $0x18, %rax
movq %rax, 0x10(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x145e0
movq 0x10(%rsp), %rdi
movslq (%rax), %rsi
callq 0x12f20
movq (%rax), %rdi
movslq 0x54(%rsp), %rsi
callq 0xb8b0
movq 0x48(%rsp), %rdi
movl 0x4(%rax), %eax
movl %eax, 0x88(%rsp)
movslq 0x90(%rsp), %rsi
callq 0xaab0
movq (%rax), %rax
movq 0x20(%rax), %rax
movslq 0x88(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x133cc
testb $0x1, 0x8f(%rsp)
je 0x133a0
movq 0x48(%rsp), %rdi
movslq 0x90(%rsp), %rsi
callq 0xaab0
movq (%rax), %rax
movq 0x28(%rax), %rax
movslq 0x88(%rsp), %rcx
movl (%rax,%rcx,4), %edx
addl $-0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x133ca
movq 0x48(%rsp), %rdi
movslq 0x90(%rsp), %rsi
callq 0xaab0
movq (%rax), %rax
movq 0x30(%rax), %rax
movslq 0x88(%rsp), %rcx
movl (%rax,%rcx,4), %edx
addl $-0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x133cc
jmp 0x133ce
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x13235
jmp 0x133e0
jmp 0x133e2
leaq 0x80(%rsp), %rdi
callq 0x145f0
jmp 0x1315a
addq $0xa8, %rsp
retq
nopl (%rax)