// File: /workspace/github_cpp_makefile_star2_O2/biotomas[P]ipasir/sat/minisat220/minisat-220/minisat/core/Solver.cc
// Function: Minisat::Solver::toDimacs(_IO_FILE*, Minisat::vec<Minisat::Lit, int> const&)
void Solver::toDimacs(FILE* f, const vec<Lit>& assumps)
{
    // Handle case when solver is in contradictory state:
    if (!ok){
        fprintf(f, "p cnf 1 2\n1 0\n-1 0\n");
        return; }

    vec<Var> map; Var max = 0;

    // Cannot use removeClauses here because it is not safe
    // to deallocate them at this point. Could be improved.
    int cnt = 0;
    for (int i = 0; i < clauses.size(); i++)
        if (!satisfied(ca[clauses[i]]))
            cnt++;
        
    for (int i = 0; i < clauses.size(); i++)
        if (!satisfied(ca[clauses[i]])){
            Clause& c = ca[clauses[i]];
            for (int j = 0; j < c.size(); j++)
                if (value(c[j]) != l_False)
                    mapVar(var(c[j]), map, max);
        }

    // Assumptions are added as unit clauses:
    cnt += assumps.size();

    fprintf(f, "p cnf %d %d\n", max, cnt);

    for (int i = 0; i < assumps.size(); i++){
        assert(value(assumps[i]) != l_False);
        fprintf(f, "%s%d 0\n", sign(assumps[i]) ? "-" : "", mapVar(var(assumps[i]), map, max)+1);
    }

    for (int i = 0; i < clauses.size(); i++)
        toDimacs(f, ca[clauses[i]], map, max);

    if (verbosity > 0)
        printf("Wrote DIMACS with %d variables and %d clauses.\n", max, cnt);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r15
cmpb $0x0, 0x2a0(%rdi)
je 0x5d02
movq %rdx, %r12
movq %rdi, %r14
andl $0x0, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
xorl %ebx, %ebx
xorl %ebp, %ebp
movslq 0x150(%r14), %rax
cmpq %rax, %rbx
jge 0x5d25
movq 0x148(%r14), %rax
movl (%rax,%rbx,4), %esi
shlq $0x2, %rsi
addq 0x2d8(%r14), %rsi
movq %r14, %rdi
callq 0x4580
xorb $0x1, %al
movzbl %al, %eax
addl %eax, %ebp
incq %rbx
jmp 0x5ccd
leaq 0x3b87(%rip), %rdi      # 0x9890
pushq $0x13
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2320
movq %r12, 0x30(%rsp)
movl %ebp, 0x14(%rsp)
movq %r15, 0x18(%rsp)
xorl %ebp, %ebp
leaq 0xf(%rsp), %r12
leaq 0x10(%rsp), %rbx
cltq
cmpq %rax, %rbp
jge 0x5de3
movq 0x148(%r14), %rax
movl (%rax,%rbp,4), %esi
shlq $0x2, %rsi
addq 0x2d8(%r14), %rsi
movq %r14, %rdi
callq 0x4580
testb %al, %al
je 0x5d77
incq %rbp
movl 0x150(%r14), %eax
jmp 0x5d3f
movq 0x148(%r14), %rax
movl (%rax,%rbp,4), %r15d
shlq $0x2, %r15
addq 0x2d8(%r14), %r15
xorl %r13d, %r13d
movl (%r15), %eax
shrl $0x5, %eax
cmpq %rax, %r13
jae 0x5d6b
movl 0x4(%r15,%r13,4), %eax
movl %eax, %ecx
sarl %ecx
movq 0x1b0(%r14), %rdx
movslq %ecx, %rcx
andb $0x1, %al
xorb (%rdx,%rcx), %al
movb %al, 0xf(%rsp)
movzbl 0x8423(%rip), %esi      # 0xe1e1
movq %r12, %rdi
callq 0x3648
testb %al, %al
je 0x5dde
movl 0x4(%r15,%r13,4), %edi
sarl %edi
leaq 0x20(%rsp), %rsi
movq %rbx, %rdx
callq 0x5bd9
incq %r13
jmp 0x5d90
movl 0x14(%rsp), %ecx
movq 0x30(%rsp), %r12
addl 0x8(%r12), %ecx
leaq 0x10(%rsp), %rax
movl (%rax), %edx
leaq 0x3aa5(%rip), %rsi      # 0x98a4
movq 0x18(%rsp), %rdi
movl %ecx, 0x14(%rsp)
xorl %eax, %eax
callq 0x2250
leaq 0x3b1d(%rip), %r15      # 0x9933
leaq 0x3d3f(%rip), %rbp      # 0x9b5c
leaq 0x3a8d(%rip), %r13      # 0x98b1
xorl %ebx, %ebx
movslq 0x8(%r12), %rax
cmpq %rax, %rbx
jge 0x5e74
movq (%r12), %rax
movl (%rax,%rbx,4), %r12d
movl %r12d, %edi
sarl %edi
leaq 0x20(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x5bd9
testb $0x1, %r12b
movq %rbp, %rdx
cmoveq %r15, %rdx
incl %eax
movq 0x18(%rsp), %rdi
movq %r13, %rsi
movl %eax, %ecx
xorl %eax, %eax
callq 0x2250
incq %rbx
movq 0x30(%rsp), %r12
jmp 0x5e26
xorl %r12d, %r12d
leaq 0x20(%rsp), %rbx
leaq 0x10(%rsp), %r15
movq 0x18(%rsp), %r13
movslq 0x150(%r14), %rax
cmpq %rax, %r12
jge 0x5ebe
movq 0x148(%r14), %rax
movl (%rax,%r12,4), %edx
shlq $0x2, %rdx
addq 0x2d8(%r14), %rdx
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rcx
movq %r15, %r8
callq 0x5af6
incq %r12
jmp 0x5e86
cmpl $0x0, 0x70(%r14)
jle 0x5edb
movl 0x10(%rsp), %esi
leaq 0x39e9(%rip), %rdi      # 0x98b9
movl 0x14(%rsp), %edx
xorl %eax, %eax
callq 0x2050
leaq 0x20(%rsp), %rdi
callq 0x6478
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5ef8
jmp 0x5ef8
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x6478
movq %rbx, %rdi
callq 0x22d0
nop