// File: /workspace/github_c_makefile_star2_O3/pwelke[P]GraphMiningTools/importantSubtrees.c
// Function: graph2Components
struct Graph* graph2Components(struct Graph* g, struct GraphPool* gp) {

	// init visited to 0
	for (int v=0; v<g->n; ++v) {
		g->vertices[v]->lowPoint = -1;
	}
	// mark vertices of connected components in g
	int nComponents = 0;
	for (int v=0; v<g->n; ++v) {
		if (g->vertices[v]->lowPoint == -1) {
			markComp(g->vertices[v], nComponents);
			++nComponents;
		}
	}

	struct Graph* result = NULL;
	if (nComponents > 0) {
		// create graph struct for each found component
		struct Graph** components = malloc(nComponents * sizeof(struct Graph*));
		for (int i=0; i<nComponents; ++i) {
			components[i] = getGraph(gp);
		}
		// make list from array.
		for (int i=0; i<nComponents-1; ++i) {
			components[i]->next = components[i+1];
		}
		// count number of vertices in each component
		for (int v=0; v<g->n; ++v) {
			int c = g->vertices[v]->lowPoint;
			++(components[c]->n);
		}
		// create vertex arrays for graphs
		for (int i=0; i<nComponents; ++i) {
			setVertexNumber(components[i], components[i]->n);
		}
		// store vertices of g in the corresponding component graphs
		for (int v=0; v<g->n; ++v) {
			int c = g->vertices[v]->lowPoint;
			int newpos = components[c]->number;
			components[c]->vertices[newpos] = g->vertices[v];
			g->vertices[v]->number = newpos;
			components[c]->number++;
		}
		// TODO set components->m, components->number, ...
		result = components[0];
		free(components);
	}
	return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movslq (%rdi), %rax
testq %rax, %rax
jle 0x975c
movq %rsi, %r12
movq %rdi, %rbx
movq 0x10(%rdi), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
movl $0xffffffff, 0x20(%rsi) # imm = 0xFFFFFFFF
incq %rdx
cmpq %rdx, %rax
jne 0x963b
xorl %r15d, %r15d
testl %eax, %eax
jle 0x975f
xorl %r14d, %r14d
movq 0x10(%rbx), %rcx
movq (%rcx,%r14,8), %rdi
cmpl $-0x1, 0x20(%rdi)
jne 0x9677
movl %r15d, %esi
callq 0x521f
incl %r15d
movl (%rbx), %eax
incq %r14
movslq %eax, %rcx
cmpq %rcx, %r14
jl 0x965c
testl %r15d, %r15d
jle 0x975c
movl %r15d, %r13d
leaq (,%r13,8), %rdi
callq 0x1190
movq %rax, %r14
xorl %ebp, %ebp
movq %r12, %rdi
callq 0x146a9
movq %rax, (%r14,%rbp,8)
incq %rbp
cmpq %rbp, %r13
jne 0x96a0
cmpl $0x1, %r15d
je 0x96d6
decl %r15d
movq (%r14), %rcx
xorl %eax, %eax
movq 0x8(%r14,%rax,8), %rdx
incq %rax
movq %rdx, 0x18(%rcx)
movq %rdx, %rcx
cmpq %rax, %r15
jne 0x96c2
cmpl $0x0, (%rbx)
jle 0x96fa
movq 0x10(%rbx), %rax
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movslq 0x20(%rdx), %rdx
movq (%r14,%rdx,8), %rdx
incl (%rdx)
incq %rcx
movslq (%rbx), %rdx
cmpq %rdx, %rcx
jl 0x96e1
xorl %r15d, %r15d
movq (%r14,%r15,8), %rdi
movl (%rdi), %esi
callq 0x7e6c
incq %r15
cmpq %r15, %r13
jne 0x96fd
movslq (%rbx), %rax
testq %rax, %rax
jle 0x974f
movq 0x10(%rbx), %rdx
xorl %ecx, %ecx
movq (%rdx,%rcx,8), %rdx
movslq 0x20(%rdx), %rsi
movq (%r14,%rsi,8), %rsi
movslq 0x8(%rsi), %rdi
movq 0x10(%rsi), %r8
movq %rdx, (%r8,%rdi,8)
movq 0x10(%rbx), %rdx
movq (%rdx,%rcx,8), %r8
movl %edi, 0x18(%r8)
incl %edi
movl %edi, 0x8(%rsi)
incq %rcx
cmpq %rcx, %rax
jne 0x971e
movq (%r14), %r15
movq %r14, %rdi
callq 0x1030
jmp 0x975f
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq