// File: 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
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x2db0
movl $0x0, -0x5c(%rbp)
movq -0x80(%rbp), %rcx
movl -0x5c(%rbp), %eax
cmpl 0x50(%rcx), %eax
jae 0x1fac
movq -0x80(%rbp), %rdi
addq $0x70, %rdi
movl -0x5c(%rbp), %eax
movl %eax, %esi
callq 0x2d90
cmpl $0x0, (%rax)
jge 0x1f7c
movq -0x80(%rbp), %rdi
addq $0xa0, %rdi
movl -0x5c(%rbp), %eax
incl %eax
movl %eax, %esi
callq 0x2d90
movl $0x0, (%rax)
movl -0x5c(%rbp), %eax
movl %eax, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2de0
jmp 0x1f60
jmp 0x1f9c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x2ea0
jmp 0x21e6
movq -0x80(%rbp), %rdi
addq $0xa0, %rdi
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x2d90
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
jmp 0x1f9e
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x1f07
movq -0x80(%rbp), %rdi
addq $0xa0, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2d90
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
leaq -0x58(%rbp), %rdi
callq 0x2e10
movb %al, -0x81(%rbp)
jmp 0x1fd7
movb -0x81(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x1fe8
jmp 0x21ac
leaq -0x58(%rbp), %rdi
callq 0x2e30
movq %rax, -0x90(%rbp)
jmp 0x1ffa
movq -0x90(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x70(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x2e50
jmp 0x2011
movq -0x80(%rbp), %rdi
addq $0xa0, %rdi
movl -0x70(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x2d90
movq -0x80(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x94(%rbp)
addq $0xa0, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2d90
movq %rax, %rcx
movl -0x94(%rbp), %eax
cmpl (%rcx), %eax
jle 0x21a7
movl $0x0, -0x74(%rbp)
movq -0x80(%rbp), %rdi
movl -0x74(%rbp), %eax
movq %rax, -0xa0(%rbp)
addq $0x88, %rdi
movslq -0x70(%rbp), %rsi
callq 0x2d50
movq %rax, %rdi
callq 0x2d70
movq %rax, %rcx
movq -0xa0(%rbp), %rax
cmpq %rcx, %rax
jae 0x21a5
movq -0x80(%rbp), %rdi
addq $0x88, %rdi
movslq -0x70(%rbp), %rsi
callq 0x2d50
movq %rax, %rdi
movl -0x74(%rbp), %eax
movl %eax, %esi
callq 0x2d90
movq -0x80(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x78(%rbp)
movq %rdi, %rax
addq $0xa0, %rax
movq %rax, -0xa8(%rbp)
addq $0x70, %rdi
movslq -0x78(%rbp), %rsi
callq 0x2d90
movq -0xa8(%rbp), %rdi
movl (%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x2d90
cmpl $0x0, (%rax)
jge 0x2195
movq -0x80(%rbp), %rdi
addq $0xa0, %rdi
movl -0x70(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x2d90
movq -0x80(%rbp), %rdi
movl (%rax), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
movq %rdi, %rax
addq $0xa0, %rax
movq %rax, -0xb8(%rbp)
addq $0x70, %rdi
movslq -0x78(%rbp), %rsi
callq 0x2d90
movq -0xb8(%rbp), %rdi
movl (%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x2d90
movl -0xac(%rbp), %ecx
movq -0x80(%rbp), %rdi
movl %ecx, (%rax)
addq $0x70, %rdi
movslq -0x78(%rbp), %rsi
callq 0x2d90
cmpl $-0x1, (%rax)
je 0x2193
movq -0x80(%rbp), %rdi
addq $0x70, %rdi
movslq -0x78(%rbp), %rsi
callq 0x2d90
movq %rax, %rsi
leaq -0x58(%rbp), %rdi
callq 0x2e70
jmp 0x2191
jmp 0x2193
jmp 0x2195
jmp 0x2197
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x205e
jmp 0x21a7
jmp 0x1fc6
movq -0x80(%rbp), %rdi
addq $0xa0, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2d90
cmpl $-0x1, (%rax)
setne %al
movb %al, -0xb9(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x2ea0
movb -0xb9(%rbp), %al
andb $0x1, %al
addq $0xc0, %rsp
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x1160
nop