// File: 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:
subq $0x358, %rsp            # imm = 0x358
movq %rdi, 0x160(%rsp)
movq %rdi, %rax
movq %rax, 0x158(%rsp)
movq %rdi, 0x350(%rsp)
movq %rsi, 0x340(%rsp)
movq 0x340(%rsp), %rdi
callq 0x7ee0
movq %rax, 0x338(%rsp)
movb $0x0, 0x337(%rsp)
movq 0x338(%rsp), %rax
movq %rax, 0x168(%rsp)
leaq 0x336(%rsp), %rdi
movq %rdi, 0x170(%rsp)
callq 0xadb0
movq 0x160(%rsp), %rdi
movq 0x168(%rsp), %rsi
movq 0x170(%rsp), %rdx
callq 0xadc0
jmp 0xa36b
leaq 0x336(%rsp), %rdi
callq 0xae40
movq 0x338(%rsp), %rax
movq %rax, 0x148(%rsp)
leaq 0x307(%rsp), %rdi
movq %rdi, 0x150(%rsp)
callq 0xae50
movq 0x148(%rsp), %rsi
movq 0x150(%rsp), %rdx
leaq 0x308(%rsp), %rdi
callq 0xae60
jmp 0xa3bc
leaq 0x307(%rsp), %rdi
callq 0xaee0
leaq 0x308(%rsp), %rdi
callq 0xaf20
movq %rax, 0x140(%rsp)
jmp 0xa3e0
movq 0x140(%rsp), %rax
movq %rax, 0x2e8(%rsp)
movq 0x2e8(%rsp), %rdi
callq 0xaef0
movq %rax, 0x138(%rsp)
jmp 0xa407
movq 0x138(%rsp), %rax
movq %rax, 0x2f0(%rsp)
movq 0x340(%rsp), %rdi
callq 0xaf50
movq %rdx, 0x128(%rsp)
movq %rax, 0x130(%rsp)
jmp 0xa436
movq 0x128(%rsp), %rax
movq 0x130(%rsp), %rcx
movq %rcx, 0x2d0(%rsp)
movq %rax, 0x2d8(%rsp)
leaq 0x2d8(%rsp), %rsi
leaq 0x2d0(%rsp), %rdi
callq 0xafe0
movb %al, 0x127(%rsp)
jmp 0xa474
movb 0x127(%rsp), %al
testb $0x1, %al
jne 0xa484
jmp 0xa61c
jmp 0xa486
leaq 0x2d8(%rsp), %rsi
leaq 0x2d0(%rsp), %rdi
callq 0xafe0
movb %al, 0x126(%rsp)
jmp 0xa4a4
movb 0x126(%rsp), %al
testb $0x1, %al
jne 0xa4b1
jmp 0xa4e3
leaq 0x2d0(%rsp), %rdi
callq 0xb030
movq %rax, 0x118(%rsp)
jmp 0xa4c8
movq 0x118(%rsp), %rax
movq %rax, 0x2c8(%rsp)
movb $0x1, %al
movb %al, 0x117(%rsp)
jmp 0xa4ee
xorl %eax, %eax
movb %al, 0x117(%rsp)
jmp 0xa4ee
movb 0x117(%rsp), %al
testb $0x1, %al
jne 0xa4fe
jmp 0xa605
movq 0x2c8(%rsp), %rdi
movq 0x340(%rsp), %rsi
callq 0xb050
movl %eax, 0x110(%rsp)
jmp 0xa51c
movl 0x110(%rsp), %eax
cltq
movq 0x2c8(%rsp), %rdi
movq 0x340(%rsp), %rsi
callq 0xb780
movq %rax, 0x108(%rsp)
jmp 0xa544
movl 0x110(%rsp), %eax
movq 0x108(%rsp), %rcx
addl %ecx, %eax
movl %eax, 0xfc(%rsp)
movq 0x2c8(%rsp), %rsi
leaq 0x2f0(%rsp), %rdi
callq 0xb7d0
movq %rax, 0x100(%rsp)
jmp 0xa57b
movq 0x100(%rsp), %rax
movl 0xfc(%rsp), %ecx
movl %ecx, (%rax)
leaq 0x2d0(%rsp), %rdi
callq 0xb820
jmp 0xa59b
jmp 0xa486
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
leaq 0x336(%rsp), %rdi
callq 0xae40
jmp 0xad83
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
leaq 0x307(%rsp), %rdi
callq 0xaee0
jmp 0xad76
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
jmp 0xad4a
jmp 0xa607
movq 0x2d8(%rsp), %rax
movq %rax, 0x2d0(%rsp)
jmp 0xa456
movq 0x338(%rsp), %rax
movq %rax, 0xe8(%rsp)
movb $0x1, 0x29f(%rsp)
leaq 0x29e(%rsp), %rdi
movq %rdi, 0xf0(%rsp)
callq 0xb850
movq 0xe8(%rsp), %rsi
movq 0xf0(%rsp), %rcx
leaq 0x2a0(%rsp), %rdi
leaq 0x29f(%rsp), %rdx
callq 0xb860
jmp 0xa670
leaq 0x29e(%rsp), %rdi
callq 0xb8e0
leaq 0x2a0(%rsp), %rdi
callq 0xb940
movl %edx, 0xdc(%rsp)
movq %rax, 0xe0(%rsp)
jmp 0xa69b
movl 0xdc(%rsp), %eax
movq 0xe0(%rsp), %rcx
movq %rcx, 0x260(%rsp)
movl %eax, 0x268(%rsp)
movl 0x268(%rsp), %eax
movl %eax, 0x278(%rsp)
movq 0x260(%rsp), %rax
movq %rax, 0x270(%rsp)
movq 0x270(%rsp), %rsi
movl 0x278(%rsp), %edx
leaq 0x280(%rsp), %rdi
callq 0xb8f0
jmp 0xa6f5
movl $0x0, 0x258(%rsp)
movslq 0x258(%rsp), %rax
cmpq 0x338(%rsp), %rax
jae 0xad1c
callq 0xb980
movq %rax, 0xd0(%rsp)
jmp 0xa725
movq 0xd0(%rsp), %rax
movq %rax, 0x250(%rsp)
movl $0xffffffff, 0x24c(%rsp) # imm = 0xFFFFFFFF
movq 0x340(%rsp), %rdi
callq 0xaf50
movq %rdx, 0xc0(%rsp)
movq %rax, 0xc8(%rsp)
jmp 0xa75f
movq 0xc0(%rsp), %rax
movq 0xc8(%rsp), %rcx
movq %rcx, 0x238(%rsp)
movq %rax, 0x240(%rsp)
leaq 0x240(%rsp), %rsi
leaq 0x238(%rsp), %rdi
callq 0xafe0
movb %al, 0xbf(%rsp)
jmp 0xa79d
movb 0xbf(%rsp), %al
testb $0x1, %al
jne 0xa7ad
jmp 0xac92
jmp 0xa7af
leaq 0x240(%rsp), %rsi
leaq 0x238(%rsp), %rdi
callq 0xafe0
movb %al, 0xbe(%rsp)
jmp 0xa7cd
movb 0xbe(%rsp), %al
testb $0x1, %al
jne 0xa7da
jmp 0xa80c
leaq 0x238(%rsp), %rdi
callq 0xb030
movq %rax, 0xb0(%rsp)
jmp 0xa7f1
movq 0xb0(%rsp), %rax
movq %rax, 0x230(%rsp)
movb $0x1, %al
movb %al, 0xaf(%rsp)
jmp 0xa817
xorl %eax, %eax
movb %al, 0xaf(%rsp)
jmp 0xa817
movb 0xaf(%rsp), %al
testb $0x1, %al
jne 0xa827
jmp 0xac7b
movq 0x230(%rsp), %rsi
leaq 0x280(%rsp), %rdi
callq 0xb990
movq %rdx, 0x98(%rsp)
movq %rax, 0xa0(%rsp)
jmp 0xa84e
movq 0x98(%rsp), %rax
movq 0xa0(%rsp), %rcx
movq %rcx, 0x220(%rsp)
movq %rax, 0x228(%rsp)
leaq 0x220(%rsp), %rdi
callq 0xba00
testb $0x1, %al
jne 0xa884
jmp 0xac65
movl $0x0, 0x21c(%rsp)
movq 0x230(%rsp), %rsi
movq 0x340(%rsp), %rdx
leaq 0x1e8(%rsp), %rdi
callq 0xba30
jmp 0xa8ae
jmp 0xa8b0
leaq 0x200(%rsp), %rsi
leaq 0x1e8(%rsp), %rdi
callq 0xbb20
movb %al, 0x97(%rsp)
jmp 0xa8ce
movb 0x97(%rsp), %al
testb $0x1, %al
jne 0xa8de
jmp 0xaa54
jmp 0xa8e0
leaq 0x200(%rsp), %rsi
leaq 0x1e8(%rsp), %rdi
callq 0xbb20
movb %al, 0x96(%rsp)
jmp 0xa8fe
movb 0x96(%rsp), %al
testb $0x1, %al
jne 0xa90b
jmp 0xa93d
leaq 0x1e8(%rsp), %rdi
callq 0xbb70
movq %rax, 0x88(%rsp)
jmp 0xa922
movq 0x88(%rsp), %rax
movq %rax, 0x1e0(%rsp)
movb $0x1, %al
movb %al, 0x87(%rsp)
jmp 0xa948
xorl %eax, %eax
movb %al, 0x87(%rsp)
jmp 0xa948
movb 0x87(%rsp), %al
testb $0x1, %al
jne 0xa958
jmp 0xaa1d
movq 0x1e0(%rsp), %rsi
leaq 0x280(%rsp), %rdi
callq 0xb990
movq %rdx, 0x70(%rsp)
movq %rax, 0x78(%rsp)
jmp 0xa979
movq 0x70(%rsp), %rax
movq 0x78(%rsp), %rcx
movq %rcx, 0x1d0(%rsp)
movq %rax, 0x1d8(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0xba00
xorb $-0x1, %al
testb $0x1, %al
jne 0xa9a8
jmp 0xaa07
movl 0x21c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x21c(%rsp)
jmp 0xaa07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
leaq 0x29e(%rsp), %rdi
callq 0xb8e0
jmp 0xad4a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
leaq 0x2a0(%rsp), %rdi
callq 0xbdc0
jmp 0xad4a
jmp 0xaa09
leaq 0x1e8(%rsp), %rdi
callq 0xbb90
jmp 0xaa18
jmp 0xa8e0
jmp 0xaa1f
movq 0x200(%rsp), %rax
movq %rax, 0x1e8(%rsp)
movq 0x208(%rsp), %rax
movq %rax, 0x1f0(%rsp)
movq 0x210(%rsp), %rax
movq %rax, 0x1f8(%rsp)
jmp 0xa8b0
movq 0x230(%rsp), %rsi
movq 0x340(%rsp), %rdx
leaq 0x1a0(%rsp), %rdi
callq 0xbbc0
jmp 0xaa73
jmp 0xaa75
leaq 0x1b8(%rsp), %rsi
leaq 0x1a0(%rsp), %rdi
callq 0xbcb0
movb %al, 0x6f(%rsp)
jmp 0xaa90
movb 0x6f(%rsp), %al
testb $0x1, %al
jne 0xaa9d
jmp 0xabad
jmp 0xaa9f
leaq 0x1b8(%rsp), %rsi
leaq 0x1a0(%rsp), %rdi
callq 0xbcb0
movb %al, 0x6e(%rsp)
jmp 0xaaba
movb 0x6e(%rsp), %al
testb $0x1, %al
jne 0xaac4
jmp 0xaaed
leaq 0x1a0(%rsp), %rdi
callq 0xbd00
movq %rax, 0x60(%rsp)
jmp 0xaad8
movq 0x60(%rsp), %rax
movq %rax, 0x198(%rsp)
movb $0x1, %al
movb %al, 0x5f(%rsp)
jmp 0xaaf5
xorl %eax, %eax
movb %al, 0x5f(%rsp)
jmp 0xaaf5
movb 0x5f(%rsp), %al
testb $0x1, %al
jne 0xaaff
jmp 0xab76
movq 0x198(%rsp), %rsi
leaq 0x280(%rsp), %rdi
callq 0xb990
movq %rdx, 0x48(%rsp)
movq %rax, 0x50(%rsp)
jmp 0xab20
movq 0x48(%rsp), %rax
movq 0x50(%rsp), %rcx
movq %rcx, 0x188(%rsp)
movq %rax, 0x190(%rsp)
leaq 0x188(%rsp), %rdi
callq 0xba00
xorb $-0x1, %al
testb $0x1, %al
jne 0xab4f
jmp 0xab60
movl 0x21c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x21c(%rsp)
jmp 0xab62
leaq 0x1a0(%rsp), %rdi
callq 0xbd20
jmp 0xab71
jmp 0xaa9f
jmp 0xab78
movq 0x1b8(%rsp), %rax
movq %rax, 0x1a0(%rsp)
movq 0x1c0(%rsp), %rax
movq %rax, 0x1a8(%rsp)
movq 0x1c8(%rsp), %rax
movq %rax, 0x1b0(%rsp)
jmp 0xaa75
movq 0x250(%rsp), %rax
movq %rax, 0x38(%rsp)
callq 0xb980
movq %rax, 0x40(%rsp)
jmp 0xabc6
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rcx
cmpq %rcx, %rax
je 0xac45
movl 0x21c(%rsp), %eax
cmpl 0x24c(%rsp), %eax
jg 0xac45
movl 0x21c(%rsp), %eax
cmpl 0x24c(%rsp), %eax
jne 0xac63
movq 0x230(%rsp), %rsi
leaq 0x2f0(%rsp), %rdi
callq 0xb7d0
movq %rax, 0x30(%rsp)
jmp 0xac11
movq 0x30(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x24(%rsp)
movq 0x250(%rsp), %rsi
leaq 0x2f0(%rsp), %rdi
callq 0xb7d0
movq %rax, 0x28(%rsp)
jmp 0xac38
movl 0x24(%rsp), %eax
movq 0x28(%rsp), %rcx
cmpl (%rcx), %eax
jle 0xac63
movq 0x230(%rsp), %rax
movq %rax, 0x250(%rsp)
movl 0x21c(%rsp), %eax
movl %eax, 0x24c(%rsp)
jmp 0xac65
jmp 0xac67
leaq 0x238(%rsp), %rdi
callq 0xb820
jmp 0xac76
jmp 0xa7af
jmp 0xac7d
movq 0x240(%rsp), %rax
movq %rax, 0x238(%rsp)
jmp 0xa77f
movq 0x250(%rsp), %rsi
leaq 0x280(%rsp), %rdi
callq 0xb990
movq %rdx, 0x10(%rsp)
movq %rax, 0x18(%rsp)
jmp 0xacb3
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, 0x178(%rsp)
movq %rax, 0x180(%rsp)
leaq 0x178(%rsp), %rdi
xorl %esi, %esi
callq 0xbd50
movq 0x160(%rsp), %rdi
movq 0x250(%rsp), %rax
movq %rax, 0x8(%rsp)
movslq 0x258(%rsp), %rsi
callq 0xbda0
movq 0x8(%rsp), %rcx
movq %rcx, (%rax)
movl 0x258(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x258(%rsp)
jmp 0xa700
movb $0x1, 0x337(%rsp)
leaq 0x2a0(%rsp), %rdi
callq 0xbdc0
leaq 0x308(%rsp), %rdi
callq 0xbdd0
testb $0x1, 0x337(%rsp)
jne 0xad66
jmp 0xad59
leaq 0x308(%rsp), %rdi
callq 0xbdd0
jmp 0xad76
movq 0x160(%rsp), %rdi
callq 0x65b0
movq 0x158(%rsp), %rax
addq $0x358, %rsp            # imm = 0x358
retq
movq 0x160(%rsp), %rdi
callq 0x65b0
movq 0x328(%rsp), %rdi
callq 0x2270