// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/subtreeIsomorphismSampling.c
// Function: uniformBlockMaximumMatching
static struct VertexList** uniformBlockMaximumMatching(struct Vertex* parent, struct Vertex* image, int* matchingSize, int* n_matchings, int computeEstimate) {
	int nUncoveredChildren;
	int nCandidateImages;
	struct VertexList** uncoveredChildren = getUncoveredNeighborArray(parent, &nUncoveredChildren);
	struct VertexList** candidateImages = getUncoveredNeighborArray(image, &nCandidateImages);

	if (nUncoveredChildren == 0) {
		// here we don't need to find a matching any more, as there are no neighbors left to be assigned.
		free(uncoveredChildren);
		free(candidateImages);
		*matchingSize = 0;
		return (void*)EMPTY_MATCHING; // encode maximum matching has size zero, but that is fine...
	}

	if (nUncoveredChildren > nCandidateImages) {
		// here, there can be no matching, as there are more uncovered neighbors than candidate images
		free(uncoveredChildren);
		free(candidateImages);
		*matchingSize = 0;
		return NULL;
	}

	assert(nUncoveredChildren > 0);
	assert(nCandidateImages > 0);
	assert(nUncoveredChildren <= nCandidateImages);

	qsort(uncoveredChildren, nUncoveredChildren, sizeof(struct VertexList*), &compareLabeledNeighbors);
	qsort(candidateImages, nCandidateImages, sizeof(struct VertexList*), &compareLabeledNeighbors);

	int* candidateImageClasses = getClassesArray(candidateImages, nCandidateImages);
	shuffleInClasses(candidateImages, candidateImageClasses);

	int currentChild = 0;
	int currentCandidate = 0;

	while ((currentChild < nUncoveredChildren)
			&& (currentCandidate < nCandidateImages)) {
		if (compareLabeledNeighbors(&(uncoveredChildren[currentChild]), &(candidateImages[currentCandidate])) == 0) {
			uncoveredChildren[currentChild]->endPoint->visited = candidateImages[currentCandidate]->endPoint->number + 1;
			candidateImages[currentCandidate]->endPoint->visited = 1;
			++currentChild;
			++currentCandidate;
		} else {
			++currentCandidate;
		}
	}

	if ((currentChild == nUncoveredChildren) && computeEstimate) {
		//matching worked, compute number of maximum matchings
		int A = 0;
		int B = 0;
		char newBlock = 1;
		*n_matchings = 1;

		currentChild = 0;
		currentCandidate = 0;

		while ((currentChild < nUncoveredChildren)
					&& (currentCandidate < nCandidateImages)) {
				if (compareLabeledNeighbors(&(uncoveredChildren[currentChild]), &(candidateImages[currentCandidate])) == 0) {
					if (newBlock) {
						newBlock = 0;
						(*n_matchings) *= n_max_matchings_complete(A, B);
						A = 0;
						B = 0;
					}
					++currentChild;
					++currentCandidate;
					++A;
					++B;
				} else {
					++currentCandidate;
					++B;
					newBlock = 1;
				}
			}
	}

	// garbage collection
	free(candidateImages);
	free(candidateImageClasses);

	if (currentChild == nUncoveredChildren) {
		//matching worked
		*matchingSize = nUncoveredChildren;
		// shuffle *covered* children to randomize the dfs/bfs strategy in case we hit the same image vertex twice in different 
		// runs of the embedding algorithm
		shuffle(uncoveredChildren, nUncoveredChildren);
		return uncoveredChildren; // which are now covered :)
	} else {
		free(uncoveredChildren);
		*matchingSize = 0;
		return NULL;
	}
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
movq %rcx, 0x40(%rsp)
movl %r8d, 0x3c(%rsp)
movq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x2e190
movq %rax, 0x28(%rsp)
movq 0x50(%rsp), %rdi
leaq 0x34(%rsp), %rsi
callq 0x2e190
movq %rax, 0x20(%rsp)
cmpl $0x0, 0x38(%rsp)
jne 0x2f3dc
movq 0x28(%rsp), %rdi
callq 0x1030
movq 0x20(%rsp), %rdi
callq 0x1030
movq 0x48(%rsp), %rax
movl $0x0, (%rax)
movq 0xed7e(%rip), %rax      # 0x3e150
movq %rax, 0x60(%rsp)
jmp 0x2f6c9
movl 0x38(%rsp), %eax
cmpl 0x34(%rsp), %eax
jle 0x2f413
movq 0x28(%rsp), %rdi
callq 0x1030
movq 0x20(%rsp), %rdi
callq 0x1030
movq 0x48(%rsp), %rax
movl $0x0, (%rax)
movq $0x0, 0x60(%rsp)
jmp 0x2f6c9
movq 0x28(%rsp), %rdi
movslq 0x38(%rsp), %rsi
movl $0x8, %edx
leaq 0x2b7(%rip), %rcx       # 0x2f6e0
callq 0x1060
movq 0x20(%rsp), %rdi
movslq 0x34(%rsp), %rsi
movl $0x8, %edx
leaq 0x29c(%rip), %rcx       # 0x2f6e0
callq 0x1060
movq 0x20(%rsp), %rdi
movl 0x34(%rsp), %esi
callq 0x2f760
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x2f890
movl $0x0, 0x14(%rsp)
movl $0x0, 0x10(%rsp)
movl 0x14(%rsp), %ecx
xorl %eax, %eax
cmpl 0x38(%rsp), %ecx
movb %al, 0x6(%rsp)
jge 0x2f49a
movl 0x10(%rsp), %eax
cmpl 0x34(%rsp), %eax
setl %al
movb %al, 0x6(%rsp)
movb 0x6(%rsp), %al
testb $0x1, %al
jne 0x2f4a7
jmp 0x2f541
movq 0x28(%rsp), %rdi
movslq 0x14(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq 0x20(%rsp), %rsi
movslq 0x10(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x2f6e0
cmpl $0x0, %eax
jne 0x2f531
movq 0x20(%rsp), %rax
movslq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x18(%rax), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movq 0x28(%rsp), %rax
movslq 0x14(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq 0x18(%rax), %rax
movl %ecx, 0x1c(%rax)
movq 0x20(%rsp), %rax
movslq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x18(%rax), %rax
movl $0x1, 0x1c(%rax)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x2f53c
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x2f47b
movl 0x14(%rsp), %eax
cmpl 0x38(%rsp), %eax
jne 0x2f667
cmpl $0x0, 0x3c(%rsp)
je 0x2f667
movl $0x0, 0xc(%rsp)
movl $0x0, 0x8(%rsp)
movb $0x1, 0x7(%rsp)
movq 0x40(%rsp), %rax
movl $0x1, (%rax)
movl $0x0, 0x14(%rsp)
movl $0x0, 0x10(%rsp)
movl 0x14(%rsp), %ecx
xorl %eax, %eax
cmpl 0x38(%rsp), %ecx
movb %al, 0x5(%rsp)
jge 0x2f5a9
movl 0x10(%rsp), %eax
cmpl 0x34(%rsp), %eax
setl %al
movb %al, 0x5(%rsp)
movb 0x5(%rsp), %al
testb $0x1, %al
jne 0x2f5b6
jmp 0x2f665
movq 0x28(%rsp), %rdi
movslq 0x14(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq 0x20(%rsp), %rsi
movslq 0x10(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x2f6e0
cmpl $0x0, %eax
jne 0x2f645
cmpb $0x0, 0x7(%rsp)
je 0x2f617
movb $0x0, 0x7(%rsp)
movl 0xc(%rsp), %edi
movl 0x8(%rsp), %esi
callq 0x2f920
movl %eax, %ecx
movq 0x40(%rsp), %rax
imull (%rax), %ecx
movl %ecx, (%rax)
movl $0x0, 0xc(%rsp)
movl $0x0, 0x8(%rsp)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0x2f660
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
movb $0x1, 0x7(%rsp)
jmp 0x2f58a
jmp 0x2f667
movq 0x20(%rsp), %rdi
callq 0x1030
movq 0x18(%rsp), %rdi
callq 0x1030
movl 0x14(%rsp), %eax
cmpl 0x38(%rsp), %eax
jne 0x2f6ab
movl 0x38(%rsp), %ecx
movq 0x48(%rsp), %rax
movl %ecx, (%rax)
movq 0x28(%rsp), %rdi
movslq 0x38(%rsp), %rsi
callq 0x2b0b0
movq 0x28(%rsp), %rax
movq %rax, 0x60(%rsp)
jmp 0x2f6c9
movq 0x28(%rsp), %rdi
callq 0x1030
movq 0x48(%rsp), %rax
movl $0x0, (%rax)
movq $0x0, 0x60(%rsp)
movq 0x60(%rsp), %rax
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)