// File: /workspace/github_cpp_makefile_star2_O1/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, (%rsp)
leaq 0x2e(%rsp), %rsi
movw %r8w, (%rsi)
xorl %eax, %eax
movq %rax, 0xa0(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x90(%rsp)
movq %rax, 0x40(%rsp)
movapd %xmm0, 0x30(%rsp)
movq %rdx, %rdi
callq 0xc0c2
movupd (%rax), %xmm0
movupd 0x10(%rax), %xmm1
movapd %xmm0, 0xb0(%rsp)
movq 0x20(%rax), %rax
movq %rax, 0xd0(%rsp)
movapd %xmm1, 0xc0(%rsp)
movzwl 0xb0(%rsp), %eax
movabsq $0x6db6db6db6db6db7, %rbx # imm = 0x6DB6DB6DB6DB6DB7
cmpw %bp, %ax
je 0xa96c
leaq 0xd0(%rsp), %r12
leaq 0x90(%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 0xac0c
imulq $0x38, %rsi, %rcx
addq %rcx, %rax
movq %r13, %rdi
movq %rax, %rsi
callq 0xb0a8
movsd 0xc0(%rsp), %xmm1
unpcklps 0x37d3(%rip), %xmm1     # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x37db(%rip), %xmm1     # 0xe0c0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0x378f(%rip), %xmm0     # 0xe088
movsd %xmm0, 0x8(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0xa91a
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0xa929
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xc344
movq %r15, %rdi
movq %r12, %rsi
callq 0xc0c2
movupd (%rax), %xmm0
movupd 0x10(%rax), %xmm1
movapd %xmm0, 0xb0(%rsp)
movzwl 0x20(%rax), %eax
movw %ax, 0xd0(%rsp)
movapd %xmm1, 0xc0(%rsp)
movzwl 0xb0(%rsp), %eax
cmpw %bp, %ax
jne 0xa89a
addq $-0x8, 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 0xac0c
imulq $0x38, %rsi, %rcx
movq (%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 0x9af0
movq 0x98(%rsp), %rbp
cmpq 0x90(%rsp), %rbp
je 0xabda
movq 0x38(%rsp), %rbx
leaq 0x80(%rsp), %r13
leaq 0x18(%rsp), %r15
leaq 0x36e6(%rip), %r14      # 0xe0d0
leaq 0xe8(%rsp), %r12
cmpq 0x30(%rsp), %rbx
je 0xaa39
leaq -0x20(%rbp), %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0xb0e5
movq %r12, %rdi
movq %r14, %rsi
callq 0x2280
movq %r13, 0x70(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xaa75
movq %rdx, 0x70(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x80(%rsp)
jmp 0xaa7f
leaq -0x20(%rbp), %rdx
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0xb0e5
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq (%rsp), %rdi
callq 0x2080
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0xabc8
callq 0x2150
jmp 0xabc8
movupd (%rcx), %xmm0
movupd %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, 0x78(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movsd -0x8(%rbx), %xmm0
movl $0x148, %edx            # imm = 0x148
leaq 0x50(%rsp), %rdi
movq 0x751b(%rip), %rsi      # 0x11fc8
leaq 0x361f(%rip), %rcx      # 0xe0d3
movb $0x1, %al
callq 0xb2ff
movq 0x70(%rsp), %rcx
movl $0xf, %esi
cmpq %r13, %rcx
je 0xaad2
movq 0x80(%rsp), %rsi
movq 0x78(%rsp), %r8
movq 0x58(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
jbe 0xab00
movl $0xf, %esi
leaq 0x60(%rsp), %rdi
cmpq %rdi, 0x50(%rsp)
je 0xaafb
movq 0x60(%rsp), %rsi
cmpq %rsi, %rax
jbe 0xab11
movq 0x50(%rsp), %rsi
leaq 0x70(%rsp), %rdi
callq 0x2080
jmp 0xab1f
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2190
movq %r15, 0x8(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0xab3f
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0xab48
movupd (%rcx), %xmm0
movupd %xmm0, (%r15)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq (%rsp), %rdi
callq 0x2080
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0xab87
callq 0x2150
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0xab9b
callq 0x2150
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0xabaa
callq 0x2150
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0xabc4
callq 0x2150
addq $-0x8, %rbx
addq $-0x20, %rbp
cmpq 0x90(%rsp), %rbp
jne 0xa9f2
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xabe9
callq 0x2150
leaq 0x90(%rsp), %rdi
callq 0xb166
movq (%rsp), %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x24ae(%rip), %rdi      # 0xd0c1
xorl %eax, %eax
callq 0x21f0
jmp 0xacad
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
jne 0xac8e
jmp 0xac93
jmp 0xac44
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0xac56
callq 0x2150
jmp 0xac56
movq %rax, %r14
jmp 0xac93
movq %rax, %r14
jmp 0xac79
movq %rax, %r14
jmp 0xac6a
movq %rax, %r14
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0xac6a
callq 0x2150
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0xac79
callq 0x2150
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0xac93
callq 0x2150
movq (%rsp), %rax
movq (%rax), %rdi
cmpq 0xe0(%rsp), %rdi
je 0xacb0
callq 0x2150
jmp 0xacb0
jmp 0xacad
movq %rax, %r14
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xacbf
callq 0x2150
leaq 0x90(%rsp), %rdi
callq 0xb166
movq %r14, %rdi
callq 0x2250