// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/treeEnumeration.c
// Function: aprioriCheckExtensionReturnList
struct IntSet* aprioriCheckExtensionReturnList(struct Graph* extension, struct Vertex* lowerLevel, struct GraphPool* gp, struct ShallowGraphPool* sgp) {

	// returning NULL will indicate that apriori property does not hold for current
	struct IntSet* aprioriTreesOfExtension = getIntSet();

	// create graph that will hold subgraphs of size n-1 (this assumes that all extension trees have the same size)
	struct Graph* subgraph = getGraph(gp);
	setVertexNumber(subgraph, extension->n - 1);
	subgraph->m = subgraph->n - 1;

	for (int v=0; v<extension->n; ++v) {
		// if the removed vertex is a leaf, we test if the resulting subtree is contained in the lower level
		if (isLeaf(extension->vertices[v]) == 1) {
			// we invalidate current by removing the edge to v from its neighbor, which makes subgraph a valid tree
			struct VertexList* edge = snatchEdge(extension->vertices[v]->neighborhood->endPoint, extension->vertices[v]);
			// now copy pointers of all vertices \neq v to subgraph, this results in a tree of size current->n - 1
			int j = 0;
			for (int i=0; i<extension->n; ++i) {
				if (i == v) {
					continue; // ...with next vertex vertices
				} else {
					subgraph->vertices[j] = extension->vertices[i];
					subgraph->vertices[j]->number = j;
					++j;
				}
			}

			// test apriori property
			struct ShallowGraph* subString = canonicalStringOfTree(subgraph, sgp);
			int aprioriTreeID = getID(lowerLevel, subString);
			dumpShallowGraph(sgp, subString);

			// restore law and order in current (and invalidate subgraph)
			addEdge(edge->startPoint, edge);

			if (aprioriTreeID == -1) {
				dumpIntSet(aprioriTreesOfExtension);
				aprioriTreesOfExtension = NULL;
				break; // looping through the vertices of current and continue with next refinement
			} else {
				addIntSortedNoDuplicates(aprioriTreesOfExtension, aprioriTreeID);
			}
		}
	}

	// clean up
	for (int v=0; v<extension->n; ++v) {
		extension->vertices[v]->number = v;
	}
	// garbage collection
	for (int v=0; v<subgraph->n; ++v) {
		subgraph->vertices[v] = NULL;
	}
	dumpGraph(gp, subgraph);

	if (aprioriTreesOfExtension != NULL) {
		assert(isSortedUniqueIntSet(aprioriTreesOfExtension));
		return aprioriTreesOfExtension;
	} else {
		return NULL;
	}
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
movq %rcx, 0x40(%rsp)
movb $0x0, %al
callq 0xdc80
movq %rax, 0x38(%rsp)
movq 0x48(%rsp), %rdi
callq 0x1fa40
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rdi
movq 0x58(%rsp), %rax
movl (%rax), %esi
subl $0x1, %esi
callq 0xaa00
movq 0x30(%rsp), %rax
movl (%rax), %ecx
subl $0x1, %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x4(%rax)
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
movq 0x58(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x31332
movq 0x58(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x2c(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xa490
movsbl %al, %eax
cmpl $0x1, %eax
jne 0x31320
movq 0x58(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x2c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rdi
movq 0x58(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x2c(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0xa780
movq %rax, 0x20(%rsp)
movl $0x0, 0x1c(%rsp)
movl $0x0, 0x18(%rsp)
movl 0x18(%rsp), %eax
movq 0x58(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x312ab
movl 0x18(%rsp), %eax
cmpl 0x2c(%rsp), %eax
jne 0x31254
jmp 0x3129e
movq 0x58(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x1c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0x1c(%rsp), %ecx
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x1c(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, 0x18(%rax)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x3129e
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x3123b
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x9eb0
movq %rax, 0x10(%rsp)
movq 0x50(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x2c350
movl %eax, 0xc(%rsp)
movq 0x40(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x1ff70
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rsp), %rsi
callq 0xa660
cmpl $-0x1, 0xc(%rsp)
jne 0x31310
movq 0x38(%rsp), %rdi
callq 0xde90
movq $0x0, 0x38(%rsp)
jmp 0x31332
movq 0x38(%rsp), %rdi
movl 0xc(%rsp), %esi
callq 0xe0c0
jmp 0x31320
jmp 0x31322
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x311c1
movl $0x0, 0x8(%rsp)
movl 0x8(%rsp), %eax
movq 0x58(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x3136d
movl 0x8(%rsp), %ecx
movq 0x58(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x8(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, 0x18(%rax)
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0x3133a
movl $0x0, 0x4(%rsp)
movl 0x4(%rsp), %eax
movq 0x30(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x313a5
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x4(%rsp), %rcx
movq $0x0, (%rax,%rcx,8)
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x31375
movq 0x48(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x1fb30
cmpq $0x0, 0x38(%rsp)
je 0x313c8
movq 0x38(%rsp), %rax
movq %rax, 0x60(%rsp)
jmp 0x313d1
movq $0x0, 0x60(%rsp)
movq 0x60(%rsp), %rax
addq $0x68, %rsp
retq
nopl (%rax,%rax)