// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
cmpq $0x0, 0x248(%rdi)
je 0x9f84
xorl %ebp, %ebp
jmp 0xa0e3
movl %esi, %ebp
movq %rdi, %rbx
movl 0x2c(%rdi), %eax
testl %eax, %eax
je 0x9fbc
movq 0x40(%rbx), %rcx
movl $0x1, %edx
movl %edx, %esi
shlq $0x4, %rsi
movl (%rcx,%rsi), %esi
btl $0x9, %esi
jb 0xa251
btl $0xa, %esi
jb 0xa232
incl %edx
cmpl %eax, %edx
jbe 0x9f99
testl %ebp, %ebp
je 0x9fed
movq 0x198(%rbx), %rsi
testq %rsi, %rsi
je 0x9fed
leaq 0x198(%rbx), %r14
movslq 0x1a4(%rbx), %rdx
shlq $0x2, %rdx
movq %rbx, %rdi
callq 0x9b29
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 0x9bf6
movq %rax, %r12
testl %r15d, %r15d
jle 0xa05c
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 0xa037
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x7927
cmpq $0x0, 0x248(%rbx)
je 0xa098
cmpl $0x14, 0x8(%rbx)
je 0xa0b0
leaq 0xa726(%rip), %rdi      # 0x147a6
leaq 0x8225(%rip), %rsi      # 0x122ac
leaq 0xa72f(%rip), %rcx      # 0x147bd
movl $0x1e11, %edx           # imm = 0x1E11
callq 0x10b0
movq %rbx, %rdi
movq %r12, %rsi
movl %r15d, %edx
callq 0x9d53
cmpq $0x0, 0x248(%rbx)
je 0xa0f5
xorl %ebp, %ebp
testl %r15d, %r15d
jle 0xa0d5
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
xorl %r14d, %r14d
movl (%r12,%r14,4), %esi
movq %rbx, %rdi
callq 0x777e
incq %r14
cmpq %r14, %r15
jne 0xa0c1
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x9b29
movq %rbp, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ebp, 0xc(%rsp)
movl (%rax), %edx
testl %edx, %edx
movq %rax, %r8
je 0xa152
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 0xa12f
movw $0x200, %dx             # imm = 0x200
btl $0xa, %edi
jae 0xa13d
jmp 0xa270
movw $0x400, %dx             # imm = 0x400
btl $0x9, %edi
jb 0xa28f
addq %rsi, %rcx
movzwl %dx, %edx
orl %edi, %edx
movw %dx, (%rcx)
movl (%rax), %edx
addq $0x4, %rax
testl %edx, %edx
jne 0xa109
movq %r8, 0x10(%rsp)
movq %r13, 0x18(%rsp)
testl %r15d, %r15d
jle 0xa1d4
movl %r15d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x20(%rsp)
xorl %r13d, %r13d
movl (%r12,%r13,4), %ebp
movl %ebp, %eax
negl %eax
cmovsl %ebp, %eax
shlq $0x4, %rax
addq 0x40(%rbx), %rax
testl %ebp, %ebp
jle 0xa18e
testb $0x2, 0x1(%rax)
jne 0xa19d
testl %ebp, %ebp
jns 0xa198
testb $0x4, 0x1(%rax)
jne 0xa19d
movb $0x1, %r14b
jmp 0xa1a0
xorl %r14d, %r14d
testb %r14b, %r14b
je 0xa1af
movq %rbx, %rdi
movl %ebp, %esi
callq 0x6d5b
cmpl $0x0, 0xc(%rsp)
sete %al
xorb $0x1, %r14b
orb %al, %r14b
jne 0xa1ca
movq %rbx, %rdi
movl %ebp, %esi
callq 0x10e26
incq %r13
cmpq %r13, 0x20(%rsp)
jne 0xa171
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6d5b
cmpl $0x0, 0xc(%rsp)
je 0xa1ef
movq %rbx, %rdi
xorl %esi, %esi
callq 0x10e26
testl %r15d, %r15d
movq 0x18(%rsp), %r13
movq 0x10(%rsp), %rbp
jle 0xa0b2
movl %r15d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %ecx, %ecx
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 0xa20c
jmp 0xa0b2
leaq 0xa5ee(%rip), %rdi      # 0x14827
leaq 0x806c(%rip), %rsi      # 0x122ac
leaq 0xa5bf(%rip), %rcx      # 0x14806
movl $0x1de0, %edx           # imm = 0x1DE0
callq 0x10b0
leaq 0xa59a(%rip), %rdi      # 0x147f2
leaq 0x804d(%rip), %rsi      # 0x122ac
leaq 0xa5a0(%rip), %rcx      # 0x14806
movl $0x1ddf, %edx           # imm = 0x1DDF
callq 0x10b0
leaq 0xa570(%rip), %rdi      # 0x147e7
leaq 0x802e(%rip), %rsi      # 0x122ac
leaq 0xa538(%rip), %rcx      # 0x147bd
movl $0x1e28, %edx           # imm = 0x1E28
callq 0x10b0
leaq 0xa546(%rip), %rdi      # 0x147dc
leaq 0x800f(%rip), %rsi      # 0x122ac
leaq 0xa519(%rip), %rcx      # 0x147bd
movl $0x1e23, %edx           # imm = 0x1E23
callq 0x10b0