// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %r14
callq 0x6060
movq %rax, 0x60(%r14)
subq 0x58(%r14), %rax
movabsq $0x431bde82d7b634db, %rcx # imm = 0x431BDE82D7B634DB
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x12, %rdx
addq %rax, %rdx
cvtsi2sd %rdx, %xmm0
movsd %xmm0, 0x8(%r14)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x20(%r14), %rbx
movq %r14, 0x50(%rsp)
movq 0x28(%r14), %r13
cmpq %r13, %rbx
je 0x3e8de
leaq 0x20(%rsp), %r15
movq %rsp, %r12
movq (%rbx), %rsi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
addq $0x20, %rsi
leaq 0x58(%rsp), %rdi
callq 0x253e0
movq 0x58(%rsp), %rbp
movq 0x60(%rsp), %r14
cmpq %r14, %rbp
je 0x3e899
movq (%rbp), %rdx
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x3e88b
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x3e893
movq %r12, %rdi
callq 0x1c69a
addq $0x8, %rbp
jmp 0x3e868
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x3e8b0
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq %r15, %rdi
movq %r12, %rsi
callq 0x2140c
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x3e8d1
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x8, %rbx
cmpq %r13, %rbx
jne 0x3e83b
movq 0x50(%rsp), %rcx
movq 0x28(%rcx), %rax
cmpq 0x20(%rcx), %rax
je 0x3eaab
movl $0x1, %eax
movq %rax, 0x48(%rsp)
xorl %edx, %edx
movq %rsp, %r13
leaq 0x58(%rsp), %rbp
movq %rdx, 0x18(%rsp)
incq %rdx
movq 0x28(%rcx), %rax
subq 0x20(%rcx), %rax
sarq $0x3, %rax
movq %rdx, 0x70(%rsp)
cmpq %rdx, %rax
jbe 0x3ea8c
movq 0x18(%rsp), %rax
leaq (%rax,%rax,2), %r14
movq 0x48(%rsp), %rsi
movq 0x20(%rsp), %rax
movq 0x8(%rax,%r14,8), %rcx
subq (%rax,%r14,8), %rcx
leaq (%rsi,%rsi,2), %rbx
movq 0x8(%rax,%rbx,8), %rdx
subq (%rax,%rbx,8), %rdx
cmpq %rdx, %rcx
jne 0x3ec82
movq %rsi, 0x40(%rsp)
movq 0x20(%rsp), %rax
movq 0x8(%rax,%r14,8), %rcx
cmpq (%rax,%r14,8), %rcx
je 0x3ea6a
leaq (%rax,%r14,8), %rax
movq $-0x8, %r15
xorl %r12d, %r12d
testq %r12, %r12
je 0x3ea11
movq (%rax), %rax
movq -0x8(%rax,%r12,8), %rsi
addq $0x8, %rsi
movq %r13, %rdi
callq 0x19a68
movq 0x20(%rsp), %rax
movq (%rax,%r14,8), %rdx
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x3e9c2
movq -0x8(%rdx,%r12,8), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x3e9cd
addq %r15, %rdx
movq %r13, %rdi
callq 0x1c69a
movq 0x20(%rsp), %rax
movq (%rax,%r14,8), %rax
movq (%rax,%r12,8), %rax
movq %rax, 0x58(%rsp)
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %rbp, %rdx
callq 0x19ae8
cmpq 0x8(%rsp), %rax
je 0x3eb40
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x3ea11
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x20(%rsp), %rcx
movq (%rcx,%r14,8), %rax
movq (%rax,%r12,8), %rdx
movq (%rcx,%rbx,8), %rsi
movq (%rsi,%r12,8), %rcx
cmpq %rcx, %rdx
je 0x3eac4
testq %r12, %r12
je 0x3ea46
cmpq -0x8(%rsi,%r12,8), %rdx
jne 0x3ea46
cmpq %rcx, -0x8(%rax,%r12,8)
je 0x3ec09
movq 0x20(%rsp), %rax
leaq (%rax,%r14,8), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
incq %r12
sarq $0x3, %rcx
addq $0x8, %r15
cmpq %r12, %rcx
ja 0x3e980
movq 0x40(%rsp), %rsi
incq %rsi
movq 0x50(%rsp), %rcx
movq 0x28(%rcx), %rax
subq 0x20(%rcx), %rax
sarq $0x3, %rax
cmpq %rsi, %rax
ja 0x3e935
movq 0x28(%rcx), %rax
subq 0x20(%rcx), %rax
sarq $0x3, %rax
incq 0x48(%rsp)
movq 0x70(%rsp), %rdx
cmpq %rdx, %rax
ja 0x3e905
leaq 0x20(%rsp), %rdi
callq 0xb4ce
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x234dd(%rip), %rdi     # 0x61fa8
leaq 0xcce4(%rip), %rsi      # 0x4b7b6
movl $0x23, %edx
callq 0x63f0
movq 0x234c5(%rip), %rdi     # 0x61fa8
movl %r12d, %esi
callq 0x6610
movq %rax, %rbx
leaq 0xcce5(%rip), %rsi      # 0x4b7da
movl $0x9, %edx
movq %rax, %rdi
callq 0x63f0
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x6610
movq %rax, %rbx
leaq 0xcccb(%rip), %rsi      # 0x4b7e4
movl $0x5, %edx
movq %rax, %rdi
callq 0x63f0
movq %rbx, %rdi
movq 0x40(%rsp), %rsi
callq 0x6610
movq %rax, %rdi
callq 0x61c0
jmp 0x3eca6
movq 0x23461(%rip), %rdi     # 0x61fa8
leaq 0xcc37(%rip), %rsi      # 0x4b785
movl $0x2a, %edx
callq 0x63f0
movq 0x23449(%rip), %rdi     # 0x61fa8
movl %r12d, %esi
callq 0x6610
movq %rax, %rbx
leaq 0xb42f(%rip), %rsi      # 0x49fa0
movl $0x2, %edx
movq %rax, %rdi
callq 0x63f0
leaq 0xcb1f(%rip), %rsi      # 0x4b6a4
movl $0x6, %edx
movq %rbx, %rdi
callq 0x63f0
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x6610
movq %rax, %rbx
leaq 0xa905(%rip), %rsi      # 0x494ae
movl $0x7, %edx
movq %rax, %rdi
callq 0x63f0
movq 0x20(%rsp), %rax
movq (%rax,%r14,8), %rax
movq -0x8(%rax,%r12,8), %rax
movl (%rax), %esi
movq %rbx, %rdi
callq 0x6610
movq %rax, %rbx
leaq 0xcbd8(%rip), %rsi      # 0x4b7b0
movl $0x5, %edx
movq %rax, %rdi
callq 0x63f0
movq 0x20(%rsp), %rax
movq (%rax,%r14,8), %rax
movq (%rax,%r12,8), %rax
movl (%rax), %esi
movq %rbx, %rdi
callq 0x6610
movq %rax, %rdi
callq 0x61c0
jmp 0x3eca6
movq 0x23398(%rip), %rdi     # 0x61fa8
leaq 0xcbd3(%rip), %rsi      # 0x4b7ea
movl $0x21, %edx
callq 0x63f0
movq 0x23380(%rip), %rdi     # 0x61fa8
movl %r12d, %esi
callq 0x6610
movq %rax, %rbx
leaq 0xcba0(%rip), %rsi      # 0x4b7da
movl $0x9, %edx
movq %rax, %rdi
callq 0x63f0
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x6610
movq %rax, %rbx
leaq 0xcb86(%rip), %rsi      # 0x4b7e4
movl $0x5, %edx
movq %rax, %rdi
callq 0x63f0
movq %rbx, %rdi
movq 0x40(%rsp), %rsi
callq 0x6610
movq %rax, %rdi
callq 0x61c0
jmp 0x3eca6
movq 0x2331f(%rip), %rdi     # 0x61fa8
leaq 0xcad0(%rip), %rsi      # 0x4b760
movl $0x24, %edx
callq 0x63f0
movq 0x23307(%rip), %rdi     # 0x61fa8
callq 0x61c0
movl $0x1, %edi
callq 0x6440
jmp 0x3ecd6
jmp 0x3ecd6
movq %rax, %rbx
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x3ecd9
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x3ecd9
jmp 0x3ecf1
jmp 0x3ecd6
jmp 0x3ecf1
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x3ecf4
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x3ecf4
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xb4ce
movq %rbx, %rdi
callq 0x6620