// File: momohatt[P]seccampDB/database.cpp
// Function: ConflictGraph::emit()
void ConflictGraph::emit() {
    FILE* fp_out = fopen(graphfilename_.c_str(), "w");

    vector<int> serial_schedule = serialize();

    fprintf(fp_out, "/*\n");
    fprintf(fp_out, "serial schedule:\n");
    for (const auto& n : serial_schedule) {
        fprintf(fp_out, "%d\n", n);
    }
    fprintf(fp_out, " */\n");

    fprintf(fp_out, "digraph g {\n");
    for (const auto& n : nodes_) {
        fprintf(fp_out, "    Tx%d;\n", n);
    }
    for (const auto& e : edges_) {
        string conflict_type =
            (e.type == ReadWrite) ? "r-w" :
            (e.type == WriteRead) ? "w-r" : "w-w";
        fprintf(fp_out, "    Tx%d -> Tx%d [label = \"%s\"];\n",
                e.from, e.to, conflict_type.c_str());
    }
    fprintf(fp_out, "}\n");
    fclose(fp_out);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
addq $0x30, %rdi
callq 0x3140
movq %rax, %rdi
leaq 0x15c6c(%rip), %rsi     # 0x1c5a9
callq 0x33e0
movq -0xc8(%rbp), %rsi
movq %rax, -0x10(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x8a40
movq -0x10(%rbp), %rdi
leaq 0x15c13(%rip), %rsi     # 0x1c574
movb $0x0, %al
callq 0x3470
movq -0x10(%rbp), %rdi
leaq 0x15c05(%rip), %rsi     # 0x1c578
movb $0x0, %al
callq 0x3470
leaq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0xaf80
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0xafb0
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0xafe0
testb $0x1, %al
jne 0x69af
jmp 0x69df
leaq -0x38(%rbp), %rdi
callq 0xb020
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rax
movl (%rax), %edx
leaq 0x15b5e(%rip), %rsi     # 0x1c52b
movb $0x0, %al
callq 0x3470
leaq -0x38(%rbp), %rdi
callq 0xb040
jmp 0x699c
movq -0x10(%rbp), %rdi
leaq 0x15ba0(%rip), %rsi     # 0x1c58a
movb $0x0, %al
callq 0x3470
movq -0x10(%rbp), %rdi
leaq 0x15b93(%rip), %rsi     # 0x1c58f
movb $0x0, %al
callq 0x3470
movq -0xc8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0xaf80
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
callq 0xafb0
movq %rax, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xafe0
testb $0x1, %al
jne 0x6a3b
jmp 0x6a6b
leaq -0x58(%rbp), %rdi
callq 0xb020
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movq -0x68(%rbp), %rax
movl (%rax), %edx
leaq 0x15b43(%rip), %rsi     # 0x1c59c
movb $0x0, %al
callq 0x3470
leaq -0x58(%rbp), %rdi
callq 0xb040
jmp 0x6a28
movq -0xc8(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0xb130
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdi
callq 0xb160
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xb190
testb $0x1, %al
jne 0x6aaa
jmp 0x6bef
leaq -0x78(%rbp), %rdi
callq 0xb1d0
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x6ad7
leaq 0x15ad9(%rip), %rax     # 0x1c5a7
movq %rax, -0xd0(%rbp)
jmp 0x6b12
movq -0x88(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jne 0x6af4
leaq 0x15ac0(%rip), %rax     # 0x1c5ab
movq %rax, -0xd8(%rbp)
jmp 0x6b04
leaq 0x15ab4(%rip), %rax     # 0x1c5af
movq %rax, -0xd8(%rbp)
jmp 0x6b04
movq -0xd8(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0xa9(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x3550
movq -0xe8(%rbp), %rsi
movq -0xe0(%rbp), %rdx
leaq -0xa8(%rbp), %rdi
callq 0x4440
jmp 0x6b4f
leaq -0xa9(%rbp), %rdi
callq 0x3380
movq -0x10(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x88(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xf0(%rbp)
movq -0x88(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0xec(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x3140
movq -0xf8(%rbp), %rdi
movl -0xf0(%rbp), %edx
movl -0xec(%rbp), %ecx
movq %rax, %r8
leaq 0x15a05(%rip), %rsi     # 0x1c5b3
movb $0x0, %al
callq 0x3470
leaq -0xa8(%rbp), %rdi
callq 0x35f8
leaq -0x78(%rbp), %rdi
callq 0xb1f0
jmp 0x6a94
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0xa9(%rbp), %rdi
callq 0x3380
jmp 0x6c30
movq -0x10(%rbp), %rdi
leaq 0x15963(%rip), %rsi     # 0x1c55d
xorl %eax, %eax
callq 0x3470
movq -0x10(%rbp), %rdi
callq 0x3310
jmp 0x6c0c
leaq -0x28(%rbp), %rdi
callq 0xab10
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xab10
movq -0xb8(%rbp), %rdi
callq 0x3540
nopw %cs:(%rax,%rax)