// File: /workspace/github_cpp_makefile_star2_O3/conp-solutions[P]cnfmiter/Main.cc
// Function: main
int main(int argc, char **argv)
{
    int opt;
    int tseitin = 0;
    int randmom_drop = 0;
    std::cerr << "c CNFmiter generates a CNF formula " << std::endl
              << "c which is unsatisfiable, if the given 2 formulas are equivalent" << std::endl;


    // Retrieve the options:
    while ((opt = getopt(argc, argv, "r:t:")) != -1) { // for each option...
        switch (opt) {
        case 'r':
            randmom_drop = atoi(optarg);
            std::cerr << "c randomly drop " << randmom_drop << " clauses from first formula" << std::endl;
            break;
        case 't':
            tseitin = atoi(optarg);
            std::cerr << "c set tseitin variable to " << tseitin << std::endl;
            break;
        case '?': // unknown option...
            std::cerr << "c unknown option: '" << char(optopt) << "'!" << std::endl;
            exit(1);
            break;
        }
    }

    if (optind + 2 != argc) {
        std::cerr << "not enough parameters, abort!" << std::endl;
        return 1;
    }

    std::string fn1 = (argv[optind + 0]);
    std::string fn2 = (argv[optind + 1]);
    gzFile in1 = gzopen(fn1.c_str(), "rb");
    gzFile in2 = gzopen(fn2.c_str(), "rb");

    if (!in1) {
        std::cerr << "failed to open first file, abort!" << std::endl;
        return 1;
    }
    if (!in2) {
        std::cerr << "failed to open second file, abort!" << std::endl;
        return 1;
    }
    if (tseitin < 0) {
        std::cerr << "tseitin variable negative, abort" << std::endl;
        return 1;
    }
    if (randmom_drop < 0) {
        std::cerr << "random_drop value negative, abort" << std::endl;
        return 1;
    }

    Formula f1, f2;

    parse_DIMACS(in1, f1);
    gzclose(in1);

    parse_DIMACS(in2, f2);
    gzclose(in2);

    std::cerr << "c Parsed formulas 1 with " << f1.nVars() << " vars and " << f1.clauses.size()
              << " and formulas 2 with " << f2.nVars() << " vars and " << f2.clauses.size() << std::endl;

    if (randmom_drop > 0) {
        srand(1234);
        for (int i = 0; i < randmom_drop && f1.clauses.size() > 0; ++i) {
            size_t p = rand() % f1.clauses.size();
            f1.clauses[p] = f1.clauses.back();
            f1.clauses.pop_back();
        }
    }

    Formula miter;

    Var maxV = f1.nVars() > f2.nVars() ? f1.nVars() : f2.nVars();
    if (tseitin > 0) {
        int offset = tseitin;
        offset = maxV > tseitin ? maxV - tseitin : 0;
        std::cerr << "c offset " << offset << " tseitin: " << tseitin << " maxV: " << maxV << std::endl;
        assert(offset == 0 || f2.nVars() <= tseitin || f2.nVars() + offset > f1.nVars());

        rewrite_variable_range(f2, tseitin, offset);

        maxV = f1.nVars() > f2.nVars() ? f1.nVars() : f2.nVars();

        while (f1.nVars() < maxV) f1.newVar();
        while (f2.nVars() < maxV) f2.newVar();

        exchange_definition_clauses(f1, f2, tseitin);
    }

    maxV = f1.nVars() > f2.nVars() ? f1.nVars() : f2.nVars();
    while (miter.nVars() < maxV) miter.newVar();

    std::cerr << "c Miter base formulas reserved " << miter.nVars() << " variables" << std::endl;

    generate_formula_miter(miter, f1, f2);

    std::size_t found = fn1.rfind("/");
    if (found != std::string::npos) fn1 = fn1.erase(0, found + 1);
    found = fn2.rfind("/");
    if (found != std::string::npos) fn2 = fn2.erase(0, found + 1);

    std::stringstream s;
    s << fn1 << " and " << fn2;
    if (tseitin != 0) s << " with tseitin base variable " << tseitin;
    if (randmom_drop) s << " with randomly dropping " << randmom_drop;
    print_formula(miter, s.str());

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %rsi, %r12
movl %edi, %r13d
movq 0x4016(%rip), %r15      # 0x6ff0
leaq 0x210d(%rip), %rsi      # 0x50ee
movl $0x23, %edx
movq %r15, %rdi
callq 0x21d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq %rax, %r14
leaq 0x20f3(%rip), %rsi      # 0x5112
movl $0x40, %edx
movq %rax, %rdi
callq 0x21d0
movl $0x0, -0x30(%rbp)
leaq 0x2119(%rip), %rbx      # 0x5153
movl $0x0, -0x2c(%rbp)
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl %r13d, %edi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x2050
cmpl $0x71, %eax
jle 0x3087
cmpl $0x74, %eax
je 0x309a
cmpl $0x72, %eax
jne 0x3068
jmp 0x30d7
cmpl $-0x1, %eax
je 0x3128
cmpl $0x3f, %eax
jne 0x3068
jmp 0x37b9
movq 0x3f07(%rip), %rax      # 0x6fa8
movq (%rax), %rdi
callq 0x2250
movl %eax, %r14d
movl $0x1a, %edx
movq %r15, %rdi
leaq 0x20ca(%rip), %rsi      # 0x5185
callq 0x21d0
movq %r15, %rdi
movl %r14d, -0x2c(%rbp)
movl %r14d, %esi
callq 0x22a0
movq %rax, %r14
jmp 0x3041
movq 0x3eca(%rip), %rax      # 0x6fa8
movq (%rax), %rdi
callq 0x2250
movl %eax, %r14d
movl $0x10, %edx
movq %r15, %rdi
leaq 0x2060(%rip), %rsi      # 0x5158
callq 0x21d0
movq %r15, %rdi
movl %r14d, -0x30(%rbp)
movl %r14d, %esi
callq 0x22a0
movq %rax, %r14
movl $0x1b, %edx
movq %rax, %rdi
leaq 0x204b(%rip), %rsi      # 0x5169
callq 0x21d0
jmp 0x3041
movq 0x3ea1(%rip), %rbx      # 0x6fd0
movslq (%rbx), %rax
leal 0x2(%rax), %ecx
cmpl %r13d, %ecx
jne 0x36ce
movq (%r12,%rax,8), %rsi
leaq -0xb0(%rbp), %rdi
leaq -0x278(%rbp), %rdx
callq 0x20b0
movslq (%rbx), %rax
movq 0x8(%r12,%rax,8), %rsi
leaq -0x90(%rbp), %rdi
leaq -0x278(%rbp), %rdx
callq 0x20b0
movq -0xb0(%rbp), %rdi
leaq 0x2057(%rip), %rsi      # 0x51d5
callq 0x2230
movl -0x2c(%rbp), %r15d
movq %rax, %r14
movq -0x90(%rbp), %rdi
leaq 0x203d(%rip), %rsi      # 0x51d5
callq 0x2230
movl $0x21, %edx
testq %r14, %r14
je 0x3713
movq %rax, %rbx
testq %rax, %rax
je 0x371c
testl %r15d, %r15d
js 0x372a
cmpl $0x0, -0x30(%rbp)
js 0x3738
xorl %eax, %eax
leaq -0x48(%rbp), %r12
movl %eax, -0x8(%r12)
xorps %xmm0, %xmm0
movups %xmm0, (%r12)
movq %rax, 0x10(%r12)
leaq -0x68(%rbp), %rcx
movl %eax, -0x8(%rcx)
movups %xmm0, (%rcx)
movq %rax, 0x10(%rcx)
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x38c0
movq %r14, %rdi
callq 0x2290
leaq -0x70(%rbp), %rsi
movq %rbx, %rdi
callq 0x38c0
movq %rbx, %rdi
callq 0x2290
movq 0x3dd1(%rip), %rdi      # 0x6ff0
leaq 0x203a(%rip), %rsi      # 0x5260
movl $0x19, %edx
callq 0x21d0
movl -0x50(%rbp), %esi
movq 0x3db6(%rip), %rdi      # 0x6ff0
callq 0x22a0
movq %rax, %rbx
leaq 0x2031(%rip), %rsi      # 0x527a
movl $0xa, %edx
movq %rax, %rdi
callq 0x21d0
movq -0x40(%rbp), %rsi
subq -0x48(%rbp), %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %r14 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r14, %rsi
movq %rbx, %rdi
callq 0x2120
movq %rax, %rbx
leaq 0x2003(%rip), %rsi      # 0x5285
movl $0x15, %edx
movq %rax, %rdi
callq 0x21d0
movl -0x70(%rbp), %esi
movq %rbx, %rdi
callq 0x22a0
movq %rax, %rbx
leaq 0x1fd6(%rip), %rsi      # 0x527a
movl $0xa, %edx
movq %rax, %rdi
callq 0x21d0
movq -0x60(%rbp), %rsi
subq -0x68(%rbp), %rsi
sarq $0x3, %rsi
imulq %r14, %rsi
movq %rbx, %rdi
callq 0x2120
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
cmpl $0x0, -0x30(%rbp)
je 0x3361
movl $0x4d2, %edi            # imm = 0x4D2
callq 0x2190
movl -0x30(%rbp), %ebx
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0x3361
callq 0x2070
cltq
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rsi
movq %rsi, %rdi
subq %rcx, %rdi
sarq $0x3, %rdi
imulq %r14, %rdi
xorl %edx, %edx
divq %rdi
addq $-0x18, %rsi
leaq (%rdx,%rdx,2), %rax
leaq (%rcx,%rax,8), %rdi
callq 0x3bfe
movq -0x40(%rbp), %rax
leaq -0x18(%rax), %rcx
movq %rcx, -0x40(%rbp)
movq -0x18(%rax), %rdi
testq %rdi, %rdi
je 0x335d
callq 0x2180
decl %ebx
jne 0x3306
leaq -0xc8(%rbp), %r13
movl $0x0, -0x8(%r13)
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
movq $0x0, 0x10(%r13)
movl -0x50(%rbp), %eax
movl -0x70(%rbp), %ebx
cmpl %ebx, %eax
cmovgl %eax, %ebx
xorl %eax, %eax
testl %r15d, %r15d
je 0x349f
movl %r15d, %ecx
movl %ebx, %r15d
subl %ecx, %r15d
cmovlel %eax, %r15d
movq 0x3c46(%rip), %rdi      # 0x6ff0
leaq 0x1eea(%rip), %rsi      # 0x529b
movl $0x9, %edx
callq 0x21d0
movq 0x3c2e(%rip), %rdi      # 0x6ff0
movl %r15d, %esi
callq 0x22a0
movq %rax, %r14
leaq 0x1ed1(%rip), %rsi      # 0x52a5
movl $0xa, %edx
movq %rax, %rdi
callq 0x21d0
movq %r14, %rdi
movl -0x2c(%rbp), %esi
callq 0x22a0
movq %rax, %r14
leaq 0x1eba(%rip), %rsi      # 0x52b0
movl $0x7, %edx
movq %rax, %rdi
callq 0x21d0
movq %r14, %rdi
movl %ebx, %esi
callq 0x22a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
testl %r15d, %r15d
je 0x3450
movl -0x70(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jle 0x3450
addl %r15d, %eax
cmpl -0x50(%rbp), %eax
jle 0x37ff
leaq -0x70(%rbp), %rbx
movq %rbx, %rdi
movl -0x2c(%rbp), %esi
movl %r15d, %edx
callq 0x29b9
movl -0x50(%rbp), %ecx
movl (%rbx), %edx
movl %edx, %eax
cmpl %edx, %ecx
cmovgl %ecx, %eax
jge 0x3473
movl %eax, -0x50(%rbp)
cmpl %edx, %ecx
jle 0x347a
movl %eax, -0x70(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x2ace
movl -0x50(%rbp), %ecx
movl -0x70(%rbp), %ebx
movl -0xd0(%rbp), %eax
cmpl %ebx, %ecx
cmovgl %ecx, %ebx
movl -0x2c(%rbp), %r15d
cmpl %ebx, %eax
jge 0x34a9
movl %ebx, -0xd0(%rbp)
movq 0x3b40(%rip), %rdi      # 0x6ff0
leaq 0x1e69(%rip), %rsi      # 0x5320
movl $0x1f, %edx
callq 0x21d0
movl -0xd0(%rbp), %esi
movq 0x3b22(%rip), %rdi      # 0x6ff0
callq 0x22a0
movq %rax, %rbx
leaq 0x1b53(%rip), %rsi      # 0x5030
movl $0xa, %edx
movq %rax, %rdi
callq 0x21d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
leaq -0xd0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x2786
leaq 0x1e14(%rip), %rsi      # 0x5340
leaq -0xb0(%rbp), %rdi
movl $0x1, %ecx
movq $-0x1, %rdx
callq 0x2200
cmpq $-0x1, %rax
je 0x356d
incq %rax
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x2060
leaq -0xb0(%rbp), %rdi
movq %rax, %rsi
callq 0x20f0
leaq 0x1dcc(%rip), %rsi      # 0x5340
leaq -0x90(%rbp), %rdi
movl $0x1, %ecx
movq $-0x1, %rdx
callq 0x2200
cmpq $-0x1, %rax
je 0x35b5
incq %rax
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x2060
leaq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0x20f0
leaq -0x278(%rbp), %rdi
callq 0x2140
leaq -0x268(%rbp), %rbx
movq -0xb0(%rbp), %rsi
movq -0xa8(%rbp), %rdx
movq %rbx, %rdi
callq 0x21d0
movq %rax, %r14
leaq 0x1a96(%rip), %rsi      # 0x507e
movl $0x5, %edx
movq %rax, %rdi
callq 0x21d0
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
movq %r14, %rdi
callq 0x21d0
testl %r15d, %r15d
je 0x362f
leaq 0x1d2b(%rip), %rsi      # 0x5342
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x21d0
movq %rbx, %rdi
movl %r15d, %esi
callq 0x22a0
cmpl $0x0, -0x30(%rbp)
je 0x3654
leaq 0x1d23(%rip), %rsi      # 0x535f
movl $0x18, %edx
movq %rbx, %rdi
callq 0x21d0
movq %rbx, %rdi
movl -0x30(%rbp), %esi
callq 0x22a0
leaq -0x260(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x2260
leaq -0xd0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x2d1d
leaq -0xe0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x368f
callq 0x2180
movq 0x3902(%rip), %rsi      # 0x6f98
leaq -0x278(%rbp), %rdi
callq 0x2150
leaq -0x1f8(%rbp), %rdi
callq 0x2090
movq %r13, %rdi
callq 0x3d20
leaq -0x68(%rbp), %rdi
callq 0x3d20
movq %r12, %rdi
callq 0x3d20
xorl %ebx, %ebx
jmp 0x377e
leaq 0x1ae2(%rip), %rsi      # 0x51b7
movl $0x1d, %edx
movq %r15, %rdi
callq 0x21d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl $0x1, %ebx
jmp 0x37a5
leaq 0x1abe(%rip), %rsi      # 0x51d8
jmp 0x373f
movl $0x22, %edx
leaq 0x1ad2(%rip), %rsi      # 0x51fa
jmp 0x373f
movl $0x20, %edx
leaq 0x1ae7(%rip), %rsi      # 0x521d
jmp 0x373f
leaq 0x1aff(%rip), %rsi      # 0x523e
movq 0x38aa(%rip), %rbx      # 0x6ff0
movq %rbx, %rdi
callq 0x21d0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq 0x3884(%rip), %rdi      # 0x6ff0
callq 0x2030
movl $0x1, %ebx
movq %rax, %rdi
callq 0x2130
leaq -0x80(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3790
callq 0x2180
leaq -0xa0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x37a5
callq 0x2180
movl %ebx, %eax
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3830(%rip), %rdi      # 0x6ff0
leaq 0x19d9(%rip), %rsi      # 0x51a0
callq 0x21b0
movq 0x37e5(%rip), %rcx      # 0x6fb8
movsbl (%rcx), %esi
movq %rax, %rdi
callq 0x21e0
leaq 0x19cf(%rip), %rsi      # 0x51b4
movq %rax, %rdi
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
movl $0x1, %edi
callq 0x21f0
leaq 0x1ab2(%rip), %rdi      # 0x52b8
leaq 0x1af4(%rip), %rsi      # 0x5301
leaq 0x1af5(%rip), %rcx      # 0x5309
movl $0xdc, %edx
callq 0x2110
movq %rax, %rbx
leaq -0xe0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3841
callq 0x2180
jmp 0x3841
jmp 0x3869
jmp 0x3869
jmp 0x3869
movq %rax, %rbx
movq 0x3750(%rip), %rsi      # 0x6f98
leaq -0x278(%rbp), %rdi
callq 0x2150
leaq -0x1f8(%rbp), %rdi
callq 0x2090
jmp 0x386c
jmp 0x388e
movq %rax, %rbx
jmp 0x38a3
movq %rax, %rbx
movq %r13, %rdi
callq 0x3d20
jmp 0x387b
jmp 0x3878
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x3d20
movq %r12, %rdi
callq 0x3d20
jmp 0x3891
movq %rax, %rbx
leaq -0x80(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x38a3
callq 0x2180
leaq -0xa0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x38b8
callq 0x2180
movq %rbx, %rdi
callq 0x22b0