// File: /workspace/github_cpp_makefile_star2_O3/biotomas[P]ipasir/sat/picosat961/picosat-961/picosat.c
// Function: next_mss
static const int *
next_mss (PS * ps, int mcs)
{
  int i, *a, size, mssize, mcsize, lit, inmss;
  const int * res, * p;
  Var * v;

  if (ps->mtcls) return 0;

  check_mss_flags_clean (ps);

  if (mcs && ps->mcsass)
    {
      DELETEN (ps->mcsass, ps->szmcsass);
      ps->nmcsass = ps->szmcsass = 0;
      ps->mcsass = 0;
    }

  size = ps->alshead - ps->als;
  NEWN (a, size);

  for (i = 0; i < size; i++)
    a[i] = LIT2INT (ps->als[i]);

  (void) picosat_sat (ps, -1);

  //TODO short cut for 'picosat_res () == 10'?

  if (ps->mtcls)
    {
      assert (picosat_res (ps) == 20);
      res = 0;
      goto DONE;
    }

  res = mss (ps, a, size);

  if (ps->mtcls)
    {
      res = 0;
      goto DONE;
    }

  for (p = res; (lit = *p); p++) 
    {
      v = ps->vars + abs (lit);
      if (lit < 0)
	{
	  assert (!v->msspos);
	  v->mssneg = 1;
	}
      else
	{
	  assert (!v->mssneg);
	  v->msspos = 1;
	}
    }

  mssize = p - res;
  mcsize = INT_MIN;

  for (i = 0; i < size; i++)
    {
      lit = a[i];
      v = ps->vars + abs (lit);
      if (lit > 0 && v->msspos)
	inmss = 1;
      else if (lit < 0 && v->mssneg)
	inmss = 1;
      else 
	inmss = 0;

      if (mssize < mcsize)
	{
	  if (inmss)
	    picosat_add (ps, -lit);
	}
      else
	{
	  if (!inmss)
	    picosat_add (ps, lit);
	}

      if (!inmss && mcs)
	push_mcsass (ps, lit);
    }
  picosat_add (ps, 0);
  if (mcs)
    push_mcsass (ps, 0);

  for (i = 0; i < size; i++)
    {
      lit = a[i];
      v = ps->vars + abs (lit);
      v->msspos = 0;
      v->mssneg = 0;
    }

DONE:

  reassume (ps, a, size);
  DELETEN (a, size);

  return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpq $0x0, 0x248(%rdi)
je 0xa088
xorl %ebp, %ebp
jmp 0xa1e7
movl %esi, %ebp
movq %rdi, %rbx
movl 0x2c(%rdi), %eax
testl %eax, %eax
je 0xa0c0
movq 0x40(%rbx), %rcx
movl $0x1, %edx
movl %edx, %esi
shlq $0x4, %rsi
movl (%rcx,%rsi), %esi
btl $0x9, %esi
jb 0xa33f
btl $0xa, %esi
jb 0xa320
incl %edx
cmpl %eax, %edx
jbe 0xa09d
testl %ebp, %ebp
je 0xa0f1
movq 0x198(%rbx), %rsi
testq %rsi, %rsi
je 0xa0f1
leaq 0x198(%rbx), %r14
movslq 0x1a4(%rbx), %rdx
shlq $0x2, %rdx
movq %rbx, %rdi
callq 0x9c31
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq 0x100(%rbx), %r13
subq 0xf8(%rbx), %r13
movq %r13, %r15
shrq $0x3, %r15
shlq $0x1d, %r13
sarq $0x1e, %r13
andq $-0x4, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x9cfe
movq %rax, %r12
testl %r15d, %r15d
jle 0xa160
movq 0x38(%rbx), %rax
movq 0xf8(%rbx), %rcx
movl %r15d, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
xorl %esi, %esi
movl (%rcx,%rsi,8), %edi
subl %eax, %edi
movl %edi, %r8d
shrl %r8d
movl %r8d, %r9d
negl %r9d
testb $0x1, %dil
cmovel %r8d, %r9d
movl %r9d, (%r12,%rsi,4)
incq %rsi
cmpq %rsi, %rdx
jne 0xa13b
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x7917
cmpq $0x0, 0x248(%rbx)
je 0xa19c
cmpl $0x14, 0x8(%rbx)
je 0xa1b4
leaq 0xb5be(%rip), %rdi      # 0x15742
leaq 0x90f1(%rip), %rsi      # 0x1327c
leaq 0xb5c7(%rip), %rcx      # 0x15759
movl $0x1e11, %edx           # imm = 0x1E11
callq 0x10b0
movq %rbx, %rdi
movq %r12, %rsi
movl %r15d, %edx
callq 0x9e6e
cmpq $0x0, 0x248(%rbx)
je 0xa1f9
xorl %ebp, %ebp
testl %r15d, %r15d
jle 0xa1d9
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
xorl %r14d, %r14d
movl (%r12,%r14,4), %esi
movq %rbx, %rdi
callq 0x777f
incq %r14
cmpq %r14, %r15
jne 0xa1c5
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x9c31
movq %rbp, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ebp, 0x4(%rsp)
movl (%rax), %edx
testl %edx, %edx
movq %rax, %r8
je 0xa256
movq %r8, %rax
addq $0x4, %rax
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
movq 0x40(%rbx), %rcx
shlq $0x4, %rsi
movzwl (%rcx,%rsi), %edi
testl %edx, %edx
js 0xa233
movw $0x200, %dx             # imm = 0x200
btl $0xa, %edi
jae 0xa241
jmp 0xa35e
movw $0x400, %dx             # imm = 0x400
btl $0x9, %edi
jb 0xa37d
addq %rsi, %rcx
movzwl %dx, %edx
orl %edi, %edx
movw %dx, (%rcx)
movl (%rax), %edx
addq $0x4, %rax
testl %edx, %edx
jne 0xa20d
movq %r8, 0x8(%rsp)
movq %r13, 0x10(%rsp)
testl %r15d, %r15d
jle 0xa2bc
movl %r15d, %r13d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
xorl %r14d, %r14d
movl (%r12,%r14,4), %ebp
movl %ebp, %eax
negl %eax
cmovsl %ebp, %eax
shlq $0x4, %rax
addq 0x40(%rbx), %rax
testl %ebp, %ebp
jle 0xa291
testb $0x2, 0x1(%rax)
je 0xa299
jmp 0xa2b4
jns 0xa299
testb $0x4, 0x1(%rax)
jne 0xa2b4
movq %rbx, %rdi
movl %ebp, %esi
callq 0x6e0a
cmpl $0x0, 0x4(%rsp)
je 0xa2b4
movq %rbx, %rdi
movl %ebp, %esi
callq 0x10ec5
incq %r14
cmpq %r14, %r13
jne 0xa272
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6e0a
cmpl $0x0, 0x4(%rsp)
je 0xa2d7
movq %rbx, %rdi
xorl %esi, %esi
callq 0x10ec5
testl %r15d, %r15d
movq 0x10(%rsp), %r13
jle 0xa316
movl %r15d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %ecx, %ecx
movq 0x8(%rsp), %rbp
movl (%r12,%rcx,4), %edx
movq 0x40(%rbx), %rsi
movl %edx, %edi
negl %edi
cmovsl %edx, %edi
shlq $0x4, %rdi
andw $0xf9ff, (%rsi,%rdi)    # imm = 0xF9FF
incq %rcx
cmpq %rcx, %rax
jne 0xa2f0
jmp 0xa1b6
movq 0x8(%rsp), %rbp
jmp 0xa1d9
leaq 0xb49c(%rip), %rdi      # 0x157c3
leaq 0x8f4e(%rip), %rsi      # 0x1327c
leaq 0xb46d(%rip), %rcx      # 0x157a2
movl $0x1de0, %edx           # imm = 0x1DE0
callq 0x10b0
leaq 0xb448(%rip), %rdi      # 0x1578e
leaq 0x8f2f(%rip), %rsi      # 0x1327c
leaq 0xb44e(%rip), %rcx      # 0x157a2
movl $0x1ddf, %edx           # imm = 0x1DDF
callq 0x10b0
leaq 0xb41e(%rip), %rdi      # 0x15783
leaq 0x8f10(%rip), %rsi      # 0x1327c
leaq 0xb3e6(%rip), %rcx      # 0x15759
movl $0x1e28, %edx           # imm = 0x1E28
callq 0x10b0
leaq 0xb3f4(%rip), %rdi      # 0x15778
leaq 0x8ef1(%rip), %rsi      # 0x1327c
leaq 0xb3c7(%rip), %rcx      # 0x15759
movl $0x1e23, %edx           # imm = 0x1E23
callq 0x10b0