// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/poset_pathCover.c
// Function: getPathCoverOfPoset
int** getPathCoverOfPoset(struct Graph* g, size_t* nPaths, struct GraphPool* gp, struct ShallowGraphPool* sgp) {

	struct Graph* flowInstance = createVertexCoverFlowInstanceOfPoset(g, gp);
	pushRelabelMaxFlow(flowInstance, flowInstance->vertices[0], flowInstance->vertices[1], sgp);

	// add one flow value to those edges that correspond to vertices
	for (int v=2; v<flowInstance->n; v+=2) {
		for (struct VertexList* e=flowInstance->vertices[v]->neighborhood; e!=NULL; e=e->next) {
			if (e->endPoint->number == v+1) {
				e->flag += 1;
				break; // iterating over the neighbors
			}
		}
	}

	// remove all edges that have 0 flow, all residual edges (assumed to go from larger vertex id to smaller),
	// and all edges containing s and t
	// init ->visited of vertices
	dumpVertexList(gp->listPool, flowInstance->vertices[0]->neighborhood);
	dumpVertexList(gp->listPool, flowInstance->vertices[1]->neighborhood);
	flowInstance->vertices[0]->neighborhood = NULL;
	flowInstance->vertices[1]->neighborhood = NULL;

	for (int vi=2; vi<flowInstance->n; ++vi) {
		struct Vertex* v = flowInstance->vertices[vi];
		struct VertexList* keep = NULL;
		v->visited = 0;
		v->d = 0;
		for (struct VertexList* e=v->neighborhood; e!=NULL; e=v->neighborhood) {
			v->neighborhood = e->next;
			if ((e->flag != 0) && (e->startPoint->number < e->endPoint->number)) {
				e->next = keep;
				keep = e;
			} else {
				dumpVertexList(gp->listPool, e);
			}
		}
		v->neighborhood = keep;
	}

	// store outflow - inflow in v->visited
	for (int v=2; v<flowInstance->n; ++v) {
		for (struct VertexList* e=flowInstance->vertices[v]->neighborhood; e!=NULL; e=e->next) {
			e->startPoint->visited += e->flag;
			e->endPoint->visited -= e->flag;
		}
	}

	// get minimum number of paths that cover all vertices
	countPossiblePaths(flowInstance, nPaths);

	// find paths from sources to sinks and store them in output
	int** paths = malloc(*nPaths * sizeof(int*));
	int i = 0;
	for (int v=2; v<flowInstance->n; v += 2) {
		struct Vertex* vertex = flowInstance->vertices[v];
		while (vertex->visited > 0) {
			paths[i] = getLongestPathInFlowInstance(vertex, flowInstance, sgp);
			++i;
		}
	}

	dumpGraph(gp, flowInstance);
	return paths;
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x80(%rsp)
movq %rsi, 0x78(%rsp)
movq %rdx, 0x70(%rsp)
movq %rcx, 0x68(%rsp)
movq 0x80(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x26b80
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdi
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rsi
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdx
movq 0x68(%rsp), %rcx
callq 0x1590
movl $0x2, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
movq 0x60(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x2715d
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x5c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rax
movq %rax, 0x50(%rsp)
cmpq $0x0, 0x50(%rsp)
je 0x2714e
movq 0x50(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x18(%rax), %eax
movl 0x5c(%rsp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2713c
movq 0x50(%rsp), %rax
movl 0x24(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x24(%rax)
jmp 0x2714e
jmp 0x2713e
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x50(%rsp)
jmp 0x2710d
jmp 0x27150
movl 0x5c(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x5c(%rsp)
jmp 0x270e5
movq 0x70(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq 0x8(%rax), %rsi
callq 0x1f410
movq 0x70(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x1f410
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq $0x0, 0x8(%rax)
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq $0x0, 0x8(%rax)
movl $0x2, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
movq 0x60(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x272be
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x4c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x40(%rsp)
movq $0x0, 0x38(%rsp)
movq 0x40(%rsp), %rax
movl $0x0, 0x1c(%rax)
movq 0x40(%rsp), %rax
movl $0x0, 0x28(%rax)
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x30(%rsp)
cmpq $0x0, 0x30(%rsp)
je 0x272a0
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x30(%rsp), %rax
cmpl $0x0, 0x24(%rax)
je 0x2727b
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movl 0x18(%rax), %eax
movq 0x30(%rsp), %rcx
movq 0x18(%rcx), %rcx
cmpl 0x18(%rcx), %eax
jge 0x2727b
movq 0x38(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x30(%rsp), %rax
movq %rax, 0x38(%rsp)
jmp 0x2728e
movq 0x70(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x30(%rsp), %rsi
callq 0x1f410
jmp 0x27290
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x30(%rsp)
jmp 0x27222
movq 0x38(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x8(%rax)
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x271cb
movl $0x2, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
movq 0x60(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x27345
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x2c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
je 0x27336
movq 0x20(%rsp), %rax
movl 0x24(%rax), %ecx
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
addl 0x1c(%rax), %ecx
movl %ecx, 0x1c(%rax)
movq 0x20(%rsp), %rax
movl 0x24(%rax), %edx
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x1c(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x1c(%rax)
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x20(%rsp)
jmp 0x272ee
jmp 0x27338
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x272c6
movq 0x60(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x26d00
movq 0x78(%rsp), %rax
movq (%rax), %rdi
shlq $0x3, %rdi
callq 0x1170
movq %rax, 0x18(%rsp)
movl $0x0, 0x14(%rsp)
movl $0x2, 0x10(%rsp)
movl 0x10(%rsp), %eax
movq 0x60(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x273ea
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
cmpl $0x0, 0x1c(%rax)
jle 0x273db
movq 0x8(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
callq 0x26d80
movq %rax, %rdx
movq 0x18(%rsp), %rax
movslq 0x14(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x2739e
jmp 0x273dd
movl 0x10(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x10(%rsp)
jmp 0x2737a
movq 0x70(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x1fb30
movq 0x18(%rsp), %rax
addq $0x88, %rsp
retq
nopw %cs:(%rax,%rax)