// File: /workspace/github_cpp_makefile_star2_O2/Kei18[P]pibt/./src/solver/pps.cpp
// Function: PPS::CLOSEST_EMPTY_VERTICLES(Agent*)
Nodes PPS::CLOSEST_EMPTY_VERTICLES(Agent* c) {
  Nodes empties;
  Nodes occupied;
  Nodes Y;
  Nodes C;

  // create occupied lists
  for (auto a : A) occupied.push_back(a->getNode());
  std::unordered_map<int, VD*> table;
  VD* n = new VD { c->getNode(), 0 };
  int id = n->v->getId();
  int d;

  std::unordered_set<int> OPEN = { id };
  table.emplace(id, n);

  while (!OPEN.empty()) {
    auto itr = std::min_element(OPEN.begin(), OPEN.end(),
                                [&table] (int a, int b)
                                { return table.at(a)->d < table.at(b)->d; });
    id = *itr;
    n = table.at(id);

    // check empty or not
    if (!inArray(n->v, occupied)) {
      if (Y.empty()) {
        d = n->d;
      } else if (d < n->d) {
        break;
      }
      // same distance
      Y.push_back(n->v);
    }

    // update list
    OPEN.erase(itr);

    C = G->neighbor(n->v);
    for (auto m : C) {
      id = m->getId();
      auto itr = table.find(id);
      if (itr == table.end()) {
        VD* l = new VD { m, n->d + 1 };
        table.emplace(id, l);
        OPEN.insert(id);
        continue;
      }
    }
  }

  return Y;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
andq $0x0, 0xa0(%rsp)
leaq 0x70(%rsp), %r14
andq $0x0, 0x10(%r14)
movaps %xmm0, (%r14)
andq $0x0, 0x10(%rdi)
movq %rdi, 0x20(%rsp)
movups %xmm0, (%rdi)
andq $0x0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq 0x20(%rsi), %r12
movq %rsi, 0x50(%rsp)
movq 0x28(%rsi), %r13
leaq 0xe0(%rsp), %r15
cmpq %r13, %r12
je 0x2f4fb
movq (%r12), %rax
movq 0x8(%rax), %rax
movq %rax, 0xe0(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x1aca4
addq $0x8, %r12
jmp 0x2f4d5
leaq 0x110(%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)
pushq $0x10
popq %rdi
callq 0x63b0
movq 0x8(%rbx), %rcx
movq %rcx, (%rax)
andl $0x0, 0x8(%rax)
movq %rax, 0x10(%rsp)
movl (%rcx), %eax
movl %eax, 0x8(%rsp)
leaq 0x5c(%rsp), %rdx
movl %eax, -0x4(%rdx)
leaq 0xe(%rsp), %rax
movq %rax, (%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0x1c(%rsp), %r8
leaq 0xf(%rsp), %r9
xorl %ecx, %ecx
callq 0x31fb0
leaq 0xe0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x3206c
leaq 0xe0(%rsp), %r15
leaq 0x8(%rsp), %r12
leaq 0x58(%rsp), %r13
cmpq $0x0, 0xc0(%rsp)
je 0x2f701
movq 0xb8(%rsp), %rbp
testq %rbp, %rbp
je 0x2f5f8
movq %rbp, %r14
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x2f5fb
movl 0x8(%rbp), %eax
movl 0x8(%r14), %ecx
movl %eax, 0x58(%rsp)
movl %ecx, 0x1c(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x323b0
movq (%rax), %rax
movl 0x8(%rax), %ebx
movq %r15, %rdi
leaq 0x1c(%rsp), %rsi
callq 0x323b0
movq (%rax), %rax
cmpl 0x8(%rax), %ebx
cmovlq %rbp, %r14
jmp 0x2f5b6
xorl %r14d, %r14d
movl 0x8(%r14), %eax
movl %eax, 0x8(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x323b0
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movq (%rax), %rdi
leaq 0x70(%rsp), %rsi
callq 0x2fc19
testb %al, %al
jne 0x2f656
movq 0x20(%rsp), %rdx
movq (%rdx), %rcx
movq 0x10(%rsp), %rsi
movl 0x8(%rsi), %eax
cmpq 0x8(%rdx), %rcx
je 0x2f648
cmpl %eax, 0x2c(%rsp)
jge 0x2f64c
jmp 0x2f701
movl %eax, 0x2c(%rsp)
movq 0x20(%rsp), %rdi
callq 0x171da
leaq 0xa8(%rsp), %rdi
movq %r14, %rsi
callq 0x27566
movq 0x50(%rsp), %rax
movq 0x38(%rax), %rsi
movq 0x10(%rsp), %rax
movq (%rax), %rdx
movq %r13, %rdi
callq 0x164ca
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0x18466
movq %r13, %rdi
callq 0x990e
movq 0x30(%rsp), %r14
movq 0x38(%rsp), %rbp
cmpq %rbp, %r14
je 0x2f597
movq (%r14), %rbx
movl (%rbx), %eax
movl %eax, 0x8(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x323ce
testq %rax, %rax
jne 0x2f6fb
pushq $0x10
popq %rdi
callq 0x63b0
movq %rbx, (%rax)
movq 0x10(%rsp), %rcx
movl 0x8(%rcx), %ecx
incl %ecx
movl %ecx, 0x8(%rax)
movq %rax, 0x58(%rsp)
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x3206c
leaq 0xa8(%rsp), %rdi
movq %r12, %rsi
callq 0x27478
addq $0x8, %r14
jmp 0x2f69e
leaq 0xa8(%rsp), %rdi
callq 0x174fe
leaq 0xe0(%rsp), %rdi
callq 0x31640
leaq 0x30(%rsp), %rdi
callq 0x990e
leaq 0x70(%rsp), %rdi
callq 0x990e
leaq 0x90(%rsp), %rdi
callq 0x990e
movq 0x20(%rsp), %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2f769
jmp 0x2f757
movq %rax, %rbx
jmp 0x2f779
jmp 0x2f769
movq %rax, %rbx
jmp 0x2f786
jmp 0x2f769
jmp 0x2f769
jmp 0x2f769
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x174fe
leaq 0xe0(%rsp), %rdi
callq 0x31640
leaq 0x30(%rsp), %rdi
callq 0x990e
movq 0x20(%rsp), %rdi
callq 0x990e
leaq 0x70(%rsp), %rdi
callq 0x990e
leaq 0x90(%rsp), %rdi
callq 0x990e
movq %rbx, %rdi
callq 0x6650
nop