user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<base64_html_encode>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x20(%rbp),%rdx
  mov    -0x3c(%rbp),%ecx
  mov    -0x38(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <base64_encode@plt>
  mov    %eax,-0x28(%rbp)
  cmpl   $0x0,-0x28(%rbp)
  jns    L173
  mov    -0x48(%rbp),%rax
  movq   $0x0,(%rax)
  mov    -0x28(%rbp),%eax
  jmp    L63
L173:
  movl   $0x0,-0x30(%rbp)
  movl   $0x0,-0x2c(%rbp)
  jmp    L160
L179:
  mov    -0x20(%rbp),%rdx
  mov    -0x2c(%rbp),%eax
  cltq
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x2b,%al
  je     L47
  mov    -0x20(%rbp),%rdx
  mov    -0x2c(%rbp),%eax
  cltq
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x2f,%al
  je     L47
  mov    -0x20(%rbp),%rdx
  mov    -0x2c(%rbp),%eax
  cltq
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x3d,%al
  jne    L40
L47:
  addl   $0x1,-0x30(%rbp)
L40:
  addl   $0x1,-0x2c(%rbp)
L160:
  mov    -0x2c(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jl     L179
  cmpl   $0x0,-0x30(%rbp)
  jne    L138
  mov    -0x20(%rbp),%rdx
  mov    -0x48(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x28(%rbp),%eax
  jmp    L63
L138:
  mov    -0x30(%rbp),%eax
  lea    (%rax,%rax,1),%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x24(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L159
  mov    -0x48(%rbp),%rax
  movq   $0x0,(%rax)
  mov    $0xffffffff,%eax
  jmp    L63
L159:
  mov    -0x10(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  movl   $0x0,-0x2c(%rbp)
  jmp    L187
L125:
  mov    -0x20(%rbp),%rdx
  mov    -0x2c(%rbp),%eax
  cltq
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x2b,%al
  jne    L143
  mov    -0x18(%rbp),%rax
  mov    $0x3,%edx
  lea    D20(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  addq   $0x3,-0x18(%rbp)
  jmp    L192
L143:
  mov    -0x20(%rbp),%rdx
  mov    -0x2c(%rbp),%eax
  cltq
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x2f,%al
  jne    L189
  mov    -0x18(%rbp),%rax
  mov    $0x3,%edx
  lea    D21(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  addq   $0x3,-0x18(%rbp)
  jmp    L192
L189:
  mov    -0x20(%rbp),%rdx
  mov    -0x2c(%rbp),%eax
  cltq
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x3d,%al
  jne    L92
  mov    -0x18(%rbp),%rax
  mov    $0x3,%edx
  lea    D6(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  addq   $0x3,-0x18(%rbp)
  jmp    L192
L92:
  mov    -0x20(%rbp),%rdx
  mov    -0x2c(%rbp),%eax
  cltq
  lea    (%rdx,%rax,1),%rcx
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rcx),%edx
  mov    %dl,(%rax)
L192:
  addl   $0x1,-0x2c(%rbp)
L187:
  mov    -0x2c(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jl     L125
  mov    -0x18(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x48(%rbp),%rax
  mov    -0x10(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x24(%rbp),%eax
L63:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L30
  call   <__stack_chk_fail@plt>
L30:
  leave
  ret
```

tool_calls: name: read_data
arguments: label: D20
type: string
name: read_data
arguments: label: D21
type: string
name: read_data
arguments: label: D6
type: string

tool: D20: %2B

tool: D21: %2F

tool: D6: %3D

assistant: ```c
int base64_html_encode(const void *data, int size, char **str) {
  int url_chrs;
  int new_len;
  char *b64_str;
  char *new_b64_str;
  char *s;
  int old_len;
  int i;
  old_len = base64_encode(data, size, &b64_str);
  if (old_len < 0) {
    *str = NULL;
    return old_len;
  }
  url_chrs = 0;
  for (i = 0; i < old_len; i++) {
    if ((b64_str[i] == '+') || (b64_str[i] == '/') || (b64_str[i] == '=')) {
      url_chrs++;
    }
  }
  if (url_chrs == 0) {
    *str = b64_str;
    return old_len;
  }
  new_len = old_len + (2 * url_chrs);
  new_b64_str = malloc(new_len + 1);
  if (new_b64_str == NULL) {
    *str = NULL;
    return -1;
  }
  s = new_b64_str;
  for (i = 0; i < old_len; i++) {
    if (b64_str[i] == '+') {
      memcpy(s, "%2B", 3);
      s += 3;
    } else if (b64_str[i] == '/') {
      memcpy(s, "%2F", 3);
      s += 3;
    } else if (b64_str[i] == '=') {
      memcpy(s, "%3D", 3);
      s += 3;
    } else {
      *(s++) = b64_str[i];
    }
  }
  *s = '\0';
  *str = new_b64_str;
  free(b64_str);
  return new_len;
}
```