// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/lwm_initAndCollect.c
// Function: getFrequentEdges
static void getFrequentEdges(struct Graph** db, int dbSize, int initialResultSetSize, struct Vertex* frequentEdges, struct GraphPool* gp) {
	int i = 0;
	struct compInfo* results = NULL;
	int resultSize = 0;

	if (initialResultSetSize > 0) {
		results = getResultVector(initialResultSetSize);
		resultSize = initialResultSetSize;
	}

	/* iterate over all graphs in the database */
	for (i=0; i<dbSize; ++i) {
		struct Graph* g = db[i];
		int v;

		/* frequency of an edge increases by one if there exists a pattern for the current graph (a spanning tree)
		that contains the edge. Thus we need to find all edges contained in any spanning tree and then add them
		to frequentEdges once omitting multiplicity */
		struct Vertex* containedEdges = getVertex(gp->vertexPool);

		/* init temporary result storage if necessary */
		int neededResultSize = g->m;
		int resultPos = 0;
		if (neededResultSize > resultSize) {
			if (results) {
				free(results);
			}

			results = getResultVector(neededResultSize);
			resultSize = neededResultSize;
		}

		for (v=0; v<g->n; ++v) {
			struct VertexList* e;
			for (e=g->vertices[v]->neighborhood; e!=NULL; e=e->next) {
				int w = e->endPoint->number;
				/* edges occur twice in patternGraph. just add them once to the search tree */
				if (w > v) {
					/* as for vertices, I use specialized code to generate
					the canonical string of a single edge */
					struct VertexList* cString;
					if (strcmp(e->startPoint->label, e->endPoint->label) < 0) {
						/* cString = v e (w) */
						struct VertexList* tmp = getVertexList(gp->listPool);
						tmp->label = e->endPoint->label;

						cString = getTerminatorEdge(gp->listPool);
						tmp->next = cString;

						cString = getVertexList(gp->listPool);
						cString->label = e->label;
						cString->next = tmp;

						tmp = getInitialisatorEdge(gp->listPool);
						tmp->next = cString;

						cString = getVertexList(gp->listPool);
						cString->label = e->startPoint->label;
						cString->next = tmp;
					} else {
						/* cString = w e (v) */
						struct VertexList* tmp = getVertexList(gp->listPool);
						tmp->label = e->startPoint->label;

						cString = getTerminatorEdge(gp->listPool);
						tmp->next = cString;

						cString = getVertexList(gp->listPool);
						cString->label = e->label;
						cString->next = tmp;

						tmp = getInitialisatorEdge(gp->listPool);
						tmp->next = cString;

						cString = getVertexList(gp->listPool);
						cString->label = e->endPoint->label;
						cString->next = tmp;
					}
					/* add the string to the search tree */
					containedEdges->d += addStringToSearchTree(containedEdges, cString, gp);
					containedEdges->number += 1;
				}
			}
		}

		/* set multiplicity of patterns to 1 and add to global edge pattern set */
		resetToUnique(containedEdges);
		mergeSearchTrees(frequentEdges, containedEdges, 1, results, &resultPos, frequentEdges, 0, gp);
		dumpSearchTree(gp, containedEdges);
	}

	if (results) {
		free(results);
	}
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movl %esi, 0x8c(%rsp)
movl %edx, 0x88(%rsp)
movq %rcx, 0x80(%rsp)
movq %r8, 0x78(%rsp)
movl $0x0, 0x74(%rsp)
movq $0x0, 0x68(%rsp)
movl $0x0, 0x64(%rsp)
cmpl $0x0, 0x88(%rsp)
jle 0x1c609
movl 0x88(%rsp), %edi
callq 0x2c430
movq %rax, 0x68(%rsp)
movl 0x88(%rsp), %eax
movl %eax, 0x64(%rsp)
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
cmpl 0x8c(%rsp), %eax
jge 0x1c975
movq 0x90(%rsp), %rax
movslq 0x74(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x58(%rsp)
movq 0x78(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x1f6a0
movq %rax, 0x48(%rsp)
movq 0x58(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x44(%rsp)
movl $0x0, 0x40(%rsp)
movl 0x44(%rsp), %eax
cmpl 0x64(%rsp), %eax
jle 0x1c691
cmpq $0x0, 0x68(%rsp)
je 0x1c67b
movq 0x68(%rsp), %rdi
callq 0x1030
movl 0x44(%rsp), %edi
callq 0x2c430
movq %rax, 0x68(%rsp)
movl 0x44(%rsp), %eax
movl %eax, 0x64(%rsp)
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
movq 0x58(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x1c90f
movq 0x58(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x54(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0x1c8fd
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x18(%rax), %eax
movl %eax, 0x34(%rsp)
movl 0x34(%rsp), %eax
cmpl 0x54(%rsp), %eax
jle 0x1c8e8
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdi
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rsi
callq 0x1120
cmpl $0x0, %eax
jge 0x1c7e9
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x1f310
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rcx
movq 0x20(%rsp), %rax
movq %rcx, (%rax)
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x8fc0
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x1f310
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rcx
movq 0x28(%rsp), %rax
movq %rcx, (%rax)
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x9000
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x1f310
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rcx
movq 0x28(%rsp), %rax
movq %rcx, (%rax)
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x8(%rax)
jmp 0x1c8b8
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x1f310
movq %rax, 0x18(%rsp)
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x8fc0
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x1f310
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rcx
movq 0x28(%rsp), %rax
movq %rcx, (%rax)
movq 0x18(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x9000
movq %rax, 0x18(%rsp)
movq 0x28(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x1f310
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rcx
movq 0x28(%rsp), %rax
movq %rcx, (%rax)
movq 0x18(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x48(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x78(%rsp), %rdx
callq 0x2bcf0
movsbl %al, %ecx
movq 0x48(%rsp), %rax
addl 0x28(%rax), %ecx
movl %ecx, 0x28(%rax)
movq 0x48(%rsp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
jmp 0x1c8ea
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
jmp 0x1c6c5
jmp 0x1c8ff
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x1c699
movq 0x48(%rsp), %rdi
callq 0x2c920
movq 0x80(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x68(%rsp), %rcx
movq 0x80(%rsp), %r9
movq 0x78(%rsp), %rax
movl $0x1, %edx
leaq 0x40(%rsp), %r8
xorl %r10d, %r10d
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x2c650
movq 0x78(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x2d3c0
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x1c611
cmpq $0x0, 0x68(%rsp)
je 0x1c987
movq 0x68(%rsp), %rdi
callq 0x1030
addq $0x98, %rsp
retq
nop