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

```asm
<mp_mul>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %rcx,-0x50(%rbp)
  mov    %r8,-0x58(%rbp)
  mov    -0x50(%rbp),%rax
  cmp    -0x58(%rbp),%rax
  jae    L5
  mov    -0x40(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x50(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x48(%rbp),%rax
  mov    %rax,-0x40(%rbp)
  mov    -0x58(%rbp),%rax
  mov    %rax,-0x50(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x48(%rbp)
  mov    -0x10(%rbp),%rax
  mov    %rax,-0x58(%rbp)
L5:
  cmpq   $0x1f,-0x50(%rbp)
  jbe    L72
  cmpq   $0x1f,-0x58(%rbp)
  ja     L133
L72:
  mov    -0x58(%rbp),%rdi
  mov    -0x50(%rbp),%rcx
  mov    -0x48(%rbp),%rdx
  mov    -0x40(%rbp),%rsi
  mov    -0x38(%rbp),%rax
  mov    %rdi,%r8
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <mp_base_mul@plt>
  cltq
  jmp    L86
L133:
  cmpq   $0x7f,-0x50(%rbp)
  ja     L89
  cmpq   $0x7f,-0x58(%rbp)
  ja     L89
  mov    -0x50(%rbp),%rax
  add    $0x1,%rax
  shr    %rax
  cmp    %rax,-0x58(%rbp)
  jbe    L89
  mov    -0x58(%rbp),%rdi
  mov    -0x50(%rbp),%rcx
  mov    -0x48(%rbp),%rdx
  mov    -0x40(%rbp),%rsi
  mov    -0x38(%rbp),%rax
  mov    %rdi,%r8
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <mp_karatsuba_mul@plt>
  cltq
  jmp    L86
L89:
  cmpq   $0x7f,-0x50(%rbp)
  jbe    L26
  cmpq   $0x7f,-0x58(%rbp)
  jbe    L26
  mov    -0x58(%rbp),%rax
  add    $0x2,%rax
  movabs $0xaaaaaaaaaaaaaaab,%rdx
  mul    %rdx
  mov    %rdx,%rcx
  shr    %rcx
  mov    -0x50(%rbp),%rax
  add    $0x2,%rax
  movabs $0xaaaaaaaaaaaaaaab,%rdx
  mul    %rdx
  mov    %rdx,%rax
  shr    %rax
  cmp    %rax,%rcx
  jne    L26
  mov    -0x58(%rbp),%rdi
  mov    -0x50(%rbp),%rcx
  mov    -0x48(%rbp),%rdx
  mov    -0x40(%rbp),%rsi
  mov    -0x38(%rbp),%rax
  mov    %rdi,%r8
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <mp_toom_mul@plt>
  cltq
  jmp    L86
L26:
  movq   $0x0,-0x28(%rbp)
  mov    -0x50(%rbp),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x30(%rbp)
  mov    -0x58(%rbp),%rdi
  mov    -0x58(%rbp),%rcx
  mov    -0x48(%rbp),%rdx
  mov    -0x40(%rbp),%rsi
  mov    -0x38(%rbp),%rax
  mov    %rdi,%r8
  mov    %rax,%rdi
  call   <mp_mul>
  mov    -0x58(%rbp),%rax
  sub    %rax,-0x50(%rbp)
  mov    -0x58(%rbp),%rax
  add    %rax,%rax
  add    %rax,-0x40(%rbp)
  mov    -0x50(%rbp),%rax
  cmp    -0x58(%rbp),%rax
  jbe    L15
  mov    -0x58(%rbp),%rax
  shl    $0x2,%rax
  mov    %rax,%rsi
  mov    $0x1,%edi
  mov    $0x0,%eax
  call   <mp_calloc@plt>
  cltq
  mov    %rax,-0x20(%rbp)
  jmp    L64
L15:
  mov    -0x50(%rbp),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  add    %rax,%rax
  mov    %rax,%rsi
  mov    $0x1,%edi
  mov    $0x0,%eax
  call   <mp_calloc@plt>
  cltq
  mov    %rax,-0x20(%rbp)
  jmp    L64
L84:
  mov    -0x28(%rbp),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x28(%rbp)
  mov    -0x58(%rbp),%rdi
  mov    -0x58(%rbp),%rcx
  mov    -0x48(%rbp),%rdx
  mov    -0x40(%rbp),%rsi
  mov    -0x20(%rbp),%rax
  mov    %rdi,%r8
  mov    %rax,%rdi
  call   <mp_mul>
  mov    %rax,-0x8(%rbp)
  mov    -0x30(%rbp),%rax
  sub    -0x28(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  lea    (%rax,%rax,1),%rcx
  mov    -0x38(%rbp),%rax
  lea    (%rcx,%rax,1),%rsi
  mov    -0x28(%rbp),%rax
  lea    (%rax,%rax,1),%rcx
  mov    -0x38(%rbp),%rax
  lea    (%rcx,%rax,1),%rdi
  mov    -0x8(%rbp),%rcx
  mov    -0x20(%rbp),%rax
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    %rax,%rdx
  mov    $0x0,%eax
  call   <mp_add@plt>
  mov    -0x58(%rbp),%rax
  sub    %rax,-0x50(%rbp)
  mov    -0x58(%rbp),%rax
  add    %rax,%rax
  add    %rax,-0x40(%rbp)
  mov    -0x58(%rbp),%rdx
  mov    -0x50(%rbp),%rax
  cmp    %rax,%rdx
  cmova  %rax,%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  lea    (%rax,%rax,1),%rdx
  mov    -0x20(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
L64:
  mov    -0x50(%rbp),%rax
  cmp    -0x58(%rbp),%rax
  jae    L84
  cmpq   $0x0,-0x50(%rbp)
  je     L170
  mov    -0x28(%rbp),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x28(%rbp)
  mov    -0x50(%rbp),%rdi
  mov    -0x58(%rbp),%rcx
  mov    -0x40(%rbp),%rdx
  mov    -0x48(%rbp),%rsi
  mov    -0x20(%rbp),%rax
  mov    %rdi,%r8
  mov    %rax,%rdi
  call   <mp_mul>
  mov    %rax,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  lea    (%rax,%rax,1),%rdx
  mov    -0x38(%rbp),%rax
  lea    (%rdx,%rax,1),%rsi
  mov    -0x28(%rbp),%rax
  lea    (%rax,%rax,1),%rdx
  mov    -0x38(%rbp),%rax
  lea    (%rdx,%rax,1),%rdi
  mov    -0x8(%rbp),%rcx
  mov    -0x30(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    %rax,%rdx
  mov    $0x0,%eax
  call   <mp_add@plt>
L170:
  mov    -0x30(%rbp),%rax
  add    %rax,%rax
  lea    -0x2(%rax),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  test   %ax,%ax
  jne    L146
  subq   $0x1,-0x30(%rbp)
L146:
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <mp_free@plt>
  mov    -0x30(%rbp),%rax
L86:
  leave
  ret
```

assistant: ```c
long mp_mul(unsigned short *rop, unsigned short *op1, unsigned short *op2, unsigned long len1, unsigned long len2) {
  if (len1 < len2) {
    unsigned short *top = op1;
    unsigned long tlen = len1;
    op1 = op2;
    len1 = len2;
    op2 = top;
    len2 = tlen;
  };
  if (len1 < 32 || len2 < 32)
    return (mp_base_mul(rop, op1, op2, len1, len2));
  else if (len1 < 128 && len2 < 128 && len2 > ((len1 + 1) >> 1))
    return (mp_karatsuba_mul(rop, op1, op2, len1, len2));
  else if (len1 >= 128 && len2 >= 128 && (len2 + 2) / 3 == (len1 + 2) / 3)
    return (mp_toom_mul(rop, op1, op2, len1, len2));
  else {
    long xsize, psize, isize;
    unsigned short *ptr;
    isize = 0;
    xsize = len1 + len2;
    mp_mul(rop, op1, op2, len2, len2);
    len1 -= len2;
    op1 += len2;
    if (len1 > len2)
      ptr = mp_calloc(1, sizeof(unsigned short) * (len2 + len2));
    else
      ptr = mp_calloc(1, sizeof(unsigned short) * (len1 + len2));
    while (len1 >= len2) {
      isize += len2;
      psize = mp_mul(ptr, op1, op2, len2, len2);
      mp_add(rop + isize, rop + isize, ptr, xsize - isize, psize);
      len1 -= len2;
      op1 += len2;
      memset(ptr, '\0', sizeof(unsigned short) * (((len1) < (len2) ? (len1) : (len2)) + len2));
    }
    if (len1) {
      isize += len2;
      psize = mp_mul(ptr, op2, op1, len2, len1);
      mp_add(rop + isize, rop + isize, ptr, xsize, psize);
    }
    if (rop[xsize - 1] == 0)
      --xsize;
    mp_free(ptr);
    return (xsize);
  }
}
```