// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movl $0x0, 0x44(%rsp)
movl 0x44(%rsp), %eax
movq 0x50(%rsp), %rcx
cmpl (%rcx), %eax
jge 0xd4c9
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x44(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl $0xffffffff, 0x20(%rax) # imm = 0xFFFFFFFF
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0xd496
movl $0x0, 0x40(%rsp)
movl $0x0, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
movq 0x50(%rsp), %rcx
cmpl (%rcx), %eax
jge 0xd533
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x3c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
cmpl $-0x1, 0x20(%rax)
jne 0xd524
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x3c(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movl 0x40(%rsp), %esi
callq 0x54a0
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0xd526
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0xd4d9
movq $0x0, 0x30(%rsp)
cmpl $0x0, 0x40(%rsp)
jle 0xd73a
movslq 0x40(%rsp), %rdi
shlq $0x3, %rdi
callq 0x1170
movq %rax, 0x28(%rsp)
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
cmpl 0x40(%rsp), %eax
jge 0xd594
movq 0x48(%rsp), %rdi
callq 0x1fa40
movq %rax, %rdx
movq 0x28(%rsp), %rax
movslq 0x24(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0xd562
movl $0x0, 0x20(%rsp)
movl 0x20(%rsp), %eax
movl 0x40(%rsp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0xd5dd
movq 0x28(%rsp), %rax
movl 0x20(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rcx
movq 0x28(%rsp), %rax
movslq 0x20(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x18(%rax)
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0xd59c
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movq 0x50(%rsp), %rcx
cmpl (%rcx), %eax
jge 0xd62d
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x1c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x20(%rax), %eax
movl %eax, 0x18(%rsp)
movq 0x28(%rsp), %rax
movslq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0xd5e5
movl $0x0, 0x14(%rsp)
movl 0x14(%rsp), %eax
cmpl 0x40(%rsp), %eax
jge 0xd66f
movq 0x28(%rsp), %rax
movslq 0x14(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x28(%rsp), %rax
movslq 0x14(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax), %esi
callq 0xaa00
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0xd635
movl $0x0, 0x10(%rsp)
movl 0x10(%rsp), %eax
movq 0x50(%rsp), %rcx
cmpl (%rcx), %eax
jge 0xd723
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x20(%rax), %eax
movl %eax, 0xc(%rsp)
movq 0x28(%rsp), %rax
movslq 0xc(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x8(%rax), %eax
movl %eax, 0x8(%rsp)
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
movq 0x28(%rsp), %rax
movslq 0xc(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rax
movslq 0x8(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0x8(%rsp), %ecx
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x10(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, 0x18(%rax)
movq 0x28(%rsp), %rax
movslq 0xc(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0xd677
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x28(%rsp), %rdi
callq 0x1030
movq 0x30(%rsp), %rax
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)