// File: /workspace/github_cpp_makefile_star2_O3/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, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x20(%r14), %rbx
movq %r14, 0x48(%rsp)
movq 0x28(%r14), %rbp
cmpq %rbp, %rbx
je 0x3e765
leaq 0x30(%rsp), %r15
movq %rsp, %r12
movq (%rbx), %rsi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
addq $0x20, %rsi
leaq 0x50(%rsp), %rdi
callq 0x25392
movq 0x50(%rsp), %r13
movq 0x58(%rsp), %r14
cmpq %r14, %r13
je 0x3e55b
movq (%r13), %rdx
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x3e545
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x3e54d
movq %r12, %rdi
callq 0x1c5cc
addq $0x8, %r13
cmpq %r14, %r13
jne 0x3e527
movq 0x50(%rsp), %r13
testq %r13, %r13
je 0x3e570
movq 0x60(%rsp), %rsi
subq %r13, %rsi
movq %r13, %rdi
callq 0x6380
movq %r15, %rdi
movq %r12, %rsi
callq 0x213a4
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x3e591
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x8, %rbx
cmpq %rbp, %rbx
jne 0x3e4f5
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rcx
movq 0x28(%rax), %rdx
cmpq %rcx, %rdx
je 0x3e765
movl $0x1, %r10d
xorl %edi, %edi
movq %rsp, %r13
leaq 0x50(%rsp), %rbp
movq %rdi, %rsi
incq %rdi
movq %rdx, %rax
subq %rcx, %rax
sarq $0x3, %rax
cmpq %rdi, %rax
jbe 0x3e759
movq %rdi, 0x68(%rsp)
movq 0x30(%rsp), %rax
movq %rsi, 0x20(%rsp)
leaq (%rsi,%rsi,2), %r14
movq %r10, 0x70(%rsp)
movq (%rax,%r14,8), %rsi
movq 0x8(%rax,%r14,8), %rdi
movq %rdi, %r8
subq %rsi, %r8
leaq (%r10,%r10,2), %rbx
movq 0x8(%rax,%rbx,8), %r9
subq (%rax,%rbx,8), %r9
cmpq %r9, %r8
jne 0x3e93c
cmpq %rsi, %rdi
je 0x3e72f
movq %r10, 0x28(%rsp)
movq $-0x8, %r15
xorl %r12d, %r12d
testq %r12, %r12
je 0x3e6cd
movq -0x8(%rsi,%r12,8), %rsi
addq $0x8, %rsi
movq %r13, %rdi
callq 0x19aae
movq 0x30(%rsp), %rax
movq (%rax,%r14,8), %rdx
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x3e679
movq -0x8(%rdx,%r12,8), %rax
movq %rax, (%rsi)
movq 0x8(%rsp), %rsi
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x3e689
addq %r15, %rdx
movq %r13, %rdi
callq 0x1c5cc
movq 0x8(%rsp), %rsi
movq 0x30(%rsp), %rax
movq (%rax,%r14,8), %rax
movq (%rax,%r12,8), %rax
movq %rax, 0x50(%rsp)
movq (%rsp), %rdi
movq %rbp, %rdx
callq 0x19b2e
cmpq 0x8(%rsp), %rax
je 0x3e7fa
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x3e6c8
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x30(%rsp), %rax
movq (%rax,%r14,8), %rcx
movq (%rcx,%r12,8), %rsi
movq (%rax,%rbx,8), %rdi
movq (%rdi,%r12,8), %rdx
cmpq %rdx, %rsi
je 0x3e77e
testq %r12, %r12
je 0x3e6fd
cmpq -0x8(%rdi,%r12,8), %rsi
jne 0x3e6fd
cmpq %rdx, -0x8(%rcx,%r12,8)
je 0x3e8c3
incq %r12
movq (%rax,%r14,8), %rsi
movq 0x8(%rax,%r14,8), %rcx
subq %rsi, %rcx
sarq $0x3, %rcx
addq $0x8, %r15
cmpq %r12, %rcx
ja 0x3e632
movq 0x48(%rsp), %rdx
movq 0x20(%rdx), %rcx
movq 0x28(%rdx), %rdx
movq 0x28(%rsp), %r10
incq %r10
movq %rdx, %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
cmpq %r10, %rsi
ja 0x3e5f5
movq %rdx, %rax
subq %rcx, %rax
sarq $0x3, %rax
movq 0x70(%rsp), %r10
movq 0x68(%rsp), %rdi
incq %r10
cmpq %rdi, %rax
ja 0x3e5c4
leaq 0x30(%rsp), %rdi
callq 0xb508
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x23823(%rip), %rdi     # 0x61fa8
leaq 0xd083(%rip), %rsi      # 0x4b80f
movl $0x23, %edx
callq 0x63f0
movq 0x2380b(%rip), %rdi     # 0x61fa8
movl %r12d, %esi
callq 0x6610
movq %rax, %rbx
leaq 0xd084(%rip), %rsi      # 0x4b833
movl $0x9, %edx
movq %rax, %rdi
callq 0x63f0
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
callq 0x6610
movq %rax, %rbx
leaq 0xd06a(%rip), %rsi      # 0x4b83d
movl $0x5, %edx
movq %rax, %rdi
callq 0x63f0
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0x6610
movq %rax, %rdi
callq 0x61c0
jmp 0x3e960
movq 0x237a7(%rip), %rdi     # 0x61fa8
leaq 0xcfd6(%rip), %rsi      # 0x4b7de
movl $0x2a, %edx
callq 0x63f0
movq 0x2378f(%rip), %rdi     # 0x61fa8
movl %r12d, %esi
callq 0x6610
movq %rax, %rbx
leaq 0xb7b3(%rip), %rsi      # 0x49fde
movl $0x2, %edx
movq %rax, %rdi
callq 0x63f0
leaq 0xcedc(%rip), %rsi      # 0x4b71b
movl $0x6, %edx
movq %rbx, %rdi
callq 0x63f0
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
callq 0x6610
movq %rax, %rbx
leaq 0xac4b(%rip), %rsi      # 0x494ae
movl $0x7, %edx
movq %rax, %rdi
callq 0x63f0
movq 0x30(%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 0xcf77(%rip), %rsi      # 0x4b809
movl $0x5, %edx
movq %rax, %rdi
callq 0x63f0
movq 0x30(%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 0x3e960
movq 0x236de(%rip), %rdi     # 0x61fa8
leaq 0xcf72(%rip), %rsi      # 0x4b843
movl $0x21, %edx
callq 0x63f0
movq 0x236c6(%rip), %rdi     # 0x61fa8
movl %r12d, %esi
callq 0x6610
movq %rax, %rbx
leaq 0xcf3f(%rip), %rsi      # 0x4b833
movl $0x9, %edx
movq %rax, %rdi
callq 0x63f0
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
callq 0x6610
movq %rax, %rbx
leaq 0xcf25(%rip), %rsi      # 0x4b83d
movl $0x5, %edx
movq %rax, %rdi
callq 0x63f0
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0x6610
movq %rax, %rdi
callq 0x61c0
jmp 0x3e960
movq 0x23665(%rip), %rdi     # 0x61fa8
leaq 0xce6f(%rip), %rsi      # 0x4b7b9
movl $0x24, %edx
callq 0x63f0
movq 0x2364d(%rip), %rdi     # 0x61fa8
callq 0x61c0
movl $0x1, %edi
callq 0x6440
jmp 0x3e990
jmp 0x3e990
jmp 0x3e9ab
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x3e993
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x3e993
jmp 0x3e990
jmp 0x3e9ab
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x3e9ae
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x3e9ae
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xb508
movq %rbx, %rdi
callq 0x6620