// File: /workspace/github_cpp_makefile_star2_O1/biotomas[P]ipasir/app/icnf/icnf.c
// Function: main
int main (int argc, char ** argv) {
  int res = 0, i, ch, lit, max_var = 0, assumption;
  char *line = NULL, *line_content;
  size_t len = 0, parsed, solves = 0, parsed_assumptions = 0, core_size = 0;
  ssize_t read;
  char * sig;
  double pre_time, post_time;
  int * current_assumptions = NULL;

  for (i = 1; i < argc; i++) {
    if (!strcmp (argv[i], "-h")) usage ();
    else if (argv[i][0] == '-') die ("invalid '%s' (try '-h')", argv[i]);
    else if (name) die ("multiple files '%s' and '%s'", name, argv[i]);
    else name = argv[i];
  }

  solver = ipasir_init ();

  sig = strdup (ipasir_signature (solver));
  msg ("icnf generic IPASIR Solver");
  msg ("initialized '%s'", sig);

  if (name) {
    closefile = 2;
    if (hasuffix (name, ".bz2")) file = pipeit (name, "bzcat %s");
    else if (hasuffix (name, ".gz")) file = pipeit (name, "gunzip -c %s");
    else file = fopen (name, "r"), closefile = 1;
    if (!file) die ("can not read '%s'", name);
  } else name = "<stdin>", file = stdin;

  msg ("reading '%s'", name);

  while (NEXT () == 'c') {
    while (NEXT () != '\n')
      if (ch == EOF)
    perr ("unexpected end-of-file in comment");
  }
  if (ch != 'p') perr ("expected 'p' or 'c'");
  if (fscanf (file, " inccnf") != 0)
    perr ("invalid header");

  msg ("found 'p inccnf' header at line %d", lineno);
  lit = 0;

  while ((read = getline(&line, &len, file)) != -1) {
    lineno ++;
    /* skip line breaks */
    if( line[0] == '\n') continue;

    /* skip short lines */
    if( read < 1 ) die ("found an empty line in the file");

    /* skip comments */
    if( line[0] == 'c' ) continue;

    line_content = line;
    parsed = 0;
    assumption = 0;

    if( line[0] == 'a' ) {
      if(read < 2) die("expected assumption vector to solve in '%s' (line %d)", line, lineno);
      parsed = 2;
      line_content = &(line[parsed]);
      assumption = 1;
      parsed_assumptions = 0;
    }

    while ( (i = sscanf (line_content, "%d", &lit)) == 1) {

      /* track highest variable */
      if (lit < 0) max_var = max_var > -lit ? max_var : -lit;
      else max_var = max_var > lit ? max_var : lit;

      /* in case we're on the assumption line, assume the literals and solver */
      if (!assumption) {
        ipasir_add (solver, lit);
      }
      else if (lit)
      {
        ipasir_assume(solver, lit);
        /* track variables to be assumed */
        if (current_assumptions == NULL || parsed_assumptions >= max_var)
          current_assumptions = realloc(current_assumptions, sizeof(int) * (max_var > parsed_assumptions ? max_var : parsed_assumptions));
        current_assumptions[parsed_assumptions] = lit;
        parsed_assumptions ++;
      }

      /* stop at the end of the clause, do not read the rest of the line */
      if (!lit) break;
      while (parsed < read && line[parsed] != ' ') ++parsed;
      /* actually skip space */
       ++parsed;
      if (parsed >= read) break;
      line_content = &(line[parsed]);
    }

    if (i != 1) die ("expected literals or a clause delimiter on line %s (line %d), but did not find any\n", lineno);

    if(assumption) {
      core_size = 0;
      solves ++;
      msg ("solved assumptions %lu (%d assumptions) on line %d ...", solves, parsed_assumptions, lineno);
      pre_time = getime ();
      res = ipasir_solve(solver);
      post_time = getime ();

      /* print model, or unsat core */
      if (res == 10)
      {
        if (max_var) {
          fflush (stdout);
          printf ("s SATISFIABLE\n");
          fputc ('v', stdout);
          for (i = 1; i <= max_var; i++) {
          if (!(i % 8)) fputs ("\nv", stdout);
            printf (" %d", ipasir_val (solver, i));
          }
          fputc ('\n', stdout);
        }
        printf ("v 0\n");
      } else if (res == 20) {
        core_size = 0;
        fflush (stdout);
        printf ("s UNSATISFIABLE\n");
        fputc ('v', stdout);
        for( i=0; i < parsed_assumptions; ++i )
        {
          if (ipasir_failed(solver, current_assumptions[i] < 0 ? -current_assumptions[i] : current_assumptions[i]))
          {
            core_size ++;
            printf (" %d", current_assumptions[i]);
          }
        }
        fputc ('\n', stdout);
        printf ("v 0\n");
      }

      msg ("solved assumptions %lu with results %d and unsat core of %u in %.2f seconds", solves, res, core_size, post_time - pre_time);
    }
  }

  if (!feof (file)) perr ("end of file is not reached yet");
  if (current_assumptions) free(current_assumptions);
  if (closefile == 2) pclose (file);
  if (closefile == 1) fclose (file);

  /* cleanup */
  fflush (stdout);
  ipasir_release (solver);
  msg ("released '%s' after %.2f seconds", sig, getime ());
  msg ("exit %d", res);
  free (sig);
  return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
xorl %eax, %eax
movq %rax, 0x18(%rsp)
movq %rax, 0x38(%rsp)
cmpl $0x2, %edi
jl 0x1790
movq %rsi, %rbx
movq 0x159f3(%rip), %r14     # 0x17138
movl %edi, %r13d
movl $0x1, %ebp
leaq 0xe8bc(%rip), %r12      # 0x10010
movq (%rbx,%rbp,8), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x1110
testl %eax, %eax
je 0x1d9b
cmpb $0x2d, (%r15)
je 0x1dae
testq %r14, %r14
jne 0x1dbf
movq %r15, 0x159b3(%rip)     # 0x17138
incq %rbp
movq %r15, %r14
cmpq %rbp, %r13
jne 0x1754
xorl %eax, %eax
callq 0x21a8
movq %rax, 0x159a2(%rip)     # 0x17140
movq %rax, %rdi
xorl %eax, %eax
callq 0x21a0
movq %rax, %rdi
callq 0x1200
movq %rax, %r12
leaq 0xe88e(%rip), %rdi      # 0x10048
xorl %eax, %eax
callq 0x1ef7
leaq 0xe89b(%rip), %rdi      # 0x10063
movq %r12, %rsi
xorl %eax, %eax
callq 0x1ef7
movq 0x1595f(%rip), %rbx     # 0x17138
testq %rbx, %rbx
je 0x1804
movl $0x2, 0x15960(%rip)     # 0x17148
leaq 0xe885(%rip), %rsi      # 0x10074
movq %rbx, %rdi
callq 0x1fc4
testl %eax, %eax
je 0x1825
leaq 0xe877(%rip), %rsi      # 0x10079
jmp 0x1843
leaq 0xe89a(%rip), %rax      # 0x100a5
movq %rax, 0x15926(%rip)     # 0x17138
movq 0x157bf(%rip), %rax     # 0x16fd8
movq (%rax), %rax
movq %rax, 0x1592d(%rip)     # 0x17150
jmp 0x1860
leaq 0xe856(%rip), %rsi      # 0x10082
movq %rbx, %rdi
callq 0x1fc4
testl %eax, %eax
je 0x1d54
leaq 0xe843(%rip), %rsi      # 0x10086
movq %rbx, %rdi
callq 0x2009
movq %rax, 0x158fe(%rip)     # 0x17150
cmpq $0x0, 0x158f6(%rip)     # 0x17150
je 0x1df3
movq 0x158d1(%rip), %rsi     # 0x17138
leaq 0xe83f(%rip), %rdi      # 0x100ad
xorl %eax, %eax
callq 0x1ef7
movq 0x158d4(%rip), %rdi     # 0x17150
callq 0x1210
cmpl $0x63, %eax
jne 0x18a9
movq 0x158c3(%rip), %rdi     # 0x17150
callq 0x1210
cmpl $0xa, %eax
je 0x18a1
cmpl $-0x1, %eax
jne 0x1886
jmp 0x1d79
incl 0x15881(%rip)           # 0x17128
jmp 0x1875
cmpl $0x70, %eax
jne 0x1d87
movq 0x15897(%rip), %rdi     # 0x17150
leaq 0xe830(%rip), %rsi      # 0x100f0
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x1070
testl %eax, %eax
jne 0x1de1
movl 0x15851(%rip), %esi     # 0x17128
leaq 0xe829(%rip), %rdi      # 0x10107
xorl %eax, %eax
callq 0x1ef7
movl $0x0, 0xc(%rsp)
movq 0x1585c(%rip), %rdx     # 0x17150
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x11d0
cmpq $-0x1, %rax
je 0x1cad
movq %rax, %r15
leaq 0x38(%rsp), %r13
xorl %ebp, %ebp
xorl %ebx, %ebx
xorl %r14d, %r14d
movq $0x0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq %rbp, 0x10(%rsp)
incl 0x157ef(%rip)           # 0x17128
movq 0x18(%rsp), %rax
cmpb $0xa, (%rax)
je 0x195a
testq %r15, %r15
jle 0x1dd3
movq 0x18(%rsp), %rsi
movb (%rsi), %bpl
cmpb $0x63, %bpl
jne 0x197c
movq 0x157ef(%rip), %rdx     # 0x17150
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x11d0
movq %rax, %r15
cmpq $-0x1, %rax
jne 0x1933
jmp 0x1ca6
cmpb $0x61, %bpl
movq %r12, 0x50(%rsp)
movq %rbx, 0x28(%rsp)
jne 0x19af
cmpq $0x1, %r15
je 0x1e17
movq 0x18(%rsp), %rsi
addq $0x2, %rsi
movl $0x2, %ebx
movq $0x0, 0x20(%rsp)
jmp 0x19b1
xorl %ebx, %ebx
movq %rsi, %rdi
leaq 0xe76c(%rip), %rsi      # 0x10127
leaq 0xc(%rsp), %rdx
xorl %eax, %eax
callq 0x1160
cmpl $0x1, %eax
sete %r12b
jne 0x1a99
movl %r14d, %eax
movl 0xc(%rsp), %esi
movl %esi, %r14d
negl %r14d
cmovsl %esi, %r14d
cmpl %r14d, %eax
cmovgl %eax, %r14d
cmpb $0x61, %bpl
jne 0x1a20
testl %esi, %esi
je 0x1a62
movq 0x15743(%rip), %rdi     # 0x17140
callq 0x221e
movl %r14d, %esi
cmpq $0x0, 0x10(%rsp)
je 0x1a2e
cmpq %rsi, 0x20(%rsp)
jae 0x1a2e
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %r13
jmp 0x1a48
movq 0x15719(%rip), %rdi     # 0x17140
callq 0x2219
jmp 0x1a62
movq 0x20(%rsp), %r13
cmpq %rsi, %r13
cmovaq %r13, %rsi
shlq $0x2, %rsi
movq 0x10(%rsp), %rdi
callq 0x1180
movl 0xc(%rsp), %ecx
movq %rax, 0x10(%rsp)
movl %ecx, (%rax,%r13,4)
incq %r13
movq %r13, 0x20(%rsp)
leaq 0x38(%rsp), %r13
cmpl $0x0, 0xc(%rsp)
je 0x1a99
cmpq %r15, %rbx
jae 0x1a84
movq 0x18(%rsp), %rax
cmpb $0x20, (%rax,%rbx)
je 0x1a84
incq %rbx
cmpq %rbx, %r15
jne 0x1a73
movq %r15, %rbx
incq %rbx
cmpq %r15, %rbx
jae 0x1a99
movq 0x18(%rsp), %rdi
addq %rbx, %rdi
jmp 0x19b4
testb $0x1, %r12b
je 0x1e03
cmpb $0x61, %bpl
movq 0x50(%rsp), %r12
movq 0x28(%rsp), %rbx
jne 0x1c7a
movq 0x30(%rsp), %rsi
incq %rsi
movl 0x15663(%rip), %ecx     # 0x17128
leaq 0xe708(%rip), %rdi      # 0x101d4
movq %rsi, 0x30(%rsp)
movq 0x20(%rsp), %r15
movq %r15, %rdx
xorl %eax, %eax
callq 0x1ef7
callq 0x2140
movsd %xmm0, 0x48(%rsp)
movq 0x1564e(%rip), %rdi     # 0x17140
callq 0x2223
movl %eax, %ebx
callq 0x2140
cmpl $0x14, %ebx
movq %rbx, 0x28(%rsp)
je 0x1baf
cmpl $0xa, %ebx
jne 0x1c54
movsd %xmm0, 0x40(%rsp)
testl %r14d, %r14d
je 0x1ca2
movq 0x154a5(%rip), %rbx     # 0x16fd0
movq (%rbx), %rdi
callq 0x1150
leaq 0xe7c1(%rip), %rdi      # 0x102fb
callq 0x1080
movq (%rbx), %rsi
movl $0x76, %edi
callq 0x1100
testl %r14d, %r14d
jle 0x1c2a
movl %r14d, %r15d
negl %r15d
movl $0x1, %ebx
leaq 0xe6a4(%rip), %rbp      # 0x1020b
testb $0x7, %bl
jne 0x1b7e
movq 0x1545d(%rip), %rax     # 0x16fd0
movq (%rax), %rsi
movq %rbp, %rdi
callq 0x10e0
movq 0x155bb(%rip), %rdi     # 0x17140
movl %ebx, %esi
callq 0x2232
leaq 0xe593(%rip), %rdi      # 0x10126
movl %eax, %esi
xorl %eax, %eax
callq 0x10b0
leal (%r15,%rbx), %eax
incl %eax
movl %ebx, %ecx
incl %ecx
movl %ecx, %ebx
cmpl $0x1, %eax
jne 0x1b67
jmp 0x1c2a
movsd %xmm0, 0x40(%rsp)
movq 0x15414(%rip), %rbx     # 0x16fd0
movq (%rbx), %rdi
callq 0x1150
leaq 0xe720(%rip), %rdi      # 0x102eb
callq 0x1080
movq (%rbx), %rsi
movl $0x76, %edi
callq 0x1100
testq %r15, %r15
je 0x1c2a
xorl %r15d, %r15d
xorl %ebx, %ebx
movq 0x15552(%rip), %rdi     # 0x17140
movq 0x10(%rsp), %rbp
movl (%rbp,%r15,4), %eax
movl %eax, %esi
negl %esi
cmovsl %eax, %esi
callq 0x222d
testl %eax, %eax
je 0x1c1e
incq %rbx
movl (%rbp,%r15,4), %esi
leaq 0xe50f(%rip), %rdi      # 0x10126
xorl %eax, %eax
callq 0x10b0
incq %r15
cmpq %r15, 0x20(%rsp)
jne 0x1be7
jmp 0x1c2c
xorl %ebx, %ebx
movq 0x1539d(%rip), %rax     # 0x16fd0
movq (%rax), %rsi
movl $0xa, %edi
callq 0x1100
leaq 0xe6c2(%rip), %rdi      # 0x10309
callq 0x1080
movsd 0x40(%rsp), %xmm0
jmp 0x1c56
xorl %ebx, %ebx
subsd 0x48(%rsp), %xmm0
leaq 0xe5ab(%rip), %rdi      # 0x1020e
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %rbx, %rcx
movq %rdx, %rbx
movb $0x1, %al
callq 0x1ef7
movq 0x10(%rsp), %rbp
movq 0x154ca(%rip), %rdx     # 0x17150
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x11d0
movq %rax, %r15
cmpq $-0x1, %rax
jne 0x192e
jmp 0x1caf
xorl %ebx, %ebx
jmp 0x1c40
movq 0x10(%rsp), %rbp
jmp 0x1caf
xorl %ebp, %ebp
movq 0x1549a(%rip), %rdi     # 0x17150
callq 0x1130
testl %eax, %eax
je 0x1dea
testq %rbp, %rbp
je 0x1cd0
movq %rbp, %rdi
callq 0x1040
cmpl $0x2, 0x15471(%rip)     # 0x17148
jne 0x1ce5
movq 0x15470(%rip), %rdi     # 0x17150
callq 0x10c0
cmpl $0x1, 0x1545c(%rip)     # 0x17148
jne 0x1cfa
movq 0x1545b(%rip), %rdi     # 0x17150
callq 0x1090
movq 0x152cf(%rip), %rax     # 0x16fd0
movq (%rax), %rdi
callq 0x1150
movq 0x15430(%rip), %rdi     # 0x17140
callq 0x2207
callq 0x2140
leaq 0xe558(%rip), %rdi      # 0x10279
movq %r12, %rsi
movb $0x1, %al
callq 0x1ef7
leaq 0xe568(%rip), %rdi      # 0x1029a
movl %ebx, %esi
xorl %eax, %eax
callq 0x1ef7
movq %r12, %rdi
callq 0x1040
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10f02(%rip), %rsi     # 0x12c5d
movq %rbx, %rdi
callq 0x11a0
movq %rax, 0x153e6(%rip)     # 0x17150
movl $0x1, 0x153d4(%rip)     # 0x17148
jmp 0x1852
leaq 0xe33a(%rip), %rdi      # 0x100ba
xorl %eax, %eax
callq 0x2067
cmpl $0xa, %eax
jne 0x1d92
incl 0x15396(%rip)           # 0x17128
leaq 0xe343(%rip), %rdi      # 0x100dc
jmp 0x1d80
leaq 0xe56b(%rip), %rdi      # 0x1030d
callq 0x1080
xorl %edi, %edi
callq 0x11f0
leaq 0xe25e(%rip), %rdi      # 0x10013
movq %r15, %rsi
xorl %eax, %eax
callq 0x1e2b
leaq 0xe265(%rip), %rdi      # 0x1002b
movq %r14, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x1e2b
leaq 0xe350(%rip), %rdi      # 0x1012a
xorl %eax, %eax
callq 0x1e2b
leaq 0xe310(%rip), %rdi      # 0x100f8
jmp 0x1d80
leaq 0xe469(%rip), %rdi      # 0x1025a
jmp 0x1d80
movq 0x1533e(%rip), %rsi     # 0x17138
leaq 0xe292(%rip), %rdi      # 0x10093
jmp 0x1db8
movl 0x1531f(%rip), %esi     # 0x17128
leaq 0xe370(%rip), %rdi      # 0x10180
xorl %eax, %eax
callq 0x1e2b
movl 0x1530b(%rip), %edx     # 0x17128
leaq 0xe326(%rip), %rdi      # 0x1014a
xorl %eax, %eax
callq 0x1e2b