// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/lwm_initAndCollect.c
// Function: edgeSearchTree2ShallowGraph
struct ShallowGraph* edgeSearchTree2ShallowGraph(struct Vertex* frequentEdges, struct Graph** newVertices, struct GraphPool* gp, struct ShallowGraphPool* sgp) {
	struct ShallowGraph* result = getShallowGraph(sgp);
	struct VertexList* e;
	struct Vertex* createdVertices = NULL;
	int nVertices = 0;
	int i;
	struct Vertex* tmp;

	for (e=frequentEdges->neighborhood; e!=NULL; e=e->next) {
		struct Vertex* v = getVertex(gp->vertexPool);
		struct VertexList* f;
		v->label = e->label;
		/* store newly created vertex in a list */
		v->next = createdVertices;
		createdVertices = v;
		++nVertices;

		for (f=e->endPoint->neighborhood->endPoint->neighborhood; f!=NULL; f=f->next) {
			struct VertexList* g;
			for (g=f->endPoint->neighborhood; g!=NULL; g=g->next) {
				struct VertexList* new = getVertexList(sgp->listPool);
				new->startPoint = v;
				new->label = f->label;
				new->endPoint = getVertex(gp->vertexPool);
				new->endPoint->label = g->label;
				pushEdge(result, new);
				/* if the edge has not identical vertex labels at both vertices,
				add the reverse edge to the output */
				if (strcmp(v->label, new->endPoint->label) != 0) {
					pushEdge(result, inverseEdge(new, sgp->listPool));
				}
				/* store newly created vertex in a list */
				new->endPoint->next = createdVertices;
				createdVertices = new->endPoint;
				++nVertices;
			}
		}
	}

	/* to avoid memory leaks, make hardcopies of the labels */
	for (e=result->edges; e!=NULL; e=e->next) {
		if (!e->isStringMaster) {
			e->isStringMaster = 1;
			e->label = copyString(e->label);
		}
		if (!e->startPoint->isStringMaster) {
			e->startPoint->isStringMaster = 1;
			e->startPoint->label = copyString(e->startPoint->label);
		}
		if (!e->endPoint->isStringMaster) {
			e->endPoint->isStringMaster = 1;
			e->endPoint->label = copyString(e->endPoint->label);
		}
	}

	/* to avoid memory leaks, make a graph containing all newly created vertices and return it*/
	*newVertices = getGraph(gp);
	setVertexNumber(*newVertices, nVertices);
	for (i=0, tmp=createdVertices; i<nVertices; ++i, tmp=tmp->next) {
		(*newVertices)->vertices[i] = tmp;
	}

	return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r13
movq %rdx, 0x8(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdi, %rbx
movq %rcx, %rdi
callq 0x117e9
movq %rax, %r12
xorl %ebp, %ebp
xorl %r14d, %r14d
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0xe8ae
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x114a5
movq (%rbx), %rcx
movq %rcx, (%rax)
movq %r14, 0x10(%rax)
incl %ebp
movq %rbx, 0x20(%rsp)
movq 0x18(%rbx), %rcx
movq 0x8(%rcx), %rcx
movq 0x18(%rcx), %rcx
movq %rax, 0x28(%rsp)
movq %rax, %r14
movq 0x8(%rcx), %rcx
testq %rcx, %rcx
je 0xe8a4
movq %rcx, 0x10(%rsp)
movq 0x18(%rcx), %r15
movq 0x8(%r15), %r15
testq %r15, %r15
je 0xe89a
movq %rbp, 0x30(%rsp)
movq 0x10(%r13), %rdi
callq 0x11307
movq %rax, %rbp
movq 0x28(%rsp), %rbx
movq %rbx, 0x10(%rax)
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq %rax, (%rbp)
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x114a5
movq %rax, 0x18(%rbp)
movq (%r15), %rcx
movq %rcx, (%rax)
movq %r12, %rdi
movq %rbp, %rsi
callq 0x61e7
movq (%rbx), %rdi
movq %r13, %rbx
movq %r12, %r13
movq 0x18(%rbp), %r12
movq (%r12), %rsi
callq 0x1130
testl %eax, %eax
je 0xe880
movq 0x10(%rbx), %rsi
movq %rbp, %rdi
callq 0x5a44
movq %r13, %rdi
movq %rax, %rsi
callq 0x61e7
movq 0x18(%rbp), %r12
movq %r14, 0x10(%r12)
movq 0x30(%rsp), %rbp
incl %ebp
movq %r12, %r14
movq %r13, %r12
movq %rbx, %r13
jmp 0xe7f5
movq 0x10(%rsp), %rcx
jmp 0xe7df
movq 0x20(%rsp), %rbx
jmp 0xe79f
movq %r12, %rbx
movq (%rbx), %rbx
testq %rbx, %rbx
je 0xe917
cmpl $0x0, 0x28(%rbx)
jne 0xe8d1
movl $0x1, 0x28(%rbx)
movq (%rbx), %rdi
callq 0x118b2
movq %rax, (%rbx)
movq 0x10(%rbx), %rax
cmpl $0x0, 0x24(%rax)
jne 0xe8f1
movl $0x1, 0x24(%rax)
movq (%rax), %rdi
callq 0x118b2
movq 0x10(%rbx), %rcx
movq %rax, (%rcx)
movq 0x18(%rbx), %rax
cmpl $0x0, 0x24(%rax)
jne 0xe911
movl $0x1, 0x24(%rax)
movq (%rax), %rdi
callq 0x118b2
movq 0x18(%rbx), %rcx
movq %rax, (%rcx)
addq $0x8, %rbx
jmp 0xe8b1
movq 0x8(%rsp), %rdi
callq 0x11619
movq 0x18(%rsp), %rbx
movq %rax, (%rbx)
movq %rax, %rdi
movl %ebp, %esi
callq 0x5c80
xorl %eax, %eax
testl %ebp, %ebp
cmovlel %eax, %ebp
cmpq %rax, %rbp
je 0xe953
movq (%rbx), %rcx
movq 0x10(%rcx), %rcx
movq %r14, (%rcx,%rax,8)
incq %rax
movq 0x10(%r14), %r14
jmp 0xe93a
movq %r12, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq