// File: /workspace/github_cpp_makefile_star2_O2/xnevs[P]bullimp/examples/../graph/ullimp_order.hpp
// Function: std::vector<boost::graph_traits<boost::adjacency_list<boost::setS, boost::vecS, boost::bidirectionalS, boost::no_property, Color, boost::no_property, boost::listS>>::vertex_descriptor, std::allocator<boost::graph_traits<boost::adjacency_list<boost::setS, boost::vecS, boost::bidirectionalS, boost::no_property, Color, boost::no_property, boost::listS>>::vertex_descriptor>> ullimp::vertex_order_RDEG_CNC<boost::adjacency_list<boost::setS, boost::vecS, boost::bidirectionalS, boost::no_property, Color, boost::no_property, boost::listS>, boost::vec_adj_list_vertex_id_map<boost::no_property, unsigned long>>(boost::adjacency_list<boost::setS, boost::vecS, boost::bidirectionalS, boost::no_property, Color, boost::no_property, boost::listS> const&, boost::vec_adj_list_vertex_id_map<boost::no_property, unsigned long>)
std::vector<typename boost::graph_traits<Graph>::vertex_descriptor>
vertex_order_RDEG_CNC(Graph const &g, IndexMap index_map) {
    using namespace boost;

    using vertex_type = typename graph_traits<Graph>::vertex_descriptor;

    auto n = num_vertices(g);

    std::vector<vertex_type> vertex_order(n);
    
    std::vector<int> clustdeg_vec(n);
    auto clustdeg = make_iterator_property_map(std::begin(clustdeg_vec), index_map);

    BGL_FORALL_VERTICES_T(u, g, Graph) {
        clustdeg[u] = detail::clustering1(u, g) + degree(u, g);
    }

    std::vector<bool> avail_vec(n, true);
    auto avail = make_iterator_property_map(std::begin(avail_vec), index_map);

    for(int idx=0; idx<n; ++idx) {
        auto bestn = graph_traits<Graph>::null_vertex();
        int bestv = -1;
        BGL_FORALL_VERTICES_T(i, g, Graph) {
            if(avail[i]) {
                int deg = 0;
                BGL_FORALL_ADJ_T(i, p, g, Graph) {
                    if(!avail[p])
                        deg++;
                }
                BGL_FORALL_INV_ADJ_T(i, p, g, Graph) {
                    if(!avail[p])
                        deg++;
                }
                if(bestn == graph_traits<Graph>::null_vertex() || (deg > bestv || (deg == bestv && clustdeg[i] > clustdeg[bestn]))) {
                    bestn = i;
                    bestv = deg;
                }
            }
        }
        avail[bestn] = false;
        vertex_order[idx] = bestn;
    }

    return vertex_order;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq 0x20(%rsi), %rax
movq %rsi, %r15
subq 0x18(%rsi), %rax
pushq $0x68
popq %r13
cqto
idivq %r13
leaq 0x58(%rsp), %rdx
movq %rdi, 0x8(%rsp)
movq %rax, %rsi
movq %rax, %rbx
callq 0x470c
leaq 0x40(%rsp), %rdi
leaq 0x58(%rsp), %rdx
movq %rbx, %rsi
movq %rbx, 0x10(%rsp)
callq 0x4760
movq 0x40(%rsp), %rax
xorl %r12d, %r12d
movq %rax, 0x20(%rsp)
movq 0x20(%r15), %rax
subq 0x18(%r15), %rax
cqto
idivq %r13
movq %rax, %rbx
cmpq %rbx, %r12
je 0x4510
imulq $0x1a, %r12, %r14
addq $0x16, %r14
cmpq %r12, %rbx
je 0x450b
movq %r12, %rdi
movq %r15, %rsi
callq 0x47b3
movq 0x18(%r15), %rcx
movl -0x30(%rcx,%r14,4), %edx
addl (%rcx,%r14,4), %edx
movq 0x20(%rsp), %rcx
addq $0x1a, %r14
addl %edx, %eax
movl %eax, (%rcx,%r12,4)
incq %r12
jmp 0x44da
movq %rbx, %r12
jmp 0x44cd
leaq 0x80(%rsp), %rdx
movb $0x1, (%rdx)
movq 0x10(%rsp), %rsi
leaq 0x58(%rsp), %rdi
leaq 0x3(%rsp), %rcx
callq 0x4a1c
movq 0x58(%rsp), %rax
leaq 0x80(%rsp), %r12
movq %r15, 0x18(%rsp)
movq %rax, (%r12)
andl $0x0, 0x8(%r12)
xorl %eax, %eax
cmpq 0x10(%rsp), %rax
je 0x46a6
movq %rax, 0x28(%rsp)
movq 0x20(%r15), %rax
subq 0x18(%r15), %rax
cqto
idivq %r13
xorl %r13d, %r13d
movq %rax, %r14
pushq $-0x1
popq %rbx
pushq $-0x1
popq %rax
movl %eax, 0x4(%rsp)
movq %r14, 0x30(%rsp)
cmpq %r14, %r13
je 0x4675
cmpq %r14, %r13
je 0x466d
movq %r12, %rdi
movq %r13, %rsi
callq 0x4a80
testq %rdx, (%rax)
je 0x4665
movq 0x18(%r15), %rax
movq %rbx, 0x38(%rsp)
imulq $0x68, %r13, %rbx
xorl %ebp, %ebp
leaq 0x8(%rax,%rbx), %r14
movq 0x10(%r14), %r15
cmpq %r14, %r15
je 0x45ef
cmpq %r14, %r15
je 0x45ea
movq 0x20(%r15), %rsi
movq %r12, %rdi
callq 0x4a80
andq (%rax), %rdx
movq %r15, %rdi
cmpq $0x1, %rdx
adcl $0x0, %ebp
callq 0x2150
movq %rax, %r15
jmp 0x45c2
movq %r14, %r15
jmp 0x45bd
movq 0x18(%rsp), %rax
movq 0x30(%rsp), %r14
movq 0x18(%rax), %rax
leaq 0x38(%rax,%rbx), %rbx
movq 0x10(%rbx), %r15
cmpq %rbx, %r15
je 0x4638
cmpq %rbx, %r15
je 0x4633
movq 0x20(%r15), %rsi
movq %r12, %rdi
callq 0x4a80
andq (%rax), %rdx
movq %r15, %rdi
cmpq $0x1, %rdx
adcl $0x0, %ebp
callq 0x2150
movq %rax, %r15
jmp 0x460b
movq %rbx, %r15
jmp 0x4606
movq 0x38(%rsp), %rbx
movq 0x18(%rsp), %r15
cmpq $-0x1, %rbx
je 0x465e
cmpl 0x4(%rsp), %ebp
jg 0x465e
jne 0x4665
movq 0x20(%rsp), %rcx
movl (%rcx,%r13,4), %eax
cmpl (%rcx,%rbx,4), %eax
jle 0x4665
movq %r13, %rbx
movl %ebp, 0x4(%rsp)
incq %r13
jmp 0x4588
movq %r14, %r13
jmp 0x457f
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4a80
notq %rdx
movq 0x28(%rsp), %rcx
andq %rdx, (%rax)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rbx, (%rax,%rcx,8)
movq %rcx, %rax
incq %rax
pushq $0x68
popq %r13
jmp 0x454d
leaq 0x58(%rsp), %rdi
callq 0x4a90
leaq 0x40(%rsp), %rdi
callq 0x4bd2
movq 0x8(%rsp), %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x46e3
jmp 0x46dc
movq %rax, %rbx
jmp 0x46fa
jmp 0x46e3
movq %rax, %rbx
jmp 0x46f0
jmp 0x46e3
leaq 0x58(%rsp), %rdi
movq %rax, %rbx
callq 0x4a90
leaq 0x40(%rsp), %rdi
callq 0x4bd2
movq 0x8(%rsp), %rdi
callq 0x4acc
movq %rbx, %rdi
callq 0x21e0