// File: /workspace/github_cpp_makefile_star2_O1/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 $0x498, %rsp            # imm = 0x498
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x48(%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 0x78(%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 0x40(%rsp), %rsi
callq *0x40(%rax)
cmpq $0x2, 0x68(%rsp)
jb 0x38493
movq 0x1ab86(%rip), %rbx     # 0x52fd0
leaq 0x92a9(%rip), %rsi      # 0x416fa
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 0x1ab54(%rip), %rdi     # 0x52fd0
callq 0x7030
movl $0x1, %ebx
movq %rax, %rdi
callq 0x7190
jmp 0x387e6
movq %r14, 0x18(%rsp)
movq %rbx, 0x10(%rsp)
movq 0x88(%rsp), %r15
cmpq %r13, %r15
je 0x3857c
movq 0x1ab1b(%rip), %r12     # 0x52fd0
leaq 0xa0(%rsp), %rbp
movq 0x20(%r15), %r14
movq (%r14), %rax
movq %r14, %rdi
movl $0x2, %esi
callq *0x30(%rax)
movl %eax, %ebx
testb %al, %al
jne 0x38568
movl $0xf, %edx
movq %r12, %rdi
leaq 0x9236(%rip), %rsi      # 0x4171e
callq 0x72c0
movq (%r14), %rax
movq %rbp, %rdi
movq %r14, %rsi
callq *0x38(%rax)
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
movq %r12, %rdi
callq 0x72c0
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 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x38560
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x7280
testb %bl, %bl
je 0x38633
movq %r15, %rdi
callq 0x72d0
movq %rax, %r15
cmpq %r13, %rax
jne 0x384bd
leaq 0xa0(%rsp), %rdi
callq 0x73f0
leaq 0x9254(%rip), %rsi      # 0x417e4
leaq 0xa0(%rsp), %rdi
movl $0x10, %edx
callq 0x7060
leaq 0x1b337(%rip), %rax     # 0x538e0
movl $0xffffff9c, (%rax)     # imm = 0xFFFFFF9C
leaq 0x923b(%rip), %rsi      # 0x417f1
leaq 0xa0(%rsp), %rdi
movl $0x2b, %edx
callq 0x72c0
movq 0x1b2b1(%rip), %rsi     # 0x53880
movq 0x1b2b2(%rip), %rdx     # 0x53888
leaq 0xa0(%rsp), %rdi
callq 0x72c0
leaq 0x9233(%rip), %rsi      # 0x4181d
movl $0x11, %edx
movq %rax, %rdi
callq 0x72c0
leaq 0x1b2e6(%rip), %r14     # 0x538e4
movl (%r14), %ebp
movl $0x2, (%r14)
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq %rax, (%rsp)
movq 0x8(%rcx), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x38641
movq 0x1a99f(%rip), %rcx     # 0x52fc8
cmpb $0x0, (%rcx)
je 0x3863d
incl 0x8(%rax)
jmp 0x38641
movl $0x1, %ebx
jmp 0x387e6
lock
incl 0x8(%rax)
leaq 0xa0(%rsp), %rdi
movq %rsp, %rsi
callq 0x29634
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
movq %rax, %rbx
leaq 0x904d(%rip), %rsi      # 0x416d2
movl $0x5, %edx
movq %rax, %rdi
callq 0x72c0
movq (%rbx), %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
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x386c8
callq 0x13308
movl %ebp, (%r14)
leaq 0xa0(%rsp), %rdi
callq 0x7330
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x7210
testl %eax, %eax
je 0x386f6
leaq 0x94c4(%rip), %rdi      # 0x41bb5
callq 0x7370
leaq 0x914f(%rip), %rdi      # 0x4184c
leaq 0x7b68(%rip), %rsi      # 0x4026c
callq 0x72e0
movq %rax, %rbx
leaq 0x2a0(%rsp), %rdi
movl $0x1f4, %esi            # imm = 0x1F4
movq %rax, %rdx
callq 0x7390
testq %rax, %rax
je 0x3880e
movq %rbx, %rdi
callq 0x7260
leaq 0x30(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x2a0(%rsp), %rbx
movq %rbx, %rdi
callq 0x7130
leaq (%rsp,%rax), %rdx
addq $0x2a0, %rdx            # imm = 0x2A0
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x1c6d0
leaq 0x90c7(%rip), %rsi      # 0x41831
leaq 0x20(%rsp), %rdi
callq 0x70c0
testl %eax, %eax
je 0x38792
leaq 0x90b0(%rip), %rsi      # 0x4182f
leaq 0x20(%rsp), %rdi
callq 0x70c0
xorl %ebx, %ebx
testl %eax, %eax
setne %bl
jmp 0x38797
movl $0x2, %ebx
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x387ae
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x7280
movq 0x1a80b(%rip), %rax     # 0x52fc0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0xa8(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0xa0(%rsp,%rcx)
callq 0x7200
leaq 0x198(%rsp), %rdi
callq 0x70d0
leaq 0x70(%rsp), %rdi
callq 0x35774
leaq 0x40(%rsp), %rdi
callq 0x357c4
movl %ebx, %eax
addq $0x498, %rsp            # imm = 0x498
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x939a(%rip), %rdi      # 0x41baf
callq 0x7370
movl $0x3, %edi
callq 0x72f0
jmp 0x3882a
jmp 0x38854
jmp 0x3882a
movq %rax, %rbx
jmp 0x38843
jmp 0x38854
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x38843
callq 0x13308
leaq 0xa0(%rsp), %rdi
callq 0x7350
jmp 0x38881
jmp 0x38854
movq %rax, %rbx
jmp 0x38881
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x38881
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x7280
leaq 0x70(%rsp), %rdi
callq 0x35774
leaq 0x40(%rsp), %rdi
callq 0x357c4
movq %rbx, %rdi
callq 0x7430
nop