// File: /workspace/github_cpp_makefile_star2_O2/Kei18[P]pibt/./src/solver/pps.cpp
// Function: PPS::CHECK_SWAPER(S*)
CHECK PPS::CHECK_SWAPER(S* s) {
  // error check
  int num = s->agents.size();
  if (num < 2 || 3 < num) {
    std::cout << "error@PPS::CHECK_SWAPER, swaper "
              << s->id << " has invalid agents" << "\n";
    std::exit(1);
  }

  // check temporaly resolved by other swapers
  if (inArray(s, doneSwapers)) {
    return CHECK::INVALID;
  }

  if ((int)s->phase >= (int)SWAPPHASE::EVAC_H) {
    return CHECK::VALID;
  }

  Agent* aH = s->agents[0];  // center
  Agent* aL = s->agents[1];
  Nodes neighbor = G->neighbor(aH->getNode());
  bool aL2aH = inArray(aL->getNode(), neighbor);

  bool aE2aH = true;
  if (num == 3) {
    Agent* aE = s->agents[2];
    aE2aH = inArray(aE->getNode(), neighbor);
  }

  Nodes piH = SHORTEST_PATH(aH->getNode(), aH->getGoal());
  Nodes piL = SHORTEST_PATH(aL->getNode(), aL->getGoal());
  bool depend = DEPEND(piH, piL) || DEPEND(piL, piH);

  if (aL2aH && aE2aH && depend) return CHECK::VALID;

  // if separated
  ADD_DONE_SWAPERS(s);
  return CHECK::INVALID;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %rbx
movq 0x10(%rsi), %r13
subq 0x8(%rsi), %r13
shrq $0x3, %r13
leal -0x4(%r13), %eax
cmpl $-0x3, %eax
jbe 0x2e697
movq %rdi, %r14
leaq 0xc8(%rdi), %rsi
movq %rbx, %rdi
callq 0x2f019
testb %al, %al
je 0x2e52d
pushq $0x1
popq %rbp
jmp 0x2e683
xorl %ebp, %ebp
cmpl $0x1, 0x78(%rbx)
jg 0x2e683
movq 0x8(%rbx), %rax
movq (%rax), %rbp
movq 0x8(%rax), %r12
movq 0x38(%r14), %rsi
movq 0x8(%rbp), %rdx
leaq 0x90(%rsp), %r15
movq %r15, %rdi
callq 0x164ca
movq 0x8(%r12), %rdi
movq %r15, %rsi
callq 0x2fc19
movl %eax, %r15d
movb $0x1, %al
cmpl $0x3, %r13d
jne 0x2e58d
movq 0x8(%rbx), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x90(%rsp), %rsi
callq 0x2fc19
movl %eax, %r13d
movq 0x8(%rbp), %rdx
movq 0x10(%rbp), %rcx
movq 0x38(%r14), %rsi
movq (%rsi), %rax
leaq 0x18(%rsp), %rdi
callq *0x18(%rax)
movq 0x8(%r12), %rdx
movq 0x10(%r12), %rcx
movq 0x38(%r14), %rsi
movq (%rsi), %rax
movq %rsp, %rdi
callq *0x18(%rax)
leaq 0x78(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x15d3a
leaq 0x60(%rsp), %rdi
movq %rsp, %rsi
callq 0x15d3a
leaq 0x78(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x2fc42
movb $0x1, %r12b
testb %al, %al
jne 0x2e632
leaq 0x48(%rsp), %rdi
movq %rsp, %rsi
callq 0x15d3a
leaq 0x30(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x15d3a
leaq 0x48(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x2fc42
movl %eax, %r12d
leaq 0x30(%rsp), %rdi
callq 0x990e
leaq 0x48(%rsp), %rdi
callq 0x990e
leaq 0x60(%rsp), %rdi
callq 0x990e
leaq 0x78(%rsp), %rdi
callq 0x990e
andb %r13b, %r15b
cmpb $0x1, %r15b
jne 0x2e656
xorl %ebp, %ebp
testb %r12b, %r12b
jne 0x2e664
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2fee4
pushq $0x1
popq %rbp
movq %rsp, %rdi
callq 0x990e
leaq 0x18(%rsp), %rdi
callq 0x990e
leaq 0x90(%rsp), %rdi
callq 0x990e
movl %ebp, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2b8fa(%rip), %rdi     # 0x59f98
leaq 0xef53(%rip), %rsi      # 0x3d5f8
callq 0x63a0
movl (%rbx), %esi
movq %rax, %rdi
callq 0x6630
leaq 0xef5e(%rip), %rsi      # 0x3d619
movq %rax, %rdi
callq 0x63a0
leaq 0xbe99(%rip), %rsi      # 0x3a563
movq %rax, %rdi
callq 0x63a0
pushq $0x1
popq %rdi
callq 0x6450
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x990e
jmp 0x2e6ec
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x990e
jmp 0x2e70e
jmp 0x2e706
movq %rax, %rbx
jmp 0x2e718
movq %rax, %rbx
jmp 0x2e72f
jmp 0x2e706
movq %rax, %rbx
jmp 0x2e739
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x990e
leaq 0x78(%rsp), %rdi
callq 0x990e
jmp 0x2e727
movq %rax, %rbx
movq %rsp, %rdi
callq 0x990e
leaq 0x18(%rsp), %rdi
callq 0x990e
leaq 0x90(%rsp), %rdi
callq 0x990e
movq %rbx, %rdi
callq 0x6650