// File: /workspace/github_cpp_makefile_star2_O1/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 %rsi, %r12
movq 0x18(%rsi), %r14
movq 0x20(%rsi), %r13
movq %r13, %rbx
subq %r14, %rbx
sarq $0x3, %rbx
movabsq $0x4ec4ec4ec4ec4ec5, %rax # imm = 0x4EC4EC4EC4EC4EC5
imulq %rax, %rbx
leaq 0x58(%rsp), %rdx
movq %rdi, 0x8(%rsp)
movq %rbx, %rsi
callq 0x5108
leaq 0x80(%rsp), %rdi
leaq 0x58(%rsp), %rdx
movq %rbx, 0x10(%rsp)
movq %rbx, %rsi
callq 0x5194
movq 0x20(%r12), %rbp
movq 0x18(%r12), %rax
subq %rax, %rbp
movq 0x80(%rsp), %rax
movq %rax, 0x20(%rsp)
je 0x4e44
sarq $0x3, %rbp
movabsq $0x4ec4ec4ec4ec4ec5, %rax # imm = 0x4EC4EC4EC4EC4EC5
imulq %rax, %rbp
movl $0x16, %ebx
xorl %r15d, %r15d
movq %r15, %rdi
movq %r12, %rsi
callq 0x521f
movq 0x18(%r12), %rcx
movl -0x30(%rcx,%rbx,4), %edx
addl (%rcx,%rbx,4), %edx
addl %edx, %eax
movq 0x20(%rsp), %rcx
movl %eax, (%rcx,%r15,4)
incq %r15
addq $0x1a, %rbx
cmpq %r15, %rbp
jne 0x4e16
leaq 0x3(%rsp), %rdx
movb $0x1, (%rdx)
leaq 0x58(%rsp), %rdi
leaq 0x2(%rsp), %rcx
movq 0x10(%rsp), %rsi
callq 0x5582
movq 0x58(%rsp), %r15
cmpq %r14, %r13
je 0x5058
movabsq $-0x8000000000000000, %rbp # imm = 0x8000000000000000
movq 0x18(%r12), %rax
movq 0x20(%r12), %rcx
movq %rcx, 0x30(%rsp)
movq %rax, 0x18(%rsp)
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $0x4ec4ec4ec4ec4ec5, %rax # imm = 0x4EC4EC4EC4EC4EC5
imulq %rax, %rcx
movq %rcx, 0x40(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x10(%rsp), %rax
cmpq $0x1, %rax
adcq $0x0, %rax
movq %rax, 0x10(%rsp)
xorl %edx, %edx
leaq 0x3f(%rbp), %r13
movq 0x30(%rsp), %rax
cmpq 0x18(%rsp), %rax
movq %rdx, 0x38(%rsp)
movq $-0x1, %rcx
je 0x500c
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
xorl %r12d, %r12d
leaq 0x3f(%r12), %rax
testq %r12, %r12
cmovnsq %r12, %rax
sarq $0x6, %rax
leaq (%r15,%rax,8), %rax
movq %r12, %rsi
andq %r13, %rsi
xorl %edx, %edx
cmpq %rbp, %rsi
setbe %dl
movq -0x8(%rax,%rdx,8), %rax
btq %r12, %rax
jae 0x4ffe
movq %rcx, 0x50(%rsp)
imulq $0x68, %r12, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x48(%rsp)
leaq 0x8(%rax,%rcx), %r14
movq 0x10(%r14), %rax
xorl %ebx, %ebx
cmpq %r14, %rax
je 0x4f82
movq 0x20(%rax), %rcx
leaq 0x3f(%rcx), %rdx
testq %rcx, %rcx
cmovnsq %rcx, %rdx
sarq $0x6, %rdx
leaq (%r15,%rdx,8), %rdx
movq %rcx, %rsi
andq %r13, %rsi
xorl %edi, %edi
cmpq %rbp, %rsi
setbe %dil
movq -0x8(%rdx,%rdi,8), %rdx
btq %rcx, %rdx
sbbl $-0x1, %ebx
movq %rax, %rdi
callq 0x2180
jmp 0x4f41
movq 0x18(%rsp), %rax
movq 0x48(%rsp), %rcx
leaq 0x38(%rax,%rcx), %r14
movq 0x10(%r14), %rax
cmpq %r14, %rax
je 0x4fd6
movq 0x20(%rax), %rcx
leaq 0x3f(%rcx), %rdx
testq %rcx, %rcx
cmovnsq %rcx, %rdx
sarq $0x6, %rdx
leaq (%r15,%rdx,8), %rdx
movq %rcx, %rsi
andq %r13, %rsi
xorl %edi, %edi
cmpq %rbp, %rsi
setbe %dil
movq -0x8(%rdx,%rdi,8), %rdx
btq %rcx, %rdx
sbbl $-0x1, %ebx
movq %rax, %rdi
callq 0x2180
jmp 0x4f95
movq 0x50(%rsp), %rcx
cmpq $-0x1, %rcx
je 0x4ff7
cmpl 0x4(%rsp), %ebx
jg 0x4ff7
jne 0x4ffe
movq 0x20(%rsp), %rdx
movl (%rdx,%r12,4), %eax
cmpl (%rdx,%rcx,4), %eax
jle 0x4ffe
movq %r12, %rcx
movl %ebx, 0x4(%rsp)
incq %r12
cmpq 0x40(%rsp), %r12
jne 0x4ef2
leaq 0x3f(%rcx), %rax
testq %rcx, %rcx
cmovnsq %rcx, %rax
sarq $0x6, %rax
leaq (%r15,%rax,8), %rax
movq %rcx, %rsi
andq %r13, %rsi
xorl %edx, %edx
cmpq %rbp, %rsi
setbe %dl
movq $-0x2, %rsi
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 0x4ecb
testq %r15, %r15
je 0x5086
movq 0x78(%rsp), %rsi
subq %r15, %rsi
movq %r15, %rdi
callq 0x2140
xorl %eax, %eax
movq %rax, 0x58(%rsp)
movl %eax, 0x60(%rsp)
movq %rax, 0x68(%rsp)
movl %eax, 0x70(%rsp)
movq %rax, 0x78(%rsp)
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x50a3
movq 0x90(%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 0x50c1
movq %rax, %r14
jmp 0x50e1
movq %rax, %r14
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x50e1
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
movq 0x8(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x50ff
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x2140
movq %r14, %rdi
callq 0x21f0
nop