// File: /workspace/github_cpp_makefile_star2_O2/eryxcc[P]lois/src/solvers.cpp
// Function: lois::SolverSPASS::solve(lois::rbool)
virtual int solve(rbool phi) {
    std::ofstream ofs;

    featurelist fl;
    phi->listFeatures(fl);
    for(auto r: fl.relations) if(!r->worksWith(SPASS)) {
      ofs << "SPASS cannot use " << r->getName() << std::endl;
      return 1;
      }

    ofs.open("query.spass", std::ofstream::out);
    ofs << "begin_problem(LoisProblem)." << std::endl;
    ofs << std::endl;

    ofs << "list_of_descriptions." << std::endl;
    ofs << "name({*LOIS*})." << std::endl;
    ofs << "author({*LOIS*})." << std::endl;
    ofs << "status(unknown)." << std::endl;
    ofs << "description({*generated by LOIS*})." << std::endl;
    ofs << "end_of_list." << std::endl;
    ofs << std::endl;

    OutputLanguage sav = outlan;

    outlan = SPASS_SYMBOLS;
    ofs << "list_of_symbols." << std::endl;
    for(auto r: fl.relations) {
      RelOrder *o = dynamic_cast<RelOrder*> (r);
      if(o) ofs << "predicates[(" << spassescape(o->opgreater) << ", 2)]." << std::endl;
      }
    for(auto d: fl.domains) 
      ofs << "sorts[" << d->name << "]." << std::endl;
    ofs << "end_of_list." << std::endl;
    ofs << std::endl;

    outlan = SPASS_AXIOMS;
    ofs << "list_of_formulae(axioms)." << std::endl;
    for(auto r: fl.relations) {
      RelOrder *o = dynamic_cast<RelOrder*> (r);
      // to do: axiomatize min/max
      // to do: specify domains
      // (BUT: it does not work effectively with order even now)
#define G << spassescape(o->opgreater) <<
      ofs << "formula(forall([x,y,z],implies(and(" G "(x,y), " G "(y,z)), " G "(x,z))),1)." << std::endl;
      ofs << "formula(forall([x,y],not(and(" G "(x,y), equal(x,y)))),2)." << std::endl;
      ofs << "formula(forall([x,y],or(" G "(x,y), " G "(y,x), equal(x,y))),3)." << std::endl;
      ofs << "formula(forall([x],exists([y], " G "(y,x))),4)." << std::endl;
      ofs << "formula(forall([x],exists([y], " G "(x,y))),5)." << std::endl;
      ofs << "formula(forall([x,z], implies(" G "(x,z), exists([y], and(" G "(x,y), " G "(y,z))))), 6)." << std::endl;
#undef G
      }
    ofs << "end_of_list." << std::endl;
    ofs << std::endl;

    outlan = SPASS;
    ofs << "list_of_formulae(conjectures)." << std::endl;
    ofs << "formula(not(" << phi << "))." << std::endl;
    ofs << "end_of_list." << std::endl;
    ofs << std::endl;

    ofs << "end_problem." << std::endl;

    outlan = sav;
    ofs.close();
    if(system(cmd.c_str()))
      printf("system error\n");
    FILE *f = fopen("query.out", "rt");
    char buf[500];
    int ans = 1;
    while(fgets(buf, 500, f)) {
      if(strstr(buf, "Proof found")) ans=0;
      if(strstr(buf, "Completion found")) ans=2;
      }
    fclose(f);
    printf("SPASS answer: %d\n", ans);
    return ans;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x598, %rsp            # imm = 0x598
movq %rsi, %r12
movq %rdi, %r15
leaq 0x1a0(%rsp), %rdi
callq 0x73e0
leaq 0x108(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x138(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq (%r12), %rdi
movq (%rdi), %rax
leaq 0x100(%rsp), %rsi
callq *0x40(%rax)
movq 0x148(%rsp), %r14
pushq $0x3
popq %rbp
leaq 0x138(%rsp), %rax
cmpq %rax, %r14
je 0x2beba
movq 0x20(%r14), %rbx
movq (%rbx), %rax
movq %rbx, %rdi
movl %ebp, %esi
callq *0x30(%rax)
testb %al, %al
je 0x2c7b4
movq %r14, %rdi
callq 0x7290
movq %rax, %r14
jmp 0x2be89
leaq 0x6a02(%rip), %rsi      # 0x328c3
leaq 0x1a0(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x7050
leaq 0x69f7(%rip), %rsi      # 0x328cf
leaq 0x1a0(%rsp), %rdi
callq 0x7230
movq %rax, %rdi
callq 0x7130
leaq 0x1a0(%rsp), %rdi
callq 0x7130
leaq 0x69ea(%rip), %rsi      # 0x328eb
leaq 0x1a0(%rsp), %rdi
callq 0x7230
movq %rax, %rdi
callq 0x7130
leaq 0x69e4(%rip), %rsi      # 0x32901
leaq 0x1a0(%rsp), %rdi
callq 0x7230
movq %rax, %rdi
callq 0x7130
leaq 0x69d8(%rip), %rsi      # 0x32911
leaq 0x1a0(%rsp), %rdi
callq 0x7230
movq %rax, %rdi
callq 0x7130
leaq 0x69ce(%rip), %rsi      # 0x32923
leaq 0x1a0(%rsp), %rdi
callq 0x7230
movq %rax, %rdi
callq 0x7130
leaq 0x69c3(%rip), %rsi      # 0x32934
leaq 0x1a0(%rsp), %rdi
callq 0x7230
movq %rax, %rdi
callq 0x7130
leaq 0x69cb(%rip), %rsi      # 0x32958
leaq 0x1a0(%rsp), %rdi
callq 0x7230
movq %rax, %rdi
callq 0x7130
leaq 0x1a0(%rsp), %rdi
callq 0x7130
movq %r12, 0x20(%rsp)
movq %r15, 0x18(%rsp)
leaq 0x1d92c(%rip), %rax     # 0x498ec
movl (%rax), %ecx
movl %ecx, 0x14(%rsp)
movl $0x4, (%rax)
leaq 0x6992(%rip), %rsi      # 0x32965
leaq 0x1a0(%rsp), %rdi
callq 0x7230
movq %rax, %rdi
callq 0x7130
movq 0x148(%rsp), %r15
leaq 0x1c029(%rip), %r12     # 0x48020
leaq 0xf0(%rsp), %r14
leaq 0x3a0(%rsp), %r13
leaq 0x138(%rsp), %rax
cmpq %rax, %r15
je 0x2c0b6
movq 0x20(%r15), %rdi
testq %rdi, %rdi
je 0x2c0a6
leaq 0x1c1cc(%rip), %rsi     # 0x481f8
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x7280
testq %rax, %rax
je 0x2c0a6
movq %rax, %rbx
leaq 0x1a0(%rsp), %rdi
leaq 0x6929(%rip), %rsi      # 0x32976
callq 0x7230
movq %rax, %rbp
addq $0x8, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xf5d8
movq %r13, %rdi
movq %r14, %rsi
callq 0x2865a
movq %rbp, %rdi
movq %r13, %rsi
callq 0x7210
movq %rax, %rdi
leaq 0x68ff(%rip), %rsi      # 0x32983
callq 0x7230
movq %rax, %rdi
callq 0x7130
movq %r13, %rdi
callq 0x7478
leaq 0xf8(%rsp), %rdi
callq 0xefce
movq %r15, %rdi
callq 0x7290
movq %rax, %r15
jmp 0x2c007
movq 0x118(%rsp), %r12
leaq 0x68c5(%rip), %rbx      # 0x3298a
leaq 0x1a0(%rsp), %r14
leaq 0x68b3(%rip), %r15      # 0x32987
leaq 0x108(%rsp), %rax
cmpq %rax, %r12
je 0x2c11c
movq 0x20(%r12), %r13
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7230
movq %rax, %rdi
movq %r13, %rsi
callq 0x7210
movq %rax, %rdi
movq %r15, %rsi
callq 0x7230
movq %rax, %rdi
callq 0x7130
movq %r12, %rdi
callq 0x7290
movq %rax, %r12
jmp 0x2c0d4
leaq 0x6835(%rip), %rsi      # 0x32958
leaq 0x1a0(%rsp), %rdi
callq 0x7230
movq %rax, %rdi
callq 0x7130
leaq 0x1a0(%rsp), %rdi
callq 0x7130
leaq 0x1d7a0(%rip), %rax     # 0x498ec
movl $0x5, (%rax)
leaq 0x6838(%rip), %rsi      # 0x32991
leaq 0x1a0(%rsp), %rdi
callq 0x7230
movq %rax, %rdi
callq 0x7130
movq 0x148(%rsp), %rcx
leaq 0x3a0(%rsp), %r13
leaq 0x160(%rsp), %r15
leaq 0x180(%rsp), %rbp
leaq 0x138(%rsp), %rax
cmpq %rax, %rcx
je 0x2c60a
movq %rcx, 0x28(%rsp)
movq 0x20(%rcx), %rdi
testq %rdi, %rdi
je 0x2c1c7
leaq 0x1c044(%rip), %rsi     # 0x481f8
leaq 0x1be65(%rip), %rdx     # 0x48020
xorl %ecx, %ecx
callq 0x7280
movq %rax, %r14
jmp 0x2c1ca
xorl %r14d, %r14d
leaq 0x1a0(%rsp), %rdi
leaq 0x67d2(%rip), %rsi      # 0x329ab
callq 0x7230
movq %rax, %r12
movq %r15, %rbx
addq $0x8, %r14
leaq 0xe0(%rsp), %r15
movq %r15, %rdi
movq %r14, 0x8(%rsp)
movq %r14, %rsi
callq 0xf5d8
movq %r13, %rdi
movq %r15, %rsi
callq 0x2865a
movq %r12, %rdi
movq %r13, %rsi
callq 0x7210
movq %rbx, %r15
movq %rax, %rdi
leaq 0x67ac(%rip), %rsi      # 0x329cf
callq 0x7230
movq %rax, %r12
leaq 0xd0(%rsp), %r14
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0xf5d8
movq %r15, %rdi
movq %r14, %rsi
callq 0x2865a
movq %r12, %rdi
movq %r15, %rsi
callq 0x7210
movq %rax, %rdi
leaq 0x6777(%rip), %rsi      # 0x329d7
callq 0x7230
movq %rax, %r12
leaq 0xc0(%rsp), %r15
movq %r15, %rdi
movq 0x8(%rsp), %rsi
callq 0xf5d8
movq %rbp, %rdi
movq %r15, %rsi
callq 0x2865a
movq %r12, %rdi
movq %rbp, %rsi
callq 0x7210
movq %rbx, %r15
leaq 0x67b7(%rip), %rbx      # 0x32a54
movq %rbp, %r14
movq %rax, %rdi
leaq 0x6736(%rip), %rsi      # 0x329e0
callq 0x7230
movq %rax, %rdi
callq 0x7130
movq %r14, %rbp
movq %r14, %rdi
callq 0x7478
leaq 0xc8(%rsp), %rdi
callq 0xefce
movq %r15, %rdi
callq 0x7478
leaq 0xd8(%rsp), %rdi
callq 0xefce
movq %r13, %rdi
callq 0x7478
leaq 0xe8(%rsp), %rdi
callq 0xefce
leaq 0x1a0(%rsp), %rdi
leaq 0x66e4(%rip), %rsi      # 0x329ec
callq 0x7230
movq %rax, %r12
movq %rbx, %r14
leaq 0xb0(%rsp), %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0xf5d8
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2865a
movq %r12, %rdi
movq %r13, %rsi
callq 0x7210
movq %rax, %rdi
leaq 0x66c2(%rip), %rsi      # 0x32a0a
callq 0x7230
movq %rax, %rdi
callq 0x7130
movq %r13, %rdi
callq 0x7478
leaq 0xb8(%rsp), %rdi
callq 0xefce
leaq 0x1a0(%rsp), %rdi
leaq 0x66aa(%rip), %rsi      # 0x32a23
callq 0x7230
movq %rax, %r12
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0xf5d8
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2865a
movq %r12, %rdi
movq %r13, %rsi
callq 0x7210
movq %rax, %rdi
leaq 0x6619(%rip), %rsi      # 0x329cf
callq 0x7230
movq %rax, %r12
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0xf5d8
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2865a
movq %r12, %rdi
movq %r15, %rsi
callq 0x7210
movq %rax, %rdi
leaq 0x6649(%rip), %rsi      # 0x32a3c
callq 0x7230
movq %rax, %rdi
callq 0x7130
movq %r15, %rdi
callq 0x7478
leaq 0x98(%rsp), %rdi
callq 0xefce
movq %r13, %rdi
callq 0x7478
leaq 0xa8(%rsp), %rdi
callq 0xefce
leaq 0x1a0(%rsp), %rdi
movq %r14, %rsi
callq 0x7230
movq %rax, %r12
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0xf5d8
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2865a
movq %r12, %rdi
movq %r13, %rsi
callq 0x7210
movq %rax, %rdi
leaq 0x6602(%rip), %rsi      # 0x32a74
callq 0x7230
movq %rax, %rdi
callq 0x7130
movq %r13, %rdi
callq 0x7478
leaq 0x88(%rsp), %rdi
callq 0xefce
leaq 0x1a0(%rsp), %rdi
movq %r14, %rsi
callq 0x7230
movq %rax, %r12
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0xf5d8
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2865a
movq %r12, %rdi
movq %r13, %rsi
callq 0x7210
movq %rax, %rdi
leaq 0x65a7(%rip), %rsi      # 0x32a80
callq 0x7230
movq %rax, %rdi
callq 0x7130
movq %r13, %rdi
callq 0x7478
leaq 0x78(%rsp), %rdi
callq 0xefce
leaq 0x1a0(%rsp), %rdi
leaq 0x6585(%rip), %rsi      # 0x32a8c
callq 0x7230
movq %rax, %r12
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0xf5d8
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2865a
movq %r12, %rdi
movq %r13, %rsi
callq 0x7210
movq %rax, %rdi
leaq 0x656a(%rip), %rsi      # 0x32aab
callq 0x7230
movq %rax, %r12
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0xf5d8
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2865a
movq %r12, %rdi
movq %r15, %rsi
callq 0x7210
movq %rax, %rdi
leaq 0x6454(%rip), %rsi      # 0x329cf
callq 0x7230
movq %rax, %r12
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0xf5d8
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x2865a
movq %r12, %rdi
movq %rbp, %rsi
callq 0x7210
movq %rax, %rdi
leaq 0x650e(%rip), %rsi      # 0x32ac3
callq 0x7230
movq %rax, %rdi
callq 0x7130
movq %rbp, %rdi
callq 0x7478
leaq 0x48(%rsp), %rdi
callq 0xefce
movq %r15, %rdi
callq 0x7478
leaq 0x58(%rsp), %rdi
callq 0xefce
movq %r13, %rdi
callq 0x7478
leaq 0x68(%rsp), %rdi
callq 0xefce
movq 0x28(%rsp), %rdi
callq 0x7290
movq %rax, %rcx
jmp 0x2c18e
leaq 0x6347(%rip), %rsi      # 0x32958
leaq 0x1a0(%rsp), %rdi
callq 0x7230
movq %rax, %rdi
callq 0x7130
leaq 0x1a0(%rsp), %rdi
callq 0x7130
leaq 0x1d2b2(%rip), %rax     # 0x498ec
movl $0x3, (%rax)
leaq 0x648b(%rip), %rsi      # 0x32ad2
leaq 0x1a0(%rsp), %rdi
callq 0x7230
movq %rax, %rdi
callq 0x7130
leaq 0x648e(%rip), %rsi      # 0x32af1
leaq 0x1a0(%rsp), %rdi
callq 0x7230
movq %rax, %rbx
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq 0x20(%rsp), %rsi
callq 0xf04a
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1ef1c
leaq 0x6467(%rip), %rsi      # 0x32afe
movq %rax, %rdi
callq 0x7230
movq %rax, %rdi
callq 0x7130
leaq 0x38(%rsp), %rdi
callq 0xefce
leaq 0x62a0(%rip), %rsi      # 0x32958
leaq 0x1a0(%rsp), %rdi
callq 0x7230
movq %rax, %rdi
callq 0x7130
leaq 0x1a0(%rsp), %rdi
callq 0x7130
leaq 0x6421(%rip), %rsi      # 0x32b02
leaq 0x1a0(%rsp), %rdi
callq 0x7230
movq %rax, %rdi
callq 0x7130
leaq 0x1d1ef(%rip), %rax     # 0x498ec
movl 0x14(%rsp), %ecx
movl %ecx, (%rax)
leaq 0x1a0(%rsp), %rdi
callq 0x7320
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x71e0
testl %eax, %eax
je 0x2c72e
leaq 0x6468(%rip), %rdi      # 0x32b91
callq 0x7370
leaq 0x641d(%rip), %rdi      # 0x32b52
leaq 0x4b30(%rip), %rsi      # 0x3126c
callq 0x72b0
movq %rax, %r14
pushq $0x1
popq %rbx
leaq 0x3a0(%rsp), %r15
xorl %ebp, %ebp
leaq 0x63c3(%rip), %r13      # 0x32b1b
pushq $0x2
popq %r12
movq %r15, %rdi
movl $0x1f4, %esi            # imm = 0x1F4
movq %r14, %rdx
callq 0x7380
testq %rax, %rax
je 0x2c79a
movq %r15, %rdi
leaq 0x6394(%rip), %rsi      # 0x32b0f
callq 0x7080
testq %rax, %rax
cmovnel %ebp, %ebx
movq %r15, %rdi
movq %r13, %rsi
callq 0x7080
testq %rax, %rax
cmovnel %r12d, %ebx
jmp 0x2c75c
movq %r14, %rdi
callq 0x7240
leaq 0x6383(%rip), %rdi      # 0x32b2c
movl %ebx, %esi
xorl %eax, %eax
callq 0x7040
jmp 0x2c804
leaq 0x60f6(%rip), %rsi      # 0x328b1
leaq 0x1a0(%rsp), %rdi
callq 0x7230
movq %rax, %r14
movq (%rbx), %rax
leaq 0x3a0(%rsp), %rdi
movq %rbx, %rsi
callq *0x38(%rax)
leaq 0x3a0(%rsp), %rsi
movq %r14, %rdi
callq 0x7210
movq %rax, %rdi
callq 0x7130
leaq 0x3a0(%rsp), %rdi
callq 0x7478
pushq $0x1
popq %rbx
leaq 0x100(%rsp), %rdi
callq 0x28770
leaq 0x1a0(%rsp), %rdi
callq 0x7350
movl %ebx, %eax
addq $0x598, %rsp            # imm = 0x598
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2ca30
jmp 0x2ca30
movq %rax, %rbx
leaq 0x3a0(%rsp), %rdi
callq 0x7478
jmp 0x2ca33
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0x2ca27
movq %rax, %rbx
jmp 0x2c8df
jmp 0x2ca30
jmp 0x2ca30
jmp 0x2ca30
movq %rax, %rbx
jmp 0x2c91e
movq %rax, %rbx
jmp 0x2c980
movq %rax, %rbx
jmp 0x2c966
movq %rax, %rbx
jmp 0x2c94c
movq %rax, %rbx
jmp 0x2c9b7
movq %rax, %rbx
jmp 0x2c99a
movq %rax, %rbx
jmp 0x2c935
movq %rax, %rbx
jmp 0x2ca1f
movq %rax, %rbx
jmp 0x2c9eb
movq %rax, %rbx
jmp 0x2c9d1
movq %rax, %rbx
jmp 0x2ca05
jmp 0x2ca30
movq %rax, %rbx
leaq 0x3a0(%rsp), %rdi
callq 0x7478
leaq 0xf8(%rsp), %rdi
jmp 0x2ca27
movq %rax, %rbx
jmp 0x2c928
movq %rax, %rbx
jmp 0x2c93f
movq %rax, %rbx
jmp 0x2c98d
movq %rax, %rbx
jmp 0x2c9de
movq %rax, %rbx
jmp 0x2c9f8
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
callq 0x7478
leaq 0x48(%rsp), %rdi
callq 0xefce
leaq 0x160(%rsp), %rdi
callq 0x7478
leaq 0x58(%rsp), %rdi
callq 0xefce
leaq 0x3a0(%rsp), %rdi
callq 0x7478
leaq 0x68(%rsp), %rdi
jmp 0x2ca27
movq %rax, %rbx
leaq 0x3a0(%rsp), %rdi
callq 0x7478
leaq 0x78(%rsp), %rdi
jmp 0x2ca27
movq %rax, %rbx
leaq 0x160(%rsp), %rdi
callq 0x7478
leaq 0x98(%rsp), %rdi
callq 0xefce
leaq 0x3a0(%rsp), %rdi
callq 0x7478
leaq 0xa8(%rsp), %rdi
jmp 0x2ca27
movq %rax, %rbx
leaq 0x3a0(%rsp), %rdi
callq 0x7478
leaq 0x88(%rsp), %rdi
jmp 0x2ca27
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
callq 0x7478
leaq 0xc8(%rsp), %rdi
callq 0xefce
leaq 0x160(%rsp), %rdi
callq 0x7478
leaq 0xd8(%rsp), %rdi
callq 0xefce
leaq 0x3a0(%rsp), %rdi
callq 0x7478
leaq 0xe8(%rsp), %rdi
jmp 0x2ca27
movq %rax, %rbx
leaq 0x3a0(%rsp), %rdi
callq 0x7478
leaq 0xb8(%rsp), %rdi
callq 0xefce
jmp 0x2ca33
jmp 0x2ca30
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
callq 0x28770
leaq 0x1a0(%rsp), %rdi
callq 0x7350
movq %rbx, %rdi
callq 0x7410
nop