// File: akinanop[P]mvl-solver/src/Formula.cc
// Function: Formula::SwapPointer(VARRECORD*)
void Formula::SwapPointer ( VARRECORD * current ) {

	int clause_num = current->c_num;

    Clause* clause = CLAUSELIST[clause_num];

	Literal watched1 = clause -> WATCHED[0];
	Literal watched2 = clause -> WATCHED[1];

	bool unitClause = true;

	if ( clause->ATOM_LIST.size() > 1 && sat ( watched2 )  == 2 ) {

		// if watched2 unassigned, watched1 falsified

		for ( int i = 0; i < clause -> ATOM_LIST.size(); i++ ) {

			Literal literal = clause -> ATOM_LIST[i];

			if (  sat(literal) != 0 && literal != watched2  ) {

				VARLIST[watched1.VAR]->removeRecord(current, watched1.VAL, watched1.EQUAL);
				VARLIST[literal.VAR]->addRecord(clause_num, literal.VAL, literal.EQUAL);

				clause -> WATCHED[0] = literal;

				unitClause = false;
				break;
			}
		}
	} else {
		if ( LOG ) cout << "Conflict" << endl;
		CONFLICT = true;
		CONFLICTINGCLAUSE = clause_num;
		unitClause = false;
	}
	if (unitClause) {
		UNITLIST.push_front(clause_num);
	}
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
movq 0x90(%rsp), %rdi
movq %rdi, 0x8(%rsp)
movq 0x88(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x84(%rsp)
addq $0x18, %rdi
movslq 0x84(%rsp), %rsi
callq 0x12f20
movq (%rax), %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rax
movq 0x20(%rax), %rcx
movq %rcx, 0x6c(%rsp)
movl 0x28(%rax), %eax
movl %eax, 0x74(%rsp)
movq 0x78(%rsp), %rax
movq 0x2c(%rax), %rcx
movq %rcx, 0x60(%rsp)
movl 0x34(%rax), %eax
movl %eax, 0x68(%rsp)
movb $0x1, 0x5f(%rsp)
movq 0x78(%rsp), %rdi
callq 0xb890
cmpq $0x1, %rax
jbe 0x11a38
movq 0x8(%rsp), %rdi
movq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movl 0x68(%rsp), %eax
movl %eax, 0x58(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movl 0x58(%rsp), %eax
movl %eax, 0x48(%rsp)
movq 0x40(%rsp), %rsi
movzbl 0x48(%rsp), %edx
callq 0x109b0
cmpl $0x2, %eax
jne 0x11a38
movl $0x0, 0x3c(%rsp)
movslq 0x3c(%rsp), %rax
movq %rax, (%rsp)
movq 0x78(%rsp), %rdi
callq 0xb890
movq %rax, %rcx
movq (%rsp), %rax
cmpq %rcx, %rax
jae 0x11a36
movq 0x78(%rsp), %rdi
movslq 0x3c(%rsp), %rsi
callq 0xb8b0
movq 0x8(%rsp), %rdi
movq (%rax), %rcx
movq %rcx, 0x30(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x38(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x24(%rsp)
movl 0x38(%rsp), %eax
movl %eax, 0x2c(%rsp)
movq 0x24(%rsp), %rax
movq %rax, 0x14(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x1c(%rsp)
movq 0x14(%rsp), %rsi
movzbl 0x1c(%rsp), %edx
callq 0x109b0
cmpl $0x0, %eax
je 0x11a24
leaq 0x30(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x13e90
testb $0x1, %al
jne 0x119b1
jmp 0x11a24
movq 0x8(%rsp), %rdi
movslq 0x6c(%rsp), %rsi
callq 0xaab0
movq (%rax), %rdi
movq 0x88(%rsp), %rsi
movl 0x70(%rsp), %edx
movb 0x74(%rsp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0xcc20
movq 0x8(%rsp), %rdi
movslq 0x30(%rsp), %rsi
callq 0xaab0
movq (%rax), %rdi
movl 0x84(%rsp), %esi
movl 0x34(%rsp), %edx
movb 0x38(%rsp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0xcb10
movq 0x78(%rsp), %rax
movq 0x30(%rsp), %rcx
movq %rcx, 0x20(%rax)
movb 0x38(%rsp), %cl
movb %cl, 0x28(%rax)
movb $0x0, 0x5f(%rsp)
jmp 0x11a36
jmp 0x11a26
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x1191a
jmp 0x11a83
movq 0x8(%rsp), %rax
testb $0x1, 0xa4(%rax)
je 0x11a68
movq 0xc583(%rip), %rdi      # 0x1dfd0
leaq 0x630a(%rip), %rsi      # 0x17d5e
callq 0x2220
movq %rax, %rdi
movq 0xc55d(%rip), %rsi      # 0x1dfc0
callq 0x2260
movq 0x8(%rsp), %rax
movb $0x1, 0x7c(%rax)
movl 0x84(%rsp), %ecx
movl %ecx, 0x80(%rax)
movb $0x0, 0x5f(%rsp)
testb $0x1, 0x5f(%rsp)
je 0x11aa0
movq 0x8(%rsp), %rdi
addq $0x60, %rdi
leaq 0x84(%rsp), %rsi
callq 0x13ec0
addq $0x98, %rsp
retq
nopl (%rax,%rax)