// File: /workspace/github_cpp_makefile_star2_O1/Kei18[P]pibt/./src/solver/solver.cpp
// Function: Solver::pathDist(Node*, Node*)
int Solver::pathDist(Node* s, Node* g) {
  // same place?
  if (s == g) return 0;

  // has already explored?
  int s_index = G->getNodeIndex(s);
  int g_index = G->getNodeIndex(g);
  int dist = dists(s_index, g_index);
  if (dist != 0) return dist;

  // new
  Nodes path = G->getPath(s, g);

  dist = path.size() - 1;  // without start node
  int index, d, cost;
  bool directed = G->isDirected();

  cost = dist;
  for (auto v : path) {
    index = G->getNodeIndex(v);
    d = dists(index, g_index);
    if ((index != g_index) && (d == 0)) {
      dists(index, g_index) = cost;
      // if not directed graph
      if (!directed) dists(g_index, index) = cost;
      --cost;
    } else if (d == cost) {
      break;
    } else {
      std::cout << "error@Solver::pathDist, "
                << s->getId() << " -> " << g->getId() << ", "
                << s->getPos() << " -> " << g->getPos() << ", "
                << "not optimal path is obtained" << "\n";
      std::exit(1);
    }
  }

  return dist;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
cmpq %rdx, %rsi
je 0x3f3d9
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x38(%rdi), %rdi
callq 0x1a31c
movl %eax, %r12d
movq 0x38(%r15), %rdi
movq %rbx, %rsi
callq 0x1a31c
testl %r12d, %r12d
js 0x3f3ea
movl %eax, %ebp
testl %eax, %eax
js 0x3f3ea
movslq %r12d, %rax
movq 0x48(%r15), %rcx
cmpq %rax, %rcx
jle 0x3f3ea
movslq %ebp, %r13
cmpq %r13, 0x50(%r15)
jle 0x3f3ea
imulq %r13, %rcx
shlq $0x2, %rcx
addq 0x40(%r15), %rcx
movl (%rcx,%rax,4), %eax
testl %eax, %eax
jne 0x3f3db
movq 0x38(%r15), %rsi
movq (%rsi), %rax
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movq %r14, 0x10(%rsp)
movq %r14, %rdx
movq %rbx, 0x8(%rsp)
movq %rbx, %rcx
callq *0x18(%rax)
movq (%r12), %rbx
movq 0x8(%r12), %r12
movq %r12, %rax
subq %rbx, %rax
shrq $0x3, %rax
decl %eax
movq %rax, 0x18(%rsp)
cmpq %rbx, %r12
je 0x3f3bb
movq 0x38(%r15), %rax
movb 0x8(%rax), %al
movb %al, 0x7(%rsp)
addq $0x8, %rbx
movq 0x18(%rsp), %rax
movl %eax, %r14d
movq -0x8(%rbx), %rsi
movq 0x38(%r15), %rdi
callq 0x1a31c
testl %eax, %eax
js 0x3f3ea
movslq %eax, %rcx
movq 0x48(%r15), %rdx
cmpq %rcx, %rdx
jle 0x3f3ea
movq 0x50(%r15), %rdi
cmpq %r13, %rdi
jle 0x3f3ea
movq 0x40(%r15), %rsi
movq %rdx, %r8
imulq %r13, %r8
leaq (%rsi,%r8,4), %r8
movl (%r8,%rcx,4), %r9d
cmpl %ebp, %eax
sete %r10b
testl %r9d, %r9d
setne %al
orb %r10b, %al
je 0x3f383
cmpl %r14d, %r9d
je 0x3f3a7
jmp 0x3f409
movl %r14d, (%r8,%rcx,4)
cmpb $0x0, 0x7(%rsp)
jne 0x3f3a4
cmpq %r13, %rdx
jle 0x3f3ea
cmpq %rcx, %rdi
jle 0x3f3ea
imulq %rcx, %rdx
leaq (%rsi,%rdx,4), %rcx
movl %r14d, (%rcx,%r13,4)
decl %r14d
cmpq %r12, %rbx
sete %cl
orb %cl, %al
addq $0x8, %rbx
testb %al, %al
je 0x3f323
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x3f3d2
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x18(%rsp), %rax
jmp 0x3f3db
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xbd46(%rip), %rdi      # 0x4b137
leaq 0xbd74(%rip), %rsi      # 0x4b16c
leaq 0xc8a7(%rip), %rcx      # 0x4bca6
movl $0x16f, %edx            # imm = 0x16F
callq 0x6260
movq 0x22b98(%rip), %rdi     # 0x61fa8
leaq 0xc3f5(%rip), %rsi      # 0x4b80c
movl $0x18, %edx
callq 0x63f0
movq 0x10(%rsp), %rax
movl (%rax), %esi
movq 0x22b79(%rip), %rdi     # 0x61fa8
callq 0x6610
movq %rax, %r15
leaq 0xb3b0(%rip), %rsi      # 0x4a7ee
movl $0x4, %edx
movq %rax, %rdi
callq 0x63f0
movq 0x8(%rsp), %rax
movl (%rax), %esi
movq %r15, %rdi
callq 0x6610
movq %rax, %r15
leaq 0xab3c(%rip), %rsi      # 0x49fa0
movl $0x2, %edx
movq %rax, %rdi
callq 0x63f0
movq 0x10(%rsp), %rax
movsd 0x20(%rax), %xmm0
leaq 0x40(%rsp), %rsi
movsd %xmm0, (%rsi)
movq %r15, %rdi
callq 0x3fdb6
movq %rax, %r14
leaq 0xb358(%rip), %rsi      # 0x4a7ee
movl $0x4, %edx
movq %rax, %rdi
callq 0x63f0
movq 0x8(%rsp), %rax
movsd 0x20(%rax), %xmm0
leaq 0x38(%rsp), %rsi
movsd %xmm0, (%rsi)
movq %r14, %rdi
callq 0x3fdb6
movq %rax, %rbx
leaq 0xaad8(%rip), %rsi      # 0x49fa0
movl $0x2, %edx
movq %rax, %rdi
callq 0x63f0
leaq 0xc349(%rip), %rsi      # 0x4b825
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x63f0
leaq 0x9073(%rip), %rsi      # 0x48563
movq %rbx, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440
jmp 0x3f508
jmp 0x3f508
jmp 0x3f508
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x3f522
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq %rbx, %rdi
callq 0x6620