// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/rdj-ovlfind-dp.c
// Function: run_dp
static inline
void run_dp(const char *u, GtUword m, const char *v, GtUword n,
            GtOvlfindDpCell **row, GtOvlfindDpCell **col)
{
  GtUword i, j, cost_r, cost_d, cost_i;
  GtOvlfindDpCell cell_r, next_cell_r;

  /* first row */
  for (i = 0; i <= m; i++)
  {
    (*col)[i].start_i = i;
    (*col)[i].start_j = 0;
    (*col)[i].edist = 0;
  }
  (*row)[0] = (*col)[m];
  /* following (*row)s */
  for (j = 1UL; j <= n; j++)
  {
    (*col)[0].start_j = j;
    cell_r.start_i = 0;
    cell_r.start_j = j - 1;
    cell_r.edist = 0;
    for (i = 1UL; i <= m; i++)
    {
      next_cell_r = (*col)[i];
      cost_i = (*col)[i].edist + 1; /* cost(e --> v[j]) */
      cost_d = (*col)[i - 1].edist + 1; /* cost(u[i] --> e)*/
      cost_r = cell_r.edist + ((u[i - 1] == v[j - 1]) ? 0 : 1);
      if (cost_r < cost_i && cost_r < cost_d)
      {
        /* replacement */
        (*col)[i].start_i = cell_r.start_i;
        (*col)[i].start_j = cell_r.start_j;
        (*col)[i].edist = cost_r;
      }
      else if (cost_i < cost_d)
      {
        /* insertion */
        /* start_i and start_j already correct */
        (*col)[i].edist = cost_i;
      }
      else
      {
        /* deletion */
        (*col)[i].start_i = (*col)[i-1].start_i;
        (*col)[i].start_j = (*col)[i-1].start_j;
        (*col)[i].edist = cost_d;
      }
      cell_r = next_cell_r;
    }
    (*row)[j] = (*col)[m];
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r8, -0x38(%rsp)
movq %rcx, -0x20(%rsp)
movq %rdx, -0x8(%rsp)
movq %r9, -0x28(%rsp)
movq (%r9), %rax
leaq 0x1(%rsi), %rcx
leaq 0x10(%rax), %r8
xorl %r9d, %r9d
cmpq %r9, %rcx
je 0x2c7d9b
movq %r9, -0x8(%r8)
andq $0x0, (%r8)
andq $0x0, -0x10(%r8)
incq %r9
addq $0x18, %r8
jmp 0x2c7d80
movq -0x38(%rsp), %rcx
movq (%rcx), %rcx
imulq $0x18, %rsi, %rdx
movq 0x10(%rax,%rdx), %r8
movq %r8, 0x10(%rcx)
movq %rdx, -0x30(%rsp)
movups (%rax,%rdx), %xmm0
movups %xmm0, (%rcx)
movabsq $0x1, %r9
cmpq -0x20(%rsp), %r9
ja 0x2c7eb5
movq -0x28(%rsp), %rax
movq (%rax), %rax
movq %r9, 0x10(%rax)
movq %r9, -0x10(%rsp)
leaq -0x1(%r9), %rdx
movq %rax, -0x18(%rsp)
leaq 0x28(%rax), %r15
movabsq $0x1, %r12
movq %rdx, %r10
xorl %r8d, %r8d
xorl %r13d, %r13d
cmpq %rsi, %r12
ja 0x2c7e7f
movq -0x28(%r15), %rcx
movq -0x10(%r15), %r9
movq -0x8(%r15), %rbp
movq (%r15), %r14
leaq 0x1(%r9), %rbx
incq %rcx
movq -0x8(%rsp), %rax
movb (%rax,%rdx), %r11b
xorl %eax, %eax
cmpb %r11b, -0x1(%rdi,%r12)
setne %al
addq %rax, %r13
cmpq %rbx, %r13
setb %al
cmpq %rcx, %r13
setb %r11b
andb %al, %r11b
cmpb $0x1, %r11b
jne 0x2c7e4f
movq %r8, -0x8(%r15)
jmp 0x2c7e63
cmpq %rcx, %rbx
jb 0x2c7e69
movq -0x20(%r15), %rax
movq -0x18(%r15), %r10
movq %rax, -0x8(%r15)
movq %rcx, %r13
movq %r10, (%r15)
movq %r13, %rbx
movq %rbx, -0x10(%r15)
incq %r12
addq $0x18, %r15
movq %r14, %r10
movq %rbp, %r8
movq %r9, %r13
jmp 0x2c7e02
movq -0x38(%rsp), %rax
movq (%rax), %rax
movq -0x10(%rsp), %r9
imulq $0x18, %r9, %rcx
movq -0x30(%rsp), %r8
movq -0x18(%rsp), %r10
movq 0x10(%r10,%r8), %rdx
movq %rdx, 0x10(%rax,%rcx)
movups (%r10,%r8), %xmm0
movups %xmm0, (%rax,%rcx)
incq %r9
jmp 0x2c7dc6
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq