// File: /workspace/github_c_makefile_star2_O3/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, %r13
movq %rdx, 0x10(%rsp)
movq %rsi, %r12
movq %rdi, %r15
movslq (%rdi), %rbx
movq %rbx, %rdi
shlq $0x4, %rdi
addq $-0x8, %rdi
callq 0x1190
movq %rax, %rbp
testq %rbx, %rbx
jle 0x30f9
xorl %r14d, %r14d
movq %r13, %rdi
callq 0x1498d
movq %rax, (%rbp,%r14,8)
incq %r14
movslq (%r15), %rbx
leaq -0x1(,%rbx,2), %rax
cmpq %rax, %r14
jl 0x30d3
movq (%rbp), %rax
jmp 0x30f9
movq %r15, 0x8(%rsp)
movl %ebx, 0x28(%r12)
movq 0x8(%r12), %rbx
testq %rbx, %rbx
movq %rax, %r15
je 0x313f
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(%r12)
movq %r15, %rsi
movq %r13, %rdx
callq 0x1e6f0
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
jne 0x3110
movq %r12, 0x18(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x1e719
testq %rax, %rax
je 0x331d
movq %rax, %r12
xorl %r14d, %r14d
movq %rbp, (%rsp)
movq %r15, 0x20(%rsp)
movq 0x8(%r12), %rbx
movl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
testq %rbx, %rbx
je 0x3258
movb $0x1, %al
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
je 0x31aa
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
jne 0x317d
jmp 0x3223
movq %r13, %rbp
movl 0x1c(%rcx), %edi
callq 0x98f0
movl %eax, %r13d
movq 0x18(%rbx), %rdi
cmpq 0x18(%rsp), %rdi
je 0x31e8
cmpq 0x10(%rsp), %rdi
je 0x31e8
cmpl $0x0, 0x1c(%rdi)
jne 0x31e8
movslq 0x28(%rdi), %rax
movq (%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %rbp, %rdx
callq 0x1e6f0
movq 0x18(%rbx), %rdi
addl %r13d, 0x24(%rbx)
movq (%rbx), %rax
subl %r13d, 0x24(%rax)
movq 0x10(%rbx), %rax
subl %r13d, 0x1c(%rax)
addl %r13d, 0x1c(%rdi)
cmpl $0x0, 0x1c(%r12)
movq %rbp, %r13
movq (%rsp), %rbp
je 0x3292
movq 0x8(%rbx), %rbx
xorl %eax, %eax
testq %rbx, %rbx
jne 0x317d
jmp 0x3275
testb $0x1, %al
je 0x3275
movq 0x8(%r12), %rax
testq %rax, %rax
je 0x3258
movl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movq 0x18(%rax), %rcx
movl 0x28(%rcx), %ecx
cmpl %r15d, %ecx
jge 0x324f
movl 0x20(%rax), %edx
incl %ecx
cmpl 0x24(%rax), %edx
cmovgl %ecx, %r15d
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x3237
movl %r15d, 0x28(%r12)
movslq %r15d, %rbx
movq (%rbp,%rbx,8), %rsi
movq %r12, %rdi
movq %r13, %rdx
callq 0x1e6f0
movl %r15d, %r14d
jmp 0x3295
cmpl $0x0, 0x1c(%r12)
je 0x3292
movslq %r14d, %rbx
movq %r12, %rdi
movq 0x20(%rsp), %rsi
movq %r13, %rdx
callq 0x1e6f0
jmp 0x3295
movslq %r14d, %rbx
movq (%rbp,%rbx,8), %r15
movq %r15, %rdi
callq 0x1e749
testq %rax, %rax
jne 0x3306
movq %r14, %rcx
shlq $0x20, %rcx
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
addq %rax, %rcx
leal -0x1(%r14), %eax
leaq (,%rax,8), %r15
addq %rbp, %r15
movl %r14d, %ebx
movq %rcx, %r12
cmpl $0x2, %r14d
jl 0x32f8
movq (%r15), %rdi
callq 0x1e749
leal -0x1(%rbx), %r14d
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
addq %r12, %rcx
addq $-0x8, %r15
testq %rax, %rax
je 0x32ca
decl %ebx
sarq $0x1d, %r12
movq (%rbp,%r12), %r15
movl %ebx, %r14d
movq %r15, %rdi
movq %r13, %rsi
callq 0x1e719
movq %rax, %r12
testq %rax, %rax
jne 0x3162
movq 0x8(%rsp), %r14
cmpl $0x0, (%r14)
jle 0x334a
xorl %ebx, %ebx
movq (%rbp,%rbx,8), %rsi
movq %r13, %rdi
callq 0x149f4
incq %rbx
movslq (%r14), %rax
leaq -0x1(,%rax,2), %rax
cmpq %rax, %rbx
jl 0x332a
movq %rbp, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1030