// File: /workspace/github_cpp_makefile_star2_O1/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 $0x108, %rsp            # imm = 0x108
movq %rdx, %rbx
xorl %eax, %eax
movq %rax, 0x80(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movq %rax, 0x10(%rdi)
movq %rdi, 0x38(%rsp)
movups %xmm0, (%rdi)
movq 0x20(%rsi), %r12
movq %rsi, 0x90(%rsp)
movq 0x28(%rsi), %r13
cmpq %r13, %r12
je 0x3ac40
leaq 0x70(%rsp), %r14
leaq 0x98(%rsp), %r15
movq (%r12), %rax
movq 0x8(%rax), %rax
movq %rax, 0x98(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x1fc22
addq $0x8, %r12
cmpq %r13, %r12
jne 0x3ac1c
leaq 0xc8(%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)
movl $0x10, %edi
callq 0x6370
movq 0x8(%rbx), %rcx
movq %rcx, (%rax)
movl $0x0, 0x8(%rax)
movq %rax, 0x30(%rsp)
movl (%rcx), %eax
movl %eax, 0x10(%rsp)
leaq 0x44(%rsp), %rdx
movl %eax, -0x4(%rdx)
leaq 0x2e(%rsp), %rax
movq %rax, (%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x68(%rsp), %r8
leaq 0x2f(%rsp), %r9
xorl %ecx, %ecx
callq 0x3e124
leaq 0x98(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x3e224
movq $0x0, 0x20(%rsp)
leaq 0x98(%rsp), %r12
leaq 0x40(%rsp), %rbp
leaq 0x68(%rsp), %r14
xorl %r15d, %r15d
cmpq $0x0, 0xe8(%rsp)
je 0x3af72
movq 0xe0(%rsp), %rbx
testq %rbx, %rbx
movq %r15, 0x88(%rsp)
je 0x3ad55
movq (%rbx), %r15
testq %r15, %r15
je 0x3ad55
movl 0x8(%r15), %eax
movl 0x8(%rbx), %ecx
movl %eax, 0x40(%rsp)
movl %ecx, 0x68(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
callq 0x3e512
movq (%rax), %rax
movl 0x8(%rax), %r13d
movq %r12, %rdi
movq %r14, %rsi
callq 0x3e512
movq (%rax), %rax
cmpl 0x8(%rax), %r13d
cmovlq %r15, %rbx
movq (%r15), %r15
jmp 0x3ad14
movl 0x8(%rbx), %eax
movl %eax, 0x10(%rsp)
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
movq 0x88(%rsp), %r15
callq 0x3e512
movq (%rax), %rax
movq %rax, 0x30(%rsp)
movq (%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %rsi
movq %rbp, %rdx
callq 0x19ae8
cmpq 0x78(%rsp), %rax
je 0x3ada4
movl 0x18(%rsp), %eax
movl %eax, 0x14(%rsp)
jmp 0x3adf1
movq 0x38(%rsp), %rcx
movq 0x8(%rcx), %rsi
movq 0x30(%rsp), %rax
movl 0x8(%rax), %eax
cmpq %rsi, (%rcx)
je 0x3adcb
movl 0x18(%rsp), %ecx
cmpl %eax, %ecx
jge 0x3adc9
xorl %eax, %eax
jmp 0x3af6a
movl %ecx, %eax
movl %eax, 0x14(%rsp)
movq 0x30(%rsp), %rdx
movq 0x38(%rsp), %rdi
cmpq 0x10(%rdi), %rsi
je 0x3adec
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x3adf1
callq 0x1c69a
leaq 0xd0(%rsp), %rdi
movq %rbx, %rsi
callq 0x302f4
movq 0x90(%rsp), %rax
movq 0x38(%rax), %rsi
movq 0x30(%rsp), %rax
movq (%rax), %rdx
movq %rbp, %rdi
callq 0x1a320
movq 0x40(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x48(%rsp), %rbx
movq 0x50(%rsp), %rax
movq %rax, 0x60(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
testq %r15, %r15
je 0x3ae5c
movq 0x20(%rsp), %rsi
subq %r15, %rsi
movq %r15, %rdi
callq 0x6380
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x3ae73
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x18(%rsp), %rax
movq %rax, %r15
cmpq %rbx, %rax
je 0x3af51
movq (%r15), %r13
movslq (%r13), %rcx
movl %ecx, 0x10(%rsp)
movq 0x98(%rsp), %rdi
movq 0xa0(%rsp), %r8
movq %rcx, %rax
xorl %edx, %edx
divq %r8
movq %rdx, %rsi
movq (%rdi,%rdx,8), %rdx
movl $0x0, %eax
testq %rdx, %rdx
je 0x3aef0
movq (%rdx), %r9
movq %rdx, %rax
cmpl 0x8(%r9), %ecx
je 0x3aef0
movq %r9, %r10
movq (%r9), %r9
testq %r9, %r9
je 0x3aeee
movslq 0x8(%r9), %rdi
movq %rdi, %rax
xorl %edx, %edx
divq %r8
movl $0x0, %eax
cmpq %rsi, %rdx
jne 0x3aef0
movq %r10, %rax
cmpl %edi, %ecx
jne 0x3aec4
jmp 0x3aef0
xorl %eax, %eax
testq %rax, %rax
je 0x3aefb
cmpq $0x0, (%rax)
jne 0x3af44
movl $0x10, %edi
callq 0x6370
movq %r13, (%rax)
movq 0x30(%rsp), %rcx
movl 0x8(%rcx), %ecx
incl %ecx
movl %ecx, 0x8(%rax)
movq %rax, 0x68(%rsp)
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
movq %r14, %rdx
callq 0x3e224
leaq 0xd0(%rsp), %rdi
movq %rdi, 0x40(%rsp)
leaq 0x10(%rsp), %rsi
movq %rbp, %rdx
callq 0x30250
addq $0x8, %r15
cmpq %rbx, %r15
jne 0x3ae84
movq 0x60(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %r15
movl 0x14(%rsp), %eax
movl %eax, 0x18(%rsp)
movb $0x1, %al
testb %al, %al
jne 0x3aced
leaq 0xd0(%rsp), %rdi
callq 0x1b8ca
leaq 0x98(%rsp), %rdi
callq 0x3d94a
testq %r15, %r15
je 0x3afa1
movq 0x20(%rsp), %rsi
subq %r15, %rsi
movq %r15, %rdi
callq 0x6380
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x3afbb
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x38(%rsp), %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
xorl %ebx, %ebx
xorl %r15d, %r15d
jmp 0x3b01d
jmp 0x3afde
movq %rax, %r14
xorl %ebx, %ebx
xorl %r15d, %r15d
jmp 0x3b02a
jmp 0x3aff4
movq %rax, %r14
xorl %ebx, %ebx
xorl %r15d, %r15d
jmp 0x3b037
movq %rax, %r14
movq 0x20(%rsp), %rbx
jmp 0x3b01d
movq %rax, %r14
movq 0x20(%rsp), %rbx
movq 0x88(%rsp), %r15
jmp 0x3b01d
movq %rax, %r14
movq 0x60(%rsp), %rbx
movq 0x18(%rsp), %r15
leaq 0xd0(%rsp), %rdi
callq 0x1b8ca
leaq 0x98(%rsp), %rdi
callq 0x3d94a
testq %r15, %r15
je 0x3b04a
subq %r15, %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x6380
movq 0x38(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3b063
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x3b07d
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq %r14, %rdi
callq 0x6620