// File: /workspace/github_cpp_makefile_star2_O3/interimadd[P]M5Stack-PixelArt/test/lib/googletest/googletest/src/gtest.cc
// Function: testing::internal::edit_distance::CalculateOptimalEdits(std::vector<unsigned long, std::allocator<unsigned long>> const&, std::vector<unsigned long, std::allocator<unsigned long>> const&)
std::vector<EditType> CalculateOptimalEdits(const std::vector<size_t>& left,
                                            const std::vector<size_t>& right) {
  std::vector<std::vector<double> > costs(
      left.size() + 1, std::vector<double>(right.size() + 1));
  std::vector<std::vector<EditType> > best_move(
      left.size() + 1, std::vector<EditType>(right.size() + 1));

  // Populate for empty right.
  for (size_t l_i = 0; l_i < costs.size(); ++l_i) {
    costs[l_i][0] = static_cast<double>(l_i);
    best_move[l_i][0] = kRemove;
  }
  // Populate for empty left.
  for (size_t r_i = 1; r_i < costs[0].size(); ++r_i) {
    costs[0][r_i] = static_cast<double>(r_i);
    best_move[0][r_i] = kAdd;
  }

  for (size_t l_i = 0; l_i < left.size(); ++l_i) {
    for (size_t r_i = 0; r_i < right.size(); ++r_i) {
      if (left[l_i] == right[r_i]) {
        // Found a match. Consume it.
        costs[l_i + 1][r_i + 1] = costs[l_i][r_i];
        best_move[l_i + 1][r_i + 1] = kMatch;
        continue;
      }

      const double add = costs[l_i + 1][r_i];
      const double remove = costs[l_i][r_i + 1];
      const double replace = costs[l_i][r_i];
      if (add < remove && add < replace) {
        costs[l_i + 1][r_i + 1] = add + 1;
        best_move[l_i + 1][r_i + 1] = kAdd;
      } else if (remove < add && remove < replace) {
        costs[l_i + 1][r_i + 1] = remove + 1;
        best_move[l_i + 1][r_i + 1] = kRemove;
      } else {
        // We make replace a little more expensive than add/remove to lower
        // their priority.
        costs[l_i + 1][r_i + 1] = replace + 1.00001;
        best_move[l_i + 1][r_i + 1] = kReplace;
      }
    }
  }

  // Reconstruct the best path. We do it in reverse order.
  std::vector<EditType> best_path;
  for (size_t l_i = left.size(), r_i = right.size(); l_i > 0 || r_i > 0;) {
    EditType move = best_move[l_i][r_i];
    best_path.push_back(move);
    l_i -= move != kAdd;
    r_i -= move != kRemove;
  }
  std::reverse(best_path.begin(), best_path.end());
  return best_path;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq (%rsi), %r13
movq 0x8(%rsi), %r12
movq 0x8(%rdx), %rsi
subq (%rdx), %rsi
sarq $0x3, %rsi
incq %rsi
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x3f838
subq %r13, %r12
sarq $0x3, %r12
incq %r12
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rdx
leaq 0xe(%rsp), %rcx
movq %r12, %rsi
callq 0x3f8c6
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2a220
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x1d460
movq (%r15), %r13
movq 0x8(%r15), %r12
movq 0x8(%r14), %rsi
subq (%r14), %rsi
sarq $0x3, %rsi
incq %rsi
leaq 0x28(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x3f95e
subq %r13, %r12
sarq $0x3, %r12
incq %r12
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rdx
leaq 0xf(%rsp), %rcx
movq %r12, %rsi
callq 0x3f9ea
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x2a27c
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x1d460
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rdx
subq %rax, %rdx
je 0x2a2f7
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
movq 0x10(%rsp), %rdx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %esi, %esi
movq 0x202fc(%rip), %xmm0    # 0x4a5b0
movapd 0x20304(%rip), %xmm1    # 0x4a5c0
xorl %edi, %edi
movq %rdi, %xmm2
punpckldq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
subpd %xmm1, %xmm2
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm2, %xmm3
movq (%rax,%rsi), %r8
movsd %xmm3, (%r8)
movq (%rdx,%rsi), %r8
movl $0x2, (%r8)
incq %rdi
addq $0x18, %rsi
cmpq %rdi, %rcx
jne 0x2a2be
movq (%rax), %rcx
movq 0x8(%rax), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq $0x2, %rdx
jb 0x2a355
movq 0x10(%rsp), %rsi
movq (%rsi), %rsi
movl $0x1, %edi
movq 0x20290(%rip), %xmm0    # 0x4a5b0
movapd 0x20298(%rip), %xmm1    # 0x4a5c0
movq %rdi, %xmm2
punpckldq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
subpd %xmm1, %xmm2
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm2, %xmm3
movsd %xmm3, (%rcx,%rdi,8)
movl $0x1, (%rsi,%rdi,4)
incq %rdi
cmpq %rdi, %rdx
jne 0x2a328
movq (%r15), %rsi
movq 0x8(%r15), %rcx
movq %rcx, %r15
subq %rsi, %r15
sarq $0x3, %r15
movq (%r14), %rdx
movq 0x8(%r14), %r12
movq %rcx, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
cmpq %rsi, %rcx
je 0x2a482
movq %r12, %rdi
subq %rdx, %rdi
sarq $0x3, %rdi
cmpq $0x1, %rdi
adcq $0x0, %rdi
cmpq $0x1, %r15
movq %r15, %r8
adcq $0x0, %r8
xorl %r9d, %r9d
movsd 0x20280(%rip), %xmm0    # 0x4a628
movsd 0x20270(%rip), %xmm1    # 0x4a620
cmpq %rdx, %r12
je 0x2a476
leaq (,%r9,8), %rcx
movq 0x40(%rsp), %rsi
movq (%rsi,%r9,8), %r10
incq %r9
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx), %r11
addq $0x18, %r11
leaq (%rax,%rcx), %r14
movq 0x10(%rsp), %r13
movq 0x18(%r13,%rcx), %r13
xorl %ebp, %ebp
cmpq (%rdx,%rbp,8), %r10
jne 0x2a404
movq (%r14), %rcx
movsd (%rcx,%rbp,8), %xmm2
movq (%r11), %rcx
movsd %xmm2, 0x8(%rcx,%rbp,8)
xorl %ecx, %ecx
jmp 0x2a463
movq (%r11), %rcx
movsd (%rcx,%rbp,8), %xmm4
movq (%r14), %rsi
movsd (%rsi,%rbp,8), %xmm2
movsd 0x8(%rsi,%rbp,8), %xmm3
ucomisd %xmm4, %xmm3
jbe 0x2a437
ucomisd %xmm4, %xmm2
jbe 0x2a437
addsd %xmm0, %xmm4
movsd %xmm4, 0x8(%rcx,%rbp,8)
movl $0x1, %ecx
jmp 0x2a463
ucomisd %xmm3, %xmm4
jbe 0x2a454
ucomisd %xmm3, %xmm2
jbe 0x2a454
addsd %xmm0, %xmm3
movsd %xmm3, 0x8(%rcx,%rbp,8)
movl $0x2, %ecx
jmp 0x2a463
addsd %xmm1, %xmm2
movsd %xmm2, 0x8(%rcx,%rbp,8)
movl $0x3, %ecx
movl %ecx, 0x4(%r13,%rbp,4)
incq %rbp
cmpq %rbp, %rdi
jne 0x2a3e9
jmp 0x2a479
incq %r9
cmpq %r8, %r9
jne 0x2a3b0
pxor %xmm0, %xmm0
movdqu %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movq 0x48(%rsp), %rcx
xorq 0x40(%rsp), %rcx
movq %r12, %rax
xorq %rdx, %rax
orq %rcx, %rax
je 0x2a54e
subq %rdx, %r12
sarq $0x3, %r12
leaq 0x28(%rsp), %r14
movq 0x10(%rsp), %rax
leaq (%r15,%r15,2), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax,%r12,4), %eax
movl %eax, 0x28(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x2a4e2
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x2a4ed
movq %rbx, %rdi
movq %r14, %rdx
callq 0x4615a
movl 0x28(%rsp), %eax
xorl %ecx, %ecx
cmpl $0x1, %eax
setne %cl
subq %rcx, %r15
xorl %ecx, %ecx
cmpl $0x2, %eax
setne %cl
subq %rcx, %r12
movq %r15, %rax
orq %r12, %rax
jne 0x2a4b7
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq %rcx, %rax
setne %dl
addq $-0x4, %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x2a54e
addq $0x4, %rax
movl -0x4(%rax), %edx
movl (%rcx), %esi
movl %esi, -0x4(%rax)
movl %edx, (%rcx)
addq $-0x4, %rcx
leaq 0x4(%rax), %rdx
cmpq %rcx, %rax
movq %rdx, %rax
jb 0x2a534
leaq 0x10(%rsp), %rdi
callq 0x3fa82
leaq 0x50(%rsp), %rdi
callq 0x3fad6
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x2a5d7
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x1d460
jmp 0x2a5d7
movq %rax, %r14
jmp 0x2a5d7
movq %rax, %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2a5e1
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x1d460
jmp 0x2a5e1
movq %rax, %r14
jmp 0x2a5e1
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x2a5cd
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x1d460
leaq 0x10(%rsp), %rdi
callq 0x3fa82
leaq 0x50(%rsp), %rdi
callq 0x3fad6
movq %r14, %rdi
callq 0x1d900