// File: Kei18[P]pibt/./src/solver/solver.cpp
// Function: Solver::solveEnd()
void Solver::solveEnd() {
  endT = std::chrono::system_clock::now();
  elapsedTime = std::chrono::duration_cast<std::chrono::milliseconds>
    (endT-startT).count();

  // check consistency
  // 1. create path
  std::vector<Nodes> paths;
  for (auto a : A) {
    Nodes path;
    for (auto s : a->getHist()) path.push_back(s->v);
    paths.push_back(path);
  }
  // 2. check continuity, vertex/swap conflict
  for (int i = 0; i < A.size(); ++i) {
    for (int j = i + 1; j < A.size(); ++j) {
      if (paths[i].size() != paths[j].size()) {
        std::cout << "error@Solver, path size is different" << std::endl;
        std::exit(1);
      }
      for (int t = 0; t < paths[i].size(); ++t) {
        if (t > 0) {
          auto cands = paths[i][t-1]->getNeighbor();
          cands.push_back(paths[i][t-1]);
          if (!inArray(paths[i][t], cands)) {
            std::cout << "error@Solver, paths is not connected at t=" << t << ", "
                      << "agent " << i
                      << ", from " << paths[i][t-1]->getId()
                      << ", to " << paths[i][t]->getId()
                      << std::endl;
            std::exit(1);
          }
        }
        if (paths[i][t] == paths[j][t]) {
          std::cout << "error@Solver, vertex conflict at t=" << t << " between "
                    << i << " and " << j << std::endl;
          std::exit(1);
        }
        if (t > 0 && paths[i][t] == paths[j][t-1] && paths[i][t-1] == paths[j][t]) {
          std::cout << "error@Solver, swap conflict at t=" << t << " between "
                    << i << " and " << j << std::endl;
          std::exit(1);
        }
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe8(%rbp)
callq 0x8090
movq -0xe8(%rbp), %rsi
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, 0x60(%rsi)
movq %rsi, %rdi
addq $0x60, %rdi
addq $0x58, %rsi
callq 0x9e150
movq %rax, -0x20(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x9e120
movq %rax, -0x18(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x9e1a0
movq %rax, %rcx
movq -0xe8(%rbp), %rax
cvtsi2sd %rcx, %xmm0
movsd %xmm0, 0x8(%rax)
leaq -0x38(%rbp), %rdi
callq 0xd9c0
movq -0xe8(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x39b60
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
callq 0x399f0
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x51bd0
testb $0x1, %al
jne 0x9c5d8
jmp 0x9c6f3
leaq -0x48(%rbp), %rdi
callq 0x51c10
movq (%rax), %rax
movq %rax, -0x58(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x3e880
movq -0x58(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x56840
jmp 0x9c603
leaq -0x90(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
callq 0x3acd0
movq %rax, -0xa8(%rbp)
movq -0x78(%rbp), %rdi
callq 0x3ad00
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3ad30
testb $0x1, %al
jne 0x9c667
leaq -0x90(%rbp), %rdi
callq 0x3ac70
jmp 0x9c6bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x9c6e5
leaq -0xa8(%rbp), %rdi
callq 0x3ad70
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x3f490
jmp 0x9c68f
jmp 0x9c691
leaq -0xa8(%rbp), %rdi
callq 0x3ad90
jmp 0x9c62e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x3ac70
jmp 0x9c6e5
leaq -0x38(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x4e770
jmp 0x9c6ce
leaq -0x70(%rbp), %rdi
callq 0xd7d0
leaq -0x48(%rbp), %rdi
callq 0x51c30
jmp 0x9c5c2
leaq -0x70(%rbp), %rdi
callq 0xd7d0
jmp 0x9cdb0
movl $0x0, -0xbc(%rbp)
movq -0xe8(%rbp), %rdi
movslq -0xbc(%rbp), %rax
movq %rax, -0xf0(%rbp)
addq $0x20, %rdi
callq 0x383b0
movq %rax, %rcx
movq -0xf0(%rbp), %rax
cmpq %rcx, %rax
jae 0x9cd9e
movl -0xbc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
movq -0xe8(%rbp), %rdi
movslq -0xc0(%rbp), %rax
movq %rax, -0xf8(%rbp)
addq $0x20, %rdi
callq 0x383b0
movq %rax, %rcx
movq -0xf8(%rbp), %rax
cmpq %rcx, %rax
jae 0x9cd88
movslq -0xbc(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
callq 0x3b0e0
movq %rax, -0x100(%rbp)
movslq -0xc0(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
callq 0x3b0e0
movq %rax, %rcx
movq -0x100(%rbp), %rax
cmpq %rcx, %rax
je 0x9c806
movq 0x647dd(%rip), %rdi     # 0x100f98
leaq 0x1a6b5(%rip), %rsi     # 0xb6e77
callq 0x84d0
movq %rax, -0x108(%rbp)
jmp 0x9c7d0
movq -0x108(%rbp), %rdi
movq 0x6476a(%rip), %rsi     # 0x100f48
callq 0x8520
jmp 0x9c7e5
movl $0x1, %edi
callq 0x85d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x9cdb0
movl $0x0, -0xc4(%rbp)
movslq -0xc4(%rbp), %rax
movq %rax, -0x110(%rbp)
movslq -0xbc(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
callq 0x3b0e0
movq %rax, %rcx
movq -0x110(%rbp), %rax
cmpq %rcx, %rax
jae 0x9cd72
cmpl $0x0, -0xc4(%rbp)
jle 0x9caac
movslq -0xbc(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
movl -0xc4(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0xda90
movq (%rax), %rsi
leaq -0xe0(%rbp), %rdi
callq 0x3add0
jmp 0x9c88a
movslq -0xbc(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
movl -0xc4(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0xda90
movq %rax, %rsi
leaq -0xe0(%rbp), %rdi
callq 0x3f490
jmp 0x9c8be
movslq -0xbc(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
movslq -0xc4(%rbp), %rsi
callq 0xda90
movq (%rax), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x9cdd0
movb %al, -0x111(%rbp)
jmp 0x9c8f4
movb -0x111(%rbp), %al
testb $0x1, %al
jne 0x9caa0
jmp 0x9c904
movq 0x6468d(%rip), %rdi     # 0x100f98
leaq 0x1a58a(%rip), %rsi     # 0xb6e9c
callq 0x84d0
movq %rax, -0x120(%rbp)
jmp 0x9c920
movq -0x120(%rbp), %rdi
movl -0xc4(%rbp), %esi
callq 0x8860
movq %rax, -0x128(%rbp)
jmp 0x9c93b
movq -0x128(%rbp), %rdi
leaq 0x18964(%rip), %rsi     # 0xb52ad
callq 0x84d0
movq %rax, -0x130(%rbp)
jmp 0x9c957
movq -0x130(%rbp), %rdi
leaq 0x1a479(%rip), %rsi     # 0xb6dde
callq 0x84d0
movq %rax, -0x138(%rbp)
jmp 0x9c973
movq -0x138(%rbp), %rdi
movl -0xbc(%rbp), %esi
callq 0x8860
movq %rax, -0x140(%rbp)
jmp 0x9c98e
movq -0x140(%rbp), %rdi
leaq 0x17b75(%rip), %rsi     # 0xb4511
callq 0x84d0
movq %rax, -0x148(%rbp)
jmp 0x9c9aa
movslq -0xbc(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
movl -0xc4(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0xda90
movq (%rax), %rdi
callq 0x3ae00
movl %eax, -0x14c(%rbp)
jmp 0x9c9dd
movl -0x14c(%rbp), %esi
movq -0x148(%rbp), %rdi
callq 0x8860
movq %rax, -0x158(%rbp)
jmp 0x9c9f8
movq -0x158(%rbp), %rdi
leaq 0x1a4c1(%rip), %rsi     # 0xb6ec7
callq 0x84d0
movq %rax, -0x160(%rbp)
jmp 0x9ca14
movslq -0xbc(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
movslq -0xc4(%rbp), %rsi
callq 0xda90
movq (%rax), %rdi
callq 0x3ae00
movl %eax, -0x164(%rbp)
jmp 0x9ca43
movl -0x164(%rbp), %esi
movq -0x160(%rbp), %rdi
callq 0x8860
movq %rax, -0x170(%rbp)
jmp 0x9ca5e
movq -0x170(%rbp), %rdi
movq 0x644dc(%rip), %rsi     # 0x100f48
callq 0x8520
jmp 0x9ca73
movl $0x1, %edi
callq 0x85d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0xd7d0
jmp 0x9cdb0
leaq -0xe0(%rbp), %rdi
callq 0xd7d0
movslq -0xbc(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
movslq -0xc4(%rbp), %rsi
callq 0xda90
movq (%rax), %rax
movq %rax, -0x178(%rbp)
movslq -0xc0(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
movslq -0xc4(%rbp), %rsi
callq 0xda90
movq %rax, %rcx
movq -0x178(%rbp), %rax
cmpq (%rcx), %rax
jne 0x9cbcb
movq 0x6448a(%rip), %rdi     # 0x100f98
leaq 0x1a3b8(%rip), %rsi     # 0xb6ecd
callq 0x84d0
movq %rax, -0x180(%rbp)
jmp 0x9cb23
movq -0x180(%rbp), %rdi
movl -0xc4(%rbp), %esi
callq 0x8860
movq %rax, -0x188(%rbp)
jmp 0x9cb3e
movq -0x188(%rbp), %rdi
leaq 0x1a3a5(%rip), %rsi     # 0xb6ef1
callq 0x84d0
movq %rax, -0x190(%rbp)
jmp 0x9cb5a
movq -0x190(%rbp), %rdi
movl -0xbc(%rbp), %esi
callq 0x8860
movq %rax, -0x198(%rbp)
jmp 0x9cb75
movq -0x198(%rbp), %rdi
leaq 0x1a378(%rip), %rsi     # 0xb6efb
callq 0x84d0
movq %rax, -0x1a0(%rbp)
jmp 0x9cb91
movq -0x1a0(%rbp), %rdi
movl -0xc0(%rbp), %esi
callq 0x8860
movq %rax, -0x1a8(%rbp)
jmp 0x9cbac
movq -0x1a8(%rbp), %rdi
movq 0x6438e(%rip), %rsi     # 0x100f48
callq 0x8520
jmp 0x9cbc1
movl $0x1, %edi
callq 0x85d0
cmpl $0x0, -0xc4(%rbp)
jle 0x9cd5c
movslq -0xbc(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
movslq -0xc4(%rbp), %rsi
callq 0xda90
movq (%rax), %rax
movq %rax, -0x1b0(%rbp)
movslq -0xc0(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
movl -0xc4(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0xda90
movq %rax, %rcx
movq -0x1b0(%rbp), %rax
cmpq (%rcx), %rax
jne 0x9cd5c
movslq -0xbc(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
movl -0xc4(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0xda90
movq (%rax), %rax
movq %rax, -0x1b8(%rbp)
movslq -0xc0(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
movslq -0xc4(%rbp), %rsi
callq 0xda90
movq %rax, %rcx
movq -0x1b8(%rbp), %rax
cmpq (%rcx), %rax
jne 0x9cd5c
movq 0x642f9(%rip), %rdi     # 0x100f98
leaq 0x1a25b(%rip), %rsi     # 0xb6f01
callq 0x84d0
movq %rax, -0x1c0(%rbp)
jmp 0x9ccb4
movq -0x1c0(%rbp), %rdi
movl -0xc4(%rbp), %esi
callq 0x8860
movq %rax, -0x1c8(%rbp)
jmp 0x9cccf
movq -0x1c8(%rbp), %rdi
leaq 0x1a214(%rip), %rsi     # 0xb6ef1
callq 0x84d0
movq %rax, -0x1d0(%rbp)
jmp 0x9cceb
movq -0x1d0(%rbp), %rdi
movl -0xbc(%rbp), %esi
callq 0x8860
movq %rax, -0x1d8(%rbp)
jmp 0x9cd06
movq -0x1d8(%rbp), %rdi
leaq 0x1a1e7(%rip), %rsi     # 0xb6efb
callq 0x84d0
movq %rax, -0x1e0(%rbp)
jmp 0x9cd22
movq -0x1e0(%rbp), %rdi
movl -0xc0(%rbp), %esi
callq 0x8860
movq %rax, -0x1e8(%rbp)
jmp 0x9cd3d
movq -0x1e8(%rbp), %rdi
movq 0x641fd(%rip), %rsi     # 0x100f48
callq 0x8520
jmp 0x9cd52
movl $0x1, %edi
callq 0x85d0
jmp 0x9cd5e
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x9c810
jmp 0x9cd74
movl -0xc0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
jmp 0x9c73d
jmp 0x9cd8a
movl -0xbc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
jmp 0x9c6fd
leaq -0x38(%rbp), %rdi
callq 0xda10
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0xda10
movq -0x98(%rbp), %rdi
callq 0x8880
nopw %cs:(%rax,%rax)