// File: cauimsouza[P]rikudo-solver/src/rikudo_solver/graph.cpp
// Function: Graph::write_sat(std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&)
void Graph::write_sat(std::vector<std::vector<int> > &clauses){
    std::ofstream ofs(get_path(sat_input));

    ofs << "p cnf " << n_vertices*n_vertices*2 << " " << (int) clauses.size() << "\n";
    for(auto c : clauses){
        bool first = true;
        for(auto v : c){
            if(!first)  ofs << " ";
            ofs << v;
            first = false;
        }
        ofs << " 0\n";
    }

    ofs.close();

    std::cout << "sat formula written\n";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2f0, %rsp            # imm = 0x2F0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2d0(%rbp)
leaq -0x251(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
callq 0x3410
movq -0x2c8(%rbp), %rdx
leaq 0xb2f5(%rip), %rsi      # 0x13124
leaq -0x250(%rbp), %rdi
callq 0x3300
jmp 0x7e3d
leaq -0x230(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x8170
jmp 0x7e52
leaq -0x210(%rbp), %rdi
leaq -0x230(%rbp), %rsi
movl $0x10, %edx
callq 0x3440
jmp 0x7e6c
leaq -0x230(%rbp), %rdi
callq 0x3170
leaq -0x250(%rbp), %rdi
callq 0x3170
leaq -0x251(%rbp), %rdi
callq 0x3270
leaq 0xb29b(%rip), %rsi      # 0x13132
leaq -0x210(%rbp), %rdi
callq 0x3230
movq %rax, -0x2d8(%rbp)
jmp 0x7eac
movq -0x2d8(%rbp), %rdi
movq -0x2d0(%rbp), %rax
movl (%rax), %esi
imull %esi, %esi
addl %esi, %esi
callq 0x33f0
movq %rax, -0x2e0(%rbp)
jmp 0x7ecf
movq -0x2e0(%rbp), %rdi
leaq 0xb2c0(%rip), %rsi      # 0x1319d
callq 0x3230
movq %rax, -0x2e8(%rbp)
jmp 0x7eeb
movq -0x10(%rbp), %rdi
callq 0x4600
movq -0x2e8(%rbp), %rdi
movl %eax, %esi
callq 0x33f0
movq %rax, -0x2f0(%rbp)
jmp 0x7f0b
movq -0x2f0(%rbp), %rdi
leaq 0xb222(%rip), %rsi      # 0x1313b
callq 0x3230
jmp 0x7f20
movq -0x10(%rbp), %rax
movq %rax, -0x270(%rbp)
movq -0x270(%rbp), %rdi
callq 0xb460
movq %rax, -0x278(%rbp)
movq -0x270(%rbp), %rdi
callq 0xb490
movq %rax, -0x280(%rbp)
leaq -0x278(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0xb4c0
testb $0x1, %al
jne 0x7f6d
jmp 0x8117
leaq -0x278(%rbp), %rdi
callq 0xb500
movq %rax, %rsi
leaq -0x298(%rbp), %rdi
callq 0x5370
jmp 0x7f8a
movb $0x1, -0x299(%rbp)
leaq -0x298(%rbp), %rax
movq %rax, -0x2a8(%rbp)
movq -0x2a8(%rbp), %rdi
callq 0x4700
movq %rax, -0x2b0(%rbp)
movq -0x2a8(%rbp), %rdi
callq 0x4730
movq %rax, -0x2b8(%rbp)
leaq -0x2b0(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0x4760
testb $0x1, %al
jne 0x7fe1
jmp 0x80e5
leaq -0x2b0(%rbp), %rdi
callq 0x47a0
movl (%rax), %eax
movl %eax, -0x2bc(%rbp)
testb $0x1, -0x299(%rbp)
jne 0x80b9
leaq 0xb194(%rip), %rsi      # 0x1319d
leaq -0x210(%rbp), %rdi
callq 0x3230
jmp 0x8017
jmp 0x80b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
jmp 0x806e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
jmp 0x8062
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x3170
leaq -0x250(%rbp), %rdi
callq 0x3170
leaq -0x251(%rbp), %rdi
callq 0x3270
jmp 0x815b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
jmp 0x814f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x43e0
jmp 0x814f
movl -0x2bc(%rbp), %esi
leaq -0x210(%rbp), %rdi
callq 0x33f0
jmp 0x80cd
movb $0x0, -0x299(%rbp)
leaq -0x2b0(%rbp), %rdi
callq 0x47c0
jmp 0x7fc5
leaq 0xb04d(%rip), %rsi      # 0x13139
leaq -0x210(%rbp), %rdi
callq 0x3230
jmp 0x80fa
leaq -0x298(%rbp), %rdi
callq 0x43e0
leaq -0x278(%rbp), %rdi
callq 0xb520
jmp 0x7f51
leaq -0x210(%rbp), %rdi
callq 0x3330
jmp 0x8125
movq 0x11ea4(%rip), %rdi     # 0x19fd0
leaq 0xb00a(%rip), %rsi      # 0x1313d
callq 0x3230
jmp 0x813a
leaq -0x210(%rbp), %rdi
callq 0x3350
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbp
retq
leaq -0x210(%rbp), %rdi
callq 0x3350
movq -0x260(%rbp), %rdi
callq 0x3400
nopw (%rax,%rax)