// File: /workspace/github_cpp_makefile_star2_O3/SNUCSE-CTA[P]GI/src/backtrack.cpp
// Function: Backtrack::mapBinaryCell()
int32_t Backtrack::mapBinaryCell()
{
	#ifdef DEBUG
	cout << __PRETTY_FUNCTION__ << endl;
	#endif

	int32_t numMatching = 0;
	int32_t i, j, u, v, child;
	int32_t numNode = coloring->numNode;
	int32_t* perm = coloring->perm;
	int32_t* cellSize = coloring->cellSize;
	int32_t* adjPos1 = g1->adjPos;
	char* one1 = g1->one;

	int32_t* childSize = dag->childSize;
	int32_t* parentSize = dag->parentSize;
	int32_t* dagArr = dag->dagArr;

	memset(mapping, -1, sizeof(int32_t) * n2);
	memset(numMappedParent, 0, sizeof(int32_t) * n);
	//for each cell
	for(i = 0; i < numNode; i += cellSize[i]) {
		if( cellSize[i] != 2 ) 
			continue;

		//for each binary cell
		if( perm[i] < n ) {
			u = perm[i];
			v = perm[i + 1];
		}
		else {
			u = perm[i + 1];
			v = perm[i];
		}

		if( one1[u] == 1 ) //coreness-1 vertex
			continue;

		mapping[u] = v;
		mapping[v] = u;
		++numMatching;

		//DAG-ordering
		for(j = 0; j < childSize[u]; ++j) {
			child = dagArr[ adjPos1[u] + parentSize[u] + j ];
			++(numMappedParent[child]);
		}
	} //for(i)

	//build heap for extendable vertices
	heap->size = 0;
	for(u = 0; u < n; ++u) {
		//for each extendable vertex
		if( one1[u] == 0 && mapping[u] == -1 && numMappedParent[u] == parentSize[u] ) {
			weight[u] = computeWeight(u);
			if( weight[u] == 0 ) //isomorphism does not exist
				return -1;

			++(heap->size); //note that heap[0] have to be empty.
			heap->heap[heap->size] = u;
			heap->locate[u] = heap->size;
		}
	}
	heap->buildMinHeap(weight);

	return numMatching;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x10(%rdi), %rax
movq 0x20(%rdi), %rcx
movl (%rcx), %edx
movl %edx, 0xc(%rsp)
movq 0x10(%rcx), %rdx
movq %rdx, 0x20(%rsp)
movq 0x20(%rcx), %rbp
movq 0x30(%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x40(%rax), %r15
movq 0x40(%rdi), %rax
movq 0x10(%rax), %r13
movq 0x18(%rax), %r12
movq 0x20(%rax), %r14
movq 0x50(%rdi), %rdi
movslq 0x34(%rbx), %rdx
shlq $0x2, %rdx
movl $0xff, %esi
callq 0x20e0
movq 0x78(%rbx), %rdi
movslq 0x2c(%rbx), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x20e0
xorl %r11d, %r11d
movl 0xc(%rsp), %ecx
testl %ecx, %ecx
jle 0x6d55
movl %ecx, %eax
movq 0x50(%rbx), %rcx
movq %rcx, 0x18(%rsp)
movq 0x78(%rbx), %rcx
xorl %r11d, %r11d
xorl %esi, %esi
movq 0x10(%rsp), %r10
movslq %esi, %rdx
cmpl $0x2, (%rbp,%rdx,4)
jne 0x6d4b
movq 0x20(%rsp), %rsi
movl (%rsi,%rdx,4), %r8d
movl 0x4(%rsi,%rdx,4), %edi
movl 0x2c(%rbx), %r9d
cmpl %r9d, %r8d
movl %edi, %esi
cmovll %r8d, %esi
movslq %esi, %rsi
cmpb $0x1, (%r10,%rsi)
je 0x6d4b
cmpl %r9d, %r8d
cmovgel %r8d, %edi
movq 0x18(%rsp), %r8
movl %edi, (%r8,%rsi,4)
movslq %edi, %rdi
movl %esi, (%r8,%rdi,4)
incl %r11d
cmpl $0x0, (%r13,%rsi,4)
jle 0x6d4b
xorl %edi, %edi
movl (%r15,%rsi,4), %r8d
addl (%r12,%rsi,4), %r8d
addl %edi, %r8d
movslq %r8d, %r8
movslq (%r14,%r8,4), %r8
incl (%rcx,%r8,4)
incl %edi
cmpl (%r13,%rsi,4), %edi
jl 0x6d2c
movl (%rbp,%rdx,4), %esi
addl %edx, %esi
cmpl %eax, %esi
jl 0x6cda
movq 0x68(%rbx), %rdi
movl $0x0, 0x10(%rdi)
movl 0x2c(%rbx), %eax
testl %eax, %eax
movl %r11d, %ebp
jle 0x6dd9
xorl %r14d, %r14d
movq 0x10(%rsp), %r15
cmpb $0x0, (%r15,%r14)
jne 0x6dce
movq 0x50(%rbx), %rcx
cmpl $-0x1, (%rcx,%r14,4)
jne 0x6dce
movq 0x78(%rbx), %rcx
movl (%rcx,%r14,4), %ecx
cmpl (%r12,%r14,4), %ecx
jne 0x6dce
movq %rbx, %rdi
movl %r14d, %esi
callq 0x77b0
movq 0x70(%rbx), %rcx
movl %eax, (%rcx,%r14,4)
testl %eax, %eax
je 0x6df3
movq 0x68(%rbx), %rdi
movslq 0x10(%rdi), %rax
leaq 0x1(%rax), %rcx
movl %ecx, 0x10(%rdi)
movq (%rdi), %rcx
movl %r14d, 0x4(%rcx,%rax,4)
movl 0x10(%rdi), %eax
movq 0x8(%rdi), %rcx
movl %eax, (%rcx,%r14,4)
movl 0x2c(%rbx), %eax
incq %r14
movslq %eax, %rcx
cmpq %rcx, %r14
jl 0x6d72
movq 0x70(%rbx), %rsi
callq 0x9136
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x6de4