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

```asm
<mg_url_decode>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %ecx,-0x30(%rbp)
  mov    %r8d,-0x3c(%rbp)
  movl   $0x0,-0x1c(%rbp)
  mov    -0x1c(%rbp),%eax
  mov    %eax,-0x20(%rbp)
  jmp    L110
L147:
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x25,%al
  jne    L8
  mov    -0x2c(%rbp),%eax
  sub    $0x2,%eax
  cmp    %eax,-0x20(%rbp)
  jge    L8
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,%edi
  call   <isxdigit@plt>
  test   %rax,%rax
  je     L8
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x2(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,%edi
  call   <isxdigit@plt>
  test   %rax,%rax
  je     L8
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,%edi
  call   <tolower@plt>
  mov    %eax,-0x18(%rbp)
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x2(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,%edi
  call   <tolower@plt>
  mov    %eax,-0x14(%rbp)
  mov    -0x18(%rbp),%eax
  mov    %eax,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L169
  mov    -0x18(%rbp),%eax
  sub    $0x30,%eax
  shl    $0x4,%eax
  mov    %eax,%ebx
  jmp    L36
L169:
  mov    -0x18(%rbp),%eax
  sub    $0x57,%eax
  shl    $0x4,%eax
  mov    %eax,%ebx
L36:
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L76
  mov    -0x14(%rbp),%eax
  sub    $0x30,%eax
  mov    %eax,%ecx
  jmp    L47
L76:
  mov    -0x14(%rbp),%eax
  sub    $0x57,%eax
  mov    %eax,%ecx
L47:
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  or     %ecx,%ebx
  mov    %ebx,%edx
  mov    %dl,(%rax)
  addl   $0x2,-0x20(%rbp)
  jmp    L63
L8:
  cmpl   $0x0,-0x3c(%rbp)
  je     L66
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x2b,%al
  jne    L66
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movb   $0x20,(%rax)
  jmp    L63
L66:
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    -0x1c(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
L63:
  addl   $0x1,-0x20(%rbp)
  addl   $0x1,-0x1c(%rbp)
L110:
  mov    -0x20(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jge    L67
  mov    -0x30(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x1c(%rbp)
  jl     L147
L67:
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x20(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L162
  mov    -0x1c(%rbp),%eax
  jmp    L101
L162:
  mov    $0xffffffff,%eax
L101:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

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;
}
```