// File: /workspace/github_cpp_makefile_star2_O2/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), %rcx
movq %rcx, 0x10(%rsp)
movq 0x30(%rax), %rcx
movq %rcx, 0x18(%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 0x2100
movq 0x78(%rbx), %rdi
movslq 0x2c(%rbx), %rdx
shlq $0x2, %rdx
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x2100
movl 0xc(%rsp), %ecx
movq 0x18(%rsp), %r10
movq 0x50(%rbx), %rax
xorl %r11d, %r11d
cmpl %ecx, %ebp
jge 0x5e71
movslq %ebp, %rdx
movq 0x10(%rsp), %rsi
movl (%rsi,%rdx,4), %esi
cmpl $0x2, %esi
jne 0x5e6a
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)
jne 0x5e26
pushq $0x2
popq %rsi
jmp 0x5e6a
cmpl %r9d, %r8d
cmovgel %r8d, %edi
movl %edi, (%rax,%rsi,4)
movslq %edi, %rdi
movl %esi, (%rax,%rdi,4)
movq 0x78(%rbx), %rdi
xorl %r8d, %r8d
cmpl (%r13,%rsi,4), %r8d
jge 0x5e5f
movl (%r15,%rsi,4), %r9d
addl (%r12,%rsi,4), %r9d
addl %r8d, %r9d
movslq %r9d, %r9
movslq (%r14,%r9,4), %r9
incl (%rdi,%r9,4)
incl %r8d
jmp 0x5e3d
incl %r11d
movq 0x10(%rsp), %rsi
movl (%rsi,%rdx,4), %esi
addl %esi, %ebp
jmp 0x5de5
movq 0x68(%rbx), %rdi
andl $0x0, 0x10(%rdi)
xorl %r14d, %r14d
pushq $-0x1
popq %rbp
movl %r11d, %r13d
movslq 0x2c(%rbx), %rax
cmpq %rax, %r14
jge 0x5eef
cmpb $0x0, (%r10,%r14)
jne 0x5eea
movq 0x50(%rbx), %rax
cmpl $-0x1, (%rax,%r14,4)
jne 0x5eea
movq 0x78(%rbx), %rax
movl (%rax,%r14,4), %eax
cmpl (%r12,%r14,4), %eax
jne 0x5eea
movq %r10, %r15
movq %rbx, %rdi
movl %r14d, %esi
callq 0x6754
movq 0x70(%rbx), %rcx
movl %eax, (%rcx,%r14,4)
testl %eax, %eax
je 0x5f0a
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)
movq %r15, %r10
incq %r14
jmp 0x5e82
movq 0x70(%rbx), %rsi
callq 0x8102
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ebp, %eax
jmp 0x5efb