// File: /workspace/github_cpp_makefile_star2_O3/keyan[P]ev_routing_engine/router.cpp
// Function: Router::build_result_string[abi:cxx11](std::unordered_map<unsigned short, Label, std::hash<unsigned short>, std::equal_to<unsigned short>, std::allocator<std::pair<unsigned short const, Label>>> const&, unsigned short, unsigned short)
std::string Router::build_result_string(const NodeToLabelMap &shortest_path_tree,
                                        NodeID source_node_id, NodeID target_node_id) {
  std::vector<std::string> names;
  std::vector<double> charge_times;

  Label curr = shortest_path_tree.at(target_node_id);
  while (curr.node_id != source_node_id) {
    names.push_back(network_.at(curr.node_id).name);
    charge_times.push_back(ms_to_hours(curr.charge_time));
    curr = shortest_path_tree.at(curr.parent);
  }

  // The last charge time is how long we charged at the source, always 0.
  charge_times.pop_back();

  // Construct results in reverse because names/charge_times are currently
  // kept in target -> source order, but spec asks for source -> target.
  std::string result = network_.at(source_node_id).name;
  auto charge_it = charge_times.rbegin();
  for (auto name_it = names.rbegin(); name_it != names.rend(); ++name_it) {
    if (charge_it == charge_times.rend()) {
      result += ", " + *name_it;
    } else {
      result += ", " + *name_it + ", " + std::to_string(*charge_it);
      ++charge_it;
    }
  }

  return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %ecx, %ebp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, 0x8(%rsp)
leaq 0x4e(%rsp), %rsi
movw %r8w, (%rsi)
xorl %eax, %eax
movq %rax, 0x80(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsp)
movq %rax, 0x40(%rsp)
movapd %xmm0, 0x30(%rsp)
movq %rdx, %rdi
callq 0xb916
testq %rax, %rax
je 0xb027
movupd 0x10(%rax), %xmm0
movupd 0x20(%rax), %xmm1
movapd %xmm0, 0xb0(%rsp)
movq 0x30(%rax), %rax
movq %rax, 0xd0(%rsp)
movapd %xmm1, 0xc0(%rsp)
movzwl 0xb0(%rsp), %eax
movabsq $0x6db6db6db6db6db7, %rbx # imm = 0x6DB6DB6DB6DB6DB7
cmpw %bp, %ax
jne 0xac91
xorl %eax, %eax
jmp 0xad7f
leaq 0xd0(%rsp), %r12
leaq 0x70(%rsp), %r13
movq (%r14), %rcx
movzwl %ax, %esi
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %rbx, %rdx
cmpq %rsi, %rdx
jbe 0xb033
imulq $0x38, %rsi, %rcx
addq %rcx, %rax
movq %r13, %rdi
movq %rax, %rsi
callq 0xb4d2
movsd 0xc0(%rsp), %xmm1
unpcklps 0x33cf(%rip), %xmm1     # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x33d7(%rip), %xmm1     # 0xe0c0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0x338b(%rip), %xmm0     # 0xe088
movsd %xmm0, 0x10(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0xad1e
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0xad2d
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0xc698
movq %r15, %rdi
movq %r12, %rsi
callq 0xb916
testq %rax, %rax
je 0xb027
movupd 0x10(%rax), %xmm0
movupd 0x20(%rax), %xmm1
movapd %xmm0, 0xb0(%rsp)
movzwl 0x30(%rax), %eax
movw %ax, 0xd0(%rsp)
movapd %xmm1, 0xc0(%rsp)
movzwl 0xb0(%rsp), %eax
cmpw %bp, %ax
jne 0xac9e
movq 0x38(%rsp), %rax
addq $-0x8, %rax
movq %rax, 0x38(%rsp)
movq (%r14), %rcx
movzwl %bp, %esi
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %rbx, %rdx
cmpq %rsi, %rdx
jbe 0xb033
imulq $0x38, %rsi, %rcx
movq 0x8(%rsp), %rdi
leaq 0x10(%rdi), %rdx
movq %rdx, 0xe0(%rsp)
movq %rdx, (%rdi)
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
addq %rsi, %rdx
callq 0x9f24
movq 0x78(%rsp), %rbp
cmpq 0x70(%rsp), %rbp
je 0xaff7
movq 0x38(%rsp), %rbx
leaq 0x60(%rsp), %r13
leaq 0x20(%rsp), %r15
leaq 0x32d8(%rip), %r14      # 0xe0d0
leaq 0xe8(%rsp), %r12
cmpq 0x30(%rsp), %rbx
je 0xae44
leaq -0x20(%rbp), %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0xb50f
movq %r12, %rdi
movq %r14, %rsi
callq 0x2280
movq %r13, 0x50(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xae81
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0xae8b
leaq -0x20(%rbp), %rdx
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0xb50f
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rdi
callq 0x2080
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0xafe8
callq 0x2150
jmp 0xafe8
movupd (%rcx), %xmm0
movupd %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, 0x58(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movsd -0x8(%rbx), %xmm0
movl $0x148, %edx            # imm = 0x148
leaq 0x90(%rsp), %rdi
movq 0x710c(%rip), %rsi      # 0x11fc8
leaq 0x3210(%rip), %rcx      # 0xe0d3
movb $0x1, %al
callq 0xb72f
movq 0x50(%rsp), %rcx
movl $0xf, %edi
cmpq %r13, %rcx
je 0xaede
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %r8
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
jbe 0xaf1b
movl $0xf, %edi
leaq 0xa0(%rsp), %r9
cmpq %r9, %rsi
je 0xaf16
movq 0xa0(%rsp), %rdi
cmpq %rdi, %rax
jbe 0xaf27
leaq 0x50(%rsp), %rdi
callq 0x2080
jmp 0xaf38
leaq 0x90(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2190
movq %r15, 0x10(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0xaf58
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0xaf61
movupd (%rcx), %xmm0
movupd %xmm0, (%r15)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rdi
callq 0x2080
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0xafa1
callq 0x2150
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0xafbb
callq 0x2150
movq 0x50(%rsp), %rdi
cmpq %r13, %rdi
je 0xafca
callq 0x2150
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0xafe4
callq 0x2150
addq $-0x8, %rbx
addq $-0x20, %rbp
cmpq 0x70(%rsp), %rbp
jne 0xae00
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xb006
callq 0x2150
leaq 0x70(%rsp), %rdi
callq 0xb590
movq 0x8(%rsp), %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x30a8(%rip), %rdi      # 0xe0d6
callq 0x21d0
leaq 0x2087(%rip), %rdi      # 0xd0c1
xorl %eax, %eax
callq 0x21f0
jmp 0xb0db
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
jne 0xb0bb
jmp 0xb0c0
jmp 0xb06b
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0xb07d
callq 0x2150
jmp 0xb07d
movq %rax, %r14
jmp 0xb0c0
movq %rax, %r14
jmp 0xb0a6
movq %rax, %r14
jmp 0xb097
movq %rax, %r14
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0xb097
callq 0x2150
movq 0x50(%rsp), %rdi
cmpq %r13, %rdi
je 0xb0a6
callq 0x2150
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0xb0c0
callq 0x2150
movq 0x8(%rsp), %rax
movq (%rax), %rdi
cmpq 0xe0(%rsp), %rdi
je 0xb0de
callq 0x2150
jmp 0xb0de
jmp 0xb0db
movq %rax, %r14
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xb0ed
callq 0x2150
leaq 0x70(%rsp), %rdi
callq 0xb590
movq %r14, %rdi
callq 0x2250
nop