// File: /workspace/github_cpp_makefile_star2_O3/eryxcc[P]lois/src/solvers.cpp
// Function: lois::SolverSMT::solve(lois::rbool)
virtual int solve(rbool phi) {

    featurelist fl;
    phi->listFeatures(fl);
    if(fl.domains.size() > 1) {
      std::cout << "SMT cannot use multiple domains yet" << std::endl;
      return 1;
      }
    for(auto r: fl.relations) if(!r->worksWith(SMT)) {
      std::cout << "SMT cannot use " << r->getName() << std::endl;
      return 1;
      }

    std::ofstream ofs;

    ofs.open("smtquery.smt", std::ofstream::out);
    
    // set 4 for nice indentation
    // indent = 4; 
    indent = -100;
    
    ofs << "(benchmark test\n  :extrasorts (A)\n  :logic " << smtLogic << "\n  :formula \n    ";
    
    OutputLanguage sav = outlan;
    outlan = SMT;
    ofs << phi << std::endl << "    )" << std::endl;
    outlan = sav;
    ofs.close();
    // system("cvc3 -lang smt < smtquery.smt > smtquery.out");  
    if(system(cmd.c_str()))
      printf("system error\n");
    FILE *f = fopen("smtquery.out", "rt");
    char buf[500];
    char *b = fgets(buf, 500, f);
    if(!b) { printf("ERROR\n"); exit(3); }
    fclose(f);
    std::string ans = buf;
    if(ans == "sat\n") return 2;
    if(ans == "unsat\n") return 0;
    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x488, %rsp            # imm = 0x488
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x38(%rsp), %rax
xorl %ecx, %ecx
movl %ecx, (%rax)
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq 0x68(%rsp), %r13
movl %ecx, (%r13)
movq %rcx, 0x8(%r13)
movq %r13, 0x10(%r13)
movq %r13, 0x18(%r13)
movq %rcx, 0x20(%r13)
movq (%rsi), %rdi
movq (%rdi), %rax
leaq 0x30(%rsp), %rsi
callq *0x40(%rax)
cmpq $0x2, 0x58(%rsp)
jb 0x37f17
movq 0x1a102(%rip), %rbx     # 0x51fd0
leaq 0x8801(%rip), %rsi      # 0x406d6
movl $0x23, %edx
movq %rbx, %rdi
callq 0x72c0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x7250
movsbl %al, %esi
movq 0x1a0d0(%rip), %rdi     # 0x51fd0
callq 0x7030
movl $0x1, %ebx
movq %rax, %rdi
callq 0x7190
jmp 0x38247
movq 0x78(%rsp), %r12
cmpq %r13, %r12
je 0x37f4c
movq 0x20(%r12), %r15
movq (%r15), %rax
movq %r15, %rdi
movl $0x2, %esi
callq *0x30(%rax)
testb %al, %al
je 0x38009
movq %r12, %rdi
callq 0x72d0
movq %rax, %r12
cmpq %r13, %rax
jne 0x37f21
leaq 0x90(%rsp), %rdi
callq 0x73f0
leaq 0x8860(%rip), %rsi      # 0x407c0
leaq 0x90(%rsp), %rdi
movl $0x10, %edx
callq 0x7060
leaq 0x1a96f(%rip), %rax     # 0x528e8
movl $0xffffff9c, (%rax)     # imm = 0xFFFFFF9C
leaq 0x8847(%rip), %rsi      # 0x407cd
leaq 0x90(%rsp), %rdi
movl $0x2b, %edx
callq 0x72c0
movq 0x1a8e9(%rip), %rsi     # 0x52888
movq 0x1a8ea(%rip), %rdx     # 0x52890
leaq 0x90(%rsp), %rdi
callq 0x72c0
leaq 0x883f(%rip), %rsi      # 0x407f9
movl $0x11, %edx
movq %rax, %rdi
callq 0x72c0
leaq 0x1a91e(%rip), %r15     # 0x528ec
movl (%r15), %ebp
movl $0x2, (%r15)
movq (%r14), %rax
movq %rax, (%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x380a7
movq 0x19fd0(%rip), %rcx     # 0x51fc8
cmpb $0x0, (%rcx)
je 0x380a3
incl 0x8(%rax)
jmp 0x380a7
movq 0x19fc0(%rip), %rdi     # 0x51fd0
leaq 0x86e3(%rip), %rsi      # 0x406fa
movl $0xf, %edx
callq 0x72c0
movq (%r15), %rax
leaq 0x90(%rsp), %rdi
movq %r15, %rsi
callq *0x38(%rax)
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq 0x19f87(%rip), %rdi     # 0x51fd0
callq 0x72c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x7250
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7030
movq %rax, %rdi
callq 0x7190
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x38099
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x7280
movl $0x1, %ebx
jmp 0x38247
lock
incl 0x8(%rax)
leaq 0x90(%rsp), %rdi
movq %rsp, %rsi
callq 0x297cc
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x7250
movsbl %al, %esi
movq %r14, %rdi
callq 0x7030
movq %rax, %rdi
callq 0x7190
movq %rax, %r14
leaq 0x85c3(%rip), %rsi      # 0x406ae
movl $0x5, %edx
movq %rax, %rdi
callq 0x72c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x7250
movsbl %al, %esi
movq %r14, %rdi
callq 0x7030
movq %rax, %rdi
callq 0x7190
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x3812e
callq 0x133fc
movl %ebp, (%r15)
leaq 0x90(%rsp), %rdi
callq 0x7330
movq 0x8(%rbx), %rdi
callq 0x7210
testl %eax, %eax
je 0x38157
leaq 0x8a3f(%rip), %rdi      # 0x40b91
callq 0x7370
leaq 0x86ca(%rip), %rdi      # 0x40828
leaq 0x7107(%rip), %rsi      # 0x3f26c
callq 0x72e0
movq %rax, %rbx
leaq 0x290(%rsp), %rdi
movl $0x1f4, %esi            # imm = 0x1F4
movq %rax, %rdx
callq 0x7390
testq %rax, %rax
je 0x3826f
movq %rbx, %rdi
callq 0x7260
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x290(%rsp), %rbx
movq %rbx, %rdi
callq 0x7130
leaq (%rsp,%rax), %rdx
addq $0x290, %rdx            # imm = 0x290
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x1c74a
leaq 0x8642(%rip), %rsi      # 0x4080d
leaq 0x10(%rsp), %rdi
callq 0x70c0
testl %eax, %eax
je 0x381f3
leaq 0x862b(%rip), %rsi      # 0x4080b
leaq 0x10(%rsp), %rdi
callq 0x70c0
xorl %ebx, %ebx
testl %eax, %eax
setne %bl
jmp 0x381f8
movl $0x2, %ebx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x3820f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7280
movq 0x19daa(%rip), %rax     # 0x51fc0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x98(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x90(%rsp,%rcx)
callq 0x7200
leaq 0x188(%rsp), %rdi
callq 0x70d0
leaq 0x60(%rsp), %rdi
callq 0x352a2
leaq 0x30(%rsp), %rdi
callq 0x352f2
movl %ebx, %eax
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8915(%rip), %rdi      # 0x40b8b
callq 0x7370
movl $0x3, %edi
callq 0x72f0
jmp 0x382dd
jmp 0x382dd
jmp 0x382b5
jmp 0x382dd
movq %rax, %rbx
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x382e0
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x7280
jmp 0x382e0
jmp 0x382b5
movq %rax, %rbx
jmp 0x382cc
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x382cc
callq 0x133fc
leaq 0x90(%rsp), %rdi
callq 0x7350
jmp 0x382e0
jmp 0x382dd
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x352a2
leaq 0x30(%rsp), %rdi
callq 0x352f2
movq %rbx, %rdi
callq 0x7430