// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/localEasySubtreeIsomorphism.c
// Function: getBlockTreeT
struct BlockTree getBlockTreeT(struct Graph* g, struct ShallowGraphPool* sgp) {

	struct ShallowGraph* biconnectedComponents = listBiconnectedComponents(g, sgp);

	for (int v=0; v<g->n; ++v) {
		g->vertices[v]->visited = -1; // isRoot
		g->vertices[v]->d = -1; // parent root
	}

	/* we mark for each component the vertex with the lowest lowPoint.
	 * that is the root of the component.
	 *
	 * Due to the order in which listBiconnectedComponents() returns the bics,
	 * we obtain the right parent roots for the roots in this way. */

	for (struct ShallowGraph* bic=biconnectedComponents; bic!=NULL; bic=bic->next) {

		// listBiconnectedComponents returns bics where the first vertex in the first edge is the root of each bic
		struct Vertex* rootOfComponent = bic->edges->startPoint;

		// mark the root of this component as root.
		rootOfComponent->visited = 1;

		// store the root as information with each vertex and the component
		int rootId = rootOfComponent->number;
		bic->data = rootId;
		for (struct VertexList* e=bic->edges; e!=NULL; e=e->next) {
			e->startPoint->d = rootId;
			e->endPoint->d = rootId;
		}
	}

	// create output struct
	struct BlockTree blockTree = {0,0,0,0,0};
	blockTree.g = g;

	// count number of roots in g, init storage
	for (int v=0; v<g->n; ++v) {
		if (g->vertices[v]->visited == 1) {
			++blockTree.nRoots;
		}
	}
	blockTree.roots = malloc(blockTree.nRoots * sizeof(struct Vertex*));
	blockTree.parents = malloc(blockTree.nRoots * sizeof(struct Vertex*));
	blockTree.vRootedBlocks = malloc(blockTree.nRoots * sizeof(struct ShallowGraph*));

	// select and sort roots by lowpoint. this ensures bottom up traversal of the
	// blocktree if iterating through the array
	for (int v=0, r=0; v<g->n; ++v) {
		if (g->vertices[v]->visited == 1) {
			// set ->visited of each root to the lowpoint of its parent root
			// this way, we can order the roots in one block correctly using lowPointComparator
			g->vertices[v]->visited = g->vertices[g->vertices[v]->d]->lowPoint;
			// if v is its own parent, mark this with a special visited value
			if (g->vertices[g->vertices[v]->d]->number == g->vertices[v]->number) {
				g->vertices[v]->visited = 0;
			}
			blockTree.roots[r] = g->vertices[v];
			++r;
		}
	}
	qsort(blockTree.roots, blockTree.nRoots, sizeof(struct Vertex*), &lowPointComparator);

	// add parents of roots to array (after sorting the above, of course)
	// init vRootedBlocks to NULL
	// set root->visited to its position in roots (so that we can map the bics efficiently)
	for (int v=0; v<blockTree.nRoots; ++v) {
		blockTree.parents[v] = g->vertices[blockTree.roots[v]->d];
		blockTree.vRootedBlocks[v] = NULL;
		blockTree.roots[v]->visited = v;
	}

	// add blocks to respective roots
	for (struct ShallowGraph* bic=popShallowGraph(&biconnectedComponents); bic!=NULL; bic=popShallowGraph(&biconnectedComponents)) {
		int rootPositionInBlockTreeArrays = g->vertices[bic->data]->visited;
		bic->next = blockTree.vRootedBlocks[rootPositionInBlockTreeArrays];
		blockTree.vRootedBlocks[rootPositionInBlockTreeArrays] = bic;
	}

	return blockTree;
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x8(%rsp)
movq %rdi, 0x10(%rsp)
movq %rsi, 0x70(%rsp)
movq %rdx, 0x68(%rsp)
movq 0x70(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x10700
movq %rax, 0x60(%rsp)
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
movq 0x70(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x16030
movq 0x70(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x5c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl $0xffffffff, 0x1c(%rax) # imm = 0xFFFFFFFF
movq 0x70(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x5c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl $0xffffffff, 0x28(%rax) # imm = 0xFFFFFFFF
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x15fe4
movq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
cmpq $0x0, 0x50(%rsp)
je 0x160d5
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
movl $0x1, 0x1c(%rax)
movq 0x48(%rsp), %rax
movl 0x18(%rax), %eax
movl %eax, 0x44(%rsp)
movl 0x44(%rsp), %ecx
movq 0x50(%rsp), %rax
movl %ecx, 0x28(%rax)
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0x160c0
movl 0x44(%rsp), %ecx
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movl %ecx, 0x28(%rax)
movl 0x44(%rsp), %ecx
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rax
movl %ecx, 0x28(%rax)
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
jmp 0x16088
jmp 0x160c2
movq 0x50(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x50(%rsp)
jmp 0x1603a
movq 0x8(%rsp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x10b0
movq 0x8(%rsp), %rax
movq 0x70(%rsp), %rcx
movq %rcx, (%rax)
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
movq 0x70(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x1613d
movq 0x70(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x34(%rsp), %rcx
movq (%rax,%rcx,8), %rax
cmpl $0x1, 0x1c(%rax)
jne 0x1612e
movq 0x8(%rsp), %rax
movl 0x20(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x20(%rax)
jmp 0x16130
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x160fb
movq 0x8(%rsp), %rax
movslq 0x20(%rax), %rdi
shlq $0x3, %rdi
callq 0x1170
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x8(%rax)
movslq 0x20(%rax), %rdi
shlq $0x3, %rdi
callq 0x1170
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x10(%rax)
movslq 0x20(%rax), %rdi
shlq $0x3, %rdi
callq 0x1170
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x18(%rax)
movl $0x0, 0x30(%rsp)
movl $0x0, 0x2c(%rsp)
movl 0x30(%rsp), %eax
movq 0x70(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x1629c
movq 0x70(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rax
cmpl $0x1, 0x1c(%rax)
jne 0x1628a
movq 0x70(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x70(%rsp), %rcx
movq 0x10(%rcx), %rcx
movslq 0x30(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x28(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movl 0x20(%rax), %ecx
movq 0x70(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x30(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, 0x1c(%rax)
movq 0x70(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x70(%rsp), %rcx
movq 0x10(%rcx), %rcx
movslq 0x30(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x28(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movl 0x18(%rax), %eax
movq 0x70(%rsp), %rcx
movq 0x10(%rcx), %rcx
movslq 0x30(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
cmpl 0x18(%rcx), %eax
jne 0x1625b
movq 0x70(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl $0x0, 0x1c(%rax)
movq 0x8(%rsp), %rax
movq 0x70(%rsp), %rcx
movq 0x10(%rcx), %rcx
movslq 0x30(%rsp), %rdx
movq (%rcx,%rdx,8), %rdx
movq 0x8(%rax), %rax
movslq 0x2c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x1628c
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x1619d
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movslq 0x20(%rax), %rsi
movl $0x8, %edx
leaq 0xfb(%rip), %rcx        # 0x163b0
callq 0x1060
movl $0x0, 0x28(%rsp)
movq 0x8(%rsp), %rcx
movl 0x28(%rsp), %eax
cmpl 0x20(%rcx), %eax
jge 0x16332
movq 0x8(%rsp), %rax
movq 0x70(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x8(%rax), %rdx
movslq 0x28(%rsp), %rsi
movq (%rdx,%rsi,8), %rdx
movslq 0x28(%rdx), %rdx
movq (%rcx,%rdx,8), %rsi
movq 0x10(%rax), %rcx
movslq 0x28(%rsp), %rdx
movq %rsi, (%rcx,%rdx,8)
movq 0x18(%rax), %rcx
movslq 0x28(%rsp), %rdx
movq $0x0, (%rcx,%rdx,8)
movl 0x28(%rsp), %ecx
movq 0x8(%rax), %rax
movslq 0x28(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, 0x1c(%rax)
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x162c2
leaq 0x60(%rsp), %rdi
callq 0x16420
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
je 0x163a4
movq 0x8(%rsp), %rax
movq 0x70(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x20(%rsp), %rdx
movslq 0x28(%rdx), %rdx
movq (%rcx,%rdx,8), %rcx
movl 0x1c(%rcx), %ecx
movl %ecx, 0x1c(%rsp)
movq 0x18(%rax), %rcx
movslq 0x1c(%rsp), %rdx
movq (%rcx,%rdx,8), %rdx
movq 0x20(%rsp), %rcx
movq %rdx, 0x18(%rcx)
movq 0x20(%rsp), %rdx
movq 0x18(%rax), %rax
movslq 0x1c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
leaq 0x60(%rsp), %rdi
callq 0x16420
movq %rax, 0x20(%rsp)
jmp 0x16341
movq 0x10(%rsp), %rax
addq $0x78, %rsp
retq
nop