// File: /workspace/github_cpp_makefile_star2_O1/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 $0xa8, %rsp
movq %rcx, %rbx
movq %rsi, 0x8(%rsp)
movq (%rdx), %rax
movq 0x8(%rdx), %rcx
subq %rax, %rcx
movl $0x1, %r15d
cmpq $0x9, %rcx
jb 0x3aa2a
movl %r8d, %ebp
movq %rdi, %r14
movq 0x8(%rax), %r12
leaq 0x30(%rsp), %rdx
movq %rsi, (%rdx)
movq 0xe0(%rdi), %rdi
movq 0xe8(%r14), %rsi
callq 0x38b4d
cmpq 0xe8(%r14), %rax
jne 0x3aa2a
leaq 0xe0(%r14), %rdx
movq %r12, %rsi
callq 0x3b58a
movl $0x2, %r15d
testb %al, %al
jne 0x3aa2a
leaq 0x30(%rsp), %rdx
movq %r12, (%rdx)
movq 0x110(%r14), %rdi
movq 0x118(%r14), %rsi
callq 0x19ae8
cmpq 0x118(%r14), %rax
jne 0x3aa2a
movq 0x20(%r14), %rcx
movq 0x28(%r14), %rax
movq %rax, %rdx
subq %rcx, %rdx
movq %rdx, %rsi
sarq $0x5, %rsi
testq %rsi, %rsi
jle 0x3a737
andq $-0x20, %rdx
addq %rcx, %rdx
incq %rsi
addq $0x10, %rcx
movq %rcx, %r13
movq -0x10(%r13), %rcx
cmpq %r12, 0x8(%rcx)
je 0x3a780
movq -0x8(%r13), %rcx
cmpq %r12, 0x8(%rcx)
je 0x3a786
movq (%r13), %rcx
cmpq %r12, 0x8(%rcx)
je 0x3a790
movq 0x8(%r13), %rcx
cmpq %r12, 0x8(%rcx)
je 0x3a78c
decq %rsi
addq $0x20, %r13
cmpq $0x1, %rsi
jg 0x3a6ff
movq %rdx, %rcx
movq %rax, %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
je 0x3a770
cmpq $0x2, %rdx
je 0x3a763
movq %rax, %r13
cmpq $0x3, %rdx
jne 0x3a790
movq (%rcx), %rdx
cmpq %r12, 0x8(%rdx)
je 0x3a77b
addq $0x8, %rcx
movq (%rcx), %rdx
cmpq %r12, 0x8(%rdx)
je 0x3a77b
addq $0x8, %rcx
movq (%rcx), %rdx
cmpq %r12, 0x8(%rdx)
cmovneq %rax, %rcx
movq %rcx, %r13
jmp 0x3a790
addq $-0x10, %r13
jmp 0x3a790
addq $-0x8, %r13
jmp 0x3a790
addq $0x8, %r13
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x40(%rsp)
movq %rcx, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
cmpq %rax, %r13
sete %cl
orb %bpl, %cl
jne 0x3a942
movq (%r13), %rsi
movq %r14, %rdi
movq %rsi, 0x70(%rsp)
callq 0x39e60
movl $0x1, %r15d
testb %al, %al
jne 0x3a9fc
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
movq 0x38(%r14), %rsi
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *0x18(%rax)
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
movups 0x18(%rsp), %xmm0
movups %xmm0, 0x38(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
testq %rdi, %rdi
je 0x3a82f
subq %rdi, %rsi
callq 0x6380
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3a846
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x70(%rsp), %rax
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
movq 0x38(%r14), %rsi
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *0x18(%rax)
movq 0x50(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x10(%rsp), %rax
movq %rax, 0x50(%rsp)
movups 0x18(%rsp), %xmm0
movups %xmm0, 0x58(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
testq %rdi, %rdi
je 0x3a89e
subq %rdi, %rsi
callq 0x6380
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3a8b5
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
leaq 0x90(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x19a68
leaq 0x78(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x19a68
leaq 0x90(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x3b64c
movl %eax, %r12d
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x3a905
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x3a922
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
testb %r12b, %r12b
je 0x3a9b0
movq 0x8(%rsp), %rsi
movq %r14, %rdi
movq 0x70(%rsp), %rdx
callq 0x3b6e4
jmp 0x3a9fc
cmpq %rax, %r13
sete %cl
movl %ebp, %edx
xorb $0x1, %dl
orb %cl, %dl
jne 0x3a9a7
movq (%r13), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x39e60
testb %al, %al
je 0x3a9b0
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 0x39e60
testb %al, %al
je 0x3a9b0
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x3b98c
movl $0x1, %r15d
testl %eax, %eax
jne 0x3a9fc
jmp 0x3a9b0
cmpq %rax, %r13
je 0x3aa3f
movq (%r13), %r15
movq 0x130(%r14), %rsi
cmpq 0x138(%r14), %rsi
je 0x3a9d6
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x130(%r14)
jmp 0x3a9e7
leaq 0x128(%r14), %rdi
leaq 0x8(%rsp), %rdx
callq 0x18edc
movzbl %bpl, %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x39f0e
movl %eax, %r15d
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x3aa13
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x3aa2a
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movl %r15d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
jmp 0x3a9fc
jmp 0x3aa8b
movq %rax, %rbx
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x3aa68
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x3aa68
movq %rax, %rbx
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x3aa8e
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x3aa8e
jmp 0x3aa8b
jmp 0x3aa8b
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x3aaa5
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x3aabc
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq %rbx, %rdi
callq 0x6620