// File: /workspace/github_cpp_makefile_star2_O3/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, %r12
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, 0x8(%rsp)
leaq 0x30(%rsp), %rdx
movq %rsi, (%rdx)
movq 0x128(%rdi), %rdi
movq 0x130(%rbx), %rsi
callq 0x388d5
movl $0x1, %r13d
cmpq 0x130(%rbx), %rax
jne 0x3a0a3
leaq 0x30(%rsp), %rdx
movq %r14, (%rdx)
movq 0xe0(%rbx), %rdi
movq 0xe8(%rbx), %rsi
callq 0x388d5
movl $0x2, %r13d
cmpq 0xe8(%rbx), %rax
jne 0x3a0a3
testb %bpl, %bpl
je 0x39d03
movq 0x100(%rbx), %rsi
jmp 0x39d33
movq 0x8(%rsp), %rax
leaq 0x30(%rsp), %rdx
movq %rax, (%rdx)
movq 0xf8(%rbx), %rdi
movq 0x100(%rbx), %rsi
callq 0x388d5
movq 0x100(%rbx), %rsi
cmpq %rsi, %rax
jne 0x3a0a3
movq 0xf8(%rbx), %rdi
leaq 0x8(%rsp), %rdx
callq 0x388d5
movq 0x100(%rbx), %rdx
cmpq %rdx, %rax
je 0x39d76
leaq 0x8(%rax), %rsi
cmpq %rdx, %rsi
je 0x39d6b
subq %rsi, %rdx
movq %rax, %rdi
callq 0x65b0
movq 0x100(%rbx), %rdx
addq $-0x8, %rdx
movq %rdx, 0x100(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x8(%rsp), %rdx
movslq (%rdx), %rax
leal 0x3f(%rax), %ecx
testq %rax, %rax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq 0x160(%rbx), %rcx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
leaq 0x3f(%rsi), %rdi
andq %rax, %rdi
xorl %r8d, %r8d
cmpq %rsi, %rdi
setbe %r8b
movq -0x8(%rcx,%r8,8), %rcx
btq %rax, %rcx
jae 0x39ec3
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x3a1ac
movq %rax, %r13
leaq 0x10(%rsp), %rdx
movq %rax, (%rdx)
movq 0xc8(%rbx), %rdi
movq 0xd0(%rbx), %rsi
xorl %r14d, %r14d
xorl %r15d, %r15d
callq 0x3da56
cmpq 0xd0(%rbx), %rax
jne 0x39e1c
cmpl $0x1, 0x78(%r13)
jne 0x3a0b8
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r14
movq 0x10(%rax), %r15
leaq 0x80(%rsp), %rdi
movq %r12, %rsi
callq 0x19aae
movq 0x38(%rbx), %rsi
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
leaq 0x80(%rsp), %r8
movq %r14, %rdx
movq %r15, %rcx
callq *0x20(%rax)
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %rax
movq %r15, 0x30(%rsp)
movq %rax, 0x38(%rsp)
movq 0x20(%rsp), %r14
movq %r14, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x39ea2
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x8(%rsp), %rsi
movzbl %bpl, %r8d
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
movq %r12, %rcx
callq 0x3a3a0
movl %eax, %r13d
jmp 0x3a040
movq 0x10(%rdx), %rcx
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %r8
callq 0x3a7a6
movq (%r14), %r15
movq 0x8(%r14), %rax
leaq 0x30(%rsp), %rdx
movq %r15, (%rdx)
movq %rax, 0x8(%rdx)
movq 0x10(%r14), %r14
movq %r14, 0x10(%rdx)
movq 0x8(%rsp), %rsi
movzbl %bpl, %ebp
movq %rbx, %rdi
movq %r12, %rcx
movl %ebp, %r8d
callq 0x3a3a0
movl %eax, %r13d
cmpl $0x1, %eax
jne 0x3a040
movq 0x8(%rsp), %rax
leaq 0x10(%rsp), %rdx
movq %rax, (%rdx)
movq 0x98(%rbx), %rdi
movq 0xa0(%rbx), %rsi
callq 0x388d5
movl $0x1, %r13d
cmpq 0xa0(%rbx), %rax
jne 0x3a090
movq 0x8(%rsp), %rdx
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x3a8aa
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
cmpq %rsi, %rdi
je 0x3a028
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rcx
movq %rbx, %rdx
callq 0x3ade0
movq (%rax), %rcx
movq 0x8(%rsp), %rdx
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %r8
callq 0x3a7a6
movq 0x60(%rsp), %rcx
movq 0x68(%rsp), %rax
movq %rcx, 0x58(%rsp)
movq %rcx, 0x30(%rsp)
movq %rax, 0x38(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x50(%rsp)
movq %rax, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
testq %r15, %r15
je 0x39ffc
subq %r15, %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x6380
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x39ffc
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x8(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
movq %r12, %rcx
movl %ebp, %r8d
callq 0x3a3a0
movl %eax, %r13d
movq 0x10(%rsp), %rdi
movq 0x50(%rsp), %r14
movq 0x58(%rsp), %r15
jmp 0x3a02e
movl $0x1, %r13d
testq %rdi, %rdi
je 0x3a040
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
testl %r13d, %r13d
jne 0x3a090
movq 0x8(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x3ae5c
movq 0xe8(%rbx), %rsi
cmpq 0xf0(%rbx), %rsi
je 0x3a079
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0xe8(%rbx)
xorl %r13d, %r13d
jmp 0x3a090
addq $0xe0, %rbx
xorl %r13d, %r13d
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x18f28
testq %r15, %r15
je 0x3a0a3
subq %r15, %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x6380
movl %r13d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
movq 0x27ee6(%rip), %rdi     # 0x61fa8
leaq 0x11399(%rip), %rsi     # 0x4b462
movl $0x29, %edx
xorl %r15d, %r15d
callq 0x63f0
movl (%r13), %esi
xorl %r14d, %r14d
movq 0x27ec4(%rip), %rdi     # 0x61fa8
xorl %r15d, %r15d
callq 0x6610
movq %rax, %rbx
xorl %r14d, %r14d
leaq 0x11393(%rip), %rsi     # 0x4b48c
movl $0xa, %edx
xorl %r15d, %r15d
movq %rax, %rdi
callq 0x63f0
movl 0x78(%r13), %esi
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %rbx, %rdi
callq 0x6610
xorl %r14d, %r14d
leaq 0xe43e(%rip), %rsi      # 0x48563
xorl %r15d, %r15d
movq %rax, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440
movq %rax, %rbx
movq 0x50(%rsp), %r14
movq 0x58(%rsp), %r15
jmp 0x3a14e
jmp 0x3a14b
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3a190
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x3a190
jmp 0x3a18d
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x3a1a3
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
jmp 0x3a19e
movq %rax, %rbx
jmp 0x3a1a3
jmp 0x3a18d
movq %rax, %rbx
testq %r15, %r15
je 0x3a1a3
subq %r15, %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x6380
movq %rbx, %rdi
callq 0x6620
nop