// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/subtreeIsomorphismSampling.c
// Function: makeBipartiteInstanceFromVertices
static struct Graph* makeBipartiteInstanceFromVertices(struct Vertex* parent, struct Vertex* parentImage, struct GraphPool* gp) {

	/* shuffle neighbors of parent and parentImage */
	int nNeighbors = degree(parent);
	struct VertexList** shuffledNeighbors = shuffleNeighbors(parent, nNeighbors);

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

	/* construct bipartite graph B(v,u) */
	struct Graph* B = createGraph(nNeighbors + nImageNeighbors, gp);

	/* add vertex numbers of original vertices to ->lowPoint of each vertex in B
	and keep a pinter to the edge to check later whether labels of edge and endpoint match.
	if parent is not the root of h, then there exists a neighbor in shuffledNeighbors that is already matched.
	if so, don't copy it to the list. */
	int i, j;
	for (i=0, j=0; j<nNeighbors; ++i, ++j) {
		if (shuffledNeighbors[j]->endPoint->visited != 0) {
			--i;
			continue;
		}
		B->vertices[i]->lowPoint = shuffledNeighbors[j]->endPoint->number;
		B->vertices[i]->label = ((char*)shuffledNeighbors[j]); // yeah, this is nasty!
	}
	/* store size of first partitioning set (without matched vertex, if it exists) */
	if (i == nNeighbors - 1) {
		B->number = i;
		nNeighbors = i;
		B->n -= 1;
		// dump last free vertex
		dumpVertex(gp->vertexPool, B->vertices[B->n]);
	} else {
		B->number = nNeighbors;
	}

	for (i=0; i<nImageNeighbors; ++i) {
		B->vertices[i+nNeighbors]->lowPoint = shuffledImageNeighbors[i]->endPoint->number;
		B->vertices[i+nNeighbors]->label = ((char*)shuffledImageNeighbors[i]); // yeah, this is nasty!
	}

	// garbage collection
	free(shuffledNeighbors);
	free(shuffledImageNeighbors);

	/* add edge (x,y) if edge and vertex label match and y is not yet used by the embedding */
	for (i=0; i<nNeighbors; ++i) {
		struct VertexList* xEdge = ((struct VertexList*)B->vertices[i]->label);
		for (j=nNeighbors; j<B->n; ++j) {
			struct VertexList* yEdge = ((struct VertexList*)B->vertices[j]->label);
			/* y has to be free */
			if (yEdge->endPoint->visited == 0) {
				if (labelCmp(xEdge->label, yEdge->label) == 0) {
					if (labelCmp(xEdge->endPoint->label, yEdge->endPoint->label) == 0) {
						addResidualEdges(B->vertices[i], B->vertices[j], gp->listPool);
						++B->m;
					}
				}
			}
		}
	}

	return B;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movq 0x50(%rsp), %rdi
callq 0xa440
movl %eax, 0x3c(%rsp)
movq 0x50(%rsp), %rdi
movl 0x3c(%rsp), %esi
callq 0x2e0e0
movq %rax, 0x30(%rsp)
movq 0x48(%rsp), %rdi
callq 0xa440
movl %eax, 0x2c(%rsp)
movq 0x48(%rsp), %rdi
movl 0x2c(%rsp), %esi
callq 0x2e0e0
movq %rax, 0x20(%rsp)
movl 0x3c(%rsp), %edi
addl 0x2c(%rsp), %edi
movq 0x40(%rsp), %rsi
callq 0xb850
movq %rax, 0x18(%rsp)
movl $0x0, 0x14(%rsp)
movl $0x0, 0x10(%rsp)
movl 0x10(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jge 0x2f157
movq 0x30(%rsp), %rax
movslq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x18(%rax), %rax
cmpl $0x0, 0x1c(%rax)
je 0x2f0ef
movl 0x14(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x2f13c
movq 0x30(%rsp), %rax
movslq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x18(%rax), %rax
movl 0x18(%rax), %ecx
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x14(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, 0x20(%rax)
movq 0x30(%rsp), %rax
movslq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x14(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x2f0bc
movl 0x14(%rsp), %eax
movl 0x3c(%rsp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2f1ab
movl 0x14(%rsp), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x8(%rax)
movl 0x14(%rsp), %eax
movl %eax, 0x3c(%rsp)
movq 0x18(%rsp), %rax
movl (%rax), %ecx
subl $0x1, %ecx
movl %ecx, (%rax)
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rsp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x1f810
jmp 0x2f1b7
movl 0x3c(%rsp), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x8(%rax)
movl $0x0, 0x14(%rsp)
movl 0x14(%rsp), %eax
cmpl 0x2c(%rsp), %eax
jge 0x2f22f
movq 0x20(%rsp), %rax
movslq 0x14(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x18(%rax), %rax
movl 0x18(%rax), %ecx
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movl 0x14(%rsp), %edx
addl 0x3c(%rsp), %edx
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, 0x20(%rax)
movq 0x20(%rsp), %rax
movslq 0x14(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movl 0x14(%rsp), %edx
addl 0x3c(%rsp), %edx
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x2f1bf
movq 0x30(%rsp), %rdi
callq 0x1030
movq 0x20(%rsp), %rdi
callq 0x1030
movl $0x0, 0x14(%rsp)
movl 0x14(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jge 0x2f355
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x14(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
movl 0x3c(%rsp), %eax
movl %eax, 0x10(%rsp)
movl 0x10(%rsp), %eax
movq 0x18(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x2f343
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq %rax, (%rsp)
movq (%rsp), %rax
movq 0x18(%rax), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x2f331
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq (%rsp), %rax
movq (%rax), %rsi
callq 0x2dcf0
cmpl $0x0, %eax
jne 0x2f32f
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
movq (%rsp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rsi
callq 0x2dcf0
cmpl $0x0, %eax
jne 0x2f32d
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x14(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rdx
callq 0x1cc0
movq 0x18(%rsp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
jmp 0x2f32f
jmp 0x2f331
jmp 0x2f333
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x2f27b
jmp 0x2f345
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x2f24b
movq 0x18(%rsp), %rax
addq $0x58, %rsp
retq
nop