// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
callq 0x6060
movq %rax, 0x60(%rbx)
subq 0x58(%rbx), %rax
movl $0xf4240, %ecx          # imm = 0xF4240
cqto
idivq %rcx
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x8(%rbx)
xorpd %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq 0x20(%rbx), %r15
movq %rbx, 0x48(%rsp)
movq 0x28(%rbx), %r13
leaq 0x60(%rsp), %r14
leaq 0x30(%rsp), %r12
cmpq %r13, %r15
je 0x3267b
movq (%r15), %rsi
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
addq $0x20, %rsi
movq %r14, %rdi
callq 0x1e8e6
movq 0x60(%rsp), %rbp
movq 0x68(%rsp), %rbx
cmpq %rbx, %rbp
je 0x32658
movq (%rbp), %rsi
movq %r12, %rdi
callq 0x171da
addq $0x8, %rbp
jmp 0x32641
movq %r14, %rdi
callq 0x15dae
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x1be00
movq %r12, %rdi
callq 0x990e
addq $0x8, %r15
jmp 0x32613
movq 0x48(%rsp), %rcx
movq 0x20(%rcx), %rax
movq 0x28(%rcx), %rcx
pushq $0x1
popq %r8
xorl %esi, %esi
leaq 0x30(%rsp), %r13
leaq 0x60(%rsp), %rbp
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x327e9
leaq 0x1(%rsi), %rdx
movq %rdx, 0x50(%rsp)
movq %rsi, (%rsp)
imulq $0x18, %rsi, %rbx
movq %r8, 0x58(%rsp)
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r8, %rdx
jbe 0x327d7
movq 0x10(%rsp), %rax
movq (%rax,%rbx), %rcx
movq 0x8(%rax,%rbx), %rdx
movq %rdx, %rsi
subq %rcx, %rsi
imulq $0x18, %r8, %r15
movq 0x8(%rax,%r15), %rdi
subq (%rax,%r15), %rdi
cmpq %rdi, %rsi
jne 0x32962
movq %r8, 0x8(%rsp)
pushq $-0x8
popq %r14
xorl %r12d, %r12d
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %r12, %rdx
jbe 0x327bd
testq %r12, %r12
je 0x32784
movq -0x8(%rcx,%r12,8), %rsi
addq $0x8, %rsi
movq %r13, %rdi
callq 0x15d3a
movq 0x10(%rsp), %rax
movq (%rax,%rbx), %rsi
addq %r14, %rsi
movq %r13, %rdi
callq 0x171da
movq 0x10(%rsp), %rax
movq (%rax,%rbx), %rax
movq (%rax,%r12,8), %rax
movq %rax, 0x60(%rsp)
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %rbp, %rdx
callq 0x15de1
cmpq 0x38(%rsp), %rax
je 0x32864
movq %r13, %rdi
callq 0x990e
movq 0x10(%rsp), %rax
movq (%rax,%rbx), %rcx
movq (%rcx,%r12,8), %rsi
movq (%rax,%r15), %rdi
movq (%rdi,%r12,8), %rdx
cmpq %rdx, %rsi
je 0x32802
testq %r12, %r12
je 0x327ac
cmpq -0x8(%rdi,%r12,8), %rsi
jne 0x327ac
cmpq %rdx, -0x8(%rcx,%r12,8)
je 0x32903
incq %r12
movq 0x8(%rax,%rbx), %rdx
addq $0x8, %r14
jmp 0x3270a
movq 0x8(%rsp), %r8
incq %r8
movq 0x48(%rsp), %rcx
movq 0x20(%rcx), %rax
movq 0x28(%rcx), %rcx
jmp 0x326c1
movq 0x58(%rsp), %r8
incq %r8
movq 0x50(%rsp), %rsi
jmp 0x32698
leaq 0x10(%rsp), %rdi
callq 0x92ec
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2778f(%rip), %rdi     # 0x59f98
leaq 0xb160(%rip), %rsi      # 0x3d970
callq 0x63a0
movq %rax, %rdi
movl %r12d, %esi
callq 0x6630
leaq 0xb16d(%rip), %rsi      # 0x3d994
movq %rax, %rdi
callq 0x63a0
movq %rax, %rdi
movq (%rsp), %rsi
callq 0x6630
leaq 0xb15c(%rip), %rsi      # 0x3d99e
movq %rax, %rdi
callq 0x63a0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x6630
movq %rax, %rdi
callq 0x6200
jmp 0x3297d
movq 0x2772d(%rip), %rdi     # 0x59f98
leaq 0xb0cd(%rip), %rsi      # 0x3d93f
callq 0x63a0
movq %rax, %rdi
movl %r12d, %esi
callq 0x6630
leaq 0x97fd(%rip), %rsi      # 0x3c086
movq %rax, %rdi
callq 0x63a0
leaq 0xafe4(%rip), %rsi      # 0x3d87c
movq %rax, %rdi
callq 0x63a0
movq %rax, %rdi
movq (%rsp), %rsi
callq 0x6630
leaq 0x8bfb(%rip), %rsi      # 0x3b4ae
movq %rax, %rdi
callq 0x63a0
movq 0x10(%rsp), %rcx
movq (%rcx,%rbx), %rcx
movq -0x8(%rcx,%r12,8), %rcx
movl (%rcx), %esi
movq %rax, %rdi
callq 0x6630
leaq 0xb090(%rip), %rsi      # 0x3d96a
movq %rax, %rdi
callq 0x63a0
movq 0x10(%rsp), %rcx
movq (%rcx,%rbx), %rcx
movq (%rcx,%r12,8), %rcx
movl (%rcx), %esi
movq %rax, %rdi
callq 0x6630
movq %rax, %rdi
callq 0x6200
jmp 0x3297d
movq 0x2768e(%rip), %rdi     # 0x59f98
leaq 0xb093(%rip), %rsi      # 0x3d9a4
callq 0x63a0
movq %rax, %rdi
movl %r12d, %esi
callq 0x6630
leaq 0xb06c(%rip), %rsi      # 0x3d994
movq %rax, %rdi
callq 0x63a0
movq %rax, %rdi
movq (%rsp), %rsi
callq 0x6630
leaq 0xb05b(%rip), %rsi      # 0x3d99e
movq %rax, %rdi
callq 0x63a0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x6630
movq %rax, %rdi
callq 0x6200
jmp 0x3297d
movq 0x2762f(%rip), %rdi     # 0x59f98
leaq 0xafaa(%rip), %rsi      # 0x3d91a
callq 0x63a0
movq %rax, %rdi
callq 0x6200
pushq $0x1
popq %rdi
callq 0x6450
jmp 0x329a3
jmp 0x329a3
jmp 0x3299e
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x15dae
jmp 0x329a6
jmp 0x329a3
jmp 0x3299e
movq %rax, %rbx
jmp 0x329b0
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x990e
leaq 0x10(%rsp), %rdi
callq 0x92ec
movq %rbx, %rdi
callq 0x6650