// File: /workspace/github_cpp_makefile_star2_O1/momohatt[P]seccampDB/database.cpp
// Function: ConflictGraph::serialize()
vector<int> ConflictGraph::serialize() {  // 全然効率的ではないです
    vector<int> ret = {};
    map<int, set<int>> outgoing_edges = {};
    map<int, set<int>> incoming_edges = {};
    set<int> nodes_without_parent(nodes_.begin(), nodes_.end());

    // initialization
    for (const auto& e : edges_) {
        if (outgoing_edges.count(e.from) <= 0) {
            outgoing_edges[e.from] = {e.to};
        } else {
            outgoing_edges[e.from].insert(e.to);
        }
        if (incoming_edges.count(e.to) <= 0) {
            incoming_edges[e.to] = {e.from};
        } else {
            incoming_edges[e.to].insert(e.from);
        }
    }

    for (const auto& e : edges_) {
        nodes_without_parent.erase(e.to);
    }

    // find serializable schedule
    while (!nodes_without_parent.empty()) {
        auto n = nodes_without_parent.begin();
        int node = *n;
        nodes_without_parent.erase(n);
        ret.push_back(node);

        for (const auto& m : outgoing_edges[node]) {
            incoming_edges[m].erase(node);

            if (incoming_edges[m].empty()) {
                nodes_without_parent.insert(m);
            }
        }
        outgoing_edges.erase(node);
    }

    // check if cycle exists
    if (!outgoing_edges.empty()) {
        return {};
    }
    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %rbx
movq %rdi, 0x30(%rsp)
xorl %eax, %eax
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
leaq 0x78(%rsp), %rcx
movaps %xmm0, 0x8(%rcx)
movaps %xmm0, 0x18(%rcx)
movaps %xmm0, -0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0xa8(%rsp), %rcx
movaps %xmm0, 0x8(%rcx)
movaps %xmm0, 0x18(%rcx)
movaps %xmm0, -0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movq (%rsi), %rsi
movq 0x8(%rbx), %rdx
leaq 0x40(%rsp), %rdi
callq 0x7900
movq 0x18(%rbx), %r15
movq %rbx, 0x38(%rsp)
movq 0x20(%rbx), %r14
cmpq %r14, %r15
je 0x715f
addq $0x4, %r15
leaq 0x70(%rsp), %rbp
leaq 0xc(%rsp), %rbx
leaq 0xa0(%rsp), %r12
leaq -0x4(%r15), %r13
movq %rbp, %rdi
movq %r13, %rsi
callq 0x7982
testq %rax, %rax
je 0x70de
movq %rbp, %rdi
movq %r13, %rsi
callq 0x79cc
movq %rax, %rdi
movq %r15, %rsi
callq 0xa650
jmp 0x7100
movl (%r15), %eax
movl %eax, 0xc(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
callq 0x79cc
movq %rax, %rdi
movq %rbx, %rsi
leaq 0x10(%rsp), %rdx
callq 0xa462
movq %r12, %rdi
movq %r15, %rsi
callq 0x7982
testq %rax, %rax
je 0x7128
movq %r12, %rdi
movq %r15, %rsi
callq 0x79cc
movq %rax, %rdi
movq %r13, %rsi
callq 0xa650
jmp 0x714b
movl -0x4(%r15), %eax
movl %eax, 0xc(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x79cc
movq %rax, %rdi
movq %rbx, %rsi
leaq 0x10(%rsp), %rdx
callq 0xa462
leaq 0xc(%r15), %rax
addq $0x8, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0x70b2
movq 0x38(%rsp), %rax
movq 0x18(%rax), %r14
movq 0x20(%rax), %r15
cmpq %r15, %r14
je 0x7196
leaq 0x40(%rsp), %rbx
leaq 0x4(%r14), %rsi
movq %rbx, %rdi
callq 0xa6fa
movq %rbx, %rdi
movq %rax, %rsi
callq 0xa772
addq $0xc, %r14
cmpq %r15, %r14
jne 0x7176
cmpq $0x0, 0x68(%rsp)
je 0x728d
leaq 0xc(%rsp), %r12
leaq 0x70(%rsp), %rbx
leaq 0xa0(%rsp), %rbp
movq 0x58(%rsp), %rsi
movl 0x20(%rsi), %eax
movl %eax, 0xc(%rsp)
leaq 0x40(%rsp), %rdi
callq 0xa818
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x71e7
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x71f4
leaq 0x10(%rsp), %rdi
movq %r12, %rdx
callq 0x9986
movq %rbx, %rdi
movq %r12, %rsi
callq 0x79cc
movq %rax, %rbx
movq 0x18(%rax), %r15
addq $0x8, %rbx
cmpq %rbx, %r15
je 0x7266
leaq 0x20(%r15), %r13
movq %rbp, %rdi
movq %r13, %rsi
callq 0x79cc
movq %rax, %r14
movq %rax, %rdi
movq %r12, %rsi
callq 0xa6fa
movq %r14, %rdi
movq %rax, %rsi
callq 0xa772
movq %rbp, %rdi
movq %r13, %rsi
callq 0x79cc
cmpq $0x0, 0x28(%rax)
jne 0x7256
leaq 0x40(%rsp), %rdi
movq %r13, %rsi
callq 0xa650
movq %r15, %rdi
callq 0x3300
movq %rax, %r15
cmpq %rbx, %rax
jne 0x720f
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0xa854
movq %rbx, %rdi
movq %rax, %rsi
callq 0xa8cc
cmpq $0x0, 0x68(%rsp)
jne 0x71b4
cmpq $0x0, 0x98(%rsp)
movq 0x30(%rsp), %rbx
movq %rbx, %rax
jne 0x72bb
leaq 0x10(%rsp), %rax
movq (%rax), %rcx
movq %rcx, (%rbx)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x40(%rsp), %rdi
callq 0x8362
leaq 0xa0(%rsp), %rdi
callq 0x83b2
leaq 0x70(%rsp), %rdi
callq 0x83b2
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x7301
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32a0
movq %rbx, %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x7334
jmp 0x7327
jmp 0x7327
jmp 0x7327
jmp 0x7327
jmp 0x7327
jmp 0x7327
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x8362
leaq 0xa0(%rsp), %rdi
callq 0x83b2
leaq 0x70(%rsp), %rdi
callq 0x83b2
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x7362
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32a0
movq %rbx, %rdi
callq 0x3410