user: Please show me the C implementation that matches the assembly code listed below:

```asm
<mg_url_decode>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rdx,%r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  test   %esi,%esi
  jle    L3
  cmp    $0x1,%ecx
  jle    L27
  lea    -0x2(%rcx),%edx
  mov    %rdi,%r9
  mov    %esi,%r14d
  mov    $0x1,%ebx
  add    $0x2,%rdx
  xor    %ebp,%ebp
  lea    -0x2(%rsi),%ecx
  jmp    L54
  nop
L75:
  test   %r8d,%r8d
  je     L30
  cmp    $0x2b,%al
  je     L98
L30:
  mov    %al,-0x1(%r13,%rbx,1)
L101:
  add    $0x1,%ebp
  movslq %ebx,%rax
  cmp    %ebp,%r14d
  jle    L97
L102:
  add    $0x1,%rbx
  cmp    %rbx,%rdx
  je     L132
L54:
  movslq %ebp,%r12
  lea    (%r9,%r12,1),%r15
  movzbl (%r15),%eax
  cmp    $0x25,%al
  jne    L75
  cmp    %ebp,%ecx
  jle    L30
  lea    0x1(%r9,%r12,1),%rax
  mov    %ecx,0x28(%rsp)
  movzbl (%rax),%edi
  mov    %r8d,0x18(%rsp)
  mov    %rdx,0x10(%rsp)
  mov    %r9,0x8(%rsp)
  mov    %rax,0x20(%rsp)
  call   <isxdigit@plt>
  mov    0x8(%rsp),%r9
  mov    0x10(%rsp),%rdx
  test   %rax,%rax
  mov    0x18(%rsp),%r8d
  mov    0x28(%rsp),%ecx
  jne    L93
L10:
  movzbl (%r15),%eax
  jmp    L75
  nopl   0x0(%rax)
L98:
  add    $0x1,%ebp
  movb   $0x20,-0x1(%r13,%rbx,1)
  movslq %ebx,%rax
  cmp    %ebp,%r14d
  jg     L102
  nopl   0x0(%rax)
L97:
  movslq %eax,%rdx
  add    %rdx,%r13
L46:
  movb   $0x0,0x0(%r13)
L50:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L132:
  add    %rax,%r13
L27:
  movb   $0x0,0x0(%r13)
  mov    $0xffffffff,%eax
  jmp    L50
  nopw   0x0(%rax,%rax,1)
L93:
  lea    0x2(%r9,%r12,1),%r12
  mov    %ecx,0x28(%rsp)
  movzbl (%r12),%edi
  mov    %r8d,0x18(%rsp)
  mov    %rdx,0x10(%rsp)
  mov    %r9,0x8(%rsp)
  call   <isxdigit@plt>
  mov    0x8(%rsp),%r9
  mov    0x10(%rsp),%rdx
  test   %rax,%rax
  mov    0x18(%rsp),%r8d
  mov    0x28(%rsp),%ecx
  je     L10
  mov    0x20(%rsp),%rax
  mov    %ecx,0x2c(%rsp)
  mov    %r8d,0x28(%rsp)
  movzbl (%rax),%edi
  mov    %r9,0x18(%rsp)
  mov    %rdx,0x10(%rsp)
  call   <tolower@plt>
  movzbl (%r12),%edi
  mov    %eax,0x8(%rsp)
  call   <tolower@plt>
  mov    0x8(%rsp),%edi
  mov    %eax,%r15d
  call   <isdigit@plt>
  mov    0x8(%rsp),%esi
  mov    %esi,%edi
  sub    $0x57,%esi
  shl    $0x4,%esi
  shl    $0x4,%edi
  test   %rax,%rax
  cmove  %esi,%edi
  mov    %edi,%r12d
  mov    %r15d,%edi
  call   <isdigit@plt>
  mov    0x10(%rsp),%rdx
  mov    0x18(%rsp),%r9
  mov    %rax,%r10
  lea    -0x30(%r15),%eax
  sub    $0x57,%r15d
  mov    0x28(%rsp),%r8d
  test   %r10,%r10
  mov    0x2c(%rsp),%ecx
  cmovne %eax,%r15d
  add    $0x2,%ebp
  or     %r15d,%r12d
  mov    %r12b,-0x1(%r13,%rbx,1)
  jmp    L101
L3:
  xor    %eax,%eax
  jmp    L46
```

assistant: ```c
int mg_url_decode(const char *src, int src_len, char *dst, int dst_len, int is_form_url_encoded) {
  int i, j, a, b;
  for (i = j = 0; i < src_len && j < dst_len - 1; i++, j++) {
    if (src[i] == '%' && i < src_len - 2 && isxdigit(*(const unsigned char *)(src + i + 1)) && isxdigit(*(const unsigned char *)(src + i + 2))) {
      a = tolower(*(const unsigned char *)(src + i + 1));
      b = tolower(*(const unsigned char *)(src + i + 2));
      dst[j] = (char)(((isdigit(a) ? a - '0' : a - 'W') << 4) | (isdigit(b) ? b - '0' : b - 'W'));
      i += 2;
    } else if (is_form_url_encoded && src[i] == '+') {
      dst[j] = ' ';
    } else {
      dst[j] = src[i];
    }
  }
  dst[j] = '\0';
  return i >= src_len ? j : -1;
}
```