// File: 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
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
callq 0x383b0
movl %eax, -0x1c(%rbp)
cmpl $0x2, -0x1c(%rbp)
jl 0x8e8fe
movl $0x3, %eax
cmpl -0x1c(%rbp), %eax
jge 0x8e947
movq 0x72693(%rip), %rdi     # 0x100f98
leaq 0x2824e(%rip), %rsi     # 0xb6b5a
callq 0x84d0
movq %rax, %rdi
movq -0x18(%rbp), %rax
movl (%rax), %esi
callq 0x8860
movq %rax, %rdi
leaq 0x28252(%rip), %rsi     # 0xb6b7b
callq 0x84d0
movq %rax, %rdi
leaq 0x24c7f(%rip), %rsi     # 0xb35b7
callq 0x84d0
movl $0x1, %edi
callq 0x85d0
movq -0x118(%rbp), %rsi
movq -0x18(%rbp), %rdi
addq $0xc8, %rsi
callq 0x8fd90
testb $0x1, %al
jne 0x8e964
jmp 0x8e970
movl $0x1, -0x4(%rbp)
jmp 0x8ed82
movq -0x18(%rbp), %rax
cmpl $0x2, 0x78(%rax)
jl 0x8e986
movl $0x0, -0x4(%rbp)
jmp 0x8ed82
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x53720
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
movl $0x1, %esi
callq 0x53720
movq %rax, %rcx
movq -0x118(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x30(%rbp)
movq 0x38(%rax), %rax
movq %rax, -0x128(%rbp)
movq -0x28(%rbp), %rdi
callq 0x51cb0
movq -0x128(%rbp), %rsi
movq %rax, %rdx
leaq -0x48(%rbp), %rdi
callq 0x3c8d0
movq -0x30(%rbp), %rdi
callq 0x51cb0
movq %rax, -0x120(%rbp)
jmp 0x8e9fa
movq -0x120(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x91410
movb %al, -0x129(%rbp)
jmp 0x8ea12
movb -0x129(%rbp), %al
andb $0x1, %al
movb %al, -0x49(%rbp)
movb $0x1, -0x5d(%rbp)
cmpl $0x3, -0x1c(%rbp)
jne 0x8ea88
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
movl $0x2, %esi
callq 0x53720
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x51cb0
movq %rax, -0x138(%rbp)
jmp 0x8ea52
movq -0x138(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x91410
movb %al, -0x139(%rbp)
jmp 0x8ea6a
movb -0x139(%rbp), %al
andb $0x1, %al
movb %al, -0x5d(%rbp)
jmp 0x8ea88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x8ed77
movq -0x28(%rbp), %rdi
callq 0x51cb0
movq %rax, -0x148(%rbp)
jmp 0x8ea9a
movq -0x28(%rbp), %rdi
callq 0x56820
movq %rax, -0x150(%rbp)
jmp 0x8eaac
movq -0x150(%rbp), %rcx
movq -0x148(%rbp), %rdx
movq -0x118(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x910b0
jmp 0x8eacc
movq -0x30(%rbp), %rdi
callq 0x51cb0
movq %rax, -0x158(%rbp)
jmp 0x8eade
movq -0x30(%rbp), %rdi
callq 0x56820
movq %rax, -0x160(%rbp)
jmp 0x8eaf0
movq -0x160(%rbp), %rcx
movq -0x158(%rbp), %rdx
movq -0x118(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x910b0
jmp 0x8eb13
movb $0x0, -0xe9(%rbp)
movb $0x0, -0x109(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x3aff0
jmp 0x8eb33
leaq -0xd0(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x3aff0
jmp 0x8eb48
movq -0x118(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x914e0
movb %al, -0x161(%rbp)
jmp 0x8eb6a
movb -0x161(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x162(%rbp)
jne 0x8ebe4
jmp 0x8eb7f
leaq -0xe8(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x3aff0
jmp 0x8eb94
movb $0x1, -0xe9(%rbp)
leaq -0x108(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x3aff0
jmp 0x8ebad
movq -0x118(%rbp), %rdi
movb $0x1, -0x109(%rbp)
leaq -0xe8(%rbp), %rsi
leaq -0x108(%rbp), %rdx
callq 0x914e0
movb %al, -0x163(%rbp)
jmp 0x8ebd6
movb -0x163(%rbp), %al
movb %al, -0x162(%rbp)
jmp 0x8ebe4
movb -0x162(%rbp), %al
movb %al, -0x164(%rbp)
testb $0x1, -0x109(%rbp)
jne 0x8ebfb
jmp 0x8ec07
leaq -0x108(%rbp), %rdi
callq 0xd7d0
testb $0x1, -0xe9(%rbp)
jne 0x8ec12
jmp 0x8ec1e
leaq -0xe8(%rbp), %rdi
callq 0xd7d0
leaq -0xd0(%rbp), %rdi
callq 0xd7d0
leaq -0xb8(%rbp), %rdi
callq 0xd7d0
movb -0x164(%rbp), %al
andb $0x1, %al
movb %al, -0x99(%rbp)
testb $0x1, -0x49(%rbp)
je 0x8ed1f
testb $0x1, -0x5d(%rbp)
je 0x8ed1f
testb $0x1, -0x99(%rbp)
je 0x8ed1f
movl $0x0, -0x4(%rbp)
movl $0x1, -0x110(%rbp)
jmp 0x8ed42
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x8ed6e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x8ed62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x8ed11
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x8ed05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x8ecec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
testb $0x1, -0x109(%rbp)
jne 0x8ecde
jmp 0x8ecea
leaq -0x108(%rbp), %rdi
callq 0xd7d0
jmp 0x8ecec
testb $0x1, -0xe9(%rbp)
jne 0x8ecf7
jmp 0x8ed03
leaq -0xe8(%rbp), %rdi
callq 0xd7d0
jmp 0x8ed05
leaq -0xd0(%rbp), %rdi
callq 0xd7d0
leaq -0xb8(%rbp), %rdi
callq 0xd7d0
jmp 0x8ed62
movq -0x118(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x91a10
jmp 0x8ed31
movl $0x1, -0x4(%rbp)
movl $0x1, -0x110(%rbp)
leaq -0x98(%rbp), %rdi
callq 0xd7d0
leaq -0x80(%rbp), %rdi
callq 0xd7d0
leaq -0x48(%rbp), %rdi
callq 0xd7d0
jmp 0x8ed82
leaq -0x98(%rbp), %rdi
callq 0xd7d0
leaq -0x80(%rbp), %rdi
callq 0xd7d0
leaq -0x48(%rbp), %rdi
callq 0xd7d0
jmp 0x8ed8e
movl -0x4(%rbp), %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x8880
nopw (%rax,%rax)