// File: /workspace/github_c_makefile_star2_O1/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 $0x18, %rsp
movq %rcx, %r12
movq %rdx, 0x10(%rsp)
movq %rsi, %r13
movq %rdi, %rbp
movslq (%rdi), %rbx
movq %rbx, %rdi
shlq $0x4, %rdi
addq $-0x8, %rdi
callq 0x1190
movq %rax, %r15
testq %rbx, %rbx
jle 0x3143
xorl %r14d, %r14d
movq %r12, %rdi
callq 0x14aae
movq %rax, (%r15,%r14,8)
incq %r14
movslq (%rbp), %rbx
leaq -0x1(,%rbx,2), %rax
cmpq %rax, %r14
jl 0x3123
movq %rbp, 0x8(%rsp)
movl %ebx, 0x28(%r13)
movq 0x8(%r13), %rbx
testq %rbx, %rbx
je 0x3186
movq (%r15), %r14
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 %r14, %rsi
movq %r12, %rdx
callq 0x1e8ac
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
jne 0x3158
movq (%r15), %rdi
movq %r12, (%rsp)
movq %r12, %rsi
callq 0x1e8d5
testq %rax, %rax
je 0x32dd
movq %rax, %rbp
xorl %r12d, %r12d
movq 0x8(%rbp), %rbx
testq %rbx, %rbx
je 0x323f
xorl %eax, %eax
movq 0x10(%rbx), %rcx
movq 0x18(%rbx), %rdx
movl 0x28(%rdx), %edx
incl %edx
cmpl %edx, 0x28(%rcx)
setne %dl
movl 0x20(%rbx), %esi
subl 0x24(%rbx), %esi
setle %dil
orb %dl, %dil
jne 0x322a
movl 0x1c(%rcx), %edi
callq 0x98e4
movl %eax, %r14d
movq 0x18(%rbx), %rdi
cmpq %r13, %rdi
je 0x3207
cmpq 0x10(%rsp), %rdi
je 0x3207
cmpl $0x0, 0x1c(%rdi)
jne 0x3207
movslq 0x28(%rdi), %rax
movq (%r15,%rax,8), %rsi
movq (%rsp), %rdx
callq 0x1e8ac
addl %r14d, 0x24(%rbx)
movq (%rbx), %rax
subl %r14d, 0x24(%rax)
movq 0x10(%rbx), %rax
subl %r14d, 0x1c(%rax)
movq 0x18(%rbx), %rax
addl %r14d, 0x1c(%rax)
movb $0x1, %al
cmpl $0x0, 0x1c(%rbp)
je 0x3237
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
jne 0x31b3
testb %al, %al
je 0x323f
cmpl $0x0, 0x1c(%rbp)
jne 0x3270
jmp 0x3283
movq 0x8(%rbp), %rax
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
testq %rax, %rax
je 0x326c
movq 0x18(%rax), %rcx
movl 0x28(%rcx), %ecx
cmpl %r12d, %ecx
jge 0x3266
movl 0x20(%rax), %edx
incl %ecx
cmpl 0x24(%rax), %edx
cmovgl %ecx, %r12d
movq 0x8(%rax), %rax
jmp 0x3249
movl %r12d, 0x28(%rbp)
movslq %r12d, %rax
movq (%r15,%rax,8), %rsi
movq %rbp, %rdi
movq (%rsp), %rdx
callq 0x1e8ac
movslq %r12d, %rax
movq (%r15,%rax,8), %rdi
callq 0x1e905
testq %rax, %rax
jne 0x32c1
leal -0x1(%r12), %eax
leaq (%r15,%rax,8), %rbx
movl %r12d, %r14d
cmpl $0x2, %r12d
jl 0x32bb
movq (%rbx), %rdi
callq 0x1e905
leal -0x1(%r14), %r12d
addq $-0x8, %rbx
testq %rax, %rax
je 0x329d
decl %r14d
movl %r14d, %r12d
movslq %r12d, %rax
movq (%r15,%rax,8), %rdi
movq (%rsp), %rsi
callq 0x1e8d5
movq %rax, %rbp
testq %rax, %rax
jne 0x31a4
movq 0x8(%rsp), %r12
cmpl $0x0, (%r12)
movq (%rsp), %r14
jle 0x330f
xorl %ebx, %ebx
movq (%r15,%rbx,8), %rsi
movq %r14, %rdi
callq 0x14b19
incq %rbx
movslq (%r12), %rax
leaq -0x1(,%rax,2), %rax
cmpq %rax, %rbx
jl 0x32ef
movq %r15, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1030