// File: /workspace/github_cpp_makefile_star2_O1/kdungs[P]codecon/src/maze.cc
// Function: solveBfs(Maze const&, Point const&, Point const&)
auto solveBfs(const Maze& maze, const Point& from, const Point& to)
    -> std::vector<Point> {
  auto visited = std::vector<bool>(maze.rows * maze.cols, false);
  auto prev = std::vector<Point>(maze.rows * maze.cols, {maze.rows, maze.cols});

  auto getAddress =
      [&maze](const Point& p) { return p.row * maze.cols + p.col; };

  auto getNeighbours = [&maze, &visited, &getAddress](const Point& p) {
    auto ns = std::vector<Point>{{p.row - 1, p.col},
                                 {p.row + 1, p.col},
                                 {p.row, p.col - 1},
                                 {p.row, p.col + 1}};
    ns.erase(std::remove_if(std::begin(ns), std::end(ns),
                            [&maze, &visited, &getAddress](const Point& np) {
                              const auto addr = getAddress(np);
                              return (np.row >= maze.rows) ||
                                     (np.col >= maze.cols) || !maze.map[addr] ||
                                     visited[addr];
                            }),
             std::end(ns));
    return ns;
  };

  auto queue = std::vector<Point>{};
  queue.emplace_back(from);

  while (!queue.empty()) {
    auto cur = queue.front();
    queue.erase(std::begin(queue));
    visited[getAddress(cur)] = true;

    if (cur == to) {
      break;
    }

    auto ns = getNeighbours(cur);
    for (const auto& n : ns) {
      prev[getAddress(n)] = cur;
      queue.emplace_back(n);
    }
  }

  auto path = std::vector<Point>{};
  for (auto cur = to; cur != from; cur = prev[getAddress(cur)]) {
    path.emplace_back(cur);
  }
  path.emplace_back(from);
  std::reverse(std::begin(path), std::end(path));
  return path;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rcx, 0xc0(%rsp)
movq %rdx, %r15
movq %rsi, %rbp
movq %rdi, %rbx
movq 0x8(%rsi), %rsi
imulq (%rbp), %rsi
leaq 0x50(%rsp), %r14
movb $0x0, (%r14)
leaq 0x98(%rsp), %rdi
leaq 0xe0(%rsp), %rcx
movq %r14, %rdx
callq 0x1c76
movq (%rbp), %rax
movq 0x8(%rbp), %rsi
movq %rax, (%r14)
movq %rsi, 0x8(%r14)
imulq %rax, %rsi
leaq 0xc8(%rsp), %rdi
leaq 0x50(%rsp), %rdx
leaq 0xe0(%rsp), %rcx
callq 0x1cde
movq %rbp, 0x28(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x18(%rsp), %rsi
testq %rsi, %rsi
movq %rbx, 0x30(%rsp)
movq %r15, 0xf8(%rsp)
je 0x137f
movups (%r15), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x18(%rsp)
jmp 0x138c
leaq 0x10(%rsp), %rdi
movq %r15, %rdx
callq 0x2034
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
addq $0x3f, %rax
movq %rax, 0x108(%rsp)
leaq 0x50(%rsp), %rbx
movq %rbp, 0x8(%rsp)
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rdx
cmpq %rdx, %rdi
je 0x16ea
movq (%rdi), %r14
movq 0x8(%rdi), %r15
leaq 0x10(%rdi), %rsi
cmpq %rdx, %rsi
je 0x13d7
subq %rsi, %rdx
callq 0x1120
addq $-0x10, 0x18(%rsp)
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rcx
imulq %r14, %rcx
leaq (%rcx,%r15), %rax
addq $0x3f, %rax
addq %r15, %rcx
cmovnsq %rcx, %rax
sarq $0x6, %rax
shlq $0x3, %rax
addq 0x98(%rsp), %rax
movq %rcx, %rdx
andq 0x108(%rsp), %rdx
xorl %esi, %esi
movabsq $-0x8000000000000000, %rdi # imm = 0x8000000000000000
cmpq %rdi, %rdx
setbe %sil
movl $0x1, %edx
shlq %cl, %rdx
orq %rdx, -0x8(%rax,%rsi,8)
movq 0xc0(%rsp), %rcx
movq (%rcx), %rax
xorq %r14, %rax
movq 0x8(%rcx), %rcx
xorq %r15, %rcx
orq %rax, %rcx
setne %al
je 0x16ea
movb %al, 0x7(%rsp)
leaq -0x1(%r14), %rax
movq %rax, 0x50(%rsp)
movq %r15, 0x58(%rsp)
leaq 0x1(%r14), %rax
movq %rax, 0x60(%rsp)
movq %r15, 0x68(%rsp)
movq %r14, 0x70(%rsp)
leaq -0x1(%r15), %rax
movq %rax, 0x78(%rsp)
movq %r14, 0x110(%rsp)
movq %r14, 0x80(%rsp)
leaq 0x1(%r15), %rax
movq %rax, 0x88(%rsp)
movl $0x4, %edx
leaq 0x38(%rsp), %rdi
movq %rbx, %rsi
leaq 0xe0(%rsp), %rcx
callq 0x1e72
movq 0x38(%rsp), %r12
movq 0x40(%rsp), %r13
movq %rbp, 0xe0(%rsp)
leaq 0x98(%rsp), %rax
movq %rax, 0xe8(%rsp)
leaq 0x28(%rsp), %rcx
movq %rcx, 0xf0(%rsp)
movq %rbp, 0x50(%rsp)
movq %rax, 0x58(%rsp)
movq %rcx, 0x60(%rsp)
movq %r13, %rax
subq %r12, %rax
movq %rax, %rbp
sarq $0x6, %rbp
testq %rbp, %rbp
jle 0x1594
andq $-0x40, %rax
addq %r12, %rax
movq %rax, 0x100(%rsp)
incq %rbp
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1bf0
testb %al, %al
jne 0x15f9
leaq 0x10(%r12), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1bf0
testb %al, %al
jne 0x15fc
leaq 0x20(%r12), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1bf0
testb %al, %al
jne 0x15fc
leaq 0x30(%r12), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1bf0
testb %al, %al
jne 0x15fc
addq $0x40, %r12
decq %rbp
cmpq $0x1, %rbp
leaq 0x50(%rsp), %rbx
jg 0x151f
movq 0x100(%rsp), %r12
movq %r13, %rax
subq %r12, %rax
sarq $0x4, %rax
cmpq $0x1, %rax
movq 0x8(%rsp), %rbp
je 0x15e3
cmpq $0x2, %rax
je 0x15d0
movq %r13, %r14
cmpq $0x3, %rax
jne 0x1601
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1bf0
testb %al, %al
jne 0x15f4
addq $0x10, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1bf0
testb %al, %al
jne 0x15f4
addq $0x10, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1bf0
testb %al, %al
cmoveq %r13, %r12
movq %r12, %r14
jmp 0x1601
movq %r12, %r14
movq 0x8(%rsp), %rbp
cmpq %r13, %r14
sete %al
leaq 0x10(%r14), %r12
cmpq %r13, %r12
sete %cl
orb %al, %cl
jne 0x1642
leaq 0xe0(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1bf0
testb %al, %al
jne 0x1639
movups (%r12), %xmm0
movups %xmm0, (%r14)
addq $0x10, %r14
addq $0x10, %r12
cmpq %r13, %r12
jne 0x161d
cmpq 0x40(%rsp), %r14
je 0x164e
movq %r14, 0x40(%rsp)
movq 0x38(%rsp), %r14
movq 0x40(%rsp), %r12
cmpq %r12, %r14
leaq 0x10(%rsp), %rbx
movq 0x110(%rsp), %r13
je 0x16c3
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rax
imulq (%r14), %rax
movq 0x8(%r14), %rcx
shlq $0x4, %rax
addq 0xc8(%rsp), %rax
shlq $0x4, %rcx
movq %r13, (%rcx,%rax)
movq %r15, 0x8(%rcx,%rax)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x16af
movups (%r14), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x18(%rsp)
jmp 0x16ba
movq %rbx, %rdi
movq %r14, %rdx
callq 0x2034
addq $0x10, %r14
cmpq %r12, %r14
jne 0x166a
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x16da
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
cmpb $0x0, 0x7(%rsp)
leaq 0x50(%rsp), %rbx
jne 0x13ac
xorps %xmm0, %xmm0
movq 0x30(%rsp), %rbx
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movq 0xc0(%rsp), %rax
movups (%rax), %xmm0
movaps %xmm0, 0x50(%rsp)
movq 0x50(%rsp), %rax
movq 0xf8(%rsp), %r14
cmpq (%r14), %rax
jne 0x172a
movq 0x8(%r14), %rax
cmpq %rax, 0x58(%rsp)
je 0x1784
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x1743
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x8(%rbx)
jmp 0x1750
leaq 0x50(%rsp), %rdx
movq %rbx, %rdi
callq 0x2158
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rax
imulq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
shlq $0x4, %rax
addq 0xc8(%rsp), %rax
shlq $0x4, %rcx
movups (%rcx,%rax), %xmm0
movaps %xmm0, 0x50(%rsp)
movq 0x50(%rsp), %rax
jmp 0x171a
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x179c
movups (%r14), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x8(%rbx)
jmp 0x17a7
movq %rbx, %rdi
movq %r14, %rdx
callq 0x2034
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq %rcx, %rax
setne %dl
addq $-0x10, %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x17f4
addq $0x10, %rax
movups -0x10(%rax), %xmm0
movaps %xmm0, 0x50(%rsp)
movups (%rcx), %xmm0
movups %xmm0, -0x10(%rax)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rcx)
addq $-0x10, %rcx
leaq 0x10(%rax), %rdx
cmpq %rcx, %rax
movq %rdx, %rax
jb 0x17cc
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x180b
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x1828
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x186d
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
xorl %eax, %eax
movq %rax, 0x98(%rsp)
movl %eax, 0xa0(%rsp)
movq %rax, 0xa8(%rsp)
movl %eax, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
movq %rbx, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x188b
jmp 0x18a6
movq %rax, %r14
jmp 0x18f9
movq %rax, %r14
movq 0x30(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x18c5
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rsi
jmp 0x18bd
movq %rax, %r14
jmp 0x18c5
movq %rax, %r14
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x18c5
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x18dc
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x18f9
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x193e
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
xorl %eax, %eax
movq %rax, 0x98(%rsp)
movl %eax, 0xa0(%rsp)
movq %rax, 0xa8(%rsp)
movl %eax, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
movq %r14, %rdi
callq 0x1130