// File: /workspace/github_cpp_makefile_star2_O3/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 0x773e
movq %rbx, %rdi
movq %r14, %rsi
callq 0x783c
movsd 0x40(%rbx), %xmm0
subsd 0x38(%rbx), %xmm0
xorpd %xmm1, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movq 0x20(%r14), %rsi
andpd 0x2031(%rip), %xmm0     # 0xdee0
leaq 0x203a(%rip), %rdi      # 0xdef0
movb $0x1, %al
callq 0x2050
callq 0x2b92
movsd %xmm0, 0x38(%rbx)
callq 0x2b92
movsd %xmm0, 0x40(%rbx)
leaq 0x11b2(%rip), %rsi      # 0xd08a
movq %r15, %rdi
callq 0x20d0
testl %eax, %eax
je 0xbef9
movl 0x34(%r14), %esi
cmpb $0x1, 0x1(%r14)
jne 0xbf05
movq %rbx, %rdi
callq 0xadde
jmp 0xbf13
movq %rbx, %rdi
xorl %esi, %esi
callq 0xb734
jmp 0xbf13
movq %rbx, %rdi
testl %esi, %esi
jne 0xbf0e
xorl %esi, %esi
callq 0xb260
movl %eax, %ebp
movsd 0x40(%rbx), %xmm0
subsd 0x38(%rbx), %xmm0
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
leaq 0x1fcb(%rip), %rdi      # 0xdefb
movb $0x2, %al
callq 0x2050
movq 0x5092(%rip), %r15      # 0x10fd0
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
testl %ebp, %ebp
je 0xbfc6
movq 0x5024(%rip), %rdi      # 0x10fd0
cmpl $0x1, %ebp
jne 0xc087
leaq 0x1f4d(%rip), %rsi      # 0xdf09
movl $0x7, %edx
jmp 0xc093
leaq 0x1eae(%rip), %rsi      # 0xde7b
movl $0x3, %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 0x7f28
cmpb $0x1, (%r14)
jne 0xc052
leaq 0x1efb(%rip), %rsi      # 0xdf11
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 0x7e84
movq 0x4f77(%rip), %r14      # 0x10fd0
leaq 0x1ebd(%rip), %rsi      # 0xdf1d
movl $0x14, %edx
movq %r14, %rdi
callq 0x2270
movq %rbx, %rdi
callq 0x7fd0
testb %al, %al
je 0xc0c9
leaq 0x1eb2(%rip), %rsi      # 0xdf32
movl $0x10, %edx
jmp 0xc0d5
leaq 0x1deb(%rip), %rsi      # 0xde79
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 0x7f28
jmp 0xc104
leaq 0x1e73(%rip), %rsi      # 0xdf43
movl $0x12, %edx
movq %r14, %rdi
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