// File: /workspace/github_cpp_makefile_star2_O2/Kei18[P]pibt/./src/solver/pps.cpp
// Function: PPS::PUSH(Agent*, std::vector<Node*, std::allocator<Node*>>&, bool)
RES PPS::PUSH(Agent* c, Nodes &T, bool swap) {
  if (inArray(c, H)) return RES::FAIL;   // l.1
  if (inArray(c, M)) return RES::PAUSE;  // l.2
  if (swap == false && inArray(c, U)) return PAUSE;  // l.3

  auto itrU = std::find(U.begin(), U.end(), c);
  if (itrU != U.end()) U.erase(itrU);  // l.4

  Nodes pi;
  RES attempt;
  if (isTmpGoals[c->getId()]) {  // l.5, used when swapping, case 3
    S* s = getS(c);
    // error check
    if (!inArray(s, doneSwapers) && s->phase != SWAPPHASE::CLEARING) {
      std::cout << "error@PPS::PUSH, invalid swap phase, s : "
                << s->id << ", phase : " << s->phase << "\n";
      std::exit(1);
    }
    pi = SHORTEST_PATH(c->getNode(), c->getGoal(), T);  // l.6
    attempt = FEASIBLE(c, pi, T, swap);     // l.16

  } else {

    pi = SHORTEST_PATH(c, c->getGoal(), T); // l.8
    attempt = FEASIBLE(c, pi, T, swap);     // l.9

    // exclude swap detected agents
    if (attempt == RES::FAIL && !inArray(c, pusherToSwaper)) {  // l.12
      Nodes Y = CLOSEST_EMPTY_VERTICLES(c);

      if (!Y.empty()) {
        Node* g = c->getGoal();
        Node* e = *std::min_element(Y.begin(), Y.end(),
                                   [this, g] (Node* e1, Node* e2)
                                   { return this->pathDist(e1, g)
                                       < this->pathDist(e2, g); });  // l.14
        pi = SHORTEST_PATH(c, e, T);  // l.15
        attempt = FEASIBLE(c, pi, T, swap);  // l.16
      }
    }
  }

  if (attempt == RES::SUCCESS) {  // l.17
    move(c, pi);  // l.18
    M.push_back(c);  // l.18
  }

  return attempt;  // l.19
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r15
movq %rsi, 0x8(%rsp)
leaq 0x128(%rdi), %rsi
movq %r13, %rdi
callq 0x2ea4f
testb %al, %al
je 0x2eb33
pushq $0x1
popq %r12
jmp 0x2ee09
leaq 0xe0(%r15), %rbx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2ea4f
pushq $0x2
popq %r12
testb %al, %al
jne 0x2ee09
testb %bpl, %bpl
jne 0x2eb6d
leaq 0xf8(%r15), %rsi
movq %r13, %rdi
callq 0x2ea4f
testb %al, %al
jne 0x2ee09
movq 0xf8(%r15), %rdi
movq 0x100(%r15), %rsi
leaq 0x8(%rsp), %rdx
callq 0x2dcba
cmpq 0x100(%r15), %rax
je 0x2eb9d
leaq 0xf8(%r15), %rdi
movq %rax, %rsi
callq 0x2d97c
xorps %xmm0, %xmm0
andq $0x0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
leaq 0x160(%r15), %rdi
movq 0x8(%rsp), %rax
movslq (%rax), %rsi
callq 0x315e8
testq %rdx, (%rax)
je 0x2ec71
movq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x2eeac
movq %rax, %r12
leaq 0xc8(%r15), %rsi
movq %rax, %rdi
callq 0x2f019
testb %al, %al
jne 0x2ebf7
cmpl $0x1, 0x78(%r12)
jne 0x2ee1e
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r12
movq 0x10(%rax), %r13
leaq 0x68(%rsp), %rdi
movq %r14, %rsi
callq 0x15d3a
movq 0x38(%r15), %rsi
movq (%rsi), %rax
leaq 0x18(%rsp), %rdi
leaq 0x68(%rsp), %r8
movq %r12, %rdx
movq %r13, %rcx
callq *0x20(%rax)
leaq 0x30(%rsp), %r12
leaq 0x18(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x18466
movq %r13, %rdi
callq 0x990e
leaq 0x68(%rsp), %rdi
callq 0x990e
movq 0x8(%rsp), %rsi
movzbl %bpl, %r8d
movq %r15, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x2f056
movl %eax, %r12d
jmp 0x2eddb
movq 0x8(%rsp), %rdx
movq 0x10(%rdx), %rcx
leaq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %r14, %r8
callq 0x2f394
leaq 0x30(%rsp), %r12
leaq 0x18(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x18466
movq %r13, %rdi
callq 0x990e
movq 0x8(%rsp), %rsi
movzbl %bpl, %r8d
movq %r15, %rdi
movq %r12, %rdx
movq %r14, %rcx
movl %r8d, 0x14(%rsp)
callq 0x2f056
movl %eax, %r12d
cmpl $0x1, %eax
jne 0x2eddb
movq 0x8(%rsp), %rdi
leaq 0x98(%r15), %rsi
callq 0x2ea4f
testb %al, %al
je 0x2eced
pushq $0x1
popq %r12
jmp 0x2edff
movq %r14, 0x58(%rsp)
movq 0x8(%rsp), %rdx
leaq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x2f472
movq 0x18(%rsp), %r14
movq 0x20(%rsp), %rax
movq %rax, 0x60(%rsp)
cmpq %rax, %r14
je 0x2edcd
movq %rbx, 0x50(%rsp)
movq 0x8(%rsp), %rax
movq 0x10(%rax), %r12
leaq 0x8(%r14), %rbx
cmpq 0x60(%rsp), %rbx
je 0x2ed6b
movq (%rbx), %rsi
movq (%r14), %rbp
movq %r15, %rdi
movq %r12, %rdx
callq 0x32cd4
movl %eax, %r13d
movq %r15, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x32cd4
movq %rbx, %rcx
cmpl %eax, %r13d
jl 0x2ed62
movq %r14, %rcx
addq $0x8, %rbx
movq %rcx, %r14
jmp 0x2ed2e
movq (%r14), %rcx
movq 0x8(%rsp), %rdx
leaq 0x80(%rsp), %rdi
movq %r15, %rsi
movq 0x58(%rsp), %rbx
movq %rbx, %r8
callq 0x2f394
leaq 0x30(%rsp), %r12
leaq 0x80(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x18466
movq %r13, %rdi
callq 0x990e
movq 0x8(%rsp), %rsi
movq %r15, %rdi
movq %r12, %rdx
movq %rbx, %rcx
movl 0x14(%rsp), %r8d
callq 0x2f056
movq 0x50(%rsp), %rbx
movl %eax, %r12d
jmp 0x2edd1
pushq $0x1
popq %r12
leaq 0x18(%rsp), %rdi
callq 0x990e
testl %r12d, %r12d
jne 0x2edff
movq 0x8(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x2f7ba
xorl %r12d, %r12d
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x930e
leaq 0x30(%rsp), %rdi
callq 0x990e
movl %r12d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2b173(%rip), %rdi     # 0x59f98
leaq 0xe797(%rip), %rsi      # 0x3d5c3
callq 0x63a0
movl (%r12), %esi
movq %rax, %rdi
callq 0x6630
leaq 0xe7a9(%rip), %rsi      # 0x3d5ed
movq %rax, %rdi
callq 0x63a0
movl 0x78(%r12), %esi
movq %rax, %rdi
callq 0x6630
leaq 0xb703(%rip), %rsi      # 0x3a563
movq %rax, %rdi
callq 0x63a0
pushq $0x1
popq %rdi
callq 0x6450
jmp 0x2ee8d
jmp 0x2ee8d
jmp 0x2ee88
jmp 0x2ee88
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0x2ee95
jmp 0x2ee88
jmp 0x2ee88
jmp 0x2ee88
movq %rax, %rbx
jmp 0x2ee9a
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x990e
leaq 0x30(%rsp), %rdi
callq 0x990e
movq %rbx, %rdi
callq 0x6650