// File: biotomas[P]ipasir/sat/picosat961/picosat-961/picosat.c
// Function: init
static PS *
init (void * pmgr, 
      picosat_malloc pnew, picosat_realloc presize, picosat_free pdelete)
{
  PS * ps;

#if 0
  int count = 3 - !pnew - !presize - !pdelete;

  ABORTIF (count && !pnew, "API usage: missing 'picosat_set_new'");
  ABORTIF (count && !presize, "API usage: missing 'picosat_set_resize'");
  ABORTIF (count && !pdelete, "API usage: missing 'picosat_set_delete'");
#endif

  ps = pnew ? pnew (pmgr, sizeof *ps) : malloc (sizeof *ps);
  ABORTIF (!ps, "failed to allocate memory for PicoSAT manager");
  memset (ps, 0, sizeof *ps);

  ps->emgr = pmgr;
  ps->enew = pnew;
  ps->eresize = presize;
  ps->edelete = pdelete;

  ps->size_vars = 1;
  ps->state = RESET;
  ps->defaultphase = JWLPHASE;
#ifdef TRACE
  ps->ocore = -1;
#endif
  ps->lastrheader = -2;
#ifndef NADC
  ps->adoconflictlimit = UINT_MAX;
#endif
  ps->min_flipped = UINT_MAX;

  NEWN (ps->lits, 2 * ps->size_vars);
  NEWN (ps->jwh, 2 * ps->size_vars);
  NEWN (ps->htps, 2 * ps->size_vars);
#ifndef NDSC
  NEWN (ps->dhtps, 2 * ps->size_vars);
#endif
  NEWN (ps->impls, 2 * ps->size_vars);
  NEWN (ps->vars, ps->size_vars);
  NEWN (ps->rnks, ps->size_vars);

  /* because '0' pos denotes not on heap
   */
  ENLARGE (ps->heap, ps->hhead, ps->eoh); 
  ps->hhead = ps->heap + 1;

  ps->vinc = base2flt (1, 0);		/* initial var activity */
  ps->ifvinc = ascii2flt ("1.05");	/* var score rescore factor */
#ifdef VISCORES
  ps->fvinc = ascii2flt ("0.9523809");	/*     1/f =     1/1.05 */
  ps->nvinc = ascii2flt ("0.0476191");	/* 1 - 1/f = 1 - 1/1.05 */
#endif
  ps->lscore = base2flt (1, 90);	/* var activity rescore limit */
  ps->ilvinc = base2flt (1, -90);	/* inverse of 'lscore' */

  ps->cinc = base2flt (1, 0);		/* initial clause activity */
  ps->fcinc = ascii2flt ("1.001");	/* cls activity rescore factor */
  ps->lcinc = base2flt (1, 90);		/* cls activity rescore limit */
  ps->ilcinc = base2flt (1, -90);	/* inverse of 'ilcinc' */

  ps->lreduceadjustcnt = ps->lreduceadjustinc = 100;
  ps->lpropagations = ~0ull;

  ps->out = stdout;
  new_prefix (ps, "c ");
  ps->verbosity = 0;
  ps->plain = 0;

#ifdef NO_BINARY_CLAUSES
  memset (&ps->impl, 0, sizeof (ps->impl));
  ps->impl.size = 2;

  memset (&ps->cimpl, 0, sizeof (ps->impl));
  ps->cimpl.size = 2;
#endif

#ifdef VISCORES
  ps->fviscores = popen (
    "/usr/bin/gnuplot -background black"
    " -xrm 'gnuplot*textColor:white'"
    " -xrm 'gnuplot*borderColor:white'"
    " -xrm 'gnuplot*axisColor:white'"
    , "w");
  fprintf (ps->fviscores, "unset key\n");
  // fprintf (ps->fviscores, "set log y\n");
  fflush (ps->fviscores);
  system ("rm -rf /tmp/picosat-viscores");
  system ("mkdir /tmp/picosat-viscores");
  system ("mkdir /tmp/picosat-viscores/data");
#ifdef WRITEGIF
  system ("mkdir /tmp/picosat-viscores/gif");
  fprintf (ps->fviscores,
           "set terminal gif giant animate opt size 1024,768 x000000 xffffff"
	   "\n");

  fprintf (ps->fviscores, 
           "set output \"/tmp/picosat-viscores/gif/animated.gif\"\n");
#endif
#endif
  ps->defaultphase = JWLPHASE;
  ps->state = READY;
  ps->last_sat_call_result = 0;

  return ps;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x3d84
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rdi
movl $0x4d0, %esi            # imm = 0x4D0
callq *%rax
movq %rax, -0x58(%rbp)
jmp 0x3d92
movl $0x4d0, %edi            # imm = 0x4D0
callq 0x1150
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x3da3
jmp 0x3dc0
jmp 0x3da5
movq 0x2024c(%rip), %rax     # 0x23ff8
movq (%rax), %rsi
leaq 0x1a1a8(%rip), %rdi     # 0x1df5e
callq 0x10c0
callq 0x1060
movq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x4d0, %edx            # imm = 0x4D0
callq 0x10d0
movq -0x8(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x4a0(%rax)
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x4a8(%rax)
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x4b0(%rax)
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x4b8(%rax)
movq -0x28(%rbp), %rax
movl $0x1, 0x30(%rax)
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movq -0x28(%rbp), %rax
movl $0x2, 0x4(%rax)
movq -0x28(%rbp), %rax
movl $0xfffffffe, 0x388(%rax) # imm = 0xFFFFFFFE
movq -0x28(%rbp), %rax
movl $0xffffffff, 0x49c(%rax) # imm = 0xFFFFFFFF
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x30(%rax), %eax
shll %eax
movl %eax, %eax
movl %eax, %esi
shlq $0x0, %rsi
callq 0x9900
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x38(%rax)
jmp 0x3e6f
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x30(%rax), %eax
shll %eax
movl %eax, %eax
movl %eax, %esi
shlq $0x2, %rsi
callq 0x9900
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x50(%rax)
jmp 0x3e96
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x30(%rax), %eax
shll %eax
movl %eax, %eax
movl %eax, %esi
shlq $0x3, %rsi
callq 0x9900
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x3ebd
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x30(%rax), %eax
shll %eax
movl %eax, %eax
movl %eax, %esi
shlq $0x3, %rsi
callq 0x9900
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x60(%rax)
jmp 0x3ee4
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x30(%rax), %eax
shll %eax
movl %eax, %eax
movl %eax, %esi
shlq $0x4, %rsi
callq 0x9900
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x68(%rax)
jmp 0x3f0b
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, %esi
shlq $0x4, %rsi
callq 0x9900
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x40(%rax)
jmp 0x3f2e
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, %esi
shlq $0x3, %rsi
callq 0x9900
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x48(%rax)
jmp 0x3f51
movq -0x28(%rbp), %rax
movq 0x1d8(%rax), %rax
movq -0x28(%rbp), %rcx
movq 0x1c8(%rcx), %rcx
subq %rcx, %rax
sarq $0x3, %rax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x3f81
movl -0x2c(%rbp), %eax
shll %eax
movl %eax, -0x5c(%rbp)
jmp 0x3f8b
movl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x3f8b
movl -0x5c(%rbp), %eax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq 0x1d0(%rax), %rax
movq -0x28(%rbp), %rcx
movq 0x1c8(%rcx), %rcx
subq %rcx, %rax
sarq $0x3, %rax
movl %eax, -0x3c(%rbp)
movq -0x28(%rbp), %rax
movq 0x1c8(%rax), %rax
movq -0x28(%rbp), %rcx
cmpq 0x1d8(%rcx), %rax
ja 0x3fce
jmp 0x3fed
leaq 0x19fc5(%rip), %rdi     # 0x1df9a
leaq 0x192c8(%rip), %rsi     # 0x1d2a4
movl $0x4b2, %edx            # imm = 0x4B2
leaq 0x19fca(%rip), %rcx     # 0x1dfb2
callq 0x10b0
jmp 0x3fef
movl -0x2c(%rbp), %eax
shlq $0x3, %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
shlq $0x3, %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x1c8(%rax), %rsi
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rcx
callq 0x4f30
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x1c8(%rax)
movq -0x28(%rbp), %rax
movq 0x1c8(%rax), %rcx
movl -0x3c(%rbp), %eax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x1d0(%rax)
movq -0x28(%rbp), %rax
movq 0x1c8(%rax), %rcx
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x1d8(%rax)
movq -0x28(%rbp), %rax
movq 0x1c8(%rax), %rcx
addq $0x8, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x1d0(%rax)
movl $0x1, %edi
xorl %esi, %esi
callq 0xdfd0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x300(%rax)
leaq 0x19f48(%rip), %rdi     # 0x1dff2
callq 0xe080
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x30c(%rax)
movl $0x1, %edi
movl $0x5a, %esi
callq 0xdfd0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x304(%rax)
movl $0x1, %edi
movl $0xffffffa6, %esi       # imm = 0xFFFFFFA6
callq 0xdfd0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x308(%rax)
movl $0x1, %edi
xorl %esi, %esi
callq 0xdfd0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x310(%rax)
leaq 0x19ee7(%rip), %rdi     # 0x1dff7
callq 0xe080
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x31c(%rax)
movl $0x1, %edi
movl $0x5a, %esi
callq 0xdfd0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x314(%rax)
movl $0x1, %edi
movl $0xffffffa6, %esi       # imm = 0xFFFFFFA6
callq 0xdfd0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x318(%rax)
movq -0x28(%rbp), %rax
movl $0x64, 0x3b0(%rax)
movq -0x28(%rbp), %rax
movl $0x64, 0x3ac(%rax)
movq -0x28(%rbp), %rax
movq $-0x1, 0x3e0(%rax)
movq 0x1fe47(%rip), %rax     # 0x23fd0
movq (%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rdi
leaq 0x1b544(%rip), %rsi     # 0x1f6e3
callq 0x5f90
movq -0x28(%rbp), %rax
movl $0x0, 0x20(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x24(%rax)
movq -0x28(%rbp), %rdi
addq $0x70, %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x10d0
movq -0x28(%rbp), %rax
movl $0x2, 0x70(%rax)
movq -0x28(%rbp), %rdi
addq $0x98, %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x10d0
movq -0x28(%rbp), %rax
movl $0x2, 0x98(%rax)
movq -0x28(%rbp), %rax
movl $0x2, 0x4(%rax)
movq -0x28(%rbp), %rax
movl $0x1, (%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x28(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)