// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x18, %rsp
movl 0x78(%rsi), %eax
addl $-0x2, %eax
cmpl $0x3, %eax
jae 0x3bbaf
movq %rsi, %r15
movq 0x8(%rsi), %rax
movq 0x10(%rsi), %rcx
subq %rax, %rcx
cmpq $0x10, %rcx
jne 0x3bbd3
movq %rdi, %rbx
movq (%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x8(%rax), %r12
movq %r12, (%rsp)
leaq 0xe0(%rdi), %r14
leaq 0x10(%rsp), %rdx
movq %rcx, (%rdx)
movq 0xe0(%rdi), %rdi
movq 0xe8(%rbx), %rsi
callq 0x388d5
movq 0xe8(%rbx), %rsi
cmpq %rsi, %rax
jne 0x3bb45
leaq 0x10(%rsp), %rdx
movq %r12, (%rdx)
movq 0xe0(%rbx), %rdi
callq 0x388d5
movq 0xe8(%rbx), %rsi
cmpq %rsi, %rax
jne 0x3bb45
movl 0x78(%r15), %eax
cmpl $0x4, %eax
je 0x3bb18
cmpl $0x3, %eax
je 0x3baf3
cmpl $0x2, %eax
jne 0x3bb3e
movq 0x8(%rsp), %rdi
movq 0x50(%r15), %rsi
callq 0x191f2
movq (%rsp), %rdi
movq 0x40(%r15), %rsi
callq 0x191f2
movl $0x3, 0x78(%r15)
jmp 0x3bb3e
movq 0x8(%rsp), %rdi
movq 0x40(%r15), %rsi
callq 0x191f2
movq (%rsp), %rdi
movq 0x58(%r15), %rsi
callq 0x191f2
movl $0x4, 0x78(%r15)
jmp 0x3bb3e
movq 0x8(%rsp), %rdi
movq 0x48(%r15), %rsi
callq 0x191f2
movq (%rsp), %rdi
movq 0x40(%r15), %rsi
callq 0x191f2
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3cb04
movq 0xe8(%rbx), %rsi
cmpq 0xf0(%rbx), %rsi
je 0x3bb6a
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
movq 0xe8(%rbx), %rsi
addq $0x8, %rsi
movq %rsi, 0xe8(%rbx)
jmp 0x3bb7e
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
callq 0x18f28
movq 0xe8(%rbx), %rsi
cmpq 0xf0(%rbx), %rsi
je 0x3bb98
movq (%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0xe8(%rbx)
jmp 0x3bba3
movq %rsp, %rdx
movq %r14, %rdi
callq 0x18f28
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x263f2(%rip), %rdi     # 0x61fa8
leaq 0xfa37(%rip), %rsi      # 0x4b5f4
callq 0x6360
leaq 0xfa48(%rip), %rsi      # 0x4b611
movq %rax, %rdi
callq 0x6360
jmp 0x3bc09
movq 0x263ce(%rip), %rdi     # 0x61fa8
leaq 0xfa13(%rip), %rsi      # 0x4b5f4
callq 0x6360
leaq 0xfa3d(%rip), %rsi      # 0x4b62a
movq %rax, %rdi
callq 0x6360
movq 0x10(%r15), %rsi
subq 0x8(%r15), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x60e0
leaq 0xc953(%rip), %rsi      # 0x48563
movq %rax, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440