user: Please show me the C implementation that matches the assembly code listed below:

```asm
<encodeblock>:
  endbr64
  push   %r13
  mov    %edx,%r13d
  push   %r12
  mov    %r8d,%r12d
  push   %rbp
  mov    %rsi,%rbp
  xor    %esi,%esi
  push   %rbx
  sub    $0x68,%rsp
  movdqa D28(%rip),%xmm0
  movzbl 0x1(%rdi),%edx
  mov    %fs:0x28,%rax
  mov    %rax,0x58(%rsp)
  xor    %eax,%eax
  movzbl (%rdi),%eax
  movl   $0x0,0xa(%rsp)
  movaps %xmm0,0x10(%rsp)
  movdqa D33(%rip),%xmm0
  mov    %eax,%r8d
  shl    $0x4,%eax
  movb   $0x0,0xe(%rsp)
  movaps %xmm0,0x20(%rsp)
  movdqa D8(%rip),%xmm0
  shr    $0x2,%r8b
  and    $0x30,%eax
  and    $0x3f,%r8d
  movaps %xmm0,0x30(%rsp)
  movdqa D20(%rip),%xmm0
  movaps %xmm0,0x40(%rsp)
  mov    0x10(%rsp,%r8,1),%sil
  mov    %edx,%r8d
  shr    $0x4,%r8b
  movzbl %r8b,%r8d
  or     %r8d,%eax
  movslq %eax,%rbx
  mov    %esi,%eax
  mov    0x10(%rsp,%rbx,1),%ah
  mov    %ax,0xa(%rsp)
  cmp    $0x1,%ecx
  jle    L54
  movb   $0x3d,0xc(%rsp)
  mov    $0x3d,%eax
L34:
  mov    %rbp,%rdi
  mov    %al,0xd(%rsp)
  call   <strlen@plt>
  movslq %r13d,%rdx
  lea    0xa(%rsp),%r13
  mov    %rbp,%rdi
  sub    %rax,%rdx
  mov    %r13,%rsi
  call   <strncat@plt>
  test   %r12d,%r12d
  jne    L23
L51:
  mov    0x58(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L56
  add    $0x68,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  cs nopw 0x0(%rax,%rax,1)
L54:
  movzbl 0x2(%rdi),%eax
  shl    $0x2,%edx
  and    $0x3c,%edx
  mov    %eax,%esi
  shr    $0x6,%sil
  movzbl %sil,%esi
  or     %esi,%edx
  movslq %edx,%rdx
  movzbl 0x10(%rsp,%rdx,1),%edx
  mov    %dl,0xc(%rsp)
  cmp    $0x1,%ecx
  je     L40
  and    $0x3f,%eax
  movzbl 0x10(%rsp,%rax,1),%eax
  jmp    L34
  nopl   0x0(%rax)
L23:
  mov    %r13,%rsi
  lea    D27(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  jmp    L51
L56:
  call   <__stack_chk_fail@plt>
L40:
  mov    $0x3d,%eax
  jmp    L34
```

tool_calls: name: unpack_data
arguments: data_label: D28
type_guessed: byte[16]
name: unpack_data
arguments: data_label: D33
type_guessed: byte[16]
name: unpack_data
arguments: data_label: D8
type_guessed: byte[16]
name: unpack_data
arguments: data_label: D20
type_guessed: byte[16]
name: unpack_data
arguments: data_label: D27
type_guessed: string

tool: {"D28": [0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50]}

tool: {"D33": [0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x61,0x62,0x63,0x64,0x65,0x66]}

tool: {"D8": [0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0x75,0x76]}

tool: {"D20": [0x77,0x78,0x79,0x7a,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x2d,0x5f]}

tool: D27: %s

assistant: ```c
int encodeblock(unsigned char *input, char *output, int oplen, int deltas, int debug) {
  int rc = 0;
  char encodedstr[4 + 1] = "";
  char encodingtabe[63 + 1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                              "abcdefghijklmnopqrstuvwxyz"
                              "0123456789"
                              "-_";
  ;
  encodedstr[0] = encodingtabe[input[0] >> 2];
  encodedstr[1] = encodingtabe[((input[0] & 0x03) << 4) | ((input[1] & 0xf0) >> 4)];
  encodedstr[2] = (deltas < 2 ? encodingtabe[((input[1] & 0x0f) << 2) | ((input[2] & 0xc0) >> 6)] : '=');
  encodedstr[3] = (deltas < 1 ? encodingtabe[input[2] & 0x3f] : '=');
  strncat(output, encodedstr, oplen - strlen(output));
  if (debug) {
    printf("%s", encodedstr);
    printf("\n");
  }
  return rc;
}
```