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

```asm
<encode_base_64>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbp
  mov    %rsi,%rbx
  mov    %edx,%r12d
  call   <strlen@plt>
  mov    %eax,%edx
  lea    0x2(%r12),%r8d
  mov    %r12d,%eax
  sub    $0x1,%eax
  cmovns %eax,%r8d
  sar    $0x2,%r8d
  cmp    $0x4,%r12d
  jle    L19
  mov    $0x0,%edi
  lea    D2(%rip),%rcx
  jmp    L76
L107:
  movsbl 0x0(%rbp),%eax
  lea    D2(%rip),%rcx
  mov    %eax,%edx
  sar    $0x2,%edx
  and    $0x3f,%edx
  movzbl (%rcx,%rdx,1),%edx
  mov    %dl,(%rbx)
  shl    $0x4,%eax
  and    $0x30,%eax
  movzbl (%rcx,%rax,1),%eax
  mov    %al,0x1(%rbx)
  lea    0x4(%rbx),%rax
  mov    $0x3d,%edx
L18:
  mov    %dl,0x2(%rbx)
  movb   $0x3d,0x3(%rbx)
  mov    %rax,%rbx
  jmp    L19
L80:
  movsbl 0x0(%rbp),%eax
  shl    $0x10,%eax
  movsbl 0x1(%rbp),%edx
  shl    $0x8,%edx
  or     %edx,%eax
  lea    D2(%rip),%rdx
  mov    %eax,%ecx
  sar    $0x12,%ecx
  and    $0x3f,%ecx
  movzbl (%rdx,%rcx,1),%ecx
  mov    %cl,(%rbx)
  mov    %eax,%ecx
  sar    $0xc,%ecx
  and    $0x3f,%ecx
  movzbl (%rdx,%rcx,1),%ecx
  mov    %cl,0x1(%rbx)
  sar    $0x6,%eax
  and    $0x3c,%eax
  movzbl (%rdx,%rax,1),%edx
  lea    0x4(%rbx),%rax
  jmp    L18
L98:
  movsbl 0x0(%rbp),%eax
  shl    $0x10,%eax
  movsbl 0x1(%rbp),%esi
  shl    $0x8,%esi
  or     %esi,%eax
  movsbl 0x2(%rbp),%esi
  or     %esi,%eax
  mov    %eax,%esi
  sar    $0x12,%esi
  and    $0x3f,%esi
  movzbl (%rcx,%rsi,1),%esi
  mov    %sil,(%rbx)
  mov    %eax,%esi
  sar    $0xc,%esi
  and    $0x3f,%esi
  movzbl (%rcx,%rsi,1),%esi
  mov    %sil,0x1(%rbx)
  mov    %eax,%esi
  sar    $0x6,%esi
  and    $0x3f,%esi
  movzbl (%rcx,%rsi,1),%esi
  mov    %sil,0x2(%rbx)
  lea    0x4(%rbx),%rsi
  and    $0x3f,%eax
  movzbl (%rcx,%rax,1),%eax
  mov    %al,0x3(%rbx)
  cmp    $0x2,%edx
  jle    L24
  add    $0x1,%edi
  add    $0x3,%rbp
  sub    $0x3,%edx
  cmp    %edi,%r8d
  jle    L32
  mov    %rsi,%rbx
L76:
  cmp    $0x1,%edx
  je     L107
  cmp    $0x2,%edx
  je     L80
  test   %edx,%edx
  jne    L98
L19:
  movb   $0x0,(%rbx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L32:
  mov    %rsi,%rbx
  jmp    L19
L24:
  mov    %rsi,%rbx
  jmp    L19
```

tool_calls: name: disassemble_data
arguments: tag: D2
data_type: string

tool: D2: 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;
}
```