// File: /workspace/github_c_makefile_star2_O1/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, %r12
movq %rdi, %rbx
movslq (%rdi), %rax
testq %rax, %rax
jle 0x9632
movq 0x10(%rbx), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
movl $0xffffffff, 0x20(%rsi) # imm = 0xFFFFFFFF
incq %rdx
cmpq %rdx, %rax
jne 0x961f
cmpl $0x0, (%rbx)
jle 0x9663
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x10(%rbx), %rax
movq (%rax,%r14,8), %rdi
cmpl $-0x1, 0x20(%rdi)
jne 0x9656
movl %r15d, %esi
callq 0x51eb
incl %r15d
incq %r14
movslq (%rbx), %rax
cmpq %rax, %r14
jl 0x963d
jmp 0x9666
xorl %r15d, %r15d
testl %r15d, %r15d
jle 0x9751
movl %r15d, %r13d
leaq (,%r13,8), %rdi
callq 0x1190
movq %rax, %r14
xorl %ebp, %ebp
movq %r12, %rdi
callq 0x147d7
movq %rax, (%r14,%rbp,8)
incq %rbp
cmpq %rbp, %r13
jne 0x9684
cmpl $0x1, %r15d
je 0x96bd
leal -0x1(%r15), %eax
xorl %ecx, %ecx
movq (%r14,%rcx,8), %rdx
movq 0x8(%r14,%rcx,8), %rsi
leaq 0x1(%rcx), %rdi
movq %rsi, 0x18(%rdx)
movq %rdi, %rcx
cmpq %rdi, %rax
jne 0x96a4
cmpl $0x0, (%rbx)
jle 0x96e1
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 0x96c8
cmpl $0x2, %r15d
movl $0x1, %r12d
cmovgel %r15d, %r12d
xorl %r15d, %r15d
movq (%r14,%r15,8), %rdi
movl (%rdi), %esi
callq 0x7e30
incq %r15
cmpq %r15, %r12
jne 0x96f2
movslq (%rbx), %rax
testq %rax, %rax
jle 0x9744
xorl %ecx, %ecx
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
cmpq %rcx, %rax
jne 0x970f
movq (%r14), %rbx
movq %r14, %rdi
callq 0x1030
jmp 0x9753
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq