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

```asm
<adbuf_printf>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x4f0,%rsp
  mov    %rdi,-0x4e8(%rbp)
  mov    %rsi,-0x4f0(%rbp)
  mov    %rdx,-0xa0(%rbp)
  mov    %rcx,-0x98(%rbp)
  mov    %r8,-0x90(%rbp)
  mov    %r9,-0x88(%rbp)
  test   %al,%al
  je     L60
  movaps %xmm0,-0x80(%rbp)
  movaps %xmm1,-0x70(%rbp)
  movaps %xmm2,-0x60(%rbp)
  movaps %xmm3,-0x50(%rbp)
  movaps %xmm4,-0x40(%rbp)
  movaps %xmm5,-0x30(%rbp)
  movaps %xmm6,-0x20(%rbp)
  movaps %xmm7,-0x10(%rbp)
L60:
  mov    %fs:0x28,%rax
  mov    %rax,-0xb8(%rbp)
  xor    %eax,%eax
  mov    -0x4f0(%rbp),%rdx
  mov    -0x4dc(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <va_start@plt>
  mov    -0x4dc(%rbp),%ecx
  mov    -0x4f0(%rbp),%rdx
  lea    -0x4c0(%rbp),%rax
  mov    $0x400,%esi
  mov    %rax,%rdi
  call   <vsnprintf@plt>
  mov    %eax,-0x4d8(%rbp)
  movb   $0x0,-0xc1(%rbp)
  mov    -0x4dc(%rbp),%eax
  mov    %eax,%edi
  call   <va_end@plt>
  cmpl   $0x0,-0x4d8(%rbp)
  jns    L7
  lea    -0x4c0(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  lea    -0x4c0(%rbp),%rcx
  mov    -0x4e8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <adbuf_add@plt>
  jmp    L21
L7:
  cmpl   $0x3ff,-0x4d8(%rbp)
  jle    L59
  mov    -0x4d8(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x4c8(%rbp)
  cmpq   $0x0,-0x4c8(%rbp)
  jne    L49
  mov    $0x1,%eax
  jmp    L21
L49:
  mov    -0x4f0(%rbp),%rdx
  mov    -0x4dc(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <va_start@plt>
  mov    -0x4d8(%rbp),%eax
  lea    0x1(%rax),%esi
  mov    -0x4dc(%rbp),%ecx
  mov    -0x4f0(%rbp),%rdx
  mov    -0x4c8(%rbp),%rax
  mov    %rax,%rdi
  call   <vsnprintf@plt>
  mov    %eax,-0x4d4(%rbp)
  mov    -0x4d8(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x4c8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x4dc(%rbp),%eax
  mov    %eax,%edi
  call   <va_end@plt>
  mov    -0x4d4(%rbp),%eax
  cmp    -0x4d8(%rbp),%eax
  jne    L13
  mov    -0x4d8(%rbp),%edx
  mov    -0x4c8(%rbp),%rcx
  mov    -0x4e8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <adbuf_add@plt>
  mov    %eax,-0x4cc(%rbp)
  mov    -0x4c8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x4cc(%rbp),%eax
  jmp    L21
L13:
  mov    -0x4c8(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    -0x4c8(%rbp),%rcx
  mov    -0x4e8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <adbuf_add@plt>
  mov    %eax,-0x4d0(%rbp)
  mov    -0x4c8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x4d0(%rbp),%eax
  jmp    L21
L59:
  mov    -0x4d8(%rbp),%edx
  lea    -0x4c0(%rbp),%rcx
  mov    -0x4e8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <adbuf_add@plt>
L21:
  mov    -0xb8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L11
  call   <__stack_chk_fail@plt>
L11:
  leave
  ret
```

assistant: ```c
int adbuf_printf(struct adbuf *dst, const char *fmt, ...) {
  char buf[1024];
  int retval;
  va_list ap;
  va_start(ap, fmt);
  retval = vsnprintf(buf, 1024, fmt, ap);
  buf[1024 - 1] = '\0';
  va_end(ap);
  if (retval <= -1) {
    return adbuf_add(dst, buf, strlen(buf));
  }
  if (retval >= 1024) {
    char *dynbuf;
    int newretval;
    if ((dynbuf = malloc(retval + 1)) == NULL)
      return 1;
    va_start(ap, fmt);
    newretval = vsnprintf(dynbuf, retval + 1, fmt, ap);
    dynbuf[retval] = '\0';
    va_end(ap);
    if (newretval == retval) {
      int rv;
      rv = adbuf_add(dst, dynbuf, retval);
      free(dynbuf);
      return rv;
    } else {
      int rv;
      rv = adbuf_add(dst, dynbuf, strlen(dynbuf));
      free(dynbuf);
      return rv;
    }
  } else {
    return adbuf_add(dst, buf, retval);
  }
}
```