user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<mg_base64_decode>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  movl   $0x0,-0x1c(%rbp)
  jmp    L40
L8:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <mg_b64rev@plt>
  mov    %eax,-0x18(%rbp)
  mov    -0x28(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <mg_b64rev@plt>
  mov    %eax,-0x14(%rbp)
  mov    -0x28(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <mg_b64rev@plt>
  mov    %eax,-0x10(%rbp)
  mov    -0x28(%rbp),%rax
  add    $0x3,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <mg_b64rev@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0x40,-0x18(%rbp)
  je     L106
  cmpl   $0x0,-0x18(%rbp)
  js     L106
  cmpl   $0x40,-0x14(%rbp)
  je     L106
  cmpl   $0x0,-0x14(%rbp)
  js     L106
  cmpl   $0x0,-0x10(%rbp)
  js     L106
  cmpl   $0x0,-0xc(%rbp)
  jns    L20
L106:
  mov    $0x0,%eax
  jmp    L71
L20:
  mov    -0x18(%rbp),%eax
  shl    $0x2,%eax
  mov    %eax,%esi
  mov    -0x14(%rbp),%eax
  sar    $0x4,%eax
  mov    %eax,%ecx
  mov    -0x1c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x1c(%rbp)
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  or     %ecx,%esi
  mov    %esi,%edx
  mov    %dl,(%rax)
  mov    -0x28(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  cmp    $0x3d,%al
  je     L21
  mov    -0x14(%rbp),%eax
  shl    $0x4,%eax
  mov    %eax,%esi
  mov    -0x10(%rbp),%eax
  sar    $0x2,%eax
  mov    %eax,%ecx
  mov    -0x1c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x1c(%rbp)
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  or     %ecx,%esi
  mov    %esi,%edx
  mov    %dl,(%rax)
  mov    -0x28(%rbp),%rax
  add    $0x3,%rax
  movzbl (%rax),%eax
  cmp    $0x3d,%al
  je     L21
  mov    -0x10(%rbp),%eax
  shl    $0x6,%eax
  mov    %eax,%esi
  mov    -0xc(%rbp),%eax
  mov    %eax,%ecx
  mov    -0x1c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x1c(%rbp)
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  or     %ecx,%esi
  mov    %esi,%edx
  mov    %dl,(%rax)
L21:
  addq   $0x4,-0x28(%rbp)
L40:
  mov    -0x28(%rbp),%rax
  add    $0x3,%rax
  cmp    %rax,-0x8(%rbp)
  ja     L8
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x1c(%rbp),%eax
L71:
  leave
  ret
```

assistant: ```c
int mg_base64_decode(const char *src, int n, char *dst) {
  const char *end = src + n;
  int len = 0;
  while (src + 3 < end) {
    int a = mg_b64rev(src[0]), b = mg_b64rev(src[1]), c = mg_b64rev(src[2]), d = mg_b64rev(src[3]);
    if (a == 64 || a < 0 || b == 64 || b < 0 || c < 0 || d < 0)
      return 0;
    dst[len++] = (a << 2) | (b >> 4);
    if (src[2] != '=') {
      dst[len++] = (b << 4) | (c >> 2);
      if (src[3] != '=')
        dst[len++] = (c << 6) | d;
    }
    src += 4;
  }
  dst[len] = '\0';
  return len;
}
```