// File: /workspace/github_cpp_makefile_star2_O1/roornelas[P]small-world/./search.hpp
// Function: searchBFS(Graph*, std::pair<int, int>, std::pair<int, int>)
int searchBFS (Graph* g, pair<int, int> start, pair<int, int> end) {
  int i1 = start.first;
  int j1 = start.second;
  int i2 = end.first;
  int j2 = end.second;

  set<Node*> visited;
  queue<Node*> nodes;
  unordered_map<Node*, Node*> parents;
  Node* begin = g->find_node(i1, j1);
  Node* target = g->find_node(i2, j2);
  Node* curr = begin;
  visited.insert(curr);

  for (pair<int, int> f : curr->friends) {
    Node* temp = g->find_node(f.first, f.second);
    if (visited.find(temp) == visited.end()) {
      nodes.push(temp);
      parents.insert(make_pair(temp, curr));
    }
  }

  while (curr != target) {
    curr = nodes.front();
    nodes.pop();
    visited.insert(curr);

    for (pair<int, int> f : curr->friends) {
      Node* temp = g->find_node(f.first, f.second);
      if (visited.find(temp) == visited.end()) {
        nodes.push(temp);
        parents.insert(make_pair(temp, curr));
      }
    }
  }

  int dist = 0;
  curr = target;
  while (curr != begin) {
    dist++;
    curr = parents.at(curr);
  }
  return dist;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x88(%rsp), %r12
movl $0x0, (%r12)
xorl %eax, %eax
movq %rax, 0x8(%r12)
movq %r12, 0x10(%r12)
movq %r12, 0x18(%r12)
movq %rax, 0x20(%r12)
xorps %xmm0, %xmm0
leaq 0x30(%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 0x3fd4
leaq 0xe0(%rsp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
movslq %r15d, %rax
movq 0x8(%rbx), %rcx
leaq (%rax,%rax,2), %rax
sarq $0x20, %r15
movq (%rcx,%rax,8), %rax
movq (%rax,%r15,8), %r15
movslq %r14d, %rax
leaq (%rax,%rax,2), %rax
sarq $0x20, %r14
movq (%rcx,%rax,8), %rax
movq (%rax,%r14,8), %rax
movq %rax, 0x10(%rsp)
movq %rsp, %rsi
movq %r15, (%rsi)
leaq 0x80(%rsp), %rdi
callq 0x414a
movq %r15, 0x28(%rsp)
movq (%rsp), %r15
movq 0x20(%r15), %r14
addq $0x10, %r15
cmpq %r15, %r14
je 0x258c
leaq 0xb0(%rsp), %r13
leaq 0x18(%rsp), %rbp
movslq 0x20(%r14), %rax
movslq 0x24(%r14), %rcx
movq 0x8(%rbx), %rdx
leaq (%rax,%rax,2), %rax
movq (%rdx,%rax,8), %rax
movq (%rax,%rcx,8), %rax
movq %rax, 0x8(%rsp)
movq 0x90(%rsp), %rdx
movq %r12, %rcx
testq %rdx, %rdx
je 0x2515
movq %r12, %rcx
xorl %esi, %esi
cmpq %rax, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x24fd
movq %r12, %rdx
cmpq %r12, %rcx
je 0x2528
cmpq 0x20(%rcx), %rax
cmovbq %r12, %rcx
movq %rcx, %rdx
cmpq %r12, %rdx
jne 0x2578
movq 0x60(%rsp), %rcx
movq 0x70(%rsp), %rdx
addq $-0x8, %rdx
cmpq %rdx, %rcx
je 0x254b
movq %rax, (%rcx)
addq $0x8, 0x60(%rsp)
jmp 0x255a
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x425c
movq 0x8(%rsp), %rax
movq (%rsp), %rcx
movq %rax, 0x18(%rsp)
movq %rcx, 0x20(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4470
movq %r14, %rdi
callq 0x2190
movq %rax, %r14
cmpq %r15, %rax
jne 0x24cd
movq 0x10(%rsp), %rax
cmpq %rax, (%rsp)
je 0x26f2
leaq 0xb0(%rsp), %rbp
leaq 0x18(%rsp), %r14
movq 0x40(%rsp), %rax
movq 0x50(%rsp), %rcx
movq (%rax), %rdx
movq %rdx, (%rsp)
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x25c8
addq $0x8, %rax
jmp 0x25fa
movq 0x48(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x2160
movq 0x58(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x58(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x48(%rsp)
leaq 0x200(%rax), %rcx
movq %rcx, 0x50(%rsp)
movq %rax, 0x40(%rsp)
leaq 0x80(%rsp), %rdi
movq %rsp, %rsi
callq 0x414a
movq (%rsp), %r13
movq 0x20(%r13), %r15
addq $0x10, %r13
cmpq %r13, %r15
je 0x26e3
movslq 0x20(%r15), %rax
movslq 0x24(%r15), %rcx
movq 0x8(%rbx), %rdx
leaq (%rax,%rax,2), %rax
movq (%rdx,%rax,8), %rax
movq (%rax,%rcx,8), %rax
movq %rax, 0x8(%rsp)
movq 0x90(%rsp), %rdx
movq %r12, %rcx
testq %rdx, %rdx
je 0x266c
movq %r12, %rcx
xorl %esi, %esi
cmpq %rax, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x2654
movq %r12, %rdx
cmpq %r12, %rcx
je 0x267f
cmpq 0x20(%rcx), %rax
cmovbq %r12, %rcx
movq %rcx, %rdx
cmpq %r12, %rdx
jne 0x26cf
movq 0x60(%rsp), %rcx
movq 0x70(%rsp), %rdx
addq $-0x8, %rdx
cmpq %rdx, %rcx
je 0x26a2
movq %rax, (%rcx)
addq $0x8, 0x60(%rsp)
jmp 0x26b1
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x425c
movq 0x8(%rsp), %rax
movq (%rsp), %rcx
movq %rax, 0x18(%rsp)
movq %rcx, 0x20(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4470
movq %r15, %rdi
callq 0x2190
movq %rax, %r15
cmpq %r13, %rax
jne 0x2624
movq 0x10(%rsp), %rax
cmpq %rax, (%rsp)
jne 0x25a8
movq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq 0x28(%rsp), %r12
xorl %ebx, %ebx
cmpq %r12, %rax
je 0x272b
leaq 0xb0(%rsp), %r14
movq %rsp, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x477a
incl %ebx
movq (%rax), %rax
movq %rax, (%rsp)
cmpq %r12, %rax
jne 0x2712
leaq 0xb0(%rsp), %rdi
callq 0x30ec
leaq 0x30(%rsp), %rdi
callq 0x315c
leaq 0x80(%rsp), %rdi
callq 0x31ac
movl %ebx, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2774
movq %rax, %rbx
jmp 0x278e
jmp 0x2774
jmp 0x2774
jmp 0x2774
jmp 0x2774
jmp 0x2774
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x30ec
leaq 0x30(%rsp), %rdi
callq 0x315c
leaq 0x80(%rsp), %rdi
callq 0x31ac
movq %rbx, %rdi
callq 0x2240