// File: /workspace/github_cpp_makefile_star2_O3/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, %r12
xorl %eax, %eax
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
leaq 0x78(%rsp), %rcx
movq %rax, 0x8(%rcx)
movaps %xmm0, -0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0xa8(%rsp), %rcx
movq %rax, 0x8(%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 0x7896
movq 0x18(%rbx), %r15
movq 0x20(%rbx), %r14
cmpq %r14, %r15
movq %r12, 0x38(%rsp)
je 0x7145
movq %rbx, 0x30(%rsp)
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 0x7912
testq %rax, %rax
je 0x708d
movq %rbp, %rdi
movq %r13, %rsi
callq 0x795a
movq %rax, %rdi
movq %r15, %rsi
callq 0xa5ac
jmp 0x70af
movl (%r15), %eax
movl %eax, 0xc(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
callq 0x795a
movq %rax, %rdi
movq %rbx, %rsi
leaq 0x10(%rsp), %rdx
callq 0xa3c2
movq %r12, %rdi
movq %r15, %rsi
callq 0x7912
testq %rax, %rax
je 0x70d7
movq %r12, %rdi
movq %r15, %rsi
callq 0x795a
movq %rax, %rdi
movq %r13, %rsi
callq 0xa5ac
jmp 0x70fa
movl -0x4(%r15), %eax
movl %eax, 0xc(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x795a
movq %rax, %rdi
movq %rbx, %rsi
leaq 0x10(%rsp), %rdx
callq 0xa3c2
leaq 0xc(%r15), %rax
addq $0x8, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0x7061
movq 0x30(%rsp), %rax
movq 0x18(%rax), %r14
movq 0x20(%rax), %r15
cmpq %r15, %r14
je 0x7145
leaq 0x40(%rsp), %rbx
leaq 0x4(%r14), %rsi
movq %rbx, %rdi
callq 0xa656
movq %rbx, %rdi
movq %rax, %rsi
callq 0xa6d4
addq $0xc, %r14
cmpq %r15, %r14
jne 0x7125
cmpq $0x0, 0x68(%rsp)
je 0x723c
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 0xa77a
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x7196
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x71a3
leaq 0x10(%rsp), %rdi
movq %r12, %rdx
callq 0x98e6
movq %rbx, %rdi
movq %r12, %rsi
callq 0x795a
movq %rax, %rbx
movq 0x18(%rax), %r15
addq $0x8, %rbx
cmpq %rbx, %r15
je 0x7215
leaq 0x20(%r15), %r13
movq %rbp, %rdi
movq %r13, %rsi
callq 0x795a
movq %rax, %r14
movq %rax, %rdi
movq %r12, %rsi
callq 0xa656
movq %r14, %rdi
movq %rax, %rsi
callq 0xa6d4
movq %rbp, %rdi
movq %r13, %rsi
callq 0x795a
cmpq $0x0, 0x28(%rax)
jne 0x7205
leaq 0x40(%rsp), %rdi
movq %r13, %rsi
callq 0xa5ac
movq %r15, %rdi
callq 0x3300
movq %rax, %r15
cmpq %rbx, %rax
jne 0x71be
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0xa7b6
movq %rbx, %rdi
movq %rax, %rsi
callq 0xa834
cmpq $0x0, 0x68(%rsp)
jne 0x7163
cmpq $0x0, 0x98(%rsp)
movq 0x38(%rsp), %rbx
movq %rbx, %rax
jne 0x7262
leaq 0x10(%rsp), %rax
movaps (%rax), %xmm0
movups %xmm0, (%rbx)
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x40(%rsp), %rdi
callq 0x82f2
leaq 0xa0(%rsp), %rdi
callq 0x8342
leaq 0x70(%rsp), %rdi
callq 0x8342
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x72a8
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 0x72db
jmp 0x72ce
jmp 0x72ce
jmp 0x72ce
jmp 0x72ce
jmp 0x72ce
jmp 0x72ce
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x82f2
leaq 0xa0(%rsp), %rdi
callq 0x8342
leaq 0x70(%rsp), %rdi
callq 0x8342
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x7309
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32a0
movq %rbx, %rdi
callq 0x3410
nop