// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/bipartiteMatching.c
// Function: pushRelabelMaxFlow
void pushRelabelMaxFlow(struct Graph* g, struct Vertex* s, struct Vertex* t, struct ShallowGraphPool* sgp) {

	struct ShallowGraph** activeVertices = pr_init(g, s, sgp);

	int i = 0;
	for (struct Vertex* active=popFromVertexQueue(activeVertices[i], sgp); active!=NULL; active=popFromVertexQueue(activeVertices[i], sgp)) {

		// look for allowed edges and push as much flow as possible
		char foundAllowedEdge = 0;
		for (struct VertexList* e=active->neighborhood; e!=NULL; e=e->next) {
			if (pr_isAllowedEdge(e)) {
				pr_push(e, s, t, activeVertices, sgp);
				foundAllowedEdge = 1;

				// if vertex lost its 'active' state, stop looping
				if (active->visited == 0) {
					break;
				}
			}
		}

		// if there are no allowed edges (left), relabel v
		if (!foundAllowedEdge) {
			i = pr_relabel(active);
			addToVertexQueue(active, activeVertices[i], sgp);
		} else {
			if (active->visited != 0) {
				addToVertexQueue(active, activeVertices[i], sgp);
			}
		}

		if (peekFromVertexQueue(activeVertices[i]) == NULL) {
			i = pr_findSmallestActiveIndex(activeVertices, i);
		}
	}

	// garbage collection
	for (i=0; i<2 * g->n - 1; ++i) {
		dumpShallowGraph(sgp, activeVertices[i]);
	}
	free(activeVertices);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %rbp
movq %rdx, 0x18(%rsp)
movq %rsi, %r13
movq %rdi, %r15
movslq (%rdi), %rbx
movq %rbx, %rdi
shlq $0x4, %rdi
addq $-0x8, %rdi
callq 0x1180
movq %rax, %r12
xorl %r14d, %r14d
leal -0x1(,%rbx,2), %eax
cltq
cmpq %rax, %r14
jge 0x14cd
movq %rbp, %rdi
callq 0x117e9
movq %rax, (%r12,%r14,8)
incq %r14
movl (%r15), %ebx
jmp 0x14ab
movl %ebx, 0x28(%r13)
movq %r13, %rbx
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0x1505
movl 0x20(%rbx), %eax
addl %eax, 0x24(%rbx)
movq (%rbx), %rcx
subl %eax, 0x24(%rcx)
movl 0x24(%rbx), %eax
movq 0x18(%rbx), %rdi
addl %eax, 0x1c(%rdi)
subl %eax, 0x1c(%r13)
movq (%r12), %rsi
movq %rbp, %rdx
callq 0x1ba70
jmp 0x14d4
movq %r13, 0x20(%rsp)
movq %r15, 0x10(%rsp)
xorl %r13d, %r13d
movq %r12, (%rsp)
movq %r12, %rbx
movq %rbp, 0x8(%rsp)
movq (%rbx), %r12
movq %r12, %rdi
movq %rbp, %rsi
callq 0x1ba99
testq %rax, %rax
je 0x16bc
movq %rax, %rbx
movb $0x1, %al
movq %rbx, %rbp
movq 0x8(%rbp), %rbp
movslq %r13d, %r15
testq %rbp, %rbp
je 0x15d2
movq 0x10(%rbp), %rcx
movq 0x18(%rbp), %rdx
movl 0x28(%rdx), %edx
incl %edx
cmpl %edx, 0x28(%rcx)
setne %dl
movl 0x20(%rbp), %esi
subl 0x24(%rbp), %esi
setle %dil
orb %dl, %dil
jne 0x153d
movl 0x1c(%rcx), %edi
callq 0x751c
movl %eax, %r14d
movq 0x18(%rbp), %rdi
cmpq 0x20(%rsp), %rdi
je 0x15ac
cmpq 0x18(%rsp), %rdi
je 0x15ac
cmpl $0x0, 0x1c(%rdi)
jne 0x15ac
movslq 0x28(%rdi), %rax
movq (%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq 0x8(%rsp), %rdx
callq 0x1ba70
movq 0x18(%rbp), %rdi
addl %r14d, 0x24(%rbp)
movq (%rbp), %rax
subl %r14d, 0x24(%rax)
movq 0x10(%rbp), %rax
subl %r14d, 0x1c(%rax)
addl %r14d, 0x1c(%rdi)
xorl %eax, %eax
cmpl $0x0, 0x1c(%rbx)
jne 0x153d
jmp 0x163e
testb $0x1, %al
je 0x160b
movl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
movq %rbx, %rax
movq 0x8(%rsp), %rbp
movq (%rsp), %r14
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x1626
movq 0x18(%rax), %rcx
movl 0x28(%rcx), %ecx
cmpl %r13d, %ecx
jge 0x15e8
movl 0x20(%rax), %edx
incl %ecx
cmpl 0x24(%rax), %edx
cmovgl %ecx, %r13d
jmp 0x15e8
cmpl $0x0, 0x1c(%rbx)
je 0x163e
movq %rbx, %rdi
movq %r12, %rsi
movq 0x8(%rsp), %rbp
movq %rbp, %rdx
callq 0x1ba70
jmp 0x1643
movl %r13d, 0x28(%rbx)
movslq %r13d, %r15
movq (%r14,%r15,8), %rsi
movq %rbx, %rdi
movq %rbp, %rdx
callq 0x1ba70
jmp 0x1647
movq 0x8(%rsp), %rbp
movq (%rsp), %r14
movq (%r14,%r15,8), %r12
movq %r12, %rdi
callq 0x1bac9
testq %rax, %rax
jne 0x1521
movq %r13, %rcx
shlq $0x20, %rcx
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
addq %rax, %rcx
leal -0x1(%r13), %eax
movq (%rsp), %r12
leaq (%r12,%rax,8), %r15
movl %r13d, %r14d
movq %rcx, %rbx
cmpl $0x2, %r13d
jl 0x16aa
movq (%r15), %rdi
callq 0x1bac9
leal -0x1(%r14), %r13d
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
addq %rbx, %rcx
addq $-0x8, %r15
testq %rax, %rax
je 0x167c
decl %r14d
sarq $0x1d, %rbx
addq %r12, %rbx
movl %r14d, %r13d
jmp 0x151e
xorl %ebx, %ebx
movq 0x10(%rsp), %r14
movq (%rsp), %r15
movslq (%r14), %rax
leaq -0x1(,%rax,2), %rax
cmpq %rax, %rbx
jge 0x16e8
movq (%r15,%rbx,8), %rsi
movq %rbp, %rdi
callq 0x1184e
incq %rbx
jmp 0x16c7
movq %r15, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1030