// File: /workspace/github_cpp_makefile_star2_O1/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 $0xb8, %rsp
movq %rsi, %rbx
movq 0x10(%rsi), %rbp
subq 0x8(%rsi), %rbp
shrq $0x3, %rbp
leal -0x4(%rbp), %eax
cmpl $-0x3, %eax
jbe 0x398cd
movq %rdi, %r14
leaq 0x20(%rsp), %rdx
movq %rbx, (%rdx)
movq 0xc8(%rdi), %rdi
movq 0xd0(%r14), %rsi
callq 0x3dd58
movl $0x1, %r15d
cmpq 0xd0(%r14), %rax
jne 0x398b8
xorl %r15d, %r15d
cmpl $0x1, 0x78(%rbx)
jg 0x398b8
movq 0x8(%rbx), %rax
movq (%rax), %r12
movq 0x8(%rax), %r13
movq 0x38(%r14), %rsi
movq 0x8(%r12), %rdx
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq 0x1a320
movq 0x8(%r13), %rax
leaq 0x8(%rsp), %rdx
movq %rax, (%rdx)
movq (%r15), %rdi
movq 0x8(%r15), %rsi
callq 0x19ae8
movq %rax, 0x50(%rsp)
movq 0x28(%rsp), %r15
cmpl $0x3, %ebp
jne 0x39731
movq 0x8(%rbx), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
leaq 0x8(%rsp), %rdx
movq %rax, (%rdx)
movq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x19ae8
cmpq 0x28(%rsp), %rax
sete %al
movl %eax, 0x4(%rsp)
jmp 0x39739
movl $0x0, 0x4(%rsp)
movq 0x8(%r12), %rdx
movq 0x10(%r12), %rcx
movq 0x38(%r14), %rsi
movq (%rsi), %rax
leaq 0x8(%rsp), %rdi
callq *0x18(%rax)
movq 0x8(%r13), %rdx
movq 0x10(%r13), %rcx
movq 0x38(%r14), %rsi
movq (%rsi), %rax
leaq 0x38(%rsp), %rdi
callq *0x18(%rax)
leaq 0xa0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x19a68
leaq 0x88(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x19a68
leaq 0xa0(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x3b64c
movl %eax, %r13d
movb $0x1, %bpl
testb %al, %al
jne 0x397db
leaq 0x70(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x19a68
leaq 0x58(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x19a68
leaq 0x70(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x3b64c
movl %eax, %ebp
testb %r13b, %r13b
jne 0x39811
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x397f7
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x39811
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x3982e
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x3984b
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
cmpq %r15, 0x50(%rsp)
sete %al
orb 0x4(%rsp), %al
jne 0x39862
xorl %r15d, %r15d
xorb $0x1, %bpl
je 0x39873
movl $0x1, %r15d
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3b9ee
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x3988a
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x398a1
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x398b8
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movl %r15d, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x286d4(%rip), %rdi     # 0x61fa8
leaq 0x11b45(%rip), %rsi     # 0x4b420
callq 0x6360
movl (%rbx), %esi
movq %rax, %rdi
callq 0x6610
leaq 0x11b50(%rip), %rsi     # 0x4b441
movq %rax, %rdi
callq 0x6360
leaq 0xec63(%rip), %rsi      # 0x48563
movq %rax, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440
movq %rax, %rbx
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x39931
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x39931
movq %rax, %rbx
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x39963
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x39963
jmp 0x3995b
movq %rax, %rbx
jmp 0x39980
movq %rax, %rbx
jmp 0x399b9
jmp 0x3995b
movq %rax, %rbx
jmp 0x399d0
movq %rax, %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x39980
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x399a2
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x399a2
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x399b9
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x399d0
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x399e7
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq %rbx, %rdi
callq 0x6620
nop