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

	struct Graph* flowInstance = createVertexCoverFlowInstanceOfPoset(g, gp);

	// find max number of s-t paths
	int nAugmentations = 0;
	while (augmentWithCapacity(flowInstance->vertices[0], flowInstance->vertices[1])) {
		++nAugmentations;
	}

	// 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 v=2; v<flowInstance->n; ++v) {
		struct VertexList* keep = NULL;
		flowInstance->vertices[v]->visited = 0;
		for (struct VertexList* e=flowInstance->vertices[v]->neighborhood; e!=NULL; e=flowInstance->vertices[v]->neighborhood) {
			flowInstance->vertices[v]->neighborhood = e->next;
			if ((e->flag != 0) && (e->startPoint->number < e->endPoint->number)) {
				e->next = keep;
				keep = e;
			} else {
				dumpVertexList(gp->listPool, e);
			}
		}
		flowInstance->vertices[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 $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
movq 0x70(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x26b80
movq %rax, 0x50(%rsp)
movl $0x0, 0x4c(%rsp)
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdi
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x1b60
cmpb $0x0, %al
je 0x26833
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x26804
movl $0x2, 0x48(%rsp)
movl 0x48(%rsp), %eax
movq 0x50(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x268b3
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x48(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rax
movq %rax, 0x40(%rsp)
cmpq $0x0, 0x40(%rsp)
je 0x268a4
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x18(%rax), %eax
movl 0x48(%rsp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x26892
movq 0x40(%rsp), %rax
movl 0x24(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x24(%rax)
jmp 0x268a4
jmp 0x26894
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x40(%rsp)
jmp 0x26863
jmp 0x268a6
movl 0x48(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x48(%rsp)
jmp 0x2683b
movq 0x60(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq 0x8(%rax), %rsi
callq 0x1f410
movq 0x60(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x1f410
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq $0x0, 0x8(%rax)
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq $0x0, 0x8(%rax)
movl $0x2, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
movq 0x50(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x26a39
movq $0x0, 0x30(%rsp)
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x3c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl $0x0, 0x1c(%rax)
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x3c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
je 0x26a0e
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x3c(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
movq 0x28(%rsp), %rax
cmpl $0x0, 0x24(%rax)
je 0x269d9
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rax
movl 0x18(%rax), %eax
movq 0x28(%rsp), %rcx
movq 0x18(%rcx), %rcx
cmpl 0x18(%rcx), %eax
jge 0x269d9
movq 0x30(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x28(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x269ec
movq 0x60(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x28(%rsp), %rsi
callq 0x1f410
jmp 0x269ee
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x3c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
jmp 0x2696f
movq 0x30(%rsp), %rcx
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x3c(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x26921
movl $0x2, 0x24(%rsp)
movl 0x24(%rsp), %eax
movq 0x50(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x26ac0
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x24(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
je 0x26ab1
movq 0x18(%rsp), %rax
movl 0x24(%rax), %ecx
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
addl 0x1c(%rax), %ecx
movl %ecx, 0x1c(%rax)
movq 0x18(%rsp), %rax
movl 0x24(%rax), %edx
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x1c(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x1c(%rax)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
jmp 0x26a69
jmp 0x26ab3
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x26a41
movq 0x50(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x26d00
movq 0x68(%rsp), %rax
movq (%rax), %rdi
shlq $0x3, %rdi
callq 0x1170
movq %rax, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
movl $0x2, 0x8(%rsp)
movl 0x8(%rsp), %eax
movq 0x50(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x26b62
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x8(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, (%rsp)
movq (%rsp), %rax
cmpl $0x0, 0x1c(%rax)
jle 0x26b53
movq (%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
callq 0x26d80
movq %rax, %rdx
movq 0x10(%rsp), %rax
movslq 0xc(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x26b18
jmp 0x26b55
movl 0x8(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x8(%rsp)
jmp 0x26af5
movq 0x60(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x1fb30
movq 0x10(%rsp), %rax
addq $0x78, %rsp
retq
nopl (%rax,%rax)