// File: /workspace/github_cpp_makefile_star2_O1/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 0x2984
cmpl $0x0, 0x50(%rbx)
je 0x1b16
xorl %r12d, %r12d
leaq 0x10(%rsp), %r14
leaq 0xc(%rsp), %r15
movq 0x70(%rbx), %rax
cmpl $0x0, (%rax,%r12,4)
js 0x1aeb
movq 0xa0(%rbx), %rax
movl $0xffffffff, 0x4(%rax,%r12,4) # imm = 0xFFFFFFFF
jmp 0x1b0b
movq 0xa0(%rbx), %rax
movl $0x0, 0x4(%rax,%r12,4)
movl %r12d, 0xc(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x2b16
incq %r12
movl 0x50(%rbx), %eax
cmpq %rax, %r12
jb 0x1ace
movq 0xa0(%rbx), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x20(%rsp), %rax
cmpq %rax, 0x40(%rsp)
je 0x1c47
leaq 0x10(%rsp), %r14
movslq (%rax), %r15
movq 0x30(%rsp), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x1b4f
addq $0x4, %rax
jmp 0x1b81
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), %rax
movq %rax, 0x28(%rsp)
leaq 0x200(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq %rax, 0x20(%rsp)
movq 0xa0(%rbx), %rax
movl 0x4(%rax,%r15,4), %ecx
cmpl (%rax), %ecx
jle 0x1c37
movq 0x88(%rbx), %rcx
leaq (%r15,%r15,2), %r12
movq (%rcx,%r12,8), %rax
cmpq %rax, 0x8(%rcx,%r12,8)
je 0x1c37
movl $0x1, %ebp
xorl %ecx, %ecx
movslq (%rax,%rcx,4), %rdx
movq 0x70(%rbx), %rsi
movq 0xa0(%rbx), %rax
movslq (%rsi,%rdx,4), %rcx
cmpl $0x0, 0x4(%rax,%rcx,4)
js 0x1bf7
movl %ebp, %ecx
movq 0x88(%rbx), %rdx
movq (%rdx,%r12,8), %rax
movq 0x8(%rdx,%r12,8), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
incl %ebp
cmpq %rcx, %rdx
ja 0x1bbb
jmp 0x1c37
leaq (%rsi,%rdx,4), %rsi
movl 0x4(%rax,%r15,4), %edx
incl %edx
movl %edx, 0x4(%rax,%rcx,4)
movl (%rsi), %eax
cmpl $-0x1, %eax
je 0x1bd5
movq 0x40(%rsp), %rcx
movq 0x50(%rsp), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rcx
je 0x1c2d
movl %eax, (%rcx)
addq $0x4, %rcx
movq %rcx, 0x40(%rsp)
jmp 0x1bd5
movq %r14, %rdi
callq 0x2d72
jmp 0x1bd5
movq 0x20(%rsp), %rax
cmpq %rax, 0x40(%rsp)
jne 0x1b38
movq 0xa0(%rbx), %rax
cmpl $-0x1, (%rax)
setne %bl
leaq 0x10(%rsp), %rdi
callq 0x2258
movl %ebx, %eax
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1c6f
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2258
movq %rbx, %rdi
callq 0x11a0