// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/listCycles.c
// Function: _backtrack
struct ShallowGraph* __backtrack(struct Graph* g, struct Vertex* v, struct Vertex* parent, struct Vertex* s, int allowance,
		struct ShallowGraph* currentPath, struct ShallowGraphPool* sgp) {
	int i,j;
	struct ShallowGraph *path = getShallowGraph(sgp);
	struct ShallowGraph *result = NULL;
	struct VertexList *neighbor, *idx;
	char flag = 0;


	/* while there exists a vertex $ w \in v->neighborhood $ with w > z
	 * s.t. there is a path from w to s which avoids the current path
	 */
	for (neighbor=v->neighborhood; neighbor; neighbor=neighbor->next) {

		/* this "removes" vertices that are too small from adjacency lists
		 * also, dont use the backwards edge to your parent */
		if ((neighbor->endPoint->number >= allowance) && (neighbor->endPoint != parent)) {

			/* " z < w " given some numbering of vertices. I take the one given by ->number.
			 * This only tries to find a path if the first condition holds. should be better,
			 * as the paths will be marked on vertex level. This seems to be not well elaborated
			 * right now..... shit
			 *
			 * z was a strange way to say: for each neighbor of v and even does harm, if incidence
			 * lists are not sorted by endPoint->number */
			if (findPath(neighbor->endPoint, v, s, allowance, path, sgp)) {
				struct Vertex* predecessorInPath = NULL;

				/* the current extension edge should be contained in the path */
				pushEdge(path, shallowCopyEdge(neighbor, sgp->listPool));

				i = 1;

				/* maybe this can be omitted as flag is not global any more*/
				flag = 0;

				/* mark all vertices on the current path as such, the others as others */
				/* TODO this could maybe be made faster by only traversing the vertices that are necessary with dfs */
				for (j=0; j<g->n; ++j) {
					if (g->vertices[j]) {
						g->vertices[j]->d = g->vertices[j]->visited;
					}
				}


				/* add vertices in path to the current path until a choice of ways to reach s is found */
				for (idx=path->edges; idx && (idx->endPoint != s) && !flag; idx=idx->next) {
					struct VertexList *innerVertexNeighbs;

					appendEdge(currentPath, shallowCopyEdge(idx, sgp->listPool));
					idx->endPoint->visited = idx->endPoint->d = 1;


					for (innerVertexNeighbs=idx->endPoint->neighborhood; innerVertexNeighbs; innerVertexNeighbs=innerVertexNeighbs->next) {
						if (innerVertexNeighbs->endPoint->number >= allowance) {
							/* if the endpoint of this edge is not the next vertex on path */
							if (innerVertexNeighbs->endPoint != idx->next->endPoint) {
								/* ...  or the parent */
								if (innerVertexNeighbs->endPoint->number != idx->startPoint->number) {
									/* ... and not visited yet, except if its s */
									if ((innerVertexNeighbs->endPoint->d == 0) || (innerVertexNeighbs->endPoint == s)) {

										/* search for a different way to s than the one given by path */
										flag = __DFS(innerVertexNeighbs->endPoint, idx->endPoint, s, allowance);

										if (flag) break;
									}
								}
							}
						} /* fi allowance */

						/* remember the predecessor on the current path so that recursive call to __backtrack
						 * knows, which edge not to use. */
						predecessorInPath = idx->startPoint;
					}
					++i;
				}


				/* this is where output is produced */
				if (!flag) {
					/* idx points to the edge closing the cycle, which is not yet included in the output */
					struct VertexList* closingEdge = shallowCopyEdge(idx, sgp->listPool);

					/* clone currentPath */
					struct ShallowGraph* clone = getShallowGraph(sgp);
					/* the output of this function is a cycle of shallow graphs, and addComponent
					 * expects its input, to be a cycle, too.
					 */
					clone->next = clone->prev = clone;

					for (idx=currentPath->edges; idx; idx=idx->next) {
						appendEdge(clone, shallowCopyEdge(idx, sgp->listPool));
					}

					appendEdge(clone, closingEdge);

					/* add it to the results list */
					result = addComponent(result, clone);

				} else {

					struct ShallowGraph* x = __backtrack(g, idx->startPoint, predecessorInPath, s, allowance, currentPath, sgp);
					result = addComponent(result, x);
				}


				if (currentPath->edges->startPoint == v) {
					/* if v is the first vertex in the path, dump the whole path */
					struct VertexList* tmp1 = currentPath->edges;
					struct VertexList* tmp2 = currentPath->edges;
					currentPath->edges = NULL;
					currentPath->lastEdge = NULL;
					while(tmp1) {
						tmp1 = tmp1->next;
						tmp2->endPoint->visited = 0;
						dumpVertexList(sgp->listPool, tmp2);
						tmp2=tmp1;
					}
				} else {
					/* go up to v in current path, then delete all following edges and set their visited values to 0.
					 * Also: set the pointer to the last element in path to v */
					for (idx=currentPath->edges; idx; idx=idx->next) {
						if (idx->endPoint == v) {
							struct VertexList* tmp1 = idx->next;
							struct VertexList* tmp2 = idx->next;
							idx->next = NULL;
							currentPath->lastEdge = idx;
							while(tmp1) {
								tmp1 = tmp1->next;
								tmp2->endPoint->visited = 0;
								dumpVertexList(sgp->listPool, tmp2);
								tmp2=tmp1;
							}
							break;
						}
					}
				}

				/* if we go to the next neighbor of v, we want to start a fresh path */
				dumpShallowGraph(sgp, path);
				path = getShallowGraph(sgp);
			}
		}
	}

	/* garbage collection */
	dumpShallowGraph(sgp, path);

	return result;
}

// Assembly:
subq $0xd8, %rsp
movq 0xe0(%rsp), %rax
movq %rdi, 0xd0(%rsp)
movq %rsi, 0xc8(%rsp)
movq %rdx, 0xc0(%rsp)
movq %rcx, 0xb8(%rsp)
movl %r8d, 0xb4(%rsp)
movq %r9, 0xa8(%rsp)
movq 0xe0(%rsp), %rdi
callq 0x1fe70
movq %rax, 0x98(%rsp)
movq $0x0, 0x90(%rsp)
movb $0x0, 0x7f(%rsp)
movq 0xc8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x88(%rsp)
cmpq $0x0, 0x88(%rsp)
je 0x1244d
movq 0x88(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x18(%rax), %eax
cmpl 0xb4(%rsp), %eax
jl 0x12432
movq 0x88(%rsp), %rax
movq 0x18(%rax), %rax
cmpq 0xc0(%rsp), %rax
je 0x12432
movq 0x88(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0xc8(%rsp), %rsi
movq 0xb8(%rsp), %rdx
movl 0xb4(%rsp), %ecx
movq 0x98(%rsp), %r8
movq 0xe0(%rsp), %r9
callq 0x11c20
cmpb $0x0, %al
je 0x12430
movq $0x0, 0x70(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x88(%rsp), %rdi
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0xa310
movq 0x28(%rsp), %rdi
movq %rax, %rsi
callq 0xb610
movl $0x1, 0xa4(%rsp)
movb $0x0, 0x7f(%rsp)
movl $0x0, 0xa0(%rsp)
movl 0xa0(%rsp), %eax
movq 0xd0(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x11f5e
movq 0xd0(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0xa0(%rsp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x11f49
movq 0xd0(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0xa0(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x1c(%rax), %ecx
movq 0xd0(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0xa0(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, 0x28(%rax)
jmp 0x11f4b
movl 0xa0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa0(%rsp)
jmp 0x11ee5
movq 0x98(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x80(%rsp)
xorl %eax, %eax
cmpq $0x0, 0x80(%rsp)
movb %al, 0x27(%rsp)
je 0x11fac
movq 0x80(%rsp), %rax
movq 0x18(%rax), %rcx
xorl %eax, %eax
cmpq 0xb8(%rsp), %rcx
movb %al, 0x27(%rsp)
je 0x11fac
cmpb $0x0, 0x7f(%rsp)
setne %al
xorb $-0x1, %al
movb %al, 0x27(%rsp)
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x11fb9
jmp 0x12132
movq 0xa8(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x80(%rsp), %rdi
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0xa310
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0xbf70
movq 0x80(%rsp), %rax
movq 0x18(%rax), %rax
movl $0x1, 0x28(%rax)
movq 0x80(%rsp), %rax
movq 0x18(%rax), %rax
movl $0x1, 0x1c(%rax)
movq 0x80(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x68(%rsp)
cmpq $0x0, 0x68(%rsp)
je 0x12108
movq 0x68(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x18(%rax), %eax
cmpl 0xb4(%rsp), %eax
jl 0x120e4
movq 0x68(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x80(%rsp), %rcx
movq 0x8(%rcx), %rcx
cmpq 0x18(%rcx), %rax
je 0x120e2
movq 0x68(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x18(%rax), %eax
movq 0x80(%rsp), %rcx
movq 0x10(%rcx), %rcx
cmpl 0x18(%rcx), %eax
je 0x120e0
movq 0x68(%rsp), %rax
movq 0x18(%rax), %rax
cmpl $0x0, 0x28(%rax)
je 0x120a6
movq 0x68(%rsp), %rax
movq 0x18(%rax), %rax
cmpq 0xb8(%rsp), %rax
jne 0x120de
movq 0x68(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x80(%rsp), %rax
movq 0x18(%rax), %rsi
movq 0xb8(%rsp), %rdx
movl 0xb4(%rsp), %ecx
callq 0x11c80
movb %al, 0x7f(%rsp)
cmpb $0x0, 0x7f(%rsp)
je 0x120dc
jmp 0x12108
jmp 0x120de
jmp 0x120e0
jmp 0x120e2
jmp 0x120e4
movq 0x80(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x70(%rsp)
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x68(%rsp)
jmp 0x12027
movl 0xa4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa4(%rsp)
movq 0x80(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x80(%rsp)
jmp 0x11f71
cmpb $0x0, 0x7f(%rsp)
jne 0x12213
movq 0x80(%rsp), %rdi
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0xa310
movq %rax, 0x60(%rsp)
movq 0xe0(%rsp), %rdi
callq 0x1fe70
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x58(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0xa8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x80(%rsp)
cmpq $0x0, 0x80(%rsp)
je 0x121e8
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x80(%rsp), %rdi
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0xa310
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0xbf70
movq 0x80(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x80(%rsp)
jmp 0x12197
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0xbf70
movq 0x90(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0xbd60
movq %rax, 0x90(%rsp)
jmp 0x12274
movq 0xd0(%rsp), %rdi
movq 0x80(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x70(%rsp), %rdx
movq 0xb8(%rsp), %rcx
movl 0xb4(%rsp), %r8d
movq 0xa8(%rsp), %r9
movq 0xe0(%rsp), %rax
movq %rax, (%rsp)
callq 0x11d90
movq %rax, 0x50(%rsp)
movq 0x90(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0xbd60
movq %rax, 0x90(%rsp)
movq 0xa8(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
cmpq 0xc8(%rsp), %rax
jne 0x1231d
movq 0xa8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x48(%rsp)
movq 0xa8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x40(%rsp)
movq 0xa8(%rsp), %rax
movq $0x0, (%rax)
movq 0xa8(%rsp), %rax
movq $0x0, 0x8(%rax)
cmpq $0x0, 0x48(%rsp)
je 0x12318
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x48(%rsp)
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rax
movl $0x0, 0x1c(%rax)
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x40(%rsp), %rsi
callq 0x1f410
movq 0x48(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x122d0
jmp 0x12406
movq 0xa8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x80(%rsp)
cmpq $0x0, 0x80(%rsp)
je 0x12404
movq 0x80(%rsp), %rax
movq 0x18(%rax), %rax
cmpq 0xc8(%rsp), %rax
jne 0x123e9
movq 0x80(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x80(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x80(%rsp), %rax
movq $0x0, 0x8(%rax)
movq 0x80(%rsp), %rcx
movq 0xa8(%rsp), %rax
movq %rcx, 0x8(%rax)
cmpq $0x0, 0x38(%rsp)
je 0x123e7
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movl $0x0, 0x1c(%rax)
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x30(%rsp), %rsi
callq 0x1f410
movq 0x38(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x1239f
jmp 0x12404
jmp 0x123eb
movq 0x80(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x80(%rsp)
jmp 0x12330
jmp 0x12406
movq 0xe0(%rsp), %rdi
movq 0x98(%rsp), %rsi
callq 0x1ff70
movq 0xe0(%rsp), %rdi
callq 0x1fe70
movq %rax, 0x98(%rsp)
jmp 0x12432
jmp 0x12434
movq 0x88(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x88(%rsp)
jmp 0x11e09
movq 0xe0(%rsp), %rdi
movq 0x98(%rsp), %rsi
callq 0x1ff70
movq 0x90(%rsp), %rax
addq $0xd8, %rsp
retq
nopw %cs:(%rax,%rax)