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

```asm
<encode_base_64>:
  endbr64
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %rsi,%rbx
  call   <strlen@plt>
  lea    0x2(%r12),%r8d
  mov    %eax,%ecx
  mov    %r12d,%eax
  sub    $0x1,%eax
  cmovns %eax,%r8d
  sar    $0x2,%r8d
  cmp    $0x4,%r12d
  jle    L11
  xor    %edi,%edi
  lea    D21(%rip),%rdx
  jmp    L53
L42:
  test   %ecx,%ecx
  je     L11
  movsbl 0x0(%rbp),%eax
  movsbl 0x1(%rbp),%esi
  add    $0x4,%rbx
  shl    $0x8,%esi
  shl    $0x10,%eax
  or     %esi,%eax
  movsbl 0x2(%rbp),%esi
  or     %esi,%eax
  mov    %eax,%esi
  sar    $0x12,%esi
  and    $0x3f,%esi
  movzbl (%rdx,%rsi,1),%esi
  mov    %sil,-0x4(%rbx)
  mov    %eax,%esi
  sar    $0xc,%esi
  and    $0x3f,%esi
  movzbl (%rdx,%rsi,1),%esi
  mov    %sil,-0x3(%rbx)
  mov    %eax,%esi
  and    $0x3f,%eax
  sar    $0x6,%esi
  movzbl (%rdx,%rax,1),%eax
  and    $0x3f,%esi
  movzbl (%rdx,%rsi,1),%esi
  mov    %sil,-0x2(%rbx)
  mov    %al,-0x1(%rbx)
  cmp    $0x2,%ecx
  jle    L11
  add    $0x1,%edi
  add    $0x3,%rbp
  sub    $0x3,%ecx
  cmp    %edi,%r8d
  jle    L11
L53:
  cmp    $0x1,%ecx
  je     L47
  cmp    $0x2,%ecx
  jne    L42
  movsbl 0x0(%rbp),%eax
  movsbl 0x1(%rbp),%edx
  add    $0x4,%rbx
  movb   $0x3d,-0x1(%rbx)
  shl    $0x8,%edx
  shl    $0x10,%eax
  or     %edx,%eax
  lea    D21(%rip),%rdx
  mov    %eax,%ecx
  sar    $0x12,%ecx
  and    $0x3f,%ecx
  movzbl (%rdx,%rcx,1),%ecx
  mov    %cl,-0x4(%rbx)
  mov    %eax,%ecx
  sar    $0x6,%eax
  sar    $0xc,%ecx
  and    $0x3c,%eax
  and    $0x3f,%ecx
  movzbl (%rdx,%rax,1),%eax
  movzbl (%rdx,%rcx,1),%ecx
  mov    %al,-0x2(%rbx)
  mov    %cl,-0x3(%rbx)
L11:
  movb   $0x0,(%rbx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L47:
  movsbl 0x0(%rbp),%eax
  lea    D21(%rip),%rcx
  add    $0x4,%rbx
  mov    %eax,%edx
  shl    $0x4,%eax
  sar    $0x2,%edx
  and    $0x30,%eax
  movzbl (%rcx,%rax,1),%eax
  and    $0x3f,%edx
  movzbl (%rcx,%rdx,1),%edx
  mov    %al,-0x3(%rbx)
  mov    $0x3d3d,%eax
  mov    %ax,-0x2(%rbx)
  mov    %dl,-0x4(%rbx)
  movb   $0x0,(%rbx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

tool_calls: name: parse_data
arguments: label: D21
datatype: string

tool: D21: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/

assistant: ```c
void encode_base_64(char *src, char *dest, int max_len) {
  static const char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  int n, l, i;
  l = strlen(src);
  max_len = (max_len - 1) / 4;
  for (i = 0; i < max_len; i++, src += 3, l -= 3) {
    switch (l) {
    case 0:
      break;
    case 1:
      n = src[0] << 16;
      *dest++ = base64[(n >> 18) & 077];
      *dest++ = base64[(n >> 12) & 077];
      *dest++ = '=';
      *dest++ = '=';
      break;
    case 2:
      n = src[0] << 16 | src[1] << 8;
      *dest++ = base64[(n >> 18) & 077];
      *dest++ = base64[(n >> 12) & 077];
      *dest++ = base64[(n >> 6) & 077];
      *dest++ = '=';
      break;
    default:
      n = src[0] << 16 | src[1] << 8 | src[2];
      *dest++ = base64[(n >> 18) & 077];
      *dest++ = base64[(n >> 12) & 077];
      *dest++ = base64[(n >> 6) & 077];
      *dest++ = base64[n & 077];
    }
    if (l < 3)
      break;
  }
  *dest++ = 0;
}
```