// File: /workspace/github_cpp_makefile_star2_O1/akinanop[P]mvl-solver/src/SolveFinite.cc
// Function: SolveFinite(CommandLine*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void SolveFinite(CommandLine * cline, string type)
{
  //local variable
  double difftime = 0;
  double totaltime = 0;
  int result = -1;
  Formula * fobj;

  //Creating object
  fobj = new Formula(cline);
  //Building database
  fobj->BuildFormula(cline);
  //Compute Buildtime
  difftime = fobj->TIME_E - fobj->TIME_S;
  totaltime += difftime;
  printf("%s \t%2.4f\t", cline->FILE, fabs(difftime));
  //reinitialize the TIME_S and TIME_E
  fobj->TIME_S = GetTime();
  fobj->TIME_E = GetTime();
  //call the algorithm
  // fobj->checkUnit(); // move this check to the algo

  // *** Extended DPLL Algorithm Options

 if(type == "ch")

 {
      // 1. Chronological Backtracking
     result = fobj->ChronoBacktrack(0); // The function defined in FDSolver/Formula.cc
    }

  // 2. NonChronological Backtracking with Clause learning
 else
    {
	 if ( cline -> WATCH  ) {


    	  result = fobj-> WatchedLiterals ( cline -> RESTARTS );

      }
      else if (cline->RESTARTS != 0) {
        result = fobj->NonChronoBacktrack(cline->RESTARTS);
      }
      else  {

     result = fobj->NonChronoBacktrack(0);
      }
    }

  // compute the search time
  difftime = fobj->TIME_E - fobj->TIME_S;
  totaltime += difftime;
  //cout<<"Solving time: "<<endl;
  printf("%2.4f\t %2.4f\t", difftime, totaltime);
  cout<<endl;
  cout<<endl;
  cout << '\a';
  if(result == 0)
    cout<<"SAT"<<endl;
  else if(result == 1)
    cout<<"TIMEOUT"<<endl;
  else
    cout<<"UNSAT"<<endl;
  fobj->PrintInfo();
  if(result == 0)
   { if(cline->MODEL) { cout<<"The model: "<<endl;
     fobj->PrintModel(); }
      cout<<"Verifying model ... ";
       if(fobj->verifyModel())
 	cout<<"model is CORRECT"<<endl;
       else
 	cout<<"model is INCORRECT"<<endl;
     }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movq %rdi, %r14
movl $0xb0, %edi
callq 0x2230
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x77f6
movq %rbx, %rdi
movq %r14, %rsi
callq 0x78f4
movsd 0x40(%rbx), %xmm0
subsd 0x38(%rbx), %xmm0
xorpd %xmm1, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movq 0x20(%r14), %rsi
andpd 0x119d(%rip), %xmm0     # 0xcee0
leaq 0x11a6(%rip), %rdi      # 0xcef0
movb $0x1, %al
callq 0x2050
callq 0x2b7e
movsd %xmm0, 0x38(%rbx)
callq 0x2b7e
movsd %xmm0, 0x40(%rbx)
leaq 0x31e(%rip), %rsi       # 0xc08a
movq %r15, %rdi
callq 0x20d0
testl %eax, %eax
je 0xbd8d
movl 0x34(%r14), %esi
cmpb $0x1, 0x1(%r14)
jne 0xbd99
movq %rbx, %rdi
callq 0xab4a
jmp 0xbda7
movq %rbx, %rdi
xorl %esi, %esi
callq 0xb494
jmp 0xbda7
movq %rbx, %rdi
testl %esi, %esi
jne 0xbda2
xorl %esi, %esi
callq 0xafd2
movl %eax, %ebp
movsd 0x40(%rbx), %xmm0
subsd 0x38(%rbx), %xmm0
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
leaq 0x1137(%rip), %rdi      # 0xcefb
movb $0x2, %al
callq 0x2050
movq 0x41fe(%rip), %r15      # 0xffd0
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 (%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
leaq 0xf(%rsp), %rsi
movb $0x7, (%rsi)
movl $0x1, %edx
movq %r15, %rdi
callq 0x2270
movq 0x4194(%rip), %rdi      # 0xffd0
testl %ebp, %ebp
je 0xbe53
cmpl $0x1, %ebp
jne 0xbe61
leaq 0x10bd(%rip), %rsi      # 0xcf09
movl $0x7, %edx
jmp 0xbe6d
leaq 0x1021(%rip), %rsi      # 0xce7b
movl $0x3, %edx
jmp 0xbe6d
leaq 0x1011(%rip), %rsi      # 0xce79
movl $0x5, %edx
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, %rdi
callq 0x7fd2
testl %ebp, %ebp
jne 0xbf66
cmpb $0x1, (%r14)
jne 0xbef2
leaq 0x105b(%rip), %rsi      # 0xcf11
movl $0xb, %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
movq %rbx, %rdi
callq 0x7f34
movq 0x40d7(%rip), %r14      # 0xffd0
leaq 0x101d(%rip), %rsi      # 0xcf1d
movl $0x14, %edx
movq %r14, %rdi
callq 0x2270
movq %rbx, %rdi
callq 0x807a
movq 0x40b4(%rip), %rdi      # 0xffd0
testb %al, %al
je 0xbf2e
leaq 0x100b(%rip), %rsi      # 0xcf32
movl $0x10, %edx
jmp 0xbf3a
leaq 0x100e(%rip), %rsi      # 0xcf43
movl $0x12, %edx
callq 0x2270
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2180
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movl $0xb0, %esi
movq %rbx, %rdi
callq 0x2240
movq %r14, %rdi
callq 0x23a0