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

```asm
<levenshtein>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x38,%rsp
  call   <strlen@plt>
  mov    %r12,%rdi
  mov    %eax,%ebx
  mov    %eax,0x1c(%rsp)
  call   <strlen@plt>
  lea    0x8(,%rax,8),%edi
  mov    %eax,%r14d
  call   <malloc@plt>
  test   %ebx,%ebx
  je     L12
  mov    %rax,%r15
  test   %r14d,%r14d
  jne    L117
  jmp    L99
  nop
L180:
  add    $0x1,%rbp
  add    $0x1,%r12
  sub    $0x1,%r14d
  subl   $0x1,0x1c(%rsp)
  je     L12
  test   %r14d,%r14d
  je     L99
L117:
  movsbl 0x0(%rbp),%edi
  call   <tolower@plt>
  movsbl (%r12),%edi
  mov    %rax,%rbx
  call   <tolower@plt>
  cmp    %rax,%rbx
  je     L180
L102:
  lea    0x1(%r14),%edx
  xor    %eax,%eax
  cmp    $0xffffffff,%r14d
  je     L172
  nopw   0x0(%rax,%rax,1)
L7:
  mov    %eax,(%r15,%rax,4)
  add    $0x1,%rax
  cmp    %rax,%rdx
  jne    L7
L172:
  movq   $0x0,0x8(%rsp)
  mov    %r14d,%eax
  mov    %rax,0x10(%rsp)
  lea    (%r15,%rax,4),%rax
  mov    %rax,0x28(%rsp)
  nopw   0x0(%rax,%rax,1)
L46:
  mov    0x8(%rsp),%rax
  xor    %r14d,%r14d
  mov    %eax,0x18(%rsp)
  lea    0x1(%rax),%r13d
  jmp    L31
  nopw   0x0(%rax,%rax,1)
L53:
  mov    %ecx,%r13d
L31:
  mov    0x8(%rsp),%rax
  movsbl 0x0(%rbp,%rax,1),%edi
  call   <tolower@plt>
  movsbl (%r12,%r14,1),%edi
  mov    %rax,%rbx
  call   <tolower@plt>
  xor    %ecx,%ecx
  cmp    %rax,%rbx
  je     L54
  mov    0x18(%rsp),%eax
  test   %eax,%eax
  je     L16
  test   %r14d,%r14d
  je     L16
  mov    0x18(%rsp),%eax
  sub    $0x1,%eax
  movsbl 0x0(%rbp,%rax,1),%edi
  call   <tolower@plt>
  movsbl (%r12,%r14,1),%edi
  mov    %rax,0x20(%rsp)
  call   <tolower@plt>
  cmp    %rax,0x20(%rsp)
  je     L91
L16:
  mov    $0x1,%ecx
L54:
  mov    0x4(%r15,%r14,4),%eax
  lea    0x1(%r13),%edi
  add    $0x1,%eax
  cmp    %edi,%eax
  cmova  %edi,%eax
  add    (%r15,%r14,4),%ecx
  mov    %r13d,(%r15,%r14,4)
  cmp    %ecx,%eax
  cmovbe %eax,%ecx
  add    $0x1,%r14
  cmp    %r14,0x10(%rsp)
  jne    L53
  mov    0x28(%rsp),%rax
  addq   $0x1,0x8(%rsp)
  mov    %ecx,(%rax)
  mov    0x8(%rsp),%rax
  cmp    %eax,0x1c(%rsp)
  ja     L46
  mov    %r15,%rdi
  mov    %ecx,0x8(%rsp)
  call   <free@plt>
  mov    0x8(%rsp),%r14d
L12:
  add    $0x38,%rsp
  mov    %r14d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L91:
  mov    0x8(%rsp),%rax
  movsbl 0x0(%rbp,%rax,1),%edi
  call   <tolower@plt>
  mov    %rax,0x20(%rsp)
  lea    -0x1(%r14),%eax
  movsbl (%r12,%rax,1),%edi
  call   <tolower@plt>
  xor    %ecx,%ecx
  cmp    %rax,0x20(%rsp)
  setne  %cl
  jmp    L54
L99:
  mov    0x1c(%rsp),%edx
  test   %edx,%edx
  je     L12
  test   %r14d,%r14d
  jne    L102
  mov    0x1c(%rsp),%r14d
  jmp    L12
```

assistant: ```c
unsigned int levenshtein(char *word1, char *word2) {
  unsigned int len1 = strlen(word1), len2 = strlen(word2);
  unsigned int *v = malloc((len2 + 1) * sizeof(unsigned int *));
  unsigned int i, j, current, next, cost;
  while (len1 > 0 && len2 > 0 && (tolower(word1[0]) == tolower(word2[0])))
    word1++, word2++, len1--, len2--;
  if (!len1)
    return len2;
  if (!len2)
    return len1;
  for (j = 0; j < len2 + 1; j++)
    v[j] = j;
  for (i = 0; i < len1; i++) {
    current = i + 1;
    for (j = 0; j < len2; j++) {
      cost = !((tolower(word1[i]) == tolower(word2[j])) || (i && j && (tolower(word1[i - 1]) == tolower(word2[j])) && (tolower(word1[i]) == tolower(word2[j - 1]))));
      next = ((((v[j + 1] + 1) < (current + 1) ? (v[j + 1] + 1) : (current + 1))) < (v[j] + cost) ? (((v[j + 1] + 1) < (current + 1) ? (v[j + 1] + 1) : (current + 1))) : (v[j] + cost));
      v[j] = current;
      current = next;
    }
    v[len2] = next;
  }
  free(v);
  return next;
}
```