// File: /workspace/github_cpp_makefile_star2_O3/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, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq (%rdx), %rax
movq 0x8(%rdx), %rcx
subq %rax, %rcx
movl $0x1, %r12d
cmpq $0x9, %rcx
jb 0x3a712
movl %r8d, %ebp
movq %rsi, %r15
movq %rdi, %r14
movq 0x8(%rax), %r13
leaq 0x10(%rsp), %rdx
movq %rsi, (%rdx)
movq 0xe0(%rdi), %rdi
movq 0xe8(%r14), %rsi
callq 0x388d5
cmpq 0xe8(%r14), %rax
jne 0x3a712
leaq 0xe0(%r14), %rdx
movq %r13, %rsi
callq 0x3b2f4
movl $0x2, %r12d
testb %al, %al
jne 0x3a712
leaq 0x10(%rsp), %rdx
movq %r13, (%rdx)
movq 0x110(%r14), %rdi
movq 0x118(%r14), %rsi
callq 0x19b2e
cmpq 0x118(%r14), %rax
jne 0x3a712
movq 0x20(%r14), %rbx
movq 0x28(%r14), %rax
movq %rax, %rsi
subq %rbx, %rsi
movq %rsi, %rdx
sarq $0x5, %rdx
testq %rdx, %rdx
jle 0x3a4b6
andq $-0x20, %rsi
movq %rsi, %rcx
addq %rbx, %rcx
incq %rdx
addq $0x10, %rbx
movq -0x10(%rbx), %rsi
cmpq %r13, 0x8(%rsi)
je 0x3a4fc
movq -0x8(%rbx), %rsi
cmpq %r13, 0x8(%rsi)
je 0x3a502
movq (%rbx), %rsi
cmpq %r13, 0x8(%rsi)
je 0x3a50c
movq 0x8(%rbx), %rsi
cmpq %r13, 0x8(%rsi)
je 0x3a508
decq %rdx
addq $0x20, %rbx
cmpq $0x1, %rdx
jg 0x3a47a
movq %rax, %rsi
subq %rcx, %rsi
jmp 0x3a4b9
movq %rbx, %rcx
sarq $0x3, %rsi
cmpq $0x1, %rsi
je 0x3a4ec
cmpq $0x2, %rsi
je 0x3a4df
movq %rax, %rbx
cmpq $0x3, %rsi
jne 0x3a50c
movq (%rcx), %rdx
cmpq %r13, 0x8(%rdx)
je 0x3a4f7
addq $0x8, %rcx
movq (%rcx), %rdx
cmpq %r13, 0x8(%rdx)
je 0x3a4f7
addq $0x8, %rcx
movq (%rcx), %rdx
cmpq %r13, 0x8(%rdx)
cmovneq %rax, %rcx
movq %rcx, %rbx
jmp 0x3a50c
addq $-0x10, %rbx
jmp 0x3a50c
addq $-0x8, %rbx
jmp 0x3a50c
addq $0x8, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x20(%rsp)
movq %rcx, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
cmpq %rax, %rbx
sete %cl
orb %bpl, %cl
jne 0x3a62f
movq (%rbx), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x39bf2
movl $0x1, %r12d
testb %al, %al
jne 0x3a6e4
movq 0x8(%r15), %rdx
movq 0x10(%r15), %rcx
movq 0x38(%r14), %rsi
movq (%rsi), %rax
leaq 0x90(%rsp), %rdi
callq *0x18(%rax)
leaq 0x90(%rsp), %rdi
movaps (%rdi), %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0x10(%rdi), %rax
movq %rax, 0x20(%rsp)
movq 0x38(%r14), %rsi
movq 0x8(%r13), %rdx
movq 0x10(%r13), %rcx
movq (%rsi), %rax
callq *0x18(%rax)
movaps 0x90(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x19aae
leaq 0x60(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x19aae
leaq 0x78(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x3b3b8
movb %al, 0xf(%rsp)
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x3a5f7
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x3a611
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
cmpb $0x0, 0xf(%rsp)
je 0x3a69c
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x3b44e
jmp 0x3a6e4
cmpq %rax, %rbx
sete %cl
movl %ebp, %edx
xorb $0x1, %dl
orb %cl, %dl
jne 0x3a693
movq (%rbx), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x39bf2
testb %al, %al
je 0x3a69c
movq 0x128(%r14), %rax
cmpq 0x130(%r14), %rax
leaq 0x50(%rsp), %rcx
cmovneq %rax, %rcx
movq (%rcx), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x39bf2
testb %al, %al
je 0x3a69c
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x3b6d8
movl $0x1, %r12d
testl %eax, %eax
jne 0x3a6e4
jmp 0x3a69c
cmpq %rax, %rbx
je 0x3a727
movq (%rbx), %r12
movq 0x130(%r14), %rsi
cmpq 0x138(%r14), %rsi
je 0x3a6bc
movq %r15, (%rsi)
addq $0x8, 0x130(%r14)
jmp 0x3a6cd
leaq 0x128(%r14), %rdi
leaq 0x50(%rsp), %rdx
callq 0x18f28
movzbl %bpl, %ecx
movq %r14, %rdi
movq %r12, %rsi
movq 0x58(%rsp), %rdx
callq 0x39c78
movl %eax, %r12d
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x3a6fb
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3a712
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movl %r12d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r12d, %r12d
jmp 0x3a6e4
jmp 0x3a76d
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x3a74d
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x3a74d
movq %rax, %rbx
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x3a770
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x3a770
jmp 0x3a76d
jmp 0x3a76d
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x3a787
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3a79e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq %rbx, %rdi
callq 0x6620