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

```asm
<smtp_fold_whitespace>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %esi,-0x5c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    D2(%rip),%rax
  mov    %rax,-0x28(%rbp)
  cmpl   $0x2,-0x5c(%rbp)
  ja     L15
  movl   $0x3,-0x5c(%rbp)
L15:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x20(%rbp)
  movq   $0x0,-0x40(%rbp)
  movq   $0x0,-0x38(%rbp)
  movq   $0x0,-0x48(%rbp)
  movq   $0x0,-0x30(%rbp)
L47:
  mov    -0x5c(%rbp),%eax
  lea    -0x2(%rax),%edx
  mov    -0x58(%rbp),%rcx
  mov    -0x40(%rbp),%rax
  add    %rcx,%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <smtp_fold_whitespace_get_offset@plt>
  mov    %rax,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %eax,%ecx
  mov    -0x48(%rbp),%rax
  lea    -0x48(%rbp),%rdx
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <smtp_si_add_size_t@plt>
  test   %rax,%rax
  jne    L57
  mov    -0x20(%rbp),%rax
  mov    %eax,%ecx
  mov    -0x48(%rbp),%rax
  lea    -0x48(%rbp),%rdx
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <smtp_si_add_size_t@plt>
  test   %rax,%rax
  jne    L57
  mov    -0x48(%rbp),%rax
  lea    -0x48(%rbp),%rdx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <smtp_si_add_size_t@plt>
  test   %rax,%rax
  jne    L57
  mov    -0x48(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L1
L57:
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
  jmp    L24
L1:
  mov    -0x10(%rbp),%rax
  mov    %rax,-0x30(%rbp)
  mov    -0x58(%rbp),%rdx
  mov    -0x40(%rbp),%rax
  lea    (%rdx,%rax,1),%rsi
  mov    -0x30(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdx
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x38(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x40(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L18
  mov    -0x18(%rbp),%rax
  add    %rax,-0x38(%rbp)
  mov    -0x30(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  add    %rax,%rdx
  mov    -0x28(%rbp),%rax
  mov    %rax,%rsi
  mov    %rdx,%rdi
  call   <strcat@plt>
  mov    -0x20(%rbp),%rax
  add    %rax,-0x38(%rbp)
  mov    -0x18(%rbp),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  add    $0x1,%rax
  mov    %rax,-0x40(%rbp)
  jmp    L47
L18:
  nop
  mov    -0x30(%rbp),%rax
L24:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L36
  call   <__stack_chk_fail@plt>
L36:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D2
datatype: string

tool: D2: 
 

assistant: ```c
char *smtp_fold_whitespace(const char *const s, unsigned int maxlen) {
  const char *const SMTP_LINE_FOLD_STR = "\r\n ";
  size_t end_slen;
  size_t s_i;
  size_t buf_i;
  size_t bufsz;
  size_t ws_offset;
  char *buf;
  char *buf_new;
  if (maxlen < 3) {
    maxlen = 3;
  }
  end_slen = strlen(SMTP_LINE_FOLD_STR);
  s_i = 0;
  buf_i = 0;
  bufsz = 0;
  buf = NULL;
  while (1) {
    ws_offset = smtp_fold_whitespace_get_offset(&s[s_i], maxlen - 2);
    if (smtp_si_add_size_t(bufsz, ws_offset, &bufsz) || smtp_si_add_size_t(bufsz, end_slen, &bufsz) || smtp_si_add_size_t(bufsz, 1, &bufsz) || (buf_new = realloc(buf, bufsz)) == NULL) {
      free(buf);
      return NULL;
    }
    buf = buf_new;
    memcpy(&buf[buf_i], &s[s_i], ws_offset);
    buf[buf_i + ws_offset] = '\0';
    if (s[s_i + ws_offset] == '\0') {
      break;
    }
    buf_i += ws_offset;
    strcat(&buf[buf_i], SMTP_LINE_FOLD_STR);
    buf_i += end_slen;
    s_i += ws_offset + 1;
  }
  return buf;
}
```