// File: /workspace/github_cpp_makefile_star2_O2/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 0x934a
xorl %r15d, %r15d
jmp 0x94a0
movl %esi, %ebp
movq %rdi, %rbx
movl 0x2c(%rdi), %eax
pushq $0x1
popq %rcx
cmpl %eax, %ecx
ja 0x9397
movq 0x40(%rbx), %rdx
movl %ecx, %esi
shlq $0x4, %rsi
movl (%rdx,%rsi), %edx
btl $0x9, %edx
jb 0x95a9
incl %ecx
btl $0xa, %edx
jae 0x9355
leaq 0xa422(%rip), %rdi      # 0x137a1
leaq 0x7eee(%rip), %rsi      # 0x11274
leaq 0xa3f3(%rip), %rcx      # 0x13780
movl $0x1de0, %edx           # imm = 0x1DE0
callq 0x10b0
testl %ebp, %ebp
je 0x93c8
movq 0x198(%rbx), %rsi
testq %rsi, %rsi
je 0x93c8
leaq 0x198(%rbx), %r14
movslq 0x1a4(%rbx), %rdx
shlq $0x2, %rdx
movq %rbx, %rdi
callq 0x8e83
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq 0x100(%rbx), %r14
subq 0xf8(%rbx), %r14
movq %r14, %r13
shrq $0x3, %r13
shlq $0x1d, %r14
sarq $0x1e, %r14
andq $-0x4, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8f50
movq %rax, %r12
xorl %eax, %eax
testl %r13d, %r13d
movl $0x0, %r15d
cmovgl %r13d, %r15d
cmpq %rax, %r15
je 0x942f
movq 0xf8(%rbx), %rcx
movl (%rcx,%rax,8), %ecx
subl 0x38(%rbx), %ecx
movl %ecx, %edx
shrl %edx
movl %edx, %esi
negl %esi
testb $0x1, %cl
cmovel %edx, %esi
movl %esi, (%r12,%rax,4)
incq %rax
jmp 0x9406
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0x6e44
cmpq $0x0, 0x248(%rbx)
je 0x9469
cmpl $0x14, 0x8(%rbx)
je 0x9481
leaq 0xa2cf(%rip), %rdi      # 0x13720
leaq 0x7e1c(%rip), %rsi      # 0x11274
leaq 0xa2d8(%rip), %rcx      # 0x13737
movl $0x1e11, %edx           # imm = 0x1E11
callq 0x10b0
movq %rbx, %rdi
movq %r12, %rsi
movl %r13d, %edx
callq 0x90dd
cmpq $0x0, 0x248(%rbx)
je 0x94b2
xorl %r15d, %r15d
movq %rbx, %rdi
movq %r12, %rsi
movl %r13d, %edx
callq 0x92c3
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x8e83
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, 0x10(%rsp)
movl (%rax), %edi
testl %edi, %edi
je 0x9502
movl %edi, %edx
negl %edx
cmovsl %edi, %edx
movq 0x40(%rbx), %rcx
shlq $0x4, %rdx
movzwl (%rcx,%rdx), %esi
testl %edi, %edi
js 0x94e3
movw $0x200, %di             # imm = 0x200
btl $0xa, %esi
jae 0x94f1
jmp 0x95c8
movw $0x400, %di             # imm = 0x400
btl $0x9, %esi
jb 0x95e7
addq %rdx, %rcx
movzwl %di, %edx
orl %esi, %edx
movw %dx, (%rcx)
addq $0x4, %rax
jmp 0x94b7
movq %r13, 0x8(%rsp)
movl %ebp, 0x4(%rsp)
xorl %r13d, %r13d
cmpq %r13, %r15
je 0x955a
movl (%r12,%r13,4), %ebp
movl %ebp, %eax
negl %eax
cmovsl %ebp, %eax
shlq $0x4, %rax
addq 0x40(%rbx), %rax
testl %ebp, %ebp
jle 0x9532
testb $0x2, 0x1(%rax)
je 0x953a
jmp 0x9555
jns 0x953a
testb $0x4, 0x1(%rax)
jne 0x9555
movq %rbx, %rdi
movl %ebp, %esi
callq 0x633b
cmpl $0x0, 0x4(%rsp)
je 0x9555
movq %rbx, %rdi
movl %ebp, %esi
callq 0xf45a
incq %r13
jmp 0x950e
movq %rbx, %rdi
xorl %esi, %esi
callq 0x633b
cmpl $0x0, 0x4(%rsp)
je 0x9575
movq %rbx, %rdi
xorl %esi, %esi
callq 0xf45a
xorl %eax, %eax
movq 0x8(%rsp), %r13
cmpq %rax, %r15
je 0x959f
movl (%r12,%rax,4), %ecx
movq 0x40(%rbx), %rdx
movl %ecx, %esi
negl %esi
cmovsl %ecx, %esi
shlq $0x4, %rsi
andw $0xf9ff, (%rdx,%rsi)    # imm = 0xF9FF
incq %rax
jmp 0x957c
movq 0x10(%rsp), %r15
jmp 0x9484
leaq 0xa1bc(%rip), %rdi      # 0x1376c
leaq 0x7cbd(%rip), %rsi      # 0x11274
leaq 0xa1c2(%rip), %rcx      # 0x13780
movl $0x1ddf, %edx           # imm = 0x1DDF
callq 0x10b0
leaq 0xa192(%rip), %rdi      # 0x13761
leaq 0x7c9e(%rip), %rsi      # 0x11274
leaq 0xa15a(%rip), %rcx      # 0x13737
movl $0x1e28, %edx           # imm = 0x1E28
callq 0x10b0
leaq 0xa168(%rip), %rdi      # 0x13756
leaq 0x7c7f(%rip), %rsi      # 0x11274
leaq 0xa13b(%rip), %rcx      # 0x13737
movl $0x1e23, %edx           # imm = 0x1E23
callq 0x10b0