// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/subtreeIsomorphismSampling.c
// Function: recursiveSubtreeIsomorphismSamplerWithShuffledImage
static char recursiveSubtreeIsomorphismSamplerWithShuffledImage(struct Vertex* parent, struct Graph* g) {

	struct Vertex* currentImage = g->vertices[parent->visited - 1];

	int nNeighbors = degree(parent);
	struct VertexList** shuffledNeighbors = shuffleNeighbors(parent, nNeighbors);

	int nImageNeighbors = degree(currentImage);
	struct VertexList** shuffledImageNeighbors = shuffleNeighbors(currentImage, nImageNeighbors);

	int unassignedNeighborsOfRoot = 0;
	int processedNeighborsOfRoot = 0;

	for (int i=0; i<nNeighbors; ++i) {
		struct VertexList* child = shuffledNeighbors[i];
		if (child->endPoint->visited == 0) {
			++unassignedNeighborsOfRoot;
			++processedNeighborsOfRoot;
			for (int j=0; j<nImageNeighbors; ++j) {
				struct VertexList* embeddingEdge = shuffledImageNeighbors[j];
				if ((embeddingEdge->endPoint->visited == 0)
						&& (labelCmp(child->label, embeddingEdge->label) == 0)
						&& (labelCmp(child->endPoint->label, embeddingEdge->endPoint->label) == 0)) {

					// if the child vertex and edge labels fit, map the vertices to each other, mark it as a novel assignment
					child->endPoint->visited = embeddingEdge->endPoint->number + 1;
					child->flag = 1;
					embeddingEdge->endPoint->visited = 1;

					// and remember that the child vertex was assigned
					--unassignedNeighborsOfRoot;
					break; //...looping over the neighbors of the image of parent in g
				}
			}
		}
	}

	// check, if we could assign all neighbors of the currentRoot to some neighbors of its image.
	if (unassignedNeighborsOfRoot > 0) {
		free(shuffledNeighbors);
		free(shuffledImageNeighbors);
		return 0;
	}

	// if none of the neighbors needs to be newly asigned, we have embedded this branch.
	if (processedNeighborsOfRoot == 0) {
		free(shuffledNeighbors);
		free(shuffledImageNeighbors);
		return 1;
	}

	// if new neighbors were assigned, recurse to the newly assigned neighbors
	char embeddingWorked = 1;
	for (int i=0; i<nNeighbors; ++i) {
		struct VertexList* child = shuffledNeighbors[i];
		if (child->flag) {
			child->flag = 0;
			embeddingWorked = recursiveSubtreeIsomorphismSampler(child->endPoint, g);
		}
		if (!embeddingWorked) {
			break;
		}
	}
	free(shuffledNeighbors);
	free(shuffledImageNeighbors);
	return embeddingWorked;
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x68(%rsp), %rcx
movl 0x1c(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x58(%rsp)
movq 0x68(%rsp), %rdi
callq 0xa440
movl %eax, 0x54(%rsp)
movq 0x68(%rsp), %rdi
movl 0x54(%rsp), %esi
callq 0x2e0e0
movq %rax, 0x48(%rsp)
movq 0x58(%rsp), %rdi
callq 0xa440
movl %eax, 0x44(%rsp)
movq 0x58(%rsp), %rdi
movl 0x44(%rsp), %esi
callq 0x2e0e0
movq %rax, 0x38(%rsp)
movl $0x0, 0x34(%rsp)
movl $0x0, 0x30(%rsp)
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
cmpl 0x54(%rsp), %eax
jge 0x2e8d4
movq 0x48(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x2e8c2
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
cmpl 0x44(%rsp), %eax
jge 0x2e8c0
movq 0x38(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x2e8ae
movq 0x20(%rsp), %rax
movq (%rax), %rdi
movq 0x10(%rsp), %rax
movq (%rax), %rsi
callq 0x2dcf0
cmpl $0x0, %eax
jne 0x2e8ae
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rsi
callq 0x2dcf0
cmpl $0x0, %eax
jne 0x2e8ae
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rax
movl %ecx, 0x1c(%rax)
movq 0x20(%rsp), %rax
movl $0x1, 0x24(%rax)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movl $0x1, 0x1c(%rax)
movl 0x34(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x2e8c0
jmp 0x2e8b0
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x2e7fa
jmp 0x2e8c2
jmp 0x2e8c4
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x2e7a8
cmpl $0x0, 0x34(%rsp)
jle 0x2e8f9
movq 0x48(%rsp), %rdi
callq 0x1030
movq 0x38(%rsp), %rdi
callq 0x1030
movb $0x0, 0x77(%rsp)
jmp 0x2e9a6
cmpl $0x0, 0x30(%rsp)
jne 0x2e91e
movq 0x48(%rsp), %rdi
callq 0x1030
movq 0x38(%rsp), %rdi
callq 0x1030
movb $0x1, 0x77(%rsp)
jmp 0x2e9a6
movb $0x1, 0xf(%rsp)
movl $0x0, 0x8(%rsp)
movl 0x8(%rsp), %eax
cmpl 0x54(%rsp), %eax
jge 0x2e98a
movq 0x48(%rsp), %rax
movslq 0x8(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, (%rsp)
movq (%rsp), %rax
cmpl $0x0, 0x24(%rax)
je 0x2e972
movq (%rsp), %rax
movl $0x0, 0x24(%rax)
movq (%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x60(%rsp), %rsi
callq 0x2e370
movb %al, 0xf(%rsp)
cmpb $0x0, 0xf(%rsp)
jne 0x2e97b
jmp 0x2e98a
jmp 0x2e97d
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0x2e92b
movq 0x48(%rsp), %rdi
callq 0x1030
movq 0x38(%rsp), %rdi
callq 0x1030
movb 0xf(%rsp), %al
movb %al, 0x77(%rsp)
movb 0x77(%rsp), %al
addq $0x78, %rsp
retq
nop