// File: conp-solutions[P]cnfmiter/Main.cc
// Function: exchange_definition_clauses(CNFMITER::Formula&, CNFMITER::Formula&, int)
void exchange_definition_clauses(Formula &f1, Formula &f2, int largest_input_variable)
{
    std::vector<std::vector<Lit>> l2r, r2l;

    // get all clauses in f1 and f2 that have variable beyond largest variable
    l2r = get_definition_clauses(f1, largest_input_variable);
    std::cerr << "c extracted " << l2r.size() << " clauses from f1" << std::endl;
    r2l = get_definition_clauses(f2, largest_input_variable);
    std::cerr << "c extracted " << r2l.size() << " clauses from f2" << std::endl;

    // add the clauses mutually to each formula
    for (const auto &c : l2r) f2.addClause_(c);
    for (const auto &c : r2l) f1.addClause_(c);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4d00
leaq -0x48(%rbp), %rdi
callq 0x4d00
movq -0x8(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x60(%rbp), %rdi
callq 0x2b90
jmp 0x2d0a
leaq -0x30(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movq %rsi, -0xd8(%rbp)
callq 0x4e10
movq -0xd8(%rbp), %rdi
callq 0x4db0
movq 0x92bf(%rip), %rdi      # 0xbff0
leaq 0x5355(%rip), %rsi      # 0x808d
callq 0x2190
movq %rax, -0xd0(%rbp)
jmp 0x2d46
leaq -0x30(%rbp), %rdi
callq 0x4bc0
movq -0xd0(%rbp), %rdi
movq %rax, %rsi
callq 0x2070
movq %rax, -0xe0(%rbp)
jmp 0x2d67
movq -0xe0(%rbp), %rdi
leaq 0x5325(%rip), %rsi      # 0x809a
callq 0x2190
movq %rax, -0xe8(%rbp)
jmp 0x2d83
movq -0xe8(%rbp), %rdi
movq 0x9207(%rip), %rsi      # 0xbf98
callq 0x21b0
jmp 0x2d98
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x88(%rbp), %rdi
callq 0x2b90
jmp 0x2dad
leaq -0x48(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movq %rsi, -0xf8(%rbp)
callq 0x4e10
movq -0xf8(%rbp), %rdi
callq 0x4db0
movq 0x9219(%rip), %rdi      # 0xbff0
leaq 0x52af(%rip), %rsi      # 0x808d
callq 0x2190
movq %rax, -0xf0(%rbp)
jmp 0x2dec
leaq -0x48(%rbp), %rdi
callq 0x4bc0
movq -0xf0(%rbp), %rdi
movq %rax, %rsi
callq 0x2070
movq %rax, -0x100(%rbp)
jmp 0x2e0d
movq -0x100(%rbp), %rdi
leaq 0x5290(%rip), %rsi      # 0x80ab
callq 0x2190
movq %rax, -0x108(%rbp)
jmp 0x2e29
movq -0x108(%rbp), %rdi
movq 0x9161(%rip), %rsi      # 0xbf98
callq 0x21b0
jmp 0x2e3e
leaq -0x30(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
callq 0x4bf0
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rdi
callq 0x4c20
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x4c50
testb $0x1, %al
jne 0x2e88
jmp 0x2ee0
leaq -0x98(%rbp), %rdi
callq 0x4c90
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x48a0
jmp 0x2ead
jmp 0x2eaf
leaq -0x98(%rbp), %rdi
callq 0x4ce0
jmp 0x2e6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4db0
leaq -0x30(%rbp), %rdi
callq 0x4db0
jmp 0x2f7a
leaq -0x48(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
callq 0x4bf0
movq %rax, -0xb8(%rbp)
movq -0xb0(%rbp), %rdi
callq 0x4c20
movq %rax, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x4c50
testb $0x1, %al
jne 0x2f2a
jmp 0x2f5f
leaq -0xb8(%rbp), %rdi
callq 0x4c90
movq %rax, -0xc8(%rbp)
movq -0x8(%rbp), %rdi
movq -0xc8(%rbp), %rsi
callq 0x48a0
jmp 0x2f4f
jmp 0x2f51
leaq -0xb8(%rbp), %rdi
callq 0x4ce0
jmp 0x2f11
leaq -0x48(%rbp), %rdi
callq 0x4db0
leaq -0x30(%rbp), %rdi
callq 0x4db0
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x22b0
nopw %cs:(%rax,%rax)