// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/outerplanar.c
// Function: createFancyBlockAndBridgeTree
struct BBTree* createFancyBlockAndBridgeTree(struct ShallowGraph* list, struct Graph *original, int** originalIDs, struct GraphPool* gp, struct ShallowGraphPool *sgp) {
	struct ShallowGraph* idx;
	struct ShallowGraph* tmp;
	struct Graph* bbTree = getGraph(gp);
	struct Graph* blocks = getGraph(gp);
	int blockNo = 0;
	int i;

	/* copy V(original) */
	setVertexNumber(bbTree, original->n);
	for (i=0; i<original->n; ++i) {
		bbTree->vertices[i] = shallowCopyVertex(original->vertices[i], gp->vertexPool);
	}

	/* copy all bridges to the new graph and delete them from list;
	 * count the number of blocks */
	for (idx=list; idx; idx=tmp) {

		tmp = idx->next;
		if (idx->m == 1) {
			struct VertexList* e = getVertexList(gp->listPool);

			/* add the edge to the bbTree */
			e->startPoint = bbTree->vertices[idx->edges->startPoint->number];
			e->endPoint = bbTree->vertices[idx->edges->endPoint->number];
			e->label = idx->edges->label;

			addEdge(bbTree->vertices[idx->edges->startPoint->number], e);
			addEdge(bbTree->vertices[idx->edges->endPoint->number], inverseEdge(e, gp->listPool));

			++bbTree->m;

			/* cut idx out of list */
			if (idx->prev) {
				idx->prev->next = tmp;
				if (tmp) {
					tmp->prev = idx->prev;
				}
			} else {
				list = tmp;
				if (tmp) {
					tmp->prev = NULL;
				}
			}

			/* dump idx */
			idx->next = NULL;
			dumpShallowGraph(sgp, idx);
		} else {
			/* we have found a block */
			++blockNo;
		}
	}

	/* add blocks */
	setVertexNumber(blocks, blockNo);
	for (i=0; i<blockNo; ++i) {
		blocks->vertices[i] = getVertex(gp->vertexPool);
		blocks->vertices[i]->number = - (i + 1);
	}

	for (i=0; i<bbTree->n; ++i) {
		if (bbTree->vertices[i]->neighborhood) {
			bbTree->vertices[i]->visited = -1;
		}
	}

	/* mark vertices that are in the block and bridge tree */
	i = 1; // component marker
	for (struct ShallowGraph* comp=list; comp!=NULL; comp=comp->next) {
		for (struct VertexList* e=comp->edges; e!=NULL; e=e->next) {
			struct Vertex* v = bbTree->vertices[e->startPoint->number];
			if (v->visited == 0) {
				v->visited = i;
			} else if (v->visited != i) {
				v->visited = -1;
			}
			v = bbTree->vertices[e->endPoint->number];
			if (v->visited == 0) {
				v->visited = i;
			} else if (v->visited != i) {
				v->visited = -1;
			}
		}
		++i;
	}

	/* add edges from block vertices to articulation vertices */
	i = 1; // component marker
	for (struct ShallowGraph* comp=list; comp!=NULL; comp=comp->next) {
		for (struct VertexList* e=comp->edges; e!=NULL; e=e->next) {
			struct Vertex* v = bbTree->vertices[e->startPoint->number];
			if ((v->visited == -1) && (v->lowPoint != i)) {
				v->lowPoint = i;
				struct Vertex* w = blocks->vertices[i-1];
				struct VertexList* f = getVertexList(gp->listPool);
				f->startPoint = v;
				f->endPoint = w;
				addEdge(v, f);
				f = getVertexList(gp->listPool);
				f->endPoint = v;
				f->startPoint = w;
				addEdge(w, f);
				++blocks->m;
			}
			v = bbTree->vertices[e->endPoint->number];
			if ((v->visited == -1) && (v->lowPoint != i)) {
				v->lowPoint = i;
				struct Vertex* w = blocks->vertices[i-1];
				struct VertexList* f = getVertexList(gp->listPool);
				f->startPoint = v;
				f->endPoint = w;
				addEdge(v, f);
				f = getVertexList(gp->listPool);
				f->endPoint = v;
				f->startPoint = w;
				addEdge(w, f);
				++blocks->m;
			}
		}
		++i;
	}

	/* remove vertices that do not belong to more than one biconnected component
	 * runtime O(n+m) */
	for (i=0; i<bbTree->n; ++i) {

		if (bbTree->vertices[i]->visited != -1) {
			/* check if to remove the vertex. if so, dump vertex and all edges dangling at it.
			* The corresponding entry in bbTree->vertices will be NULL */
			dumpVertexListRecursively(gp->listPool, bbTree->vertices[i]->neighborhood);
			dumpVertex(gp->vertexPool, bbTree->vertices[i]);
			bbTree->vertices[i] = NULL;
		}
	}

	return compressedBBTree(bbTree, blocks, list, originalIDs, gp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, 0x20(%rsp)
movq %rcx, %rbx
movq %rdx, 0x30(%rsp)
movq %rsi, %r14
movq %rdi, %rbp
movq %rcx, %rdi
callq 0x11619
movq %rax, %r15
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
callq 0x11619
movq %rax, 0x10(%rsp)
movl (%r14), %esi
movq %r15, %rdi
callq 0x5c80
xorl %r12d, %r12d
movslq (%r14), %rax
cmpq %rax, %r12
jge 0x14ac6
movq 0x10(%r14), %rax
movq (%rax,%r12,8), %rdi
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0x5a70
movq 0x10(%r15), %rcx
movq %rax, (%rcx,%r12,8)
incq %r12
jmp 0x14a9b
movq $0x0, 0x18(%rsp)
movq %rbp, %r14
movq 0x8(%rsp), %rbx
movq %rbp, %r13
testq %r13, %r13
movq %r14, 0x28(%rsp)
je 0x14bcd
movq 0x18(%r13), %rbp
cmpl $0x1, 0x10(%r13)
jne 0x14bc3
movq %rbp, %r12
movq 0x18(%rbx), %rdi
callq 0x11307
movq %rax, %r14
movq 0x10(%r15), %rax
movq (%r13), %rcx
movq 0x10(%rcx), %rdx
movslq 0x18(%rdx), %rdx
movq (%rax,%rdx,8), %rdx
movq %rdx, 0x10(%r14)
movq 0x18(%rcx), %rdx
movslq 0x18(%rdx), %rdx
movq (%rax,%rdx,8), %rdx
movq %rdx, 0x18(%r14)
movq (%rcx), %rdx
movq %rdx, (%r14)
movq 0x10(%rcx), %rcx
movslq 0x18(%rcx), %rcx
movq (%rax,%rcx,8), %rdi
movq %r14, %rsi
callq 0x5b2c
movq 0x10(%r15), %rax
movq (%r13), %rcx
movq 0x18(%rcx), %rcx
movslq 0x18(%rcx), %rcx
movq (%rax,%rcx,8), %rbp
movq 0x18(%rbx), %rsi
movq %r14, %rdi
callq 0x5a44
movq %rbp, %rdi
movq %rax, %rsi
callq 0x5b2c
incl 0x4(%r15)
movq 0x20(%r13), %rax
testq %rax, %rax
je 0x14b8e
movq %r12, 0x18(%rax)
movq 0x28(%rsp), %rcx
movq %rcx, %r14
jmp 0x14b9c
movl $0x0, %eax
movq %r12, %rcx
movl $0x0, %r14d
testq %r12, %r12
je 0x14ba9
movq %rax, 0x20(%r12)
movq %rcx, %r14
andq $0x0, 0x18(%r13)
movq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0x1184e
movq %r12, %r13
jmp 0x14ada
incq 0x18(%rsp)
jmp 0x14ad7
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rbx
movl %ebx, %esi
callq 0x5c80
pushq $-0x1
popq %rbp
xorl %r14d, %r14d
subq $0x1, %rbx
jb 0x14c18
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x114a5
movq 0x10(%rsp), %rdx
movq 0x10(%rdx), %rcx
movq %rax, (%rcx,%r14)
movq 0x10(%rdx), %rax
movq (%rax,%r14), %rax
movl %ebp, 0x18(%rax)
decl %ebp
addq $0x8, %r14
jmp 0x14be4
movl (%r15), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movq 0x28(%rsp), %r12
cmpq %rcx, %rax
je 0x14c44
movq 0x10(%r15), %rdx
movq (%rdx,%rcx,8), %rdx
cmpq $0x0, 0x8(%rdx)
je 0x14c3f
orl $-0x1, 0x1c(%rdx)
incq %rcx
jmp 0x14c27
pushq $0x1
popq %rax
pushq $-0x1
popq %rcx
movq %r12, %rdx
movq %rdx, %rsi
testq %rdx, %rdx
je 0x14cb7
movq (%rsi), %rsi
testq %rsi, %rsi
je 0x14caf
movq 0x10(%r15), %rdi
movq 0x10(%rsi), %r8
movslq 0x18(%r8), %r8
movq (%rdi,%r8,8), %r8
movl 0x1c(%r8), %r10d
movl %eax, %r9d
testl %r10d, %r10d
je 0x14c81
movl %ecx, %r9d
cmpl %eax, %r10d
je 0x14c85
movl %r9d, 0x1c(%r8)
movq 0x18(%rsi), %r8
movslq 0x18(%r8), %r8
movq (%rdi,%r8,8), %rdi
movl 0x1c(%rdi), %r9d
movl %eax, %r8d
testl %r9d, %r9d
je 0x14ca5
movl %ecx, %r8d
cmpl %eax, %r9d
je 0x14ca9
movl %r8d, 0x1c(%rdi)
addq $0x8, %rsi
jmp 0x14c55
incl %eax
movq 0x18(%rdx), %rdx
jmp 0x14c4d
pushq $0x1
popq %rbp
movq %r15, 0x20(%rsp)
testq %r12, %r12
je 0x14de5
movq %r12, 0x18(%rsp)
movq (%r12), %r12
testq %r12, %r12
je 0x14dd3
movq 0x10(%r15), %rax
movq 0x10(%r12), %rcx
movslq 0x18(%rcx), %rcx
movq (%rax,%rcx,8), %r14
cmpl $-0x1, 0x1c(%r14)
jne 0x14d56
movl 0x20(%r14), %ecx
cmpq %rcx, %rbp
je 0x14d56
movl %ebp, 0x20(%r14)
movq 0x10(%rsp), %rbx
movq 0x10(%rbx), %rax
movq -0x8(%rax,%rbp,8), %r13
movq 0x8(%rsp), %r15
movq 0x18(%r15), %rdi
callq 0x11307
movq %r14, 0x10(%rax)
movq %r13, 0x18(%rax)
movq %r14, %rdi
movq %rax, %rsi
callq 0x5b2c
movq 0x18(%r15), %rdi
movq 0x20(%rsp), %r15
callq 0x11307
movq %r14, 0x18(%rax)
movq %r13, 0x10(%rax)
movq %r13, %rdi
movq %rax, %rsi
callq 0x5b2c
incl 0x4(%rbx)
movq 0x10(%r15), %rax
movq 0x18(%r12), %rcx
movslq 0x18(%rcx), %rcx
movq (%rax,%rcx,8), %r14
cmpl $-0x1, 0x1c(%r14)
jne 0x14dca
movl 0x20(%r14), %eax
cmpq %rax, %rbp
je 0x14dca
movl %ebp, 0x20(%r14)
movq 0x10(%rsp), %rbx
movq 0x10(%rbx), %rax
movq -0x8(%rax,%rbp,8), %r13
movq 0x8(%rsp), %r15
movq 0x18(%r15), %rdi
callq 0x11307
movq %r14, 0x10(%rax)
movq %r13, 0x18(%rax)
movq %r14, %rdi
movq %rax, %rsi
callq 0x5b2c
movq 0x18(%r15), %rdi
movq 0x20(%rsp), %r15
callq 0x11307
movq %r14, 0x18(%rax)
movq %r13, 0x10(%rax)
movq %r13, %rdi
movq %rax, %rsi
callq 0x5b2c
incl 0x4(%rbx)
addq $0x8, %r12
jmp 0x14ccd
incq %rbp
movq 0x18(%rsp), %r12
movq 0x18(%r12), %r12
jmp 0x14cbf
xorl %r14d, %r14d
movq 0x28(%rsp), %r12
movq 0x8(%rsp), %rbx
movslq (%r15), %rax
cmpq %rax, %r14
jge 0x14e34
movq 0x10(%r15), %rax
movq (%rax,%r14,8), %rax
cmpl $-0x1, 0x1c(%rax)
je 0x14e2f
movq 0x18(%rbx), %rdi
movq 0x8(%rax), %rsi
callq 0x1138e
movq 0x10(%rbx), %rdi
movq 0x10(%r15), %rax
movq (%rax,%r14,8), %rsi
callq 0x11512
movq 0x10(%r15), %rax
andq $0x0, (%rax,%r14,8)
incq %r14
jmp 0x14df2
movq %r15, %rdi
movq 0x10(%rsp), %rsi
movq %r12, %rdx
movq 0x30(%rsp), %rcx
movq 0x8(%rsp), %r8
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x149ea