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

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

    std::ofstream ofs;
    ofs.open("smtquery.cvc", std::ofstream::out);
    ofs << "A:TYPE;" << std::endl;
    OutputLanguage sav = outlan;
    outlan = CVC3;
    ofs << "CHECKSAT " << phi << ";" << std::endl;
    outlan = sav;
    ofs.close();
    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;
    printf("Answer: %s", buf);
    if(ans == "Satisfiable.\n") return 2;
    if(ans == "Unsatisfiable.\n") return 0;
    // for CVC4
    if(ans == "sat\n") return 2;
    if(ans == "unsat\n") return 0;
    return 1;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x590, %rsp            # imm = 0x590
movq %rsi, -0x520(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x528(%rbp)
leaq -0x78(%rbp), %rdi
movq %rdi, -0x518(%rbp)
callq 0x5b6c0
movq -0x520(%rbp), %rdi
callq 0x3ece0
movq -0x518(%rbp), %rsi
movq %rax, %rdi
movq (%rdi), %rax
movq 0x40(%rax), %rax
callq *%rax
jmp 0x66266
leaq -0x78(%rbp), %rdi
callq 0x63680
cmpq $0x1, %rax
je 0x662d0
movq 0x3ed5c(%rip), %rdi     # 0xa4fd8
leaq 0xd620(%rip), %rsi      # 0x738a3
callq 0x82b0
movq %rax, -0x530(%rbp)
jmp 0x66291
movq -0x530(%rbp), %rdi
movq 0x3ed11(%rip), %rsi     # 0xa4fb0
callq 0x8300
jmp 0x662a6
movl $0x1, -0x4(%rbp)
movl $0x1, -0x88(%rbp)
jmp 0x667b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x667c8
leaq -0x78(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
callq 0x5b6f0
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rdi
callq 0x5b720
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x5b750
testb $0x1, %al
jne 0x66321
jmp 0x6641f
leaq -0x98(%rbp), %rdi
callq 0x5b780
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
movq (%rdi), %rax
movq 0x30(%rax), %rax
movl $0x1, %esi
callq *%rax
movb %al, -0x531(%rbp)
jmp 0x66354
movb -0x531(%rbp), %al
testb $0x1, %al
jne 0x6640c
jmp 0x66364
movq 0x3ec6d(%rip), %rdi     # 0xa4fd8
leaq 0xd555(%rip), %rsi      # 0x738c7
callq 0x82b0
movq %rax, -0x540(%rbp)
jmp 0x66380
movq -0xa8(%rbp), %rsi
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0xc8(%rbp), %rdi
callq *%rax
jmp 0x66399
movq -0x540(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x8280
movq %rax, -0x548(%rbp)
jmp 0x663b5
movq -0x548(%rbp), %rdi
movq 0x3ebed(%rip), %rsi     # 0xa4fb0
callq 0x8300
jmp 0x663ca
leaq -0xc8(%rbp), %rdi
callq 0x8578
movl $0x1, -0x4(%rbp)
movl $0x1, -0x88(%rbp)
jmp 0x667b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x8578
jmp 0x667c8
jmp 0x6640e
leaq -0x98(%rbp), %rdi
callq 0x5b7b0
jmp 0x66305
leaq -0x2c8(%rbp), %rdi
callq 0x84a0
jmp 0x6642d
leaq 0xd4a3(%rip), %rsi      # 0x738d7
leaq -0x2c8(%rbp), %rdi
movl $0x10, %edx
callq 0x8060
jmp 0x66447
leaq 0xd496(%rip), %rsi      # 0x738e4
leaq -0x2c8(%rbp), %rdi
callq 0x82b0
movq %rax, -0x550(%rbp)
jmp 0x66463
movq -0x550(%rbp), %rdi
movq 0x3eb3f(%rip), %rsi     # 0xa4fb0
callq 0x8300
jmp 0x66478
leaq 0x3f4e5(%rip), %rax     # 0xa5964
movl (%rax), %ecx
movl %ecx, -0x2cc(%rbp)
movl $0x1, (%rax)
leaq 0xd458(%rip), %rsi      # 0x738ec
leaq -0x2c8(%rbp), %rdi
callq 0x82b0
movq %rax, -0x558(%rbp)
jmp 0x664a9
movq -0x520(%rbp), %rsi
leaq -0x2e0(%rbp), %rdi
movq %rdi, -0x568(%rbp)
callq 0x11030
movq -0x558(%rbp), %rdi
movq -0x568(%rbp), %rsi
callq 0x40060
movq %rax, -0x560(%rbp)
jmp 0x664df
movq -0x560(%rbp), %rdi
leaq 0xd3fd(%rip), %rsi      # 0x738ea
callq 0x82b0
movq %rax, -0x570(%rbp)
jmp 0x664fb
movq -0x570(%rbp), %rdi
movq 0x3eaa7(%rip), %rsi     # 0xa4fb0
callq 0x8300
jmp 0x66510
leaq -0x2e0(%rbp), %rdi
callq 0x11060
movl -0x2cc(%rbp), %ecx
leaq 0x3f43b(%rip), %rax     # 0xa5964
movl %ecx, (%rax)
leaq -0x2c8(%rbp), %rdi
callq 0x8400
jmp 0x66539
movq -0x528(%rbp), %rdi
addq $0x8, %rdi
callq 0x8130
movq %rax, %rdi
callq 0x8260
movl %eax, -0x574(%rbp)
jmp 0x66559
movl -0x574(%rbp), %eax
cmpl $0x0, %eax
je 0x665aa
leaq 0xd2f9(%rip), %rdi      # 0x73864
xorl %eax, %eax
callq 0x8050
jmp 0x66574
jmp 0x665aa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x667a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0x11060
jmp 0x667a5
leaq 0xd2e5(%rip), %rdi      # 0x73896
leaq 0xbd2d(%rip), %rsi      # 0x722e5
callq 0x8380
movq %rax, -0x580(%rbp)
jmp 0x665c6
movq -0x580(%rbp), %rax
movq %rax, -0x2e8(%rbp)
movq -0x2e8(%rbp), %rdx
leaq -0x4e0(%rbp), %rdi
movl $0x1f4, %esi            # imm = 0x1F4
callq 0x8450
movq %rax, -0x588(%rbp)
jmp 0x665f5
movq -0x588(%rbp), %rax
movq %rax, -0x4e8(%rbp)
cmpq $0x0, -0x4e8(%rbp)
jne 0x66627
leaq 0xd25e(%rip), %rdi      # 0x73872
xorl %eax, %eax
callq 0x8050
jmp 0x6661d
movl $0x3, %edi
callq 0x8390
movq -0x2e8(%rbp), %rdi
callq 0x82c0
jmp 0x66635
leaq -0x509(%rbp), %rdi
movq %rdi, -0x590(%rbp)
callq 0x84e0
movq -0x590(%rbp), %rdx
leaq -0x508(%rbp), %rdi
leaq -0x4e0(%rbp), %rsi
callq 0x10f40
jmp 0x66664
leaq -0x509(%rbp), %rdi
callq 0x8320
leaq 0xd27f(%rip), %rdi      # 0x738f6
xorl %eax, %eax
leaq -0x4e0(%rbp), %rsi
callq 0x8050
jmp 0x66687
leaq -0x508(%rbp), %rdi
leaq 0xd26c(%rip), %rsi      # 0x73901
callq 0x50ce0
testb $0x1, %al
jne 0x666a0
jmp 0x666f6
movl $0x2, -0x4(%rbp)
movl $0x1, -0x88(%rbp)
jmp 0x6678b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x509(%rbp), %rdi
callq 0x8320
jmp 0x667a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x508(%rbp), %rdi
callq 0x8578
jmp 0x667a5
leaq -0x508(%rbp), %rdi
leaq 0xd20b(%rip), %rsi      # 0x7390f
callq 0x50ce0
testb $0x1, %al
jne 0x6670f
jmp 0x66722
movl $0x0, -0x4(%rbp)
movl $0x1, -0x88(%rbp)
jmp 0x6678b
leaq -0x508(%rbp), %rdi
leaq 0xd14b(%rip), %rsi      # 0x7387b
callq 0x50ce0
testb $0x1, %al
jne 0x6673b
jmp 0x6674e
movl $0x2, -0x4(%rbp)
movl $0x1, -0x88(%rbp)
jmp 0x6678b
leaq -0x508(%rbp), %rdi
leaq 0xd11d(%rip), %rsi      # 0x73879
callq 0x50ce0
testb $0x1, %al
jne 0x66767
jmp 0x6677a
movl $0x0, -0x4(%rbp)
movl $0x1, -0x88(%rbp)
jmp 0x6678b
movl $0x1, -0x4(%rbp)
movl $0x1, -0x88(%rbp)
leaq -0x508(%rbp), %rdi
callq 0x8578
leaq -0x2c8(%rbp), %rdi
callq 0x8430
jmp 0x667b3
leaq -0x2c8(%rbp), %rdi
callq 0x8430
jmp 0x667c8
leaq -0x78(%rbp), %rdi
callq 0x5b7e0
movl -0x4(%rbp), %eax
addq $0x590, %rsp            # imm = 0x590
popq %rbp
retq
leaq -0x78(%rbp), %rdi
callq 0x5b7e0
movq -0x80(%rbp), %rdi
callq 0x84d0
nopw (%rax,%rax)