// File: /workspace/github_c_makefile_star2_O3/pwelke[P]GraphMiningTools/treeEnumeration.c
// Function: refinementGraph
struct Graph* refinementGraph(struct Graph* g, int v, struct VertexList* newEdge, struct GraphPool* gp) {
	struct Graph* copy = getGraph(gp);
	int i;

	copy->activity = g->activity;
	copy->m = g->m; // addEdgebetweenVertices adds plus 1 itself
	copy->n = g->n + 1;
	copy->number = g->number;

	copy->vertices = malloc(copy->n * sizeof(struct Vertex*));

	/* copy vertices */
	for (i=0; i<g->n; ++i) {
		if (g->vertices[i]) {
			copy->vertices[i] = shallowCopyVertex(g->vertices[i], gp->vertexPool);
		}
	}

	/* copy new vertex and edge */
	copy->vertices[copy->n - 1] = shallowCopyVertex(newEdge->endPoint, gp->vertexPool);
	copy->vertices[copy->n - 1]->number = copy->n - 1;
	addEdgeBetweenVertices(v, copy->n - 1, newEdge->label, copy, gp);

	/* copy edges */
	for (i=0; i<g->n; ++i) {
		if (g->vertices[i]) {
			struct VertexList* e;
			for (e=g->vertices[i]->neighborhood; e; e=e->next) {
				struct VertexList* tmp = getVertexList(gp->listPool);
				tmp->endPoint = copy->vertices[e->endPoint->number];
				tmp->startPoint = copy->vertices[e->startPoint->number];
				tmp->label = e->label;

				/* add the shallow copy to the new graph */
				tmp->next = copy->vertices[e->startPoint->number]->neighborhood;
				copy->vertices[e->startPoint->number]->neighborhood = tmp;
			}
		}
	}
	return copy;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r12
movl %esi, %ebp
movq %rdi, %r14
movq %rcx, %rdi
callq 0x146a9
movq %rax, %r15
movl 0xc(%r14), %eax
movl %eax, 0xc(%r15)
movslq (%r14), %rax
leaq 0x1(%rax), %rcx
movl %ecx, (%r15)
movq 0x4(%r14), %rcx
movq %rcx, 0x4(%r15)
leaq 0x8(,%rax,8), %rdi
callq 0x1190
movq %rax, 0x10(%r15)
movl (%r14), %eax
testl %eax, %eax
jle 0x1d51a
xorl %r13d, %r13d
movq 0x10(%r14), %rcx
movq (%rcx,%r13,8), %rdi
testq %rdi, %rdi
je 0x1d50f
movq 0x10(%rbx), %rsi
callq 0x7c34
movq 0x10(%r15), %rcx
movq %rax, (%rcx,%r13,8)
movl (%r14), %eax
incq %r13
movslq %eax, %rcx
cmpq %rcx, %r13
jl 0x1d4ee
movq 0x18(%r12), %rdi
movq 0x10(%rbx), %rsi
callq 0x7c34
movq 0x10(%r15), %rcx
movslq (%r15), %rsi
movq %rax, -0x8(%rcx,%rsi,8)
movq 0x10(%r15), %rax
movq -0x8(%rax,%rsi,8), %rax
decq %rsi
movl %esi, 0x18(%rax)
movq (%r12), %rdx
movl %ebp, %edi
movq %r15, %rcx
movq %rbx, %r8
callq 0x84a3
movl (%r14), %eax
testl %eax, %eax
jle 0x1d5df
xorl %r12d, %r12d
movq 0x10(%r14), %rcx
movq (%rcx,%r12,8), %rcx
testq %rcx, %rcx
je 0x1d5d4
movq 0x8(%rcx), %r13
testq %r13, %r13
je 0x1d5d4
movq 0x18(%rbx), %rdi
callq 0x141f1
movq 0x10(%r15), %rcx
movq 0x18(%r13), %rdx
movslq 0x18(%rdx), %rdx
movq (%rcx,%rdx,8), %rdx
movq %rdx, 0x18(%rax)
movq 0x10(%r13), %rdx
movslq 0x18(%rdx), %rdx
movq (%rcx,%rdx,8), %rdx
movq %rdx, 0x10(%rax)
movq (%r13), %rdx
movq %rdx, (%rax)
movq 0x10(%r13), %rdx
movslq 0x18(%rdx), %rdx
movq (%rcx,%rdx,8), %rsi
movq 0x8(%rsi), %rsi
movq %rsi, 0x8(%rax)
movq (%rcx,%rdx,8), %rcx
movq %rax, 0x8(%rcx)
movq 0x8(%r13), %r13
testq %r13, %r13
jne 0x1d578
movl (%r14), %eax
incq %r12
movslq %eax, %rcx
cmpq %rcx, %r12
jl 0x1d562
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq