// File: biotomas[P]ipasir/sat/picosat961/picosat-961/app.c
// Function: parse
static const char *
parse (PicoSAT * picosat, int force)
{
  int ch, sign, lit, vars, clauses;

  lineno = 1;
  inputid = fileno (input);

SKIP_COMMENTS:
  ch = next ();
  if (ch == 'c')
    {
      while ((ch = next ()) != EOF && ch != '\n')
	;
      goto SKIP_COMMENTS;
    }

  if (isspace (ch))
    goto SKIP_COMMENTS;

  if (ch != 'p')
INVALID_HEADER:
    return "missing or invalid 'p cnf <variables> <clauses>' header";

  if (!isspace (next ()))
    goto INVALID_HEADER;

  while (isspace (ch = next ()))
    ;

  if (ch != 'c' || next () != 'n' || next () != 'f' || !isspace (next ()))
    goto INVALID_HEADER;

  while (isspace (ch = next ()))
    ;
    
  if (!isdigit (ch))
    goto INVALID_HEADER;

  vars = ch - '0';
  while (isdigit (ch = next ()))
    vars = 10 * vars + (ch - '0');

  if (!isspace (ch))
    goto INVALID_HEADER;

  while (isspace (ch = next ()))
    ;

  if (!isdigit (ch))
    goto INVALID_HEADER;

  clauses = ch - '0';
  while (isdigit (ch = next ()))
    clauses = 10 * clauses + (ch - '0');

  if (!isspace (ch) && ch != '\n' )
    goto INVALID_HEADER;

  if (verbose)
    {
      fprintf (output, "c parsed header 'p cnf %d %d'\n", vars, clauses);
      fflush (output);
    }

  picosat_adjust (picosat, vars);

  if (incremental_rup_file)
    picosat_set_incremental_rup_file (picosat, incremental_rup_file, vars, clauses);

  lit = 0;
READ_LITERAL:
  ch = next ();

  if (ch == 'c')
    {
      while ((ch = next ()) != EOF && ch != '\n')
	;
      goto READ_LITERAL;
    }

  if (ch == EOF)
    {
      if (lit)
	return "trailing 0 missing";

      if (clauses && !force)
	return "clause missing";

      return 0;
    }

  if (isspace (ch))
    goto READ_LITERAL;

  sign = 1;
  if (ch == '-')
    {
      sign = -1;
      ch = next ();
    }

  if (!isdigit (ch))
    return "expected number";

  lit = ch - '0';
  while (isdigit (ch = next ()))
    lit = 10 * lit + (ch - '0');

  if (!clauses && !force)
    return "too many clauses";

  if (lit)
    {
      if (lit > vars && !force)
	return "maximal variable index exceeded";

      lit *= sign;
    }
  else
    clauses--;

  picosat_add (picosat, lit);

  goto READ_LITERAL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl $0x1, 0x214b0(%rip)     # 0x2417c
movq 0x21485(%rip), %rdi     # 0x24158
callq 0x1140
movl %eax, 0x214fa(%rip)     # 0x241d8
callq 0x3aa0
movl %eax, -0x18(%rbp)
cmpl $0x63, -0x18(%rbp)
jne 0x2d19
jmp 0x2cee
callq 0x3aa0
movl %eax, %ecx
movl %ecx, -0x18(%rbp)
xorl %eax, %eax
cmpl $-0x1, %ecx
movb %al, -0x29(%rbp)
je 0x2d0c
cmpl $0xa, -0x18(%rbp)
setne %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
testb $0x1, %al
jne 0x2d15
jmp 0x2d17
jmp 0x2cee
jmp 0x2cde
callq 0x1200
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x2d35
jmp 0x2cde
cmpl $0x70, -0x18(%rbp)
je 0x2d4d
jmp 0x2d3d
leaq 0x1a1c8(%rip), %rax     # 0x1cf0c
movq %rax, -0x8(%rbp)
jmp 0x3144
callq 0x1200
movq (%rax), %rax
movq %rax, -0x38(%rbp)
callq 0x3aa0
movl %eax, %ecx
movq -0x38(%rbp), %rax
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0x2d77
jmp 0x2d3d
jmp 0x2d79
callq 0x1200
movq (%rax), %rax
movq %rax, -0x40(%rbp)
callq 0x3aa0
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, -0x18(%rbp)
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x2da6
jmp 0x2d79
cmpl $0x63, -0x18(%rbp)
jne 0x2de8
callq 0x3aa0
cmpl $0x6e, %eax
jne 0x2de8
callq 0x3aa0
cmpl $0x66, %eax
jne 0x2de8
callq 0x1200
movq (%rax), %rax
movq %rax, -0x48(%rbp)
callq 0x3aa0
movl %eax, %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0x2ded
jmp 0x2d3d
jmp 0x2def
callq 0x1200
movq (%rax), %rax
movq %rax, -0x50(%rbp)
callq 0x3aa0
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, -0x18(%rbp)
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x2e1c
jmp 0x2def
callq 0x1200
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0x2e3b
jmp 0x2d3d
movl -0x18(%rbp), %eax
subl $0x30, %eax
movl %eax, -0x24(%rbp)
callq 0x1200
movq (%rax), %rax
movq %rax, -0x58(%rbp)
callq 0x3aa0
movl %eax, %ecx
movq -0x58(%rbp), %rax
movl %ecx, -0x18(%rbp)
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x2e80
imull $0xa, -0x24(%rbp), %eax
movl -0x18(%rbp), %ecx
subl $0x30, %ecx
addl %ecx, %eax
movl %eax, -0x24(%rbp)
jmp 0x2e44
callq 0x1200
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0x2e9f
jmp 0x2d3d
jmp 0x2ea1
callq 0x1200
movq (%rax), %rax
movq %rax, -0x60(%rbp)
callq 0x3aa0
movl %eax, %ecx
movq -0x60(%rbp), %rax
movl %ecx, -0x18(%rbp)
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x2ece
jmp 0x2ea1
callq 0x1200
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0x2eed
jmp 0x2d3d
movl -0x18(%rbp), %eax
subl $0x30, %eax
movl %eax, -0x28(%rbp)
callq 0x1200
movq (%rax), %rax
movq %rax, -0x68(%rbp)
callq 0x3aa0
movl %eax, %ecx
movq -0x68(%rbp), %rax
movl %ecx, -0x18(%rbp)
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x2f32
imull $0xa, -0x28(%rbp), %eax
movl -0x18(%rbp), %ecx
subl $0x30, %ecx
addl %ecx, %eax
movl %eax, -0x28(%rbp)
jmp 0x2ef6
callq 0x1200
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0x2f57
cmpl $0xa, -0x18(%rbp)
je 0x2f57
jmp 0x2d3d
cmpl $0x0, 0x2120a(%rip)     # 0x24168
je 0x2f87
movq 0x211f9(%rip), %rdi     # 0x24160
movl -0x24(%rbp), %edx
movl -0x28(%rbp), %ecx
leaq 0x19fd0(%rip), %rsi     # 0x1cf44
movb $0x0, %al
callq 0x1130
movq 0x211de(%rip), %rdi     # 0x24160
callq 0x1160
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x42e0
cmpq $0x0, 0x211b5(%rip)     # 0x24150
je 0x2fb3
movq -0x10(%rbp), %rdi
movq 0x211a8(%rip), %rsi     # 0x24150
movl -0x24(%rbp), %edx
movl -0x28(%rbp), %ecx
callq 0x5e80
movl $0x0, -0x20(%rbp)
callq 0x3aa0
movl %eax, -0x18(%rbp)
cmpl $0x63, -0x18(%rbp)
jne 0x2ff5
jmp 0x2fca
callq 0x3aa0
movl %eax, %ecx
movl %ecx, -0x18(%rbp)
xorl %eax, %eax
cmpl $-0x1, %ecx
movb %al, -0x69(%rbp)
je 0x2fe8
cmpl $0xa, -0x18(%rbp)
setne %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x2ff1
jmp 0x2ff3
jmp 0x2fca
jmp 0x2fba
cmpl $-0x1, -0x18(%rbp)
jne 0x303a
cmpl $0x0, -0x20(%rbp)
je 0x3011
leaq 0x19f5b(%rip), %rax     # 0x1cf63
movq %rax, -0x8(%rbp)
jmp 0x3144
cmpl $0x0, -0x28(%rbp)
je 0x302d
cmpl $0x0, -0x14(%rbp)
jne 0x302d
leaq 0x19f52(%rip), %rax     # 0x1cf76
movq %rax, -0x8(%rbp)
jmp 0x3144
movq $0x0, -0x8(%rbp)
jmp 0x3144
callq 0x1200
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x3059
jmp 0x2fba
movl $0x1, -0x1c(%rbp)
cmpl $0x2d, -0x18(%rbp)
jne 0x3075
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
callq 0x3aa0
movl %eax, -0x18(%rbp)
callq 0x1200
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0x309f
leaq 0x19eef(%rip), %rax     # 0x1cf85
movq %rax, -0x8(%rbp)
jmp 0x3144
movl -0x18(%rbp), %eax
subl $0x30, %eax
movl %eax, -0x20(%rbp)
callq 0x1200
movq (%rax), %rax
movq %rax, -0x78(%rbp)
callq 0x3aa0
movl %eax, %ecx
movq -0x78(%rbp), %rax
movl %ecx, -0x18(%rbp)
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x30e4
imull $0xa, -0x20(%rbp), %eax
movl -0x18(%rbp), %ecx
subl $0x30, %ecx
addl %ecx, %eax
movl %eax, -0x20(%rbp)
jmp 0x30a8
cmpl $0x0, -0x28(%rbp)
jne 0x30fd
cmpl $0x0, -0x14(%rbp)
jne 0x30fd
leaq 0x19e9e(%rip), %rax     # 0x1cf95
movq %rax, -0x8(%rbp)
jmp 0x3144
cmpl $0x0, -0x20(%rbp)
je 0x312a
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jle 0x311e
cmpl $0x0, -0x14(%rbp)
jne 0x311e
leaq 0x19e8e(%rip), %rax     # 0x1cfa6
movq %rax, -0x8(%rbp)
jmp 0x3144
movl -0x1c(%rbp), %eax
imull -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x3133
movl -0x28(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x6880
jmp 0x2fba
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)