// File: biotomas[P]ipasir/app/ipasir-check-conflict/./SATSolver.h
// Function: SATSolver::solve(std::vector<int, std::allocator<int>> const&, std::vector<int, std::allocator<int>>&, std::vector<int, std::allocator<int>>&)
int solve(const std::vector<int>& assumptions, std::vector<int>& model, std::vector<int>&conflict) {
    for( int i=0; i < assumptions.size(); ++ i ) {
      IPASIR( ipasir_assume(ipasirSolver, assumptions[i]); );
      maxVar = assumptions[i] > maxVar ? assumptions[i] : maxVar;
      maxVar = -assumptions[i] > maxVar ? -assumptions[i] : maxVar;
    }
//     std::cerr << "solve ipasir with maxvar: " << maxVar << std::endl;
    int SATret = 0;
    IPASIR( SATret = ipasir_solve(ipasirSolver); );
    
    if( SATret == 10 ) {
      model.clear();
      model.resize(maxVar+1);
      for( int v = 1; v <= maxVar; ++ v ) {
	IPASIR( model[v] = ipasir_val(ipasirSolver, v); );
      }
    } else if (SATret == 20) {
      conflict.clear();
      for( int i=0; i < assumptions.size(); ++i ) {
	IPASIR( if(ipasir_failed(ipasirSolver,  assumptions[i])) conflict.push_back(-assumptions[i]);
	        else if(ipasir_failed(ipasirSolver, -assumptions[i])) conflict.push_back(-assumptions[i]); );
      }
    } else {
      std::cerr << "ipasir SAT solver terminated with unexpected exit code: " << SATret << ". Abort." << std::endl;
      exit(1);
    }
    
    return SATret;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x24(%rbp)
movslq -0x24(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3560
movq %rax, %rcx
movq -0x48(%rbp), %rax
cmpq %rcx, %rax
jae 0x2ee6
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0x35a0
movq -0x50(%rbp), %rdi
movl (%rax), %esi
callq 0x47f0
movq -0x10(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0x35a0
movq -0x40(%rbp), %rcx
movl (%rax), %eax
cmpl 0x8(%rcx), %eax
jle 0x2e7a
movq -0x10(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0x35a0
movl (%rax), %eax
movl %eax, -0x54(%rbp)
jmp 0x2e84
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x54(%rbp)
movq -0x40(%rbp), %rax
movl -0x54(%rbp), %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0x35a0
movq -0x40(%rbp), %rcx
movq %rax, %rdx
xorl %eax, %eax
subl (%rdx), %eax
cmpl 0x8(%rcx), %eax
jle 0x2ec4
movq -0x10(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0x35a0
movq %rax, %rcx
xorl %eax, %eax
subl (%rcx), %eax
movl %eax, -0x58(%rbp)
jmp 0x2ece
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x58(%rbp)
movq -0x40(%rbp), %rax
movl -0x58(%rbp), %ecx
movl %ecx, 0x8(%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2e0a
movq -0x40(%rbp), %rax
movl $0x0, -0x28(%rbp)
movq (%rax), %rdi
callq 0x4820
movl %eax, -0x28(%rbp)
cmpl $0xa, -0x28(%rbp)
jne 0x2f68
movq -0x18(%rbp), %rdi
callq 0x35c0
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rdi
movl 0x8(%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x35e0
movl $0x1, -0x2c(%rbp)
movq -0x40(%rbp), %rcx
movl -0x2c(%rbp), %eax
cmpl 0x8(%rcx), %eax
jg 0x2f63
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movl -0x2c(%rbp), %esi
callq 0x4870
movl %eax, -0x5c(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
callq 0x3580
movl -0x5c(%rbp), %ecx
movl %ecx, (%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2f28
jmp 0x30b1
cmpl $0x14, -0x28(%rbp)
jne 0x3069
movq -0x20(%rbp), %rdi
callq 0x35c0
movl $0x0, -0x30(%rbp)
movslq -0x30(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3560
movq %rax, %rcx
movq -0x68(%rbp), %rax
cmpq %rcx, %rax
jae 0x3067
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0x35a0
movq -0x70(%rbp), %rdi
movl (%rax), %esi
callq 0x4840
cmpl $0x0, %eax
je 0x2ff9
movq -0x20(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0x35a0
movq -0x78(%rbp), %rdi
movq %rax, %rcx
xorl %eax, %eax
subl (%rcx), %eax
movl %eax, -0x34(%rbp)
leaq -0x34(%rbp), %rsi
callq 0x2bb0
jmp 0x3057
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0x35a0
movq -0x80(%rbp), %rdi
xorl %esi, %esi
subl (%rax), %esi
callq 0x4840
cmpl $0x0, %eax
je 0x3055
movq -0x20(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0x35a0
movq -0x88(%rbp), %rdi
movq %rax, %rcx
xorl %eax, %eax
subl (%rcx), %eax
movl %eax, -0x38(%rbp)
leaq -0x38(%rbp), %rsi
callq 0x2bb0
jmp 0x3057
jmp 0x3059
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x2f82
jmp 0x30af
movq 0x21f80(%rip), %rdi     # 0x24ff0
leaq 0x1a16d(%rip), %rsi     # 0x1d1e4
callq 0x2170
movq %rax, %rdi
movl -0x28(%rbp), %esi
callq 0x2300
movq %rax, %rdi
leaq 0x1a18c(%rip), %rsi     # 0x1d21d
callq 0x2170
movq %rax, %rdi
movq 0x21f18(%rip), %rsi     # 0x24fb8
callq 0x21a0
movl $0x1, %edi
callq 0x2230
jmp 0x30b1
movl -0x28(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)