// File: /workspace/github_cpp_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movslq (%rsi), %r14
movq 0x18(%rdi), %rax
movq (%rax,%r14,8), %r11
movq (%r11), %rax
movq 0x8(%r11), %rdx
movq %rdx, %rdi
subq %rax, %rdi
sarq $0x2, %rdi
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdi, %rcx
cmpq $0x2, %rcx
jb 0xac6d
movq 0x2c(%r11), %r8
movq (%rbx), %rdi
movslq %r8d, %r9
movq (%rdi,%r9,8), %r9
movq 0x20(%r9), %r9
movq %r8, %r10
sarq $0x20, %r10
cmpl $0x0, (%r9,%r10,4)
je 0xacd2
cmpb $0x1, 0xa4(%rbx)
jne 0xacb8
movq 0x6353(%rip), %r15      # 0x10fd0
leaq 0x318a(%rip), %rsi      # 0xde0e
movl $0x8, %edx
movq %r15, %rdi
callq 0x2270
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2180
movb $0x1, 0x7c(%rbx)
movl %r14d, 0x80(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r11, 0x10(%rsp)
movq %r14, 0x18(%rsp)
cmpq %rax, %rdx
je 0xad6a
movq 0x10(%rsp), %rdx
movslq 0x20(%rdx), %r9
movq %r9, 0x20(%rsp)
movl 0x24(%rdx), %r9d
movl %r9d, 0xc(%rsp)
movb 0x28(%rdx), %r10b
movq %r8, %r11
shrq $0x20, %r11
movb 0x34(%rdx), %r9b
addq $0x8, %rax
movq -0x8(%rax), %r12
movzbl (%rax), %ebp
movl %ebp, %r15d
andl $0x1, %r15d
decl %r15d
orl $0x1, %r15d
movslq %r12d, %r14
movq (%rdi,%r14,8), %rdx
movq 0x20(%rdx), %rdx
movq %r12, %r13
sarq $0x20, %r13
movl (%rdx,%r13,4), %edx
cmpl %r15d, %edx
setne %r15b
testl %edx, %edx
setne %dl
testb %dl, %r15b
jne 0xad61
movq %r12, %r15
shrq $0x20, %r15
cmpl %r8d, %r12d
jne 0xad94
cmpl %r11d, %r15d
jne 0xad94
cmpb %r9b, %bpl
jne 0xad94
addq $0xc, %rax
decq %rcx
jne 0xad0f
movq 0x60(%rbx), %r15
movl $0x18, %edi
callq 0x2230
movq 0x18(%rsp), %rcx
movl %ecx, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x2070
incq 0x70(%rbx)
jmp 0xacc3
shlq $0x3, %r14
movq 0x20(%rsp), %rax
movq (%rdi,%rax,8), %rdi
movzbl %r10b, %ecx
andl $0x1, %ecx
movl 0xc(%rsp), %edx
callq 0x75b2
movq (%rbx), %rax
movq (%rax,%r14), %rdi
movzbl %bpl, %ecx
andl $0x1, %ecx
movq 0x18(%rsp), %rsi
movl %r15d, %edx
callq 0x7558
movq 0x10(%rsp), %rax
movq %r12, 0x20(%rax)
movb %bpl, 0x28(%rax)
jmp 0xacc3