// File: /workspace/github_cpp_makefile_star2_O3/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), %r13
movq 0x18(%rsi), %r14
movabsq $0x4ec4ec4ec4ec4ec5, %rax # imm = 0x4EC4EC4EC4EC4EC5
leaq 0x70(%rsp), %rdx
movq %rsi, %r12
movq %rdi, 0x8(%rsp)
movq %r13, %rbx
subq %r14, %rbx
sarq $0x3, %rbx
imulq %rax, %rbx
movq %rbx, %rsi
callq 0x4fe4
leaq 0x58(%rsp), %rdi
leaq 0x70(%rsp), %rdx
movq %rbx, %rsi
movq %rbx, 0x10(%rsp)
callq 0x5074
movq 0x20(%r12), %rbp
movq 0x18(%r12), %rax
movq 0x58(%rsp), %rcx
subq %rax, %rbp
movq %rcx, 0x20(%rsp)
je 0x4d40
sarq $0x3, %rbp
movabsq $0x4ec4ec4ec4ec4ec5, %rax # imm = 0x4EC4EC4EC4EC4EC5
movl $0x16, %ebx
xorl %r15d, %r15d
imulq %rax, %rbp
movq %r15, %rdi
movq %r12, %rsi
callq 0x5103
movq 0x18(%r12), %rcx
movl -0x30(%rcx,%rbx,4), %edx
addl (%rcx,%rbx,4), %edx
movq 0x20(%rsp), %rcx
addq $0x1a, %rbx
addl %edx, %eax
movl %eax, (%rcx,%r15,4)
incq %r15
cmpq %r15, %rbp
jne 0x4d12
leaq 0x3(%rsp), %rdx
movb $0x1, (%rdx)
movq 0x10(%rsp), %rsi
leaq 0x70(%rsp), %rdi
leaq 0x2(%rsp), %rcx
callq 0x53ce
movq 0x70(%rsp), %r15
cmpq %r14, %r13
je 0x4f56
movq 0x18(%r12), %rax
movq 0x20(%r12), %rcx
movq 0x8(%rsp), %rsi
movabsq $-0x8000000000000000, %rbp # imm = 0x8000000000000000
leaq 0x3f(%rbp), %r13
movq %rcx, 0x30(%rsp)
subq %rax, %rcx
movq %rax, 0x18(%rsp)
movabsq $0x4ec4ec4ec4ec4ec5, %rax # imm = 0x4EC4EC4EC4EC4EC5
sarq $0x3, %rcx
imulq %rax, %rcx
movq (%rsi), %rax
movq %rcx, 0x40(%rsp)
movq 0x10(%rsp), %rcx
movq %rax, 0x28(%rsp)
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %edx, %edx
movq %rcx, 0x10(%rsp)
movq 0x30(%rsp), %rax
movq $-0x1, %rcx
movq %rdx, 0x38(%rsp)
cmpq 0x18(%rsp), %rax
je 0x4f08
xorl %r12d, %r12d
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
leaq 0x3f(%r12), %rax
testq %r12, %r12
movq %r12, %rsi
cmovnsq %r12, %rax
andq %r13, %rsi
xorl %edx, %edx
sarq $0x6, %rax
cmpq %rbp, %rsi
leaq (%r15,%rax,8), %rax
setbe %dl
movq -0x8(%rax,%rdx,8), %rax
btq %r12, %rax
jae 0x4efa
movq 0x18(%rsp), %rax
movq %rcx, 0x50(%rsp)
imulq $0x68, %r12, %rcx
xorl %ebx, %ebx
movq %rcx, 0x48(%rsp)
leaq 0x8(%rax,%rcx), %r14
movq 0x10(%r14), %rax
cmpq %r14, %rax
je 0x4e7e
movq 0x20(%rax), %rcx
leaq 0x3f(%rcx), %rdx
testq %rcx, %rcx
movq %rcx, %rsi
cmovnsq %rcx, %rdx
andq %r13, %rsi
xorl %edi, %edi
sarq $0x6, %rdx
cmpq %rbp, %rsi
leaq (%r15,%rdx,8), %rdx
setbe %dil
movq -0x8(%rdx,%rdi,8), %rdx
movq %rax, %rdi
btq %rcx, %rdx
sbbl $-0x1, %ebx
callq 0x2180
jmp 0x4e3d
movq 0x18(%rsp), %rax
movq 0x48(%rsp), %rcx
leaq 0x38(%rax,%rcx), %r14
movq 0x10(%r14), %rax
cmpq %r14, %rax
je 0x4ed2
movq 0x20(%rax), %rcx
leaq 0x3f(%rcx), %rdx
testq %rcx, %rcx
movq %rcx, %rsi
cmovnsq %rcx, %rdx
andq %r13, %rsi
xorl %edi, %edi
sarq $0x6, %rdx
cmpq %rbp, %rsi
leaq (%r15,%rdx,8), %rdx
setbe %dil
movq -0x8(%rdx,%rdi,8), %rdx
movq %rax, %rdi
btq %rcx, %rdx
sbbl $-0x1, %ebx
callq 0x2180
jmp 0x4e91
movq 0x50(%rsp), %rcx
cmpq $-0x1, %rcx
je 0x4ef3
cmpl 0x4(%rsp), %ebx
jg 0x4ef3
jne 0x4efa
movq 0x20(%rsp), %rdx
movl (%rdx,%r12,4), %eax
cmpl (%rdx,%rcx,4), %eax
jle 0x4efa
movq %r12, %rcx
movl %ebx, 0x4(%rsp)
incq %r12
cmpq 0x40(%rsp), %r12
jne 0x4dee
leaq 0x3f(%rcx), %rax
testq %rcx, %rcx
movq %rcx, %rsi
cmovnsq %rcx, %rax
andq %r13, %rsi
xorl %edx, %edx
sarq $0x6, %rax
cmpq %rbp, %rsi
movq $-0x2, %rsi
leaq (%r15,%rax,8), %rax
setbe %dl
rolq %cl, %rsi
andq %rsi, -0x8(%rax,%rdx,8)
movq 0x28(%rsp), %rax
movq 0x38(%rsp), %rdx
movq %rcx, (%rax,%rdx,8)
incq %rdx
cmpq 0x10(%rsp), %rdx
jne 0x4dc7
jmp 0x4f5b
testq %r15, %r15
je 0x4f6e
movq 0x90(%rsp), %rsi
movq %r15, %rdi
subq %r15, %rsi
callq 0x2140
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x4f85
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
movq 0x8(%rsp), %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4fa3
movq %rax, %r14
jmp 0x4fbd
movq 0x58(%rsp), %rdi
movq %rax, %r14
testq %rdi, %rdi
je 0x4fbd
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
movq 0x8(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x4fdb
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x2140
movq %r14, %rdi
callq 0x21f0
nop