// File: /workspace/github_cpp_makefile_star2_O2/jkunlin[P]maxclique/Vertices.cpp
// Function: Vertices::colo_sort(bool const* const*, int)
void Vertices::colo_sort(const bool * const * conn, int min_k) {
	if(min_k <= 0)
		min_k = 1;
	typedef std::vector<int> color;
	typedef std::vector<color> colors;
	static color C;
	static colors Cs;
	size_t colors_num = 0;
	C.resize(0);

	for(colors::iterator iter = Cs.begin(); iter != Cs.end(); ++iter) {
		iter->resize(0);
	}

	vvec_type::iterator insert_ver_iter = vertices.begin();
	for(vvec_type::iterator ver_iter = vertices.begin(); ver_iter != vertices.end(); ++ver_iter) {

		//find the proper color to insert vertex
		colors::size_type i = 0;
		for(; i != colors_num; ++i) {
			if(!color_conflict(conn, ver_iter->get_index(), Cs[i])) {
				//proper color found
				Cs[i].push_back(ver_iter->get_index());
				break;
			}
		}

		//no proper color found, create empty one
		if(i == colors_num) {
			C.resize(0);
			C.push_back(ver_iter->get_index());
			if(Cs.size() > colors_num)
				C.swap(Cs[colors_num]);
			else
				Cs.push_back(C);
			++colors_num;
		}
		//contain small color vertices in order
		if(i + 1 < static_cast<unsigned int>(min_k)) {
			insert_ver_iter->set_index(ver_iter->get_index());
			insert_ver_iter->set_degree(0);
			++insert_ver_iter;
		}
		/*
		//find the proper color to insert vertex
		colors::iterator colors_iter = Cs.begin();
		for(; colors_iter != Cs.end(); ++colors_iter) {
			if(!color_conflict(conn, ver_iter->get_index(), *colors_iter)) {
				//proper color found
				(*colors_iter).push_back(ver_iter->get_index());
				break;
			}
		}

		//no proper color found, create empty one
		if(colors_iter == Cs.end()) {
			C.resize(0);
			C.push_back(ver_iter->get_index());
			Cs.push_back(C);
			colors_iter = Cs.end() - 1;
			++colors_num;
		}
		//contain small color vertices in order
		if(colors_iter - Cs.begin() + 1 < min_k) {
			insert_ver_iter->set_index(ver_iter->get_index());
			insert_ver_iter->set_degree(0);
			++insert_ver_iter;
		}
		*/
	}
	colors::size_type i = min_k - 1;
	for(; i < Cs.size(); ++i) {
		for(color::size_type j = 0; j != Cs[i].size(); ++insert_ver_iter, ++j) {
			insert_ver_iter->set_index(Cs[i][j]);
			insert_ver_iter->set_degree(i);
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, 0x20(%rsp)
movq %rdi, 0x8(%rsp)
cmpl $0x2, %edx
pushq $0x1
popq %rbx
cmovgel %edx, %ebx
movb 0x5a5d(%rip), %al       # 0x8198
testb %al, %al
je 0x28dd
movb 0x5a6f(%rip), %al       # 0x81b8
testb %al, %al
je 0x292e
leaq 0x5a28(%rip), %rdi      # 0x8180
xorl %esi, %esi
callq 0x2b0e
movq 0x5a3a(%rip), %r15      # 0x81a0
cmpq 0x5a3b(%rip), %r15      # 0x81a8
je 0x277f
movq %r15, %rdi
xorl %esi, %esi
callq 0x2b0e
addq $0x18, %r15
jmp 0x2766
movq 0x8(%rsp), %rax
movq (%rax), %r14
movq %rbx, 0x10(%rsp)
movl %ebx, %eax
movq %rax, 0x18(%rsp)
xorl %r12d, %r12d
movq %r14, %rbx
movq 0x8(%rsp), %rax
cmpq 0x8(%rax), %rbx
je 0x2874
movq 0x59f1(%rip), %r13      # 0x81a0
pushq $-0x1
popq %r15
leaq (%r12,%r15), %rax
cmpq $-0x1, %rax
je 0x27db
movl (%rbx), %ebp
movq 0x20(%rsp), %rdi
movl %ebp, %esi
movq %r13, %rdx
callq 0x26e9
testb %al, %al
je 0x282b
decq %r15
addq $0x18, %r13
jmp 0x27b3
leaq 0x599e(%rip), %r15      # 0x8180
movq %r15, %rdi
xorl %esi, %esi
callq 0x2b0e
movl (%rbx), %eax
movl %eax, (%rsp)
movq %r15, %rdi
movq %rsp, %rsi
callq 0x2e04
movq 0x59a5(%rip), %rax      # 0x81a8
movq 0x5996(%rip), %rsi      # 0x81a0
subq %rsi, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq %r12, %rax
jbe 0x2841
imulq $0x18, %r12, %rax
addq %rax, %rsi
movq %r15, %rdi
callq 0x3148
jmp 0x2850
movl %ebp, 0x4(%rsp)
movq %r13, %rdi
leaq 0x4(%rsp), %rsi
callq 0x2e04
negq %r15
jmp 0x2856
leaq 0x5958(%rip), %rdi      # 0x81a0
movq %r15, %rsi
callq 0x2b40
incq %r12
movq %r12, %r15
cmpq 0x18(%rsp), %r15
jae 0x286b
movl (%rbx), %eax
movl %eax, (%r14)
andl $0x0, 0x4(%r14)
addq $0x8, %r14
addq $0x8, %rbx
jmp 0x2799
movq 0x10(%rsp), %r9
decl %r9d
movq 0x5925(%rip), %rax      # 0x81a8
movq 0x5916(%rip), %rcx      # 0x81a0
subq %rcx, %rax
cqto
pushq $0x18
popq %rsi
idivq %rsi
cmpq %rax, %r9
jae 0x28ce
imulq $0x18, %r9, %rsi
movq (%rcx,%rsi), %rdx
movq 0x8(%rcx,%rsi), %rsi
subq %rdx, %rsi
sarq $0x2, %rsi
xorl %edi, %edi
cmpq %rdi, %rsi
je 0x28c9
movl (%rdx,%rdi,4), %r8d
movl %r8d, (%r14)
movl %r9d, 0x4(%r14)
addq $0x8, %r14
incq %rdi
jmp 0x28b0
incq %r9
jmp 0x2895
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x58b4(%rip), %rdi      # 0x8198
callq 0x2290
testl %eax, %eax
je 0x2743
xorps %xmm0, %xmm0
movups %xmm0, 0x5885(%rip)     # 0x8180
andq $0x0, 0x588d(%rip)      # 0x8190
leaq 0x5876(%rip), %rsi      # 0x8180
leaq 0x1d5(%rip), %rdi       # 0x2ae6
leaq 0x5848(%rip), %rdx      # 0x8160
callq 0x21a0
leaq 0x5874(%rip), %rdi      # 0x8198
callq 0x2120
jmp 0x2743
leaq 0x5883(%rip), %rdi      # 0x81b8
callq 0x2290
testl %eax, %eax
je 0x2751
xorps %xmm0, %xmm0
movups %xmm0, 0x5854(%rip)     # 0x81a0
andq $0x0, 0x585c(%rip)      # 0x81b0
leaq 0x5845(%rip), %rsi      # 0x81a0
leaq 0x18a(%rip), %rdi       # 0x2aec
leaq 0x57f7(%rip), %rdx      # 0x8160
callq 0x21a0
leaq 0x5843(%rip), %rdi      # 0x81b8
callq 0x2120
jmp 0x2751
nop