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

```asm
<doapr_outch>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    %rsi,-0x10(%rbp)
  mov    %rdx,-0x18(%rbp)
  mov    %rcx,-0x20(%rbp)
  mov    %r8d,-0x24(%rbp)
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L66
  cmpq   $0x0,-0x10(%rbp)
  je     L86
L66:
  mov    $0x1,%eax
  jmp    L84
L86:
  mov    $0x0,%eax
L84:
  mov    %eax,%edi
  call   <assert@plt>
  cmpq   $0x0,-0x10(%rbp)
  je     L54
  jmp    L49
L116:
  mov    -0x10(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L101
  mov    -0x20(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L93
  mov    -0x20(%rbp),%rax
  movq   $0x400,(%rax)
L93:
  mov    -0x20(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <OPENSSL_malloc@plt>
  mov    -0x10(%rbp),%rdx
  mov    %rax,(%rdx)
  mov    -0x10(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L90
  mov    -0x18(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L103
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  setne  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x18(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rcx
  mov    -0x10(%rbp),%rax
  mov    (%rax),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
L103:
  mov    -0x8(%rbp),%rax
  movq   $0x0,(%rax)
  jmp    L49
L101:
  mov    -0x20(%rbp),%rax
  mov    (%rax),%rax
  lea    0x400(%rax),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x10(%rbp),%rax
  mov    (%rax),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <OPENSSL_realloc@plt>
  mov    -0x10(%rbp),%rdx
  mov    %rax,(%rdx)
  mov    -0x10(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L209
L49:
  mov    -0x18(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jae    L116
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L207
  mov    -0x10(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L94
L207:
  mov    $0x1,%eax
  jmp    L92
L94:
  mov    $0x0,%eax
L92:
  mov    %eax,%edi
  call   <assert@plt>
L54:
  mov    -0x18(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jae    L134
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L67
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rsi
  mov    -0x18(%rbp),%rax
  mov    (%rax),%rax
  lea    0x1(%rax),%rcx
  mov    -0x18(%rbp),%rdx
  mov    %rcx,(%rdx)
  add    %rsi,%rax
  mov    -0x24(%rbp),%edx
  mov    %dl,(%rax)
  jmp    L134
L67:
  mov    -0x10(%rbp),%rax
  mov    (%rax),%rsi
  mov    -0x18(%rbp),%rax
  mov    (%rax),%rax
  lea    0x1(%rax),%rcx
  mov    -0x18(%rbp),%rdx
  mov    %rcx,(%rdx)
  add    %rsi,%rax
  mov    -0x24(%rbp),%edx
  mov    %dl,(%rax)
  jmp    L134
L90:
  nop
  jmp    L118
L209:
  nop
  jmp    L118
L134:
  nop
L118:
  leave
  ret
```

assistant: ```c
void doapr_outch(char **sbuffer, char **buffer, size_t *currlen, size_t *maxlen, int c) {
  assert(*sbuffer != NULL || buffer != NULL);
  if (buffer) {
    while (*currlen >= *maxlen) {
      if (*buffer == NULL) {
        if (*maxlen == 0)
          *maxlen = 1024;
        *buffer = OPENSSL_malloc(*maxlen);
        if (!*buffer) {
          return;
        }
        if (*currlen > 0) {
          assert(*sbuffer != NULL);
          memcpy(*buffer, *sbuffer, *currlen);
        }
        *sbuffer = NULL;
      } else {
        *maxlen += 1024;
        *buffer = OPENSSL_realloc(*buffer, *maxlen);
        if (!*buffer) {
          return;
        }
      }
    }
    assert(*sbuffer != NULL || *buffer != NULL);
  }
  if (*currlen < *maxlen) {
    if (*sbuffer)
      (*sbuffer)[(*currlen)++] = (char)c;
    else
      (*buffer)[(*currlen)++] = (char)c;
  }
  return;
}
```