// File: akinanop[P]mvl-solver/src/Formula.cc
// Function: Formula::watchedUndoTheory(int)
void Formula::watchedUndoTheory ( int level ) { // FIXME  fixed ?

	for ( unsigned int  i = 1; i < VARLIST.size(); i++ ) {

		for ( int j = 0; j < VARLIST[i] -> DOMAINSIZE; j++ ) {
			//if this domain has been assigned at level this or greater undo
			if ( VARLIST[i]->ATOMLEVEL[j] > level ) {

				// cout << "unassign " << i << " " << j <<endl;
				VARLIST[i] -> VAL = -1;
				VARLIST[i]->ATOMASSIGN[j] = 0;
				VARLIST[i]->ATOMLEVEL[j] = -10;
				VARLIST[i]->CLAUSEID[j] = -10;

			}
		}
	}
	//undo the decision stack
	int decsize = DECSTACK.size();
	for ( int i = decsize - 1; i > -1; i-- ) {
		if ( VARLIST[DECSTACK[i] . VAR] -> ATOMASSIGN[DECSTACK[i] . VAL] == 0 ) {
			DECSTACK.erase ( DECSTACK.begin() + i );
		}
	}
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movl %esi, 0x5c(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x20(%rsp)
movl $0x1, 0x58(%rsp)
movq 0x20(%rsp), %rdi
movl 0x58(%rsp), %eax
movq %rax, 0x18(%rsp)
callq 0xaa90
movq %rax, %rcx
movq 0x18(%rsp), %rax
cmpq %rcx, %rax
jae 0x10016
movl $0x0, 0x54(%rsp)
movq 0x20(%rsp), %rdi
movl 0x54(%rsp), %eax
movl %eax, 0x14(%rsp)
movl 0x58(%rsp), %eax
movl %eax, %esi
callq 0xaab0
movq %rax, %rcx
movl 0x14(%rsp), %eax
movq (%rcx), %rcx
cmpl 0x8(%rcx), %eax
jge 0x10004
movq 0x20(%rsp), %rdi
movl 0x58(%rsp), %eax
movl %eax, %esi
callq 0xaab0
movq (%rax), %rax
movq 0x18(%rax), %rax
movslq 0x54(%rsp), %rcx
movl (%rax,%rcx,4), %eax
cmpl 0x5c(%rsp), %eax
jle 0xfff2
movq 0x20(%rsp), %rdi
movl 0x58(%rsp), %eax
movl %eax, %esi
callq 0xaab0
movq 0x20(%rsp), %rdi
movq (%rax), %rax
movl $0xffffffff, 0x4(%rax)  # imm = 0xFFFFFFFF
movl 0x58(%rsp), %eax
movl %eax, %esi
callq 0xaab0
movq 0x20(%rsp), %rdi
movq (%rax), %rax
movq 0x20(%rax), %rax
movslq 0x54(%rsp), %rcx
movl $0x0, (%rax,%rcx,4)
movl 0x58(%rsp), %eax
movl %eax, %esi
callq 0xaab0
movq 0x20(%rsp), %rdi
movq (%rax), %rax
movq 0x18(%rax), %rax
movslq 0x54(%rsp), %rcx
movl $0xfffffff6, (%rax,%rcx,4) # imm = 0xFFFFFFF6
movl 0x58(%rsp), %eax
movl %eax, %esi
callq 0xaab0
movq (%rax), %rax
movq 0x48(%rax), %rax
movslq 0x54(%rsp), %rcx
movl $0xfffffff6, (%rax,%rcx,4) # imm = 0xFFFFFFF6
jmp 0xfff4
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0xff1b
jmp 0x10006
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0xfeef
movq 0x20(%rsp), %rdi
addq $0x88, %rdi
callq 0xb890
movl %eax, 0x50(%rsp)
movl 0x50(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x4c(%rsp)
cmpl $-0x1, 0x4c(%rsp)
jle 0x10103
movq 0x20(%rsp), %rdi
addq $0x88, %rdi
movslq 0x4c(%rsp), %rsi
callq 0xb8b0
movq 0x20(%rsp), %rdi
movslq (%rax), %rsi
callq 0xaab0
movq 0x20(%rsp), %rdi
movq (%rax), %rax
movq 0x20(%rax), %rax
movq %rax, 0x8(%rsp)
addq $0x88, %rdi
movslq 0x4c(%rsp), %rsi
callq 0xb8b0
movq %rax, %rcx
movq 0x8(%rsp), %rax
movslq 0x4(%rcx), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x100f1
movq 0x20(%rsp), %rdi
movq %rdi, %rax
addq $0x88, %rax
movq %rax, (%rsp)
addq $0x88, %rdi
callq 0xc3c0
movq %rax, 0x30(%rsp)
movslq 0x4c(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x13d90
movq %rax, 0x38(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x13dd0
movq (%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x13d20
movq %rax, 0x28(%rsp)
jmp 0x100f3
movl 0x4c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x10036
addq $0x68, %rsp
retq
nopl (%rax,%rax)