// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/searchTree.c
// Function: filterSearchTree
char filterSearchTree(struct Vertex* current, int threshold, struct Vertex* root, struct GraphPool* gp) {
	struct VertexList* e;
	struct VertexList* dump = NULL;
	struct VertexList* good = NULL;

	for (e=current->neighborhood; e!=NULL; e=e->next) {
		e->used = filterSearchTree(e->endPoint, threshold, root, gp);
	}

	for (e=current->neighborhood; e!=NULL; ) {
		struct VertexList* next = e->next;
		if (e->used) {
			e->next = good;
			good = e;
		} else {
			e->next = dump;
			dump = e;
		}
		e = next;
	}

	for (e=good, current->neighborhood=NULL; e!=NULL; ) {
		struct VertexList* next = e->next;
		e->next = current->neighborhood;
		current->neighborhood = e;
		e = next;
	}
	dumpVertexListRecursively(gp->listPool, dump);

	/* if all children of current were deleted and current is not end of frequent
	string, delete current and notify caller that we can delete the edge */
	if (current->visited < threshold) {
		if (current->visited > 0) {
			/* "remove" string from search tree */ 
			root->number -= current->visited;
			--root->d;
		}

		/* if current is not an internal vertex, we dump it and tell the caller
		that the edge is unused. otherwise, the vertex stays and the edge is marked
		as used */
		if (current->neighborhood == NULL) {
			/* an empty search tree still consists of the root */
			if (current != root) {
				dumpVertex(gp->vertexPool, current);
			}
			return 0;
		} else {
			return 1;
		}

	} else {
		/* string is frequent. */
		return 1;
	}
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movl %esi, 0x44(%rsp)
movq %rdx, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
je 0x2cbc6
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rdi
movl 0x44(%rsp), %esi
movq 0x38(%rsp), %rdx
movq 0x30(%rsp), %rcx
callq 0x2cb50
movsbl %al, %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x20(%rax)
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
jmp 0x2cb87
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
je 0x2cc33
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x28(%rsp), %rax
cmpl $0x0, 0x20(%rax)
je 0x2cc0f
movq 0x18(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x2cc27
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x28(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x28(%rsp)
jmp 0x2cbd4
movq 0x18(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x48(%rsp), %rax
movq $0x0, 0x8(%rax)
cmpq $0x0, 0x28(%rsp)
je 0x2cc8c
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x28(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x8(%rsp), %rax
movq %rax, 0x28(%rsp)
jmp 0x2cc4a
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x20(%rsp), %rsi
callq 0x1f460
movq 0x48(%rsp), %rax
movl 0x1c(%rax), %eax
cmpl 0x44(%rsp), %eax
jge 0x2cd14
movq 0x48(%rsp), %rax
cmpl $0x0, 0x1c(%rax)
jle 0x2ccdb
movq 0x48(%rsp), %rax
movl 0x1c(%rax), %edx
movq 0x38(%rsp), %rax
movl 0x18(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x18(%rax)
movq 0x38(%rsp), %rax
movl 0x28(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x28(%rax)
movq 0x48(%rsp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x2cd0d
movq 0x48(%rsp), %rax
cmpq 0x38(%rsp), %rax
je 0x2cd06
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x48(%rsp), %rsi
callq 0x1f810
movb $0x0, 0x57(%rsp)
jmp 0x2cd19
movb $0x1, 0x57(%rsp)
jmp 0x2cd19
movb $0x1, 0x57(%rsp)
movb 0x57(%rsp), %al
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)