// File: /workspace/github_cpp_makefile_star2_O2/Kei18[P]pibt/./src/solver/pps.cpp
// Function: PPS::FEASIBLE(Agent*, std::vector<Node*, std::allocator<Node*>>&, std::vector<Node*, std::allocator<Node*>>&, bool)
RES PPS::FEASIBLE(Agent* c, Nodes &pi, Nodes &T, bool swap) {
  if (pi.size() < 2) return RES::FAIL;  // l.1
  Node* v = pi[1];  // l.2

  if (inArray(c, M)) {
    return RES::FAIL;
  }

  if (reserved(v, M)) {  // l.3
    return RES::PAUSE;  // l.4
  }

  if (inArray(v, L)) {  // l.5, reserved
    return RES::PAUSE;  // l.6
  }

  auto itrA = std::find_if(A.begin(), A.end(),
                           [v] (Agent* a) { return a->getNode() == v; });
  Nodes pi_one, pi_two;
  Agent* a = nullptr;

  if (itrA != A.end() && swap == false) {  // l.10
    a = *itrA;
    if (inS(a)) return RES::FAIL;  // l.11

    pi_one = SHORTEST_PATH(c->getNode(), c->getGoal());  // l.12
    pi_two = SHORTEST_PATH(a->getNode(), a->getGoal());  // l.13

    if (DEPEND(pi_one, pi_two)) {  // l.15
      SETUP_SWAP(c, a);  // l.16 & 17
      return RES::FAIL;  // l.18
    }

  } else if (itrA != A.end() && swap == true) {  // l.19
    a = *itrA;
    if (inS(a)) {  // l.20
      Agent* origin = c;
      if (!H.empty()) origin = H[0];
      if (inS(origin)) {
        if (CHECK_PRIORITY(origin, a) == CHECK::INVALID) {
          return RES::FAIL;  // l.22
        }
      }
    }
  } else if (itrA == A.end()) {
    return RES::SUCCESS;  // l.23
  }

  a = *itrA;
  H.push_back(c);
  return PUSH(a, T, swap);  // l.24, recursive push
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rcx, 0x48(%rsp)
movq %rsi, 0x8(%rsp)
movq (%rdx), %rax
movq 0x8(%rdx), %rcx
subq %rax, %rcx
pushq $0x1
popq %r12
cmpq $0x9, %rcx
jb 0x2f337
movl %r8d, %ebp
movq %rsi, %r15
movq %rdi, %r14
movq 0x8(%rax), %r13
leaq 0xe0(%rdi), %rbx
movq %rsi, %rdi
movq %rbx, %rsi
callq 0x2ea4f
testb %al, %al
jne 0x2f337
movq %r13, %rsi
movq %rbx, %rdx
callq 0x2fb72
pushq $0x2
popq %r12
testb %al, %al
jne 0x2f337
leaq 0x110(%r14), %rsi
movq %r13, %rdi
callq 0x2fc19
testb %al, %al
jne 0x2f337
movq 0x20(%r14), %rcx
movq 0x28(%r14), %rax
movq %rax, %rdx
subq %rcx, %rdx
movq %rdx, %rsi
sarq $0x5, %rsi
testq %rsi, %rsi
jle 0x2f12c
movq (%rcx), %rdi
cmpq %r13, 0x8(%rdi)
je 0x2f17c
movq 0x8(%rcx), %rdi
cmpq %r13, 0x8(%rdi)
je 0x2f16c
movq 0x10(%rcx), %rdi
cmpq %r13, 0x8(%rdi)
je 0x2f172
movq 0x18(%rcx), %rdi
cmpq %r13, 0x8(%rdi)
je 0x2f178
addq $0x20, %rcx
decq %rsi
addq $-0x20, %rdx
jmp 0x2f0f3
sarq $0x3, %rdx
cmpq $0x1, %rdx
je 0x2f15f
cmpq $0x2, %rdx
je 0x2f152
movq %rax, %rbx
cmpq $0x3, %rdx
jne 0x2f17f
movq (%rcx), %rdx
cmpq %r13, 0x8(%rdx)
je 0x2f17c
addq $0x8, %rcx
movq (%rcx), %rdx
cmpq %r13, 0x8(%rdx)
je 0x2f17c
addq $0x8, %rcx
movq (%rcx), %rdx
cmpq %r13, 0x8(%rdx)
cmovneq %rax, %rcx
jmp 0x2f17c
addq $0x8, %rcx
jmp 0x2f17c
addq $0x10, %rcx
jmp 0x2f17c
addq $0x18, %rcx
movq %rcx, %rbx
xorps %xmm0, %xmm0
andq $0x0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
cmpq %rax, %rbx
sete %cl
orb %bpl, %cl
jne 0x2f291
movq (%rbx), %rsi
movq %r14, %rdi
movq %rsi, (%rsp)
callq 0x2ea90
pushq $0x1
popq %r12
testb %al, %al
jne 0x2f323
movq 0x8(%r15), %rdx
movq 0x10(%r15), %rcx
movq 0x38(%r14), %rsi
movq (%rsi), %rax
leaq 0x80(%rsp), %rdi
callq *0x18(%rax)
leaq 0x30(%rsp), %rdi
leaq 0x80(%rsp), %r13
movq %r13, %rsi
callq 0x18466
movq %r13, %rdi
callq 0x990e
movq (%rsp), %rax
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
movq 0x38(%r14), %rsi
movq (%rsi), %rax
leaq 0x80(%rsp), %rdi
callq *0x18(%rax)
leaq 0x10(%rsp), %rdi
leaq 0x80(%rsp), %r13
movq %r13, %rsi
callq 0x18466
movq %r13, %rdi
callq 0x990e
leaq 0x68(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x15d3a
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x15d3a
leaq 0x68(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x2fc42
movl %eax, %r13d
leaq 0x50(%rsp), %rdi
callq 0x990e
leaq 0x68(%rsp), %rdi
callq 0x990e
testb %r13b, %r13b
je 0x2f2f8
movq %r14, %rdi
movq %r15, %rsi
movq (%rsp), %rdx
callq 0x2fca6
jmp 0x2f323
cmpq %rax, %rbx
sete %cl
movl %ebp, %edx
xorb $0x1, %dl
orb %cl, %dl
jne 0x2f2f3
movq (%rbx), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2ea90
testb %al, %al
je 0x2f2f8
movq 0x128(%r14), %rax
cmpq 0x130(%r14), %rax
leaq 0x8(%rsp), %rcx
cmovneq %rax, %rcx
movq (%rcx), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x2ea90
testb %al, %al
je 0x2f2f8
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x2fe82
testl %eax, %eax
je 0x2f2f8
pushq $0x1
popq %r12
jmp 0x2f323
cmpq %rax, %rbx
je 0x2f34c
movq (%rbx), %r15
leaq 0x128(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0x930e
movzbl %bpl, %ecx
movq %r14, %rdi
movq %r15, %rsi
movq 0x48(%rsp), %rdx
callq 0x2eaf6
movl %eax, %r12d
leaq 0x10(%rsp), %rdi
callq 0x990e
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
xorl %r12d, %r12d
jmp 0x2f323
jmp 0x2f375
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x990e
jmp 0x2f365
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x990e
jmp 0x2f378
jmp 0x2f375
jmp 0x2f375
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x990e
leaq 0x30(%rsp), %rdi
callq 0x990e
movq %rbx, %rdi
callq 0x6650