// File: /workspace/github_cpp_makefile_star2_O3/kelvinabrokwa[P]bottleneck/./CBottleneckDistance.cpp
// Function: CBottleneckDistance::BFS()
bool CBottleneckDistance::BFS()
{
    std::queue<int> vertex_queue;

    // For every vertex v given by Generators1
    for (unsigned int v = 0; v < Max_Size; v++) {
        // If its not paired to vertex in Generators2
        if (Pair[v] < 0) {
            // Set its layer to 0 and put it in the queue
            Layers[v + 1] = 0;
            vertex_queue.push(v);
        }
        else {
            // Otherwise mark it as matched (set Layer to NILL)
            Layers[v + 1] = -1;
        }
    }

    // Set layer for NIL
    Layers[0] = -1;

    // Search the vertices in the queue
    while (!vertex_queue.empty()) {
        int v = vertex_queue.front();
        vertex_queue.pop();
        if (Layers[ v + 1 ] > Layers[ 0 ]) {
            for(unsigned int i = 0; i < Connections[ v ].size(); ++i) {
                int u = Connections[ v ][ i ];
                // Check if the vertex has an edge to the match vertex
                if (Layers[ Pair[ u ] + 1 ] < 0) {
                    // Set the layer of the vertex (it can be NILL) which is matched to the matched vertex u
                    Layers[ Pair[ u ] + 1 ] = Layers[ v + 1 ] + 1;
                    // If the pairing vertex is not NIL add it into the queue
                    if(Pair[ u ] != -1)
                        vertex_queue.push(Pair[u]);
                }
            }
        }
    }

    return Layers[0] != -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x60, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0x2960
cmpl $0x0, 0x50(%rbx)
je 0x1aeb
xorl %r12d, %r12d
leaq 0x10(%rsp), %r14
leaq 0xc(%rsp), %r15
movq 0x70(%rbx), %rcx
movq 0xa0(%rbx), %rax
cmpl $0x0, (%rcx,%r12,4)
js 0x1ac7
movl $0xffffffff, 0x4(%rax,%r12,4) # imm = 0xFFFFFFFF
jmp 0x1ae0
movl $0x0, 0x4(%rax,%r12,4)
movl %r12d, 0xc(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x2af2
incq %r12
movl 0x50(%rbx), %eax
cmpq %rax, %r12
jb 0x1aaa
movq 0xa0(%rbx), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x20(%rsp), %rcx
cmpq %rcx, 0x40(%rsp)
je 0x1c2b
leaq 0x10(%rsp), %r14
movslq (%rcx), %r15
movq 0x30(%rsp), %rax
addq $-0x4, %rax
cmpq %rax, %rcx
je 0x1b24
addq $0x4, %rcx
jmp 0x1b56
movq 0x28(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x1120
movq 0x38(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x38(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x28(%rsp)
leaq 0x200(%rcx), %rax
movq %rax, 0x30(%rsp)
movq %rcx, 0x20(%rsp)
movq 0xa0(%rbx), %rax
movl 0x4(%rax,%r15,4), %edx
cmpl (%rax), %edx
jle 0x1c11
movq 0x88(%rbx), %rax
leaq (%r15,%r15,2), %r12
movq (%rax,%r12,8), %rdx
cmpq %rdx, 0x8(%rax,%r12,8)
je 0x1c11
movl $0x1, %ebp
xorl %ecx, %ecx
movslq (%rdx,%rcx,4), %rsi
movq 0x70(%rbx), %rdi
movq 0xa0(%rbx), %rcx
movslq (%rdi,%rsi,4), %rdx
cmpl $0x0, 0x4(%rcx,%rdx,4)
js 0x1bc5
movl %ebp, %ecx
movq (%rax,%r12,8), %rdx
movq 0x8(%rax,%r12,8), %rsi
subq %rdx, %rsi
sarq $0x2, %rsi
incl %ebp
cmpq %rcx, %rsi
ja 0x1b90
jmp 0x1c0c
leaq (%rdi,%rsi,4), %rsi
movl 0x4(%rcx,%r15,4), %edi
incl %edi
movl %edi, 0x4(%rcx,%rdx,4)
movl (%rsi), %ecx
cmpl $-0x1, %ecx
je 0x1baa
movq 0x40(%rsp), %rdx
movq 0x50(%rsp), %rdi
addq $-0x4, %rdi
cmpq %rdi, %rdx
je 0x1bfb
movl %ecx, (%rdx)
addq $0x4, %rdx
movq %rdx, 0x40(%rsp)
jmp 0x1baa
movq %r14, %rdi
callq 0x2d4e
movq 0x88(%rbx), %rax
jmp 0x1baa
movq 0x20(%rsp), %rcx
cmpq %rcx, 0x40(%rsp)
jne 0x1b0d
movq 0xa0(%rbx), %rax
cmpl $-0x1, (%rax)
setne %bl
jmp 0x1c2d
xorl %ebx, %ebx
leaq 0x10(%rsp), %rdi
callq 0x223c
movl %ebx, %eax
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1c48
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x223c
movq %rbx, %rdi
callq 0x11a0
nop