// File: 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
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpl $0x0, -0x14(%rbp)
jg 0x2d7b
movl $0x1, -0x14(%rbp)
cmpb $0x0, 0x10476(%rip)     # 0x131f8
jne 0x2dc7
leaq 0x1046d(%rip), %rdi     # 0x131f8
callq 0x2320
cmpl $0x0, %eax
je 0x2dc7
leaq 0x10444(%rip), %rdi     # 0x131e0
callq 0x3a50
leaq 0xcc8(%rip), %rdi       # 0x3a70
leaq 0x10431(%rip), %rsi     # 0x131e0
leaq 0x1040a(%rip), %rdx     # 0x131c0
callq 0x21c0
leaq 0x10436(%rip), %rdi     # 0x131f8
callq 0x2130
cmpb $0x0, 0x1044a(%rip)     # 0x13218
jne 0x2e13
leaq 0x10441(%rip), %rdi     # 0x13218
callq 0x2320
cmpl $0x0, %eax
je 0x2e13
leaq 0x10418(%rip), %rdi     # 0x13200
callq 0x3ad0
leaq 0xcfc(%rip), %rdi       # 0x3af0
leaq 0x10405(%rip), %rsi     # 0x13200
leaq 0x103be(%rip), %rdx     # 0x131c0
callq 0x21c0
leaq 0x1040a(%rip), %rdi     # 0x13218
callq 0x2130
movq $0x0, -0x20(%rbp)
leaq 0x103be(%rip), %rdi     # 0x131e0
xorl %eax, %eax
movl %eax, %esi
callq 0x3b50
leaq 0x103ce(%rip), %rdi     # 0x13200
callq 0x3be0
movq %rax, -0x28(%rbp)
leaq 0x103be(%rip), %rdi     # 0x13200
callq 0x3c50
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3c10
testb $0x1, %al
jne 0x2e5e
jmp 0x2e7e
leaq -0x28(%rbp), %rdi
callq 0x3c80
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3b50
leaq -0x28(%rbp), %rdi
callq 0x3ca0
jmp 0x2e3b
movq -0x70(%rbp), %rdi
callq 0x34b0
movq -0x70(%rbp), %rdi
movq %rax, -0x38(%rbp)
callq 0x34b0
movq %rax, -0x40(%rbp)
movq -0x70(%rbp), %rdi
callq 0x3560
movq %rax, -0x48(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x36d0
testb $0x1, %al
jne 0x2ebb
jmp 0x305f
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x20(%rbp), %rax
je 0x2f60
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3710
movq %rax, %rdi
callq 0x35b0
movl %eax, -0x74(%rbp)
movq -0x50(%rbp), %rsi
leaq 0x10308(%rip), %rdi     # 0x13200
callq 0x3cc0
movq -0x80(%rbp), %rdi
movl -0x74(%rbp), %esi
movq %rax, %rdx
callq 0x2cc0
testb $0x1, %al
jne 0x2f4d
movq -0x50(%rbp), %rsi
leaq 0x102e5(%rip), %rdi     # 0x13200
callq 0x3cc0
movq %rax, -0x88(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3710
movq %rax, %rdi
callq 0x35b0
movq -0x88(%rbp), %rdi
movl %eax, -0x54(%rbp)
leaq -0x54(%rbp), %rsi
callq 0x36a0
jmp 0x2f60
jmp 0x2f4f
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x2ec3
movq -0x50(%rbp), %rax
cmpq -0x20(%rbp), %rax
jne 0x2ff4
leaq 0x1026b(%rip), %rdi     # 0x131e0
xorl %eax, %eax
movl %eax, %esi
callq 0x3b50
leaq -0x40(%rbp), %rdi
callq 0x3710
movq %rax, %rdi
callq 0x35b0
movl %eax, -0x58(%rbp)
leaq 0x10247(%rip), %rdi     # 0x131e0
leaq -0x58(%rbp), %rsi
callq 0x36a0
leaq 0x10257(%rip), %rdi     # 0x13200
callq 0x3ce0
cmpq -0x20(%rbp), %rax
jbe 0x2fd5
movq -0x20(%rbp), %rsi
leaq 0x10241(%rip), %rdi     # 0x13200
callq 0x3cc0
movq %rax, %rsi
leaq 0x10212(%rip), %rdi     # 0x131e0
callq 0x3d10
jmp 0x2fe8
leaq 0x10224(%rip), %rdi     # 0x13200
leaq 0x101fd(%rip), %rsi     # 0x131e0
callq 0x3d70
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movl -0x14(%rbp), %ecx
cmpq %rcx, %rax
jae 0x304f
leaq -0x38(%rbp), %rdi
callq 0x3710
movq %rax, -0x90(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3710
movq %rax, %rdi
callq 0x35b0
movq -0x90(%rbp), %rdi
movl %eax, %esi
callq 0x3390
leaq -0x38(%rbp), %rdi
callq 0x3710
movq %rax, %rdi
xorl %esi, %esi
callq 0x3730
leaq -0x38(%rbp), %rdi
callq 0x3750
jmp 0x3051
leaq -0x40(%rbp), %rdi
callq 0x3750
jmp 0x2e98
movl -0x14(%rbp), %eax
subl $0x1, %eax
cltq
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq 0x10183(%rip), %rdi     # 0x13200
callq 0x3ce0
movq %rax, %rcx
movq -0x98(%rbp), %rax
cmpq %rcx, %rax
jae 0x314d
movq $0x0, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x60(%rbp), %rsi
leaq 0x1014d(%rip), %rdi     # 0x13200
callq 0x3cc0
movq %rax, %rdi
callq 0x3de0
movq %rax, %rcx
movq -0xa0(%rbp), %rax
cmpq %rcx, %rax
je 0x313a
leaq -0x38(%rbp), %rdi
callq 0x3710
movq %rax, -0xa8(%rbp)
movq -0x60(%rbp), %rsi
leaq 0x10116(%rip), %rdi     # 0x13200
callq 0x3cc0
movq %rax, %rdi
movq -0x68(%rbp), %rsi
callq 0x3e00
movq -0xa8(%rbp), %rdi
movl (%rax), %esi
callq 0x3390
leaq -0x38(%rbp), %rdi
callq 0x3710
movq %rax, %rdi
movq -0x60(%rbp), %rax
movl %eax, %esi
callq 0x3730
leaq -0x38(%rbp), %rdi
callq 0x3750
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x309d
jmp 0x313c
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x306b
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)