// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
movq %rdi, %r8
movslq (%rsi), %r14
movq 0x18(%rdi), %rax
movq (%rax,%r14,8), %rbp
movq 0x8(%rbp), %rax
subq (%rbp), %rax
sarq $0x2, %rax
movabsq $-0x5555555555555555, %r10 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r10, %rax
cmpq $0x2, %rax
jb 0xa96d
movq 0x2c(%rbp), %r11
movq (%r8), %rax
movslq %r11d, %rcx
movq (%rax,%rcx,8), %rax
movq 0x20(%rax), %rax
movq %r11, %rcx
sarq $0x20, %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0xa9da
cmpb $0x1, 0xa4(%r8)
jne 0xa9bf
movq 0x5652(%rip), %r15      # 0xffd0
leaq 0x2489(%rip), %rsi      # 0xce0e
movl $0x8, %edx
movq %r15, %rdi
movq %r8, %rbx
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
movq %rbx, %r8
movb $0x1, 0x7c(%r8)
movl %r14d, 0x80(%r8)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbp), %rcx
cmpq %rcx, 0x8(%rbp)
je 0xab21
movq %r14, 0x18(%rsp)
movslq 0x20(%rbp), %rax
movq %rax, 0x28(%rsp)
movl 0x24(%rbp), %eax
movl %eax, 0x14(%rsp)
movq %r11, %rax
shrq $0x20, %rax
movq %rax, 0x40(%rsp)
movb 0x34(%rbp), %al
movb %al, 0xf(%rsp)
movb $0x1, %al
movl $0x8, %r15d
xorl %r14d, %r14d
movzbl 0x28(%rbp), %edx
andl $0x1, %edx
movl %edx, 0x10(%rsp)
movq %r8, 0x20(%rsp)
movq %rsi, 0x38(%rsp)
movq %r11, 0x30(%rsp)
movq -0x8(%rcx,%r15), %r13
movzbl (%rcx,%r15), %ebx
movl %ebx, %edx
andl $0x1, %edx
decl %edx
orl $0x1, %edx
movq (%r8), %rcx
movslq %r13d, %rdi
movq (%rcx,%rdi,8), %rdi
movq 0x20(%rdi), %r9
movq %r13, %rdi
sarq $0x20, %rdi
movl (%r9,%rdi,4), %edi
cmpl %edx, %edi
setne %dl
testl %edi, %edi
setne %dil
testb %dil, %dl
je 0xaa76
movb $0x1, %dl
jmp 0xaaed
movq %r13, %r12
shrq $0x20, %r12
cmpl %r11d, %r13d
jne 0xaa91
cmpl 0x40(%rsp), %r12d
jne 0xaa91
movb $0x1, %dl
cmpb 0xf(%rsp), %bl
je 0xaaed
movq 0x28(%rsp), %rax
movq (%rcx,%rax,8), %rdi
movl 0x14(%rsp), %edx
movl 0x10(%rsp), %ecx
callq 0x7660
movq 0x20(%rsp), %rax
movq (%rax), %rax
movslq %r13d, %rcx
movq (%rax,%rcx,8), %rdi
movzbl %bl, %ecx
andl $0x1, %ecx
movq 0x18(%rsp), %rsi
movl %r12d, %edx
callq 0x7604
movq 0x30(%rsp), %r11
movabsq $-0x5555555555555555, %r10 # imm = 0xAAAAAAAAAAAAAAAB
movq 0x38(%rsp), %rsi
movq 0x20(%rsp), %r8
movq %r13, 0x20(%rbp)
movb %bl, 0x28(%rbp)
xorl %edx, %edx
xorl %eax, %eax
testb %dl, %dl
je 0xab14
incq %r14
movq (%rbp), %rcx
movq 0x8(%rbp), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
imulq %r10, %rdx
addq $0xc, %r15
cmpq %r14, %rdx
ja 0xaa35
testb $0x1, %al
movq 0x18(%rsp), %r14
je 0xa9cb
movq 0x60(%r8), %r15
movl $0x18, %edi
movq %r8, %rbx
callq 0x2230
movl %r14d, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x2070
incq 0x70(%rbx)
jmp 0xa9cb