// File: ynilu[P]elastic/graph.cpp
// Function: Phy_graph::BFS_find_path(int, int)
void Phy_graph::BFS_find_path(int source, int destination)
{
    int num_nodes = node_list.size();
    vector<Parents> parents;
    parents.resize(num_nodes);
    vector<int> distance(num_nodes, 1 << 30);
    vector<bool> visited(num_nodes, false);
    queue<int> Q;

    // BFS
    Q.push(source);
    distance[source] = 0;

    while (!Q.empty())
    {
        int v = Q.front();
        Q.pop();

        if(visited[v])
        {
            continue;
        }

        for(auto &w : get_node(v).neighbor)
        {
            if(distance[w] > distance[v])
            {
                distance[w] = distance[v] + 1;
                parents[w].push_back(v);
                Q.push(w);
            }
        }

        visited[v] = true;

    }

    CandidatePath path;
    DFS_back_trace(destination, parents, get_path_list(source, destination), path);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x160(%rbp)
addq $0x8, %rdi
callq 0xb0c0
movl %eax, -0x14(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x158(%rbp)
callq 0x1be40
movq -0x158(%rbp), %rdi
movslq -0x14(%rbp), %rsi
callq 0x1be60
jmp 0x1afee
movslq -0x14(%rbp), %rax
movq %rax, -0x170(%rbp)
movl $0x40000000, -0x5c(%rbp) # imm = 0x40000000
leaq -0x5d(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0xc1a0
movq -0x170(%rbp), %rsi
movq -0x168(%rbp), %rcx
leaq -0x58(%rbp), %rdi
leaq -0x5c(%rbp), %rdx
callq 0x1bef0
jmp 0x1b02d
leaq -0x5d(%rbp), %rdi
callq 0xc240
movslq -0x14(%rbp), %rax
movq %rax, -0x180(%rbp)
movb $0x0, -0x89(%rbp)
leaq -0x8a(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x1bf70
movq -0x180(%rbp), %rsi
movq -0x178(%rbp), %rcx
leaq -0x88(%rbp), %rdi
leaq -0x89(%rbp), %rdx
callq 0x1bf90
jmp 0x1b07e
leaq -0x8a(%rbp), %rdi
callq 0x1c010
leaq -0xe0(%rbp), %rdi
callq 0x1c030
jmp 0x1b098
leaq -0xe0(%rbp), %rdi
leaq -0xc(%rbp), %rsi
callq 0x1c060
jmp 0x1b0aa
movslq -0xc(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0xb210
movl $0x0, (%rax)
leaq -0xe0(%rbp), %rdi
callq 0x1c090
movb %al, -0x181(%rbp)
jmp 0x1b0d1
movb -0x181(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x1b0e2
jmp 0x1b370
leaq -0xe0(%rbp), %rdi
callq 0x1c0b0
movq %rax, -0x190(%rbp)
jmp 0x1b0f7
movq -0x190(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xe4(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x1c0d0
jmp 0x1b114
movslq -0xe4(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x1c0f0
movq %rdx, -0x1a0(%rbp)
movq %rax, -0x198(%rbp)
jmp 0x1b137
movq -0x1a0(%rbp), %rax
movq -0x198(%rbp), %rcx
movq %rcx, -0xf8(%rbp)
movq %rax, -0xf0(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x1c150
testb $0x1, %al
jne 0x1b165
jmp 0x1b1d4
jmp 0x1b0bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1b43d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x5d(%rbp), %rdi
callq 0xc240
jmp 0x1b43d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x8a(%rbp), %rdi
callq 0x1c010
jmp 0x1b434
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1b428
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1b41c
movq -0x160(%rbp), %rdi
movl -0xe4(%rbp), %esi
callq 0x1b450
movq %rax, -0x1a8(%rbp)
jmp 0x1b1ef
movq -0x1a8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rdi
callq 0xbf70
movq %rax, -0x108(%rbp)
movq -0x100(%rbp), %rdi
callq 0xbfa0
movq %rax, -0x110(%rbp)
leaq -0x108(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0xbfd0
testb $0x1, %al
jne 0x1b243
jmp 0x1b31b
leaq -0x108(%rbp), %rdi
callq 0xc010
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rax
movslq (%rax), %rsi
leaq -0x58(%rbp), %rdi
callq 0xb210
movl (%rax), %eax
movl %eax, -0x1ac(%rbp)
movslq -0xe4(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0xb210
movq %rax, %rcx
movl -0x1ac(%rbp), %eax
cmpl (%rcx), %eax
jle 0x1b308
movslq -0xe4(%rbp), %rsi
leaq -0x58(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0xb210
movq -0x1b8(%rbp), %rdi
movl (%rax), %eax
incl %eax
movl %eax, -0x1b0(%rbp)
movq -0x118(%rbp), %rax
movslq (%rax), %rsi
callq 0xb210
movl -0x1b0(%rbp), %ecx
movl %ecx, (%rax)
movq -0x118(%rbp), %rax
movslq (%rax), %rsi
leaq -0x30(%rbp), %rdi
callq 0x1c180
movq %rax, %rdi
leaq -0xe4(%rbp), %rsi
callq 0x1c1a0
jmp 0x1b2f1
movq -0x118(%rbp), %rsi
leaq -0xe0(%rbp), %rdi
callq 0x1c060
jmp 0x1b306
jmp 0x1b308
jmp 0x1b30a
leaq -0x108(%rbp), %rdi
callq 0xc030
jmp 0x1b227
movslq -0xe4(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x1c0f0
movq %rdx, -0x1c8(%rbp)
movq %rax, -0x1c0(%rbp)
jmp 0x1b33e
movq -0x1c8(%rbp), %rax
movq -0x1c0(%rbp), %rcx
movq %rcx, -0x128(%rbp)
movq %rax, -0x120(%rbp)
leaq -0x128(%rbp), %rdi
movl $0x1, %esi
callq 0x1c210
jmp 0x1b0bd
leaq -0x150(%rbp), %rdi
callq 0x1ba90
jmp 0x1b37e
movq -0x160(%rbp), %rdi
movl -0x10(%rbp), %edx
movl %edx, -0x1d4(%rbp)
movl -0xc(%rbp), %esi
callq 0x1b670
movq %rax, -0x1d0(%rbp)
jmp 0x1b39f
movq -0x1d0(%rbp), %rcx
movl -0x1d4(%rbp), %esi
movq -0x160(%rbp), %rdi
leaq -0x30(%rbp), %rdx
leaq -0x150(%rbp), %r8
callq 0x1b480
jmp 0x1b3c5
leaq -0x150(%rbp), %rdi
callq 0x1bac0
leaq -0xe0(%rbp), %rdi
callq 0x1c260
leaq -0x88(%rbp), %rdi
callq 0x1c280
leaq -0x58(%rbp), %rdi
callq 0xaef0
leaq -0x30(%rbp), %rdi
callq 0xd420
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x1bac0
leaq -0xe0(%rbp), %rdi
callq 0x1c260
leaq -0x88(%rbp), %rdi
callq 0x1c280
leaq -0x58(%rbp), %rdi
callq 0xaef0
leaq -0x30(%rbp), %rdi
callq 0xd420
movq -0x38(%rbp), %rdi
callq 0x3340
nop