// File: /workspace/github_c_makefile_star2_O2/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
movq %rsi, %r15
movq %rdi, %rbx
movl (%rdi), %eax
xorl %ecx, %ecx
testl %eax, %eax
movl $0x0, %edx
cmovgl %eax, %edx
cmpq %rcx, %rdx
je 0x72ad
movq 0x10(%rbx), %rsi
movq (%rsi,%rcx,8), %rsi
orl $-0x1, 0x20(%rsi)
incq %rcx
jmp 0x7297
xorl %r14d, %r14d
xorl %r12d, %r12d
movslq %eax, %rcx
cmpq %rcx, %r14
jge 0x72db
movq 0x10(%rbx), %rcx
movq (%rcx,%r14,8), %rdi
cmpl $-0x1, 0x20(%rdi)
jne 0x72d6
movl %r12d, %esi
callq 0x3307
incl %r12d
movl (%rbx), %eax
incq %r14
jmp 0x72b3
testl %r12d, %r12d
jle 0x73b1
movl %r12d, %r13d
leaq (,%r13,8), %rdi
callq 0x1180
movq %rax, %r14
xorl %ebp, %ebp
cmpq %rbp, %r13
je 0x730f
movq %r15, %rdi
callq 0x11619
movq %rax, (%r14,%rbp,8)
incq %rbp
jmp 0x72f9
decl %r12d
xorl %eax, %eax
cmpq %rax, %r12
je 0x732b
movq (%r14,%rax,8), %rcx
movq 0x8(%r14,%rax,8), %rdx
incq %rax
movq %rdx, 0x18(%rcx)
jmp 0x7314
xorl %eax, %eax
movslq (%rbx), %rcx
cmpq %rcx, %rax
jge 0x734c
movq 0x10(%rbx), %rcx
movq (%rcx,%rax,8), %rcx
movslq 0x20(%rcx), %rcx
movq (%r14,%rcx,8), %rcx
incl (%rcx)
incq %rax
jmp 0x732d
xorl %r15d, %r15d
cmpq %r15, %r13
je 0x7364
movq (%r14,%r15,8), %rdi
movl (%rdi), %esi
callq 0x5c80
incq %r15
jmp 0x734f
movl (%rbx), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpq %rcx, %rax
je 0x73a4
movq 0x10(%rbx), %rdx
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), %rdx
movl %edi, 0x18(%rdx)
leal 0x1(%rdi), %edx
movl %edx, 0x8(%rsi)
incq %rcx
jmp 0x736d
movq (%r14), %rbx
movq %r14, %rdi
callq 0x1030
jmp 0x73b3
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq