user: Converte this assembly snippet into its equivalent C code:

```asm
<narrowbandUnitCostDistanceSameLengthBestScoreLastRowColumnLowMemUsesPointers>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %rdi,0x8(%rsp)
  mov    %rsi,0x10(%rsp)
  mov    %edx,0x58(%rsp)
  mov    %r8d,0x4c(%rsp)
  cmp    %ecx,%edx
  jne    L132
  lea    0x1(%rdx),%edi
  mov    $0x8,%esi
  mov    %ecx,%r15d
  mov    %edx,%ebx
  movslq %edi,%rdi
  call   <calloc@plt>
  mov    %rax,0x30(%rsp)
  test   %ebx,%ebx
  js     L359
  mov    0x4c(%rsp),%eax
  mov    0x58(%rsp),%ebx
  mov    0x30(%rsp),%r14
  sub    %eax,%ebx
  mov    %eax,%r12d
  mov    %eax,%r13d
  lea    0x1(%rbx),%ebp
  neg    %r12d
  xor    %ebx,%ebx
  nopl   0x0(%rax,%rax,1)
L342:
  xor    %ecx,%ecx
  mov    %ebx,%esi
  test   %r12d,%r12d
  mov    %r13d,%eax
  cmovg  %r12d,%esi
  setg   %cl
  xor    %edx,%edx
  cmp    %r13d,%r15d
  cmovle %r15d,%eax
  setg   %dl
  add    $0x1,%r12d
  add    $0x1,%r13d
  add    $0x8,%r14
  sub    %esi,%eax
  mov    $0x4,%esi
  lea    0x1(%rcx,%rax,1),%edi
  add    %edx,%edi
  movslq %edi,%rdi
  call   <calloc@plt>
  mov    %rax,-0x8(%r14)
  cmp    %ebp,%r12d
  jne    L342
L359:
  mov    0x30(%rsp),%rax
  mov    0x4c(%rsp),%esi
  mov    (%rax),%rax
  mov    %rax,0x50(%rsp)
  test   %esi,%esi
  js     L115
  cmp    0x4c(%rsp),%r15d
  jg     L33
  lea    0x1(%r15),%ecx
  xor    %edi,%edi
  xor    %r13d,%r13d
  test   %ecx,%ecx
  jg     L301
  jmp    L95
L33:
  mov    0x4c(%rsp),%eax
  mov    $0x1,%edi
  lea    0x1(%rax),%ecx
L301:
  mov    0x50(%rsp),%rdx
  xor    %eax,%eax
  nopl   0x0(%rax)
L315:
  mov    %eax,(%rdx)
  mov    %eax,%esi
  add    $0x1,%eax
  add    $0x4,%rdx
  cmp    %eax,%ecx
  jne    L315
  mov    0x50(%rsp),%rbx
  lea    0x1(%rsi),%eax
  xor    %r13d,%r13d
  lea    (%rbx,%rax,4),%rax
L47:
  test   %edi,%edi
  je     L95
  movl   $0x3e8,(%rax)
L95:
  mov    0x58(%rsp),%ecx
  test   %ecx,%ecx
  jle    L109
  mov    0x4c(%rsp),%ebx
  mov    $0x1,%eax
  mov    %r15d,0x48(%rsp)
  mov    $0x1,%r14d
  sub    %ebx,%eax
  mov    %eax,0x28(%rsp)
  lea    0x1(%rbx),%eax
  movslq 0x58(%rsp),%rbx
  mov    %eax,0x2c(%rsp)
  add    %r15d,%eax
  mov    %rbx,0x40(%rsp)
  mov    0x50(%rsp),%rbx
  mov    %eax,0x5c(%rsp)
  mov    %rbx,%r15
  xchg   %ax,%ax
L357:
  mov    0x28(%rsp),%eax
  mov    0x30(%rsp),%rcx
  lea    (%r15,%r13,4),%r8
  mov    %r14d,%ebx
  mov    (%rcx,%r14,8),%r15
  mov    %eax,%r12d
  test   %eax,%eax
  jle    L161
  mov    0x2c(%rsp),%eax
  cmp    %eax,0x48(%rsp)
  jle    L55
  sub    0x28(%rsp),%eax
  movl   $0x1,0x38(%rsp)
  add    $0x1,%eax
  mov    %eax,0x24(%rsp)
L149:
  movl   $0x3e8,(%r15)
  mov    %r8,%r10
  mov    %r15,%r9
  mov    $0x4,%eax
  mov    $0x1,%r13d
L273:
  lea    (%r15,%rax,1),%rcx
  add    %rax,%r8
  mov    0x24(%rsp),%eax
  mov    %rcx,0x18(%rsp)
  lea    0x0(%r13,%rax,1),%r11d
  cmp    %r13d,%r11d
  jle    L144
  mov    %r13d,0x3c(%rsp)
  mov    %r13d,%edx
  sub    %r13d,%r12d
  nopl   0x0(%rax)
L37:
  mov    %ebx,%eax
  test   %edx,%edx
  je     L40
  mov    0x10(%rsp),%rbp
  mov    (%r8),%eax
  lea    (%r12,%rdx,1),%esi
  mov    (%r9),%edi
  mov    0x8(%rsp),%r13
  movslq %esi,%rsi
  add    $0x1,%eax
  add    $0x1,%edi
  movzbl -0x1(%r13,%r14,1),%r13d
  cmp    %r13b,-0x1(%rbp,%rsi,1)
  setne  %sil
  movzbl %sil,%esi
  add    (%r10),%esi
  cmp    %esi,%eax
  mov    %esi,%ebp
  cmovle %eax,%ebp
  cmp    %edi,%eax
  cmovg  %edi,%eax
  cmp    %esi,%edi
  cmovge %ebp,%eax
L40:
  add    $0x1,%edx
  mov    %eax,(%rcx)
  add    $0x4,%r8
  add    $0x4,%rcx
  add    $0x4,%r9
  add    $0x4,%r10
  cmp    %r11d,%edx
  jne    L37
  mov    0x24(%rsp),%eax
  mov    0x18(%rsp),%rbx
  movslq 0x3c(%rsp),%r13
  sub    $0x1,%eax
  lea    0x4(%rbx,%rax,4),%rax
  mov    %rax,0x18(%rsp)
L144:
  mov    0x38(%rsp),%edx
  test   %edx,%edx
  je     L0
  mov    0x18(%rsp),%rax
  movl   $0x3e8,(%rax)
L0:
  addl   $0x1,0x28(%rsp)
  addl   $0x1,0x2c(%rsp)
  cmp    %r14,0x40(%rsp)
  je     L269
  add    $0x1,%r14
  jmp    L357
  nopl   0x0(%rax)
L161:
  mov    0x48(%rsp),%ecx
  mov    0x2c(%rsp),%eax
  xor    %edi,%edi
  lea    -0x4(%r15),%r9
  lea    -0x4(%r8),%r10
  cmp    %eax,%ecx
  cmovle %ecx,%eax
  setg   %dil
  xor    %r13d,%r13d
  xor    %r12d,%r12d
  mov    %edi,0x38(%rsp)
  add    $0x1,%eax
  mov    %eax,0x24(%rsp)
  xor    %eax,%eax
  jmp    L273
  nopl   0x0(%rax,%rax,1)
L55:
  mov    0x5c(%rsp),%eax
  movl   $0x0,0x38(%rsp)
  sub    %ebx,%eax
  mov    %eax,0x24(%rsp)
  jmp    L149
  nopw   0x0(%rax,%rax,1)
L269:
  mov    0x48(%rsp),%r15d
L10:
  mov    0x58(%rsp),%eax
  mov    0x4c(%rsp),%ebx
  mov    %eax,%ecx
  add    %ebx,%eax
  sub    %ebx,%ecx
  mov    %eax,%edx
  mov    $0x1,%eax
  test   %ecx,%ecx
  jg     L313
  xor    %eax,%eax
  xor    %ecx,%ecx
L313:
  cmp    %edx,%r15d
  jle    L275
  xor    %r10d,%r10d
  mov    $0x1,%esi
L118:
  sub    %ecx,%edx
  mov    0x30(%rsp),%rbx
  mov    0x40(%rsp),%rcx
  add    $0x1,%edx
  mov    (%rbx,%rcx,8),%r9
  lea    (%rax,%rdx,1),%edi
  add    %esi,%edi
  mov    (%r9),%r12d
  lea    0x4(%r9),%rcx
  cmp    $0x1,%edi
  jle    L370
  movslq %edi,%rdi
  lea    (%r9,%rdi,4),%r8
  xchg   %ax,%ax
L74:
  mov    (%rcx),%edi
  cmp    %edi,%r12d
  cmovg  %edi,%r12d
  add    $0x4,%rcx
  cmp    %r8,%rcx
  jne    L74
L370:
  mov    0x58(%rsp),%ebx
  test   %ebx,%ebx
  js     L140
  test   %r10b,%r10b
  je     L180
  lea    -0x1(%rbx),%edi
  mov    0x4c(%rsp),%ebx
  mov    0x30(%rsp),%r11
  xor    %r10d,%r10d
  movslq %edi,%rcx
  lea    (%rbx,%rdi,1),%r8d
  sub    %ebx,%edi
  nopl   0x0(%rax,%rax,1)
L276:
  movslq %edx,%rdx
  add    %rdx,%rax
  add    %rsi,%rax
  mov    -0x4(%r9,%rax,4),%eax
  cmp    %eax,%r12d
  cmovg  %eax,%r12d
  cmp    $0xffffffff,%ecx
  je     L6
  xor    %eax,%eax
  mov    %r10d,%r9d
  test   %edi,%edi
  cmovg  %edi,%r9d
  setg   %al
  cmp    %r8d,%r15d
  jle    L93
L6:
  mov    0x30(%rsp),%r13
  mov    0x50(%rsp),%rdi
  xor    %ebx,%ebx
  mov    0x58(%rsp),%ebp
  jmp    L229
  nop
L251:
  mov    0x0(%r13,%rbx,8),%rdi
L229:
  call   <free@plt>
  add    $0x1,%rbx
  cmp    %ebx,%ebp
  jge    L251
L140:
  mov    0x30(%rsp),%rdi
  call   <free@plt>
L358:
  add    $0x68,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L93:
  mov    %r15d,%edx
  sub    $0x1,%r8d
  sub    $0x1,%edi
  sub    %r9d,%edx
  add    $0x1,%edx
  test   %ecx,%ecx
  js     L6
  mov    (%r11,%rcx,8),%r9
  xor    %esi,%esi
  sub    $0x1,%rcx
  jmp    L276
L275:
  mov    %r15d,%edx
  mov    $0x1,%r10d
  xor    %esi,%esi
  jmp    L118
L115:
  mov    0x50(%rsp),%rax
  xor    %edi,%edi
  cmp    0x4c(%rsp),%r15d
  mov    $0x1,%r13d
  setg   %dil
  movl   $0x3e8,(%rax)
  add    $0x4,%rax
  jmp    L47
L109:
  movslq 0x58(%rsp),%rax
  mov    %rax,0x40(%rsp)
  jmp    L10
L180:
  mov    0x58(%rsp),%eax
  test   %eax,%eax
  js     L140
  jmp    L6
  nopl   0x0(%rax,%rax,1)
L132:
  mov    $0xffffffff,%r12d
  jmp    L358
```

assistant: ```c
int narrowbandUnitCostDistanceSameLengthBestScoreLastRowColumnLowMemUsesPointers(char *seq1, char *seq2, int len1, int len2, int maxerr) {
  int **S;
  int score;
  int row, col;
  int match;
  int left, up, diagonal;
  int from, to;
  int rowlength;
  int leftboundary, rightboundary;
  int previousleftboundary;
  int *Sp, *Spu, *Spl, *Spd;
  if (len1 != len2) {
    return (-1);
  }
  S = (int **)calloc((len1 + 1), sizeof(int *));
  for (row = 0; row <= len1; row++) {
    from = row - maxerr;
    to = row + maxerr;
    leftboundary = 0;
    if (from <= 0)
      from = 0;
    else
      leftboundary = 1;
    rightboundary = 0;
    if (to >= len2)
      to = len2;
    else
      rightboundary = 1;
    rowlength = to - from + 1;
    S[row] = (int *)calloc(leftboundary + rowlength + rightboundary, sizeof(int));
  }
  row = 0;
  from = row - maxerr;
  to = row + maxerr;
  leftboundary = 0;
  if (from <= 0)
    from = 0;
  else
    leftboundary = 1;
  rightboundary = 0;
  if (to >= len2)
    to = len2;
  else
    rightboundary = 1;
  rowlength = to - from + 1;
  Sp = S[row];
  if (leftboundary) {
    (*Sp) = 1000;
  }
  Sp += leftboundary;
  for (col = leftboundary; col <= leftboundary + rowlength - 1; col++) {
    (*Sp) = col;
    Sp++;
  }
  if (rightboundary) {
    (*Sp) = 1000;
  }
  previousleftboundary = leftboundary;
  for (row = 1; row <= len1; row++) {
    from = row - maxerr;
    to = row + maxerr;
    leftboundary = 0;
    if (from <= 0)
      from = 0;
    else
      leftboundary = 1;
    rightboundary = 0;
    if (to >= len2)
      to = len2;
    else
      rightboundary = 1;
    rowlength = to - from + 1;
    Sp = S[row];
    Spu = S[row - 1] + previousleftboundary;
    Spl = Sp - 1;
    Spd = Spu - 1;
    if (leftboundary) {
      (*Sp) = 1000;
    }
    Sp += leftboundary;
    Spu += leftboundary;
    Spl += leftboundary;
    Spd += leftboundary;
    for (col = leftboundary; col <= leftboundary + rowlength - 1; col++) {
      if (col == 0)
        (*Sp) = row;
      else {
        match = (seq1[row - 1] == seq2[from + col - leftboundary - 1]) ? 0 : 1;
        up = (*Spu) + 1;
        left = (*Spl) + 1;
        diagonal = (*Spd) + match;
        (*Sp) = ((diagonal <= left) ? ((diagonal <= up) ? diagonal : up) : ((left <= up) ? left : up));
      }
      Sp++;
      Spu++;
      Spl++;
      Spd++;
    }
    if (rightboundary) {
      (*Sp) = 1000;
    }
    previousleftboundary = leftboundary;
  }
  row = len1;
  from = row - maxerr;
  to = row + maxerr;
  leftboundary = 0;
  if (from <= 0)
    from = 0;
  else
    leftboundary = 1;
  rightboundary = 0;
  if (to >= len2)
    to = len2;
  else
    rightboundary = 1;
  rowlength = to - from + 1;
  Sp = S[row];
  score = (*Sp);
  Sp++;
  for (col = 1; col <= leftboundary + rowlength + rightboundary - 1; col++) {
    if ((*Sp) < score) {
      score = (*Sp);
    }
    Sp++;
  }
  row = len1;
  from = row - maxerr;
  to = row + maxerr;
  leftboundary = 0;
  if (from <= 0)
    from = 0;
  else
    leftboundary = 1;
  rightboundary = 0;
  if (to >= len2)
    to = len2;
  else
    rightboundary = 1;
  rowlength = to - from + 1;
  while ((row >= 0) && (to == len2)) {
    Sp = S[row] + leftboundary + rowlength + rightboundary - 1;
    if ((*Sp) < score) {
      score = (*Sp);
    }
    row--;
    if (row >= 0) {
      from = row - maxerr;
      to = row + maxerr;
      leftboundary = 0;
      if (from <= 0)
        from = 0;
      else
        leftboundary = 1;
      rightboundary = 0;
      if (to >= len2)
        to = len2;
      else
        rightboundary = 1;
      rowlength = to - from + 1;
    }
  }
  for (row = 0; row <= len1; row++) {
    free(S[row]);
  }
  free(S);
  return (score);
}
```