// File: /workspace/github_cpp_makefile_star2_O3/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, 0x8(%rsp)
movq %rax, 0x40(%rsp)
cmpl $0x2, %edi
jl 0x1771
movq 0x159f6(%rip), %rax     # 0x17138
movl %edi, %ecx
movl $0x1, %edi
movq (%rsi,%rdi,8), %rdx
cmpb $0x2d, (%rdx)
je 0x1e11
testq %rax, %rax
jne 0x1e30
movq %rdx, 0x159d2(%rip)     # 0x17138
incq %rdi
movq %rdx, %rax
cmpq %rdi, %rcx
jne 0x1749
xorl %eax, %eax
callq 0x2220
movq %rax, 0x159c1(%rip)     # 0x17140
movq %rax, %rdi
xorl %eax, %eax
callq 0x2218
movq %rax, %rdi
callq 0x1200
movq %rax, %r12
leaq 0xe8aa(%rip), %rdi      # 0x10045
xorl %eax, %eax
callq 0x1f6f
leaq 0xe8b7(%rip), %rdi      # 0x10060
movq %r12, %rsi
xorl %eax, %eax
callq 0x1f6f
movq 0x1597e(%rip), %rbx     # 0x17138
testq %rbx, %rbx
je 0x17e5
movl $0x2, 0x1597f(%rip)     # 0x17148
leaq 0xe8a1(%rip), %rsi      # 0x10071
movq %rbx, %rdi
callq 0x203c
testl %eax, %eax
je 0x1806
leaq 0xe893(%rip), %rsi      # 0x10076
jmp 0x1824
leaq 0xe8b6(%rip), %rsi      # 0x100a2
movq %rsi, 0x15945(%rip)     # 0x17138
movq 0x157de(%rip), %rax     # 0x16fd8
movq (%rax), %rax
movq %rax, 0x1594c(%rip)     # 0x17150
jmp 0x1843
leaq 0xe872(%rip), %rsi      # 0x1007f
movq %rbx, %rdi
callq 0x203c
testl %eax, %eax
je 0x1dca
leaq 0xe85f(%rip), %rsi      # 0x10083
movq %rbx, %rdi
callq 0x2081
movq %rax, 0x1591d(%rip)     # 0x17150
movq 0x158fe(%rip), %rsi     # 0x17138
testq %rax, %rax
je 0x1e8c
leaq 0xe860(%rip), %rdi      # 0x100aa
xorl %eax, %eax
callq 0x1f6f
movq 0x158f8(%rip), %rdi     # 0x17150
callq 0x1210
cmpl $0x63, %eax
jne 0x1885
movq 0x158e7(%rip), %rdi     # 0x17150
callq 0x1210
cmpl $0xa, %eax
je 0x187d
cmpl $-0x1, %eax
jne 0x1862
jmp 0x1def
incl 0x158a5(%rip)           # 0x17128
jmp 0x1851
cmpl $0x70, %eax
jne 0x1dfd
movq 0x158bb(%rip), %rdi     # 0x17150
leaq 0xe851(%rip), %rsi      # 0x100ed
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x1070
testl %eax, %eax
jne 0x1e74
movl 0x15875(%rip), %esi     # 0x17128
leaq 0xe84a(%rip), %rdi      # 0x10104
xorl %eax, %eax
callq 0x1f6f
movl $0x0, 0x4(%rsp)
movq 0x15880(%rip), %rdx     # 0x17150
leaq 0x8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x11d0
cmpq $-0x1, %rax
je 0x1d1e
movq %rax, %r15
leaq 0x8(%rsp), %r14
leaq 0x40(%rsp), %rbx
xorl %r13d, %r13d
xorl %ebp, %ebp
movl $0x0, (%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x38(%rsp)
movq %r13, 0x10(%rsp)
movl 0x15809(%rip), %edx     # 0x17128
incl %edx
movl %edx, 0x15801(%rip)     # 0x17128
movq 0x8(%rsp), %rsi
movb (%rsi), %r13b
cmpb $0xa, %r13b
je 0x1944
testq %r15, %r15
jle 0x1e52
cmpb $0x63, %r13b
jne 0x1964
movq 0x15805(%rip), %rdx     # 0x17150
movq %r14, %rdi
movq %rbx, %rsi
callq 0x11d0
movq %rax, %r15
cmpq $-0x1, %rax
jne 0x1919
jmp 0x1d17
cmpb $0x61, %r13b
movq %r12, 0x18(%rsp)
movq %rbp, 0x28(%rsp)
jne 0x1996
cmpq $0x1, %r15
movl (%rsp), %r14d
je 0x1e95
addq $0x2, %rsi
movl $0x2, %ebx
movq $0x0, 0x20(%rsp)
jmp 0x199c
xorl %ebx, %ebx
movl (%rsp), %r14d
movq %rsi, %rdi
leaq 0xe77e(%rip), %rsi      # 0x10124
leaq 0x4(%rsp), %rdx
xorl %eax, %eax
callq 0x1160
cmpl $0x1, %eax
jne 0x1e60
movl %r14d, %r12d
movl 0x4(%rsp), %ebp
movl %ebp, %eax
negl %eax
movl %ebp, %r14d
movl %eax, 0x4c(%rsp)
cmovnsl %eax, %r14d
cmpl %r14d, %r12d
cmovgl %r12d, %r14d
cmpb $0x61, %r13b
jne 0x1a1b
testl %ebp, %ebp
je 0x1ac4
movq 0x15753(%rip), %rdi     # 0x17140
movq %rbp, 0x30(%rsp)
movl %ebp, %esi
callq 0x2296
movl %r14d, (%rsp)
movl %r14d, %esi
cmpq $0x0, 0x10(%rsp)
je 0x1a2f
cmpq %rsi, 0x20(%rsp)
jae 0x1a2f
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %r14
jmp 0x1a49
movq 0x1571e(%rip), %rdi     # 0x17140
movl %ebp, %esi
callq 0x2291
movl 0x4(%rsp), %ecx
jmp 0x1a67
movq 0x20(%rsp), %r14
cmpq %rsi, %r14
cmovaq %r14, %rsi
shlq $0x2, %rsi
movq 0x10(%rsp), %rdi
callq 0x1180
movl 0x4(%rsp), %ecx
movq %rax, 0x10(%rsp)
movl %ecx, (%rax,%r14,4)
incq %r14
movq %r14, 0x20(%rsp)
movl (%rsp), %r14d
movq 0x30(%rsp), %rbp
testl %ecx, %ecx
je 0x1aba
cmpq %r15, %rbx
jae 0x1a86
movq 0x8(%rsp), %rax
cmpb $0x20, (%rax,%rbx)
je 0x1a86
incq %rbx
cmpq %rbx, %r15
jne 0x1a75
movq %r15, %rbx
incq %rbx
cmpq %r15, %rbx
jae 0x1aba
movq 0x8(%rsp), %rdi
addq %rbx, %rdi
leaq 0xe687(%rip), %rsi      # 0x10124
leaq 0x4(%rsp), %rdx
xorl %eax, %eax
callq 0x1160
movl %r14d, %r12d
cmpl $0x1, %eax
je 0x19be
jmp 0x1e60
cmpb $0x61, %r13b
jne 0x1bdd
movq 0x38(%rsp), %rsi
incq %rsi
movl 0x15656(%rip), %ecx     # 0x17128
leaq 0xe6f8(%rip), %rdi      # 0x101d1
movq %rsi, 0x38(%rsp)
movq 0x20(%rsp), %r15
movq %r15, %rdx
xorl %eax, %eax
callq 0x1f6f
callq 0x21b8
movsd %xmm0, 0x30(%rsp)
movq 0x15641(%rip), %rdi     # 0x17140
callq 0x229b
movl %eax, %ebx
callq 0x21b8
cmpl $0x14, %ebx
movq 0x10(%rsp), %r13
movl %r14d, (%rsp)
je 0x1bfa
movq %rbx, 0x28(%rsp)
cmpl $0xa, %ebx
jne 0x1c76
movsd %xmm0, 0x50(%rsp)
testl %r14d, %r14d
je 0x1c8f
movq 0x1548f(%rip), %rbx     # 0x16fd0
movq (%rbx), %rdi
callq 0x1150
leaq 0xe7a8(%rip), %rdi      # 0x102f8
callq 0x1080
movq (%rbx), %rsi
movl $0x76, %edi
callq 0x1100
movq %rbp, %r15
cmpl %r15d, %r12d
cmovgl %r12d, %r15d
movl 0x4c(%rsp), %eax
cmpl %eax, %r15d
cmovlel %eax, %r15d
negl %r15d
movl $0x1, %ebx
movq 0x18(%rsp), %r12
leaq 0xe598(%rip), %rbp      # 0x10123
testb $0x7, %bl
jne 0x1ba6
movq 0x15439(%rip), %rax     # 0x16fd0
movq (%rax), %rsi
leaq 0xe667(%rip), %rdi      # 0x10208
callq 0x10e0
movq 0x15593(%rip), %rdi     # 0x17140
movl %ebx, %esi
callq 0x22aa
movq %rbp, %rdi
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 0x1b8b
xorl %ebx, %ebx
movq 0x28(%rsp), %rbp
jmp 0x1ca4
movl %r14d, (%rsp)
movq 0x18(%rsp), %r12
movq 0x28(%rsp), %rbp
movq 0x10(%rsp), %r13
leaq 0x8(%rsp), %r14
jmp 0x1cf1
movsd %xmm0, 0x50(%rsp)
movq %rbx, %rbp
movq 0x153c6(%rip), %rbx     # 0x16fd0
movq (%rbx), %rdi
callq 0x1150
leaq 0xe6cf(%rip), %rdi      # 0x102e8
callq 0x1080
movq (%rbx), %rsi
movl $0x76, %edi
callq 0x1100
testq %r15, %r15
je 0x1c9d
xorl %r14d, %r14d
xorl %ebx, %ebx
movq 0x18(%rsp), %r12
movq 0x154ff(%rip), %rdi     # 0x17140
movl (%r13,%r14,4), %eax
movl %eax, %esi
negl %esi
cmovsl %eax, %esi
callq 0x22a5
testl %eax, %eax
je 0x1c6c
incq %rbx
movl (%r13,%r14,4), %esi
leaq 0xe4be(%rip), %rdi      # 0x10123
xorl %eax, %eax
callq 0x10b0
incq %r14
cmpq %r14, %r15
jne 0x1c3a
jmp 0x1ca4
xorl %ebx, %ebx
movq 0x18(%rsp), %r12
movq 0x28(%rsp), %rbp
leaq 0x8(%rsp), %r14
movsd 0x30(%rsp), %xmm1
jmp 0x1cd5
xorl %ebx, %ebx
movq 0x18(%rsp), %r12
movq 0x28(%rsp), %rbp
jmp 0x1cb8
xorl %ebx, %ebx
movq 0x18(%rsp), %r12
movq 0x15325(%rip), %rax     # 0x16fd0
movq (%rax), %rsi
movl $0xa, %edi
callq 0x1100
leaq 0xe647(%rip), %rdi      # 0x10306
callq 0x1080
leaq 0x8(%rsp), %r14
movsd 0x30(%rsp), %xmm1
movsd 0x50(%rsp), %xmm0
subsd %xmm1, %xmm0
leaq 0xe52b(%rip), %rdi      # 0x1020b
movq 0x38(%rsp), %rsi
movl %ebp, %edx
movq %rbx, %rcx
movb $0x1, %al
callq 0x1f6f
movq 0x15458(%rip), %rdx     # 0x17150
movq %r14, %rdi
leaq 0x40(%rsp), %rbx
movq %rbx, %rsi
callq 0x11d0
movq %rax, %r15
cmpq $-0x1, %rax
jne 0x1914
jmp 0x1d21
movq 0x10(%rsp), %r13
jmp 0x1d21
xorl %r13d, %r13d
movq 0x15428(%rip), %rdi     # 0x17150
callq 0x1130
testl %eax, %eax
je 0x1e80
testq %r13, %r13
je 0x1d42
movq %r13, %rdi
callq 0x1040
movl 0x15400(%rip), %eax     # 0x17148
cmpl $0x2, %eax
jne 0x1d5f
movq 0x153fc(%rip), %rdi     # 0x17150
callq 0x10c0
movl 0x153e9(%rip), %eax     # 0x17148
cmpl $0x1, %eax
jne 0x1d70
movq 0x153e5(%rip), %rdi     # 0x17150
callq 0x1090
movq 0x15259(%rip), %rax     # 0x16fd0
movq (%rax), %rdi
callq 0x1150
movq 0x153ba(%rip), %rdi     # 0x17140
callq 0x227f
callq 0x21b8
leaq 0xe4df(%rip), %rdi      # 0x10276
movq %r12, %rsi
movb $0x1, %al
callq 0x1f6f
leaq 0xe4ef(%rip), %rdi      # 0x10297
movl %ebp, %esi
xorl %eax, %eax
callq 0x1f6f
movq %r12, %rdi
callq 0x1040
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10e58(%rip), %rsi     # 0x12c29
movq %rbx, %rdi
callq 0x11a0
movq %rax, 0x15370(%rip)     # 0x17150
movl $0x1, 0x1535e(%rip)     # 0x17148
jmp 0x1833
leaq 0xe2c1(%rip), %rdi      # 0x100b7
xorl %eax, %eax
callq 0x20df
cmpl $0xa, %eax
jne 0x1e08
incl 0x15320(%rip)           # 0x17128
leaq 0xe2ca(%rip), %rdi      # 0x100d9
jmp 0x1df6
cmpb $0x68, 0x1(%rdx)
jne 0x1e41
cmpb $0x0, 0x2(%rdx)
jne 0x1e41
leaq 0xe4e6(%rip), %rdi      # 0x1030a
callq 0x1080
xorl %edi, %edi
callq 0x11f0
leaq 0xe1f1(%rip), %rdi      # 0x10028
movq %rax, %rsi
xorl %eax, %eax
callq 0x1ea3
leaq 0xe1c8(%rip), %rdi      # 0x10010
movq %rdx, %rsi
xorl %eax, %eax
callq 0x1ea3
leaq 0xe2ce(%rip), %rdi      # 0x10127
xorl %eax, %eax
callq 0x1ea3
movl 0x152c2(%rip), %esi     # 0x17128
leaq 0xe310(%rip), %rdi      # 0x1017d
xorl %eax, %eax
callq 0x1ea3
leaq 0xe27a(%rip), %rdi      # 0x100f5
jmp 0x1df6
leaq 0xe3d0(%rip), %rdi      # 0x10257
jmp 0x1df6
leaq 0xe1fd(%rip), %rdi      # 0x10090
jmp 0x1e4b
leaq 0xe2ab(%rip), %rdi      # 0x10147
xorl %eax, %eax
callq 0x1ea3