// File: /workspace/github_cpp_makefile_star2_O1/Kei18[P]pibt/./src/solver/pps.cpp
// Function: PPS::SWAP_PRIMITIVES(S*)
void PPS::SWAP_PRIMITIVES(S* s) {
  // error check
  if (s->phase != SWAPPHASE::EVAC_H &&
      s->phase != SWAPPHASE::EVAC_L &&
      s->phase != SWAPPHASE::SWAP_DONE) {
    std::cout << "error@PPS::SWAP_PRIMITIVES, "
              << "invalid phase was called" << "\n";
    std::exit(1);
  }
  if (s->agents.size() != 2) {
    std::cout << "error@PPS::SWAP_PRIMITIVES, "
              << "the size of agents must be 2, not "
              <<  s->agents.size() << "\n";
    std::exit(1);
  }

  Agent* aH = s->agents[0];
  Agent* aL = s->agents[1];

  if (inArray(aH, M) || inArray(aL, M)) {
    M.push_back(aH);
    M.push_back(aL);
    return;
  }

  switch (s->phase) {
  case SWAPPHASE::EVAC_H:
    aH->setNode(s->evacH);
    aL->setNode(s->target);
    s->phase = SWAPPHASE::EVAC_L;
    break;
  case SWAPPHASE::EVAC_L:
    aH->setNode(s->target);
    aL->setNode(s->evacL);
    s->phase = SWAPPHASE::SWAP_DONE;
    break;
  case SWAPPHASE::SWAP_DONE:
    aH->setNode(s->origin);
    aL->setNode(s->target);
    FINISH_SWAP(s);
    break;
  default:
    break;
  }
  M.push_back(aH);
  M.push_back(aL);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl 0x78(%rsi), %eax
addl $-0x2, %eax
cmpl $0x3, %eax
jae 0x3be5d
movq %rsi, %r15
movq 0x8(%rsi), %rax
movq 0x10(%rsi), %rcx
subq %rax, %rcx
cmpq $0x10, %rcx
jne 0x3be81
movq %rdi, %rbx
movq (%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
leaq 0xe0(%rdi), %r14
leaq 0x18(%rsp), %rdx
movq %rcx, (%rdx)
movq 0xe0(%rdi), %rdi
movq 0xe8(%rbx), %rsi
callq 0x38b4d
movq 0xe8(%rbx), %rsi
cmpq %rsi, %rax
jne 0x3bd64
movq 0x8(%rsp), %rax
leaq 0x18(%rsp), %rdx
movq %rax, (%rdx)
movq 0xe0(%rbx), %rdi
callq 0x38b4d
cmpq 0xe8(%rbx), %rax
je 0x3bdcc
movq 0xe8(%rbx), %rsi
cmpq 0xf0(%rbx), %rsi
je 0x3bd86
movq 0x10(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0xe8(%rbx)
jmp 0x3bd93
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x18edc
movq 0xe8(%rbx), %rsi
cmpq 0xf0(%rbx), %rsi
je 0x3bdb5
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0xe8(%rbx)
jmp 0x3bdc2
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
callq 0x18edc
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
movl 0x78(%r15), %eax
cmpl $0x4, %eax
je 0x3be31
cmpl $0x3, %eax
je 0x3be08
cmpl $0x2, %eax
jne 0x3bd64
movq 0x10(%rsp), %rdi
movq 0x50(%r15), %rsi
callq 0x191a6
movq 0x8(%rsp), %rdi
movq 0x40(%r15), %rsi
callq 0x191a6
movl $0x3, 0x78(%r15)
jmp 0x3bd64
movq 0x10(%rsp), %rdi
movq 0x40(%r15), %rsi
callq 0x191a6
movq 0x8(%rsp), %rdi
movq 0x58(%r15), %rsi
callq 0x191a6
movl $0x4, 0x78(%r15)
jmp 0x3bd64
movq 0x10(%rsp), %rdi
movq 0x48(%r15), %rsi
callq 0x191a6
movq 0x8(%rsp), %rdi
movq 0x40(%r15), %rsi
callq 0x191a6
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3ce46
jmp 0x3bd64
movq 0x26144(%rip), %rdi     # 0x61fa8
leaq 0xf712(%rip), %rsi      # 0x4b57d
callq 0x6360
leaq 0xf723(%rip), %rsi      # 0x4b59a
movq %rax, %rdi
callq 0x6360
jmp 0x3beb7
movq 0x26120(%rip), %rdi     # 0x61fa8
leaq 0xf6ee(%rip), %rsi      # 0x4b57d
callq 0x6360
leaq 0xf718(%rip), %rsi      # 0x4b5b3
movq %rax, %rdi
callq 0x6360
movq 0x10(%r15), %rsi
subq 0x8(%r15), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x60e0
leaq 0xc6a5(%rip), %rsi      # 0x48563
movq %rax, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440