// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
movq (%rsi), %rax
cmpq %rax, 0x8(%rsi)
je 0x3183
xorl %r13d, %r13d
movq (%rbx), %rdi
movl (%rax,%r13,4), %esi
callq 0x37ae
movq (%r15), %rax
movl (%rax,%r13,4), %ecx
movl 0x8(%rbx), %edx
cmpl %edx, %ecx
cmovgl %ecx, %edx
movl %edx, 0x8(%rbx)
xorl %ecx, %ecx
subl (%rax,%r13,4), %ecx
cmpl %ecx, %edx
cmovgl %edx, %ecx
movl %ecx, 0x8(%rbx)
incq %r13
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r13, %rcx
ja 0x3141
movq (%rbx), %rdi
callq 0x37b3
movl %eax, %ebp
cmpl $0xa, %eax
je 0x324e
cmpl $0x14, %ebp
jne 0x32ad
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x31ac
movq %rax, 0x8(%r14)
movq (%r15), %rax
cmpq %rax, 0x8(%r15)
je 0x329c
xorl %r12d, %r12d
leaq 0x4(%rsp), %r13
movq (%rbx), %rdi
movl (%rax,%r12,4), %esi
callq 0x37bd
testl %eax, %eax
je 0x31f0
movq (%r15), %rcx
xorl %eax, %eax
subl (%rcx,%r12,4), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
jne 0x321b
movq %r14, %rdi
movq %r13, %rdx
jmp 0x322d
movq (%rbx), %rdi
movq (%r15), %rax
xorl %esi, %esi
subl (%rax,%r12,4), %esi
callq 0x37bd
testl %eax, %eax
je 0x3232
movq (%r15), %rcx
xorl %eax, %eax
subl (%rcx,%r12,4), %eax
movl %eax, (%rsp)
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x3227
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r14)
jmp 0x3232
movq %r14, %rdi
movq %rsp, %rdx
callq 0x3576
incq %r12
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r12, %rcx
ja 0x31c1
jmp 0x329c
movq (%r12), %rax
cmpq %rax, 0x8(%r12)
je 0x325e
movq %rax, 0x8(%r12)
movslq 0x8(%rbx), %rsi
incq %rsi
movq %r12, %rdi
callq 0x33dc
cmpl $0x0, 0x8(%rbx)
jle 0x329c
movl $0x1, %r14d
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x37c2
movq (%r12), %rcx
movl %eax, (%rcx,%r14,4)
leaq 0x1(%r14), %rax
movslq 0x8(%rbx), %rcx
cmpq %rcx, %r14
movq %rax, %r14
jl 0x3279
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x14d3c(%rip), %rdi     # 0x17ff0
leaq 0xdf1d(%rip), %rsi      # 0x111d8
callq 0x2160
movq %rax, %rdi
movl %ebp, %esi
callq 0x2290
leaq 0xdf40(%rip), %rsi      # 0x11211
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x2090
movl $0x1, %edi
callq 0x21e0
nop