// File: 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
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
jne 0x9d448
movl $0x0, -0x4(%rbp)
jmp 0x9d82a
movq -0xa0(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x3c8b0
movl %eax, %ecx
movq -0xa0(%rbp), %rax
movl %ecx, -0x24(%rbp)
movq 0x38(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x3c8b0
movq -0xa0(%rbp), %rdi
movl %eax, -0x28(%rbp)
addq $0x40, %rdi
movslq -0x24(%rbp), %rsi
movslq -0x28(%rbp), %rdx
callq 0x9e310
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x9d4a6
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x9d82a
movq -0xa0(%rbp), %rax
movq 0x38(%rax), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq (%rsi), %rax
movq 0x18(%rax), %rax
leaq -0x48(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq *%rax
movq -0xb0(%rbp), %rdi
callq 0x3b0e0
movq %rax, %rcx
movq -0xa0(%rbp), %rax
decl %ecx
movl %ecx, -0x2c(%rbp)
movq 0x38(%rax), %rdi
callq 0x4c1d0
movb %al, -0xa1(%rbp)
jmp 0x9d4f9
movb -0xa1(%rbp), %al
andb $0x1, %al
movb %al, -0x55(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0x3b730
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdi
callq 0x3b760
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x3b790
testb $0x1, %al
jne 0x9d542
jmp 0x9d81b
leaq -0x78(%rbp), %rdi
callq 0x3bb00
movq %rax, %rcx
movq -0xa0(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x88(%rbp)
movq 0x38(%rax), %rdi
movq -0x88(%rbp), %rsi
callq 0x3c8b0
movl %eax, -0xb4(%rbp)
jmp 0x9d577
movq -0xa0(%rbp), %rdi
movl -0xb4(%rbp), %eax
movl %eax, -0x4c(%rbp)
addq $0x40, %rdi
movslq -0x4c(%rbp), %rsi
movslq -0x28(%rbp), %rdx
callq 0x9e310
movq %rax, -0xc0(%rbp)
jmp 0x9d5a1
movq -0xc0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x50(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x28(%rbp), %eax
je 0x9d665
cmpl $0x0, -0x50(%rbp)
jne 0x9d665
movq -0xa0(%rbp), %rdi
movl -0x54(%rbp), %eax
movl %eax, -0xcc(%rbp)
addq $0x40, %rdi
movslq -0x4c(%rbp), %rsi
movslq -0x28(%rbp), %rdx
callq 0x9e310
movq %rax, -0xc8(%rbp)
jmp 0x9d5ed
movq -0xc8(%rbp), %rax
movl -0xcc(%rbp), %ecx
movl %ecx, (%rax)
testb $0x1, -0x55(%rbp)
jne 0x9d657
movq -0xa0(%rbp), %rdi
movl -0x54(%rbp), %eax
movl %eax, -0xdc(%rbp)
addq $0x40, %rdi
movslq -0x28(%rbp), %rsi
movslq -0x4c(%rbp), %rdx
callq 0x9e310
movq %rax, -0xd8(%rbp)
jmp 0x9d62c
movq -0xd8(%rbp), %rax
movl -0xdc(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x9d657
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xd7d0
jmp 0x9d836
movl -0x54(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x9d80b
movl -0x50(%rbp), %eax
cmpl -0x54(%rbp), %eax
jne 0x9d672
jmp 0x9d81b
movq 0x6391f(%rip), %rdi     # 0x100f98
leaq 0x198a3(%rip), %rsi     # 0xb6f23
callq 0x84d0
movq %rax, -0xe8(%rbp)
jmp 0x9d68e
movq -0x18(%rbp), %rdi
callq 0x3ae00
movl %eax, -0xec(%rbp)
jmp 0x9d69f
movl -0xec(%rbp), %esi
movq -0xe8(%rbp), %rdi
callq 0x8860
movq %rax, -0xf8(%rbp)
jmp 0x9d6ba
movq -0xf8(%rbp), %rdi
leaq 0x185f4(%rip), %rsi     # 0xb5cbc
callq 0x84d0
movq %rax, -0x100(%rbp)
jmp 0x9d6d6
movq -0x20(%rbp), %rdi
callq 0x3ae00
movl %eax, -0x104(%rbp)
jmp 0x9d6e7
movl -0x104(%rbp), %esi
movq -0x100(%rbp), %rdi
callq 0x8860
movq %rax, -0x110(%rbp)
jmp 0x9d702
movq -0x110(%rbp), %rdi
leaq 0x17b9d(%rip), %rsi     # 0xb52ad
callq 0x84d0
movq %rax, -0x118(%rbp)
jmp 0x9d71e
movq -0x18(%rbp), %rdi
callq 0x416e0
movaps %xmm0, -0x130(%rbp)
jmp 0x9d730
movq -0x118(%rbp), %rdi
movaps -0x130(%rbp), %xmm0
movlpd %xmm0, -0x90(%rbp)
leaq -0x90(%rbp), %rsi
callq 0x9e410
movq %rax, -0x138(%rbp)
jmp 0x9d75b
movq -0x138(%rbp), %rdi
leaq 0x18553(%rip), %rsi     # 0xb5cbc
callq 0x84d0
movq %rax, -0x140(%rbp)
jmp 0x9d777
movq -0x20(%rbp), %rdi
callq 0x416e0
movaps %xmm0, -0x150(%rbp)
jmp 0x9d789
movq -0x140(%rbp), %rdi
movaps -0x150(%rbp), %xmm0
movlpd %xmm0, -0x98(%rbp)
leaq -0x98(%rbp), %rsi
callq 0x9e410
movq %rax, -0x158(%rbp)
jmp 0x9d7b4
movq -0x158(%rbp), %rdi
leaq 0x17aeb(%rip), %rsi     # 0xb52ad
callq 0x84d0
movq %rax, -0x160(%rbp)
jmp 0x9d7d0
movq -0x160(%rbp), %rdi
leaq 0x1975e(%rip), %rsi     # 0xb6f3c
callq 0x84d0
movq %rax, -0x168(%rbp)
jmp 0x9d7ec
movq -0x168(%rbp), %rdi
leaq 0x15dbd(%rip), %rsi     # 0xb35b7
callq 0x84d0
jmp 0x9d801
movl $0x1, %edi
callq 0x85d0
jmp 0x9d80d
leaq -0x78(%rbp), %rdi
callq 0x3bad0
jmp 0x9d52c
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xd7d0
movl -0x4(%rbp), %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x8880
nop