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

```asm
<Base64Encode>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdx,(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %esi,%esi
  jle    L76
  mov    %rdi,%rbp
  mov    %esi,%ebx
  mov    $0x3,%r14d
  mov    $0x0,%r12d
  mov    $0x0,%r13d
  lea    -0x1(%rcx),%r15d
  mov    $0x1,%eax
  sub    %ecx,%eax
  mov    %eax,0xc(%rsp)
  jmp    L140
L122:
  mov    %esi,%ecx
  and    $0x3f,%ecx
  cmp    $0x19,%cl
  jg     L47
  add    $0x41,%ecx
  mov    %cl,(%rdx)
L219:
  sar    $0x6,%esi
  mov    %r9d,%r12d
  sub    %eax,%r12d
  sub    $0x1,%eax
  cmp    %r13d,%eax
  jl     L24
  sub    $0x1,%rdx
  cmp    %edi,%eax
  je     L39
L130:
  cmp    %eax,%r8d
  jge    L122
  movb   $0x3d,(%rdx)
  jmp    L219
L47:
  cmp    $0x33,%cl
  jg     L205
  add    $0x47,%ecx
  mov    %cl,(%rdx)
  jmp    L219
L205:
  cmp    $0x3d,%cl
  jg     L20
  sub    $0x4,%ecx
  mov    %cl,(%rdx)
  jmp    L219
L20:
  cmp    $0x3f,%cl
  je     L119
  movb   $0x2b,(%rdx)
  jmp    L219
L119:
  movb   $0x2f,(%rdx)
  jmp    L219
L24:
  mov    %esi,0x14(%rsp)
L17:
  add    $0x4,%r13d
  add    $0x4,%r14d
  test   %ebx,%ebx
  jle    L26
L140:
  movl   $0x0,0x14(%rsp)
  lea    -0x1(%rbx),%edi
  mov    $0x2,%esi
  call   <min@plt>
  test   %ebx,%ebx
  jle    L114
  mov    $0x1,%edx
L53:
  mov    0x0(%rbp),%ecx
  mov    %ecx,0x18(%rsp,%rdx,4)
  add    $0x4,%rbp
  sub    $0x1,%ebx
  mov    %edx,%ecx
  not    %ecx
  shr    $0x1f,%ecx
  test   %ebx,%ebx
  setg   %sil
  sub    $0x1,%rdx
  test   %cl,%sil
  jne    L53
  lea    0x1(%rax,%r13,1),%r8d
  mov    %r14d,%eax
L181:
  cmp    %r12d,%r15d
  jle    L17
  mov    0x14(%rsp),%esi
  movslq %eax,%rdx
  add    (%rsp),%rdx
  mov    0xc(%rsp),%edi
  add    %r14d,%edi
  add    %r12d,%edi
  lea    0x1(%r14,%r12,1),%r9d
  jmp    L130
L39:
  mov    %esi,0x14(%rsp)
  jmp    L17
L76:
  mov    $0x0,%r12d
L26:
  movslq %r12d,%rax
  mov    (%rsp),%rdi
  movb   $0x0,(%rdi,%rax,1)
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L31
  mov    %r12d,%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L114:
  lea    0x1(%rax,%r13,1),%r8d
  mov    %r14d,%eax
  jmp    L181
L31:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int Base64Encode(uint8_t *pSrc, int SrcLen, char *pDest, int DstLen) {
  int idx = 0;
  uint32_t d = 0;
  uint8_t *p = (uint8_t *)&d;
  int len;
  int cnt = 0;
  while (SrcLen > 0) {
    d = 0;
    len = min(SrcLen - 1, 2);
    for (int i = 2; i >= 0 && SrcLen > 0; i--) {
      p[i] = *pSrc;
      pSrc++;
      SrcLen--;
    }
    len += 1 + idx;
    for (int i = idx + 3; i >= idx && cnt < DstLen - 1; i--) {
      if (i > len)
        pDest[i] = '=';
      else {
        pDest[i] = d & 0x3f;
        if (pDest[i] < 26)
          pDest[i] += 'A';
        else if (pDest[i] < 52)
          pDest[i] += 'a' - 26;
        else if (pDest[i] < 62)
          pDest[i] += '0' - 52;
        else if (pDest[i] == 63)
          pDest[i] = '/';
        else
          pDest[i] = '+';
      }
      d >>= 6;
      cnt++;
    }
    idx += 4;
  }
  pDest[cnt] = '\0';
  return cnt;
}
```