user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<pd_getline>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,%r15
  mov    %esi,%r13d
  mov    %rdx,%r12
  mov    %rcx,%r14
  mov    %r8,0x10(%rsp)
  mov    %r9,0x28(%rsp)
  mov    0x78(%rsp),%rbp
  mov    $0x400,%edi
  call   <malloc@plt>
  mov    %rax,0x0(%rbp)
  test   %rax,%rax
  je     L32
  movb   $0x0,(%rax)
  mov    $0x400,%ebx
  movl   $0x0,0xc(%rsp)
  lea    -0x1(%r13),%eax
  mov    %eax,0x18(%rsp)
L29:
  mov    (%r12),%edi
  cmp    (%r14),%edi
  jl     L11
  movl   $0x0,(%r12)
  mov    0x88(%rsp),%r8d
  mov    0x80(%rsp),%rcx
  mov    0x18(%rsp),%edx
  mov    %r15,%rsi
  mov    0x70(%rsp),%edi
  mov    0x10(%rsp),%rax
  call   *%rax
  mov    %eax,(%r14)
  test   %eax,%eax
  jle    L47
  cltq
  movb   $0x0,(%r15,%rax,1)
  jmp    L29
L32:
  mov    0x28(%rsp),%rcx
  test   %rcx,%rcx
  je     L119
  mov    0x88(%rsp),%edx
  mov    0x80(%rsp),%rsi
  mov    0x70(%rsp),%edi
  mov    %rcx,%rax
  call   *%rax
  mov    $0x0,%eax
  jmp    L119
L11:
  movslq %edi,%rdi
  add    %r15,%rdi
  mov    $0xa,%esi
  call   <strchr@plt>
  mov    %rax,0x20(%rsp)
  test   %rax,%rax
  je     L2
  mov    $0x1,%eax
  sub    (%r12),%eax
  mov    0x20(%rsp),%rcx
  mov    %rcx,%rdx
  sub    %r15,%rdx
  add    %edx,%eax
  mov    %eax,0x1c(%rsp)
  movb   $0x0,(%rcx)
L6:
  mov    0x1c(%rsp),%ecx
  mov    %ecx,%r13d
  mov    %ebx,%eax
  sub    0xc(%rsp),%eax
  cmp    %ecx,%eax
  jge    L45
L95:
  add    %ebx,%ebx
  mov    %ebx,%esi
  mov    0x0(%rbp),%rdi
  call   <realloc@plt>
  test   %rax,%rax
  je     L40
  mov    %rax,0x0(%rbp)
  mov    %ebx,%eax
  sub    0xc(%rsp),%eax
  cmp    %r13d,%eax
  jl     L95
L45:
  movslq (%r12),%rsi
  add    %r15,%rsi
  mov    0xc(%rsp),%r13d
  movslq %r13d,%rdi
  add    0x0(%rbp),%rdi
  mov    0x1c(%rsp),%edx
  call   <memcpy@plt>
  mov    0x1c(%rsp),%eax
  add    %eax,%r13d
  mov    %r13d,0xc(%rsp)
  add    %eax,(%r12)
  cmpq   $0x0,0x20(%rsp)
  je     L29
  mov    $0xd,%esi
  mov    0x0(%rbp),%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L147
  movb   $0x0,(%rax)
L147:
  mov    (%r12),%edx
  movslq %edx,%rcx
  mov    $0x1,%eax
  cmpb   $0x0,(%r15,%rcx,1)
  jne    L119
  add    $0x1,%edx
  mov    %edx,(%r12)
  jmp    L119
L2:
  mov    (%r12),%eax
  mov    (%r14),%edx
  sub    %eax,%edx
  cltq
  lea    (%r15,%rax,1),%rdi
  mov    $0x0,%esi
  call   <memchr@plt>
  mov    %rax,0x20(%rsp)
  test   %rax,%rax
  je     L199
  mov    $0x1,%eax
  sub    (%r12),%eax
  mov    0x20(%rsp),%rdx
  sub    %r15,%rdx
  add    %edx,%eax
  mov    %eax,0x1c(%rsp)
  jmp    L6
L199:
  mov    (%r14),%eax
  sub    (%r12),%eax
  mov    %eax,0x1c(%rsp)
  jmp    L6
L40:
  mov    0x0(%rbp),%rdi
  call   <free@plt>
  movq   $0x0,0x0(%rbp)
  mov    $0x0,%eax
  mov    0x28(%rsp),%rcx
  test   %rcx,%rcx
  je     L119
  mov    0x88(%rsp),%edx
  mov    0x80(%rsp),%rsi
  mov    0x70(%rsp),%edi
  mov    %rcx,%rax
  call   *%rax
  mov    $0x0,%eax
L119:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L47:
  mov    0x0(%rbp),%rdi
  call   <free@plt>
  movq   $0x0,0x0(%rbp)
  mov    $0x0,%eax
  mov    0x28(%rsp),%rcx
  test   %rcx,%rcx
  je     L119
  mov    0x88(%rsp),%edx
  mov    0x80(%rsp),%rsi
  mov    0x70(%rsp),%edi
  call   *%rcx
  mov    $0x0,%eax
  jmp    L119
```

assistant: ```c
int pd_getline(char *buf, unsigned int bufsize, int *bufcur, int *buflen, int (*readfunc)(int, void *, unsigned int, char *, int), int (*closefunc)(int, char *, int), int readfd, char **line, char *errdesc, int errlen) {
  char *eol;
  unsigned int srcsize;
  int linelen;
  int linesize = 1024;
  linelen = 0;
  if (!(*line = malloc(linesize))) {
    if (closefunc)
      (void)closefunc(readfd, errdesc, errlen);
    return 0;
  }
  **line = 0;
top:
  while (*bufcur < *buflen) {
    if (!(eol = strchr(buf + *bufcur, '\n'))) {
      if (!(eol = memchr(buf + *bufcur, '\0', *buflen - *bufcur))) {
        srcsize = *buflen - *bufcur;
      } else {
        srcsize = eol - buf - *bufcur + 1;
      }
    } else {
      srcsize = eol - buf - *bufcur + 1;
      *eol = 0;
    }
    while ((int)srcsize > (linesize - linelen)) {
      char *newline;
      linesize *= 2;
      if ((newline = realloc(*line, linesize)) == NULL) {
        free(*line);
        *line = NULL;
        *line = NULL;
        if (closefunc)
          (void)closefunc(readfd, errdesc, errlen);
        return 0;
      }
      *line = newline;
    }
    memcpy(*line + linelen, buf + *bufcur, srcsize);
    linelen += srcsize;
    *bufcur += srcsize;
    if (eol) {
      if ((eol = strchr(*line, '\r')) != NULL)
        *eol = 0;
      if (!buf[*bufcur])
        (*bufcur)++;
      return 1;
    }
  }
  *bufcur = 0;
  if ((*buflen = readfunc(readfd, buf, bufsize - 1, errdesc, errlen)) <= 0) {
    free(*line);
    *line = NULL;
    *line = NULL;
    if (closefunc)
      (void)closefunc(readfd, errdesc, errlen);
    return 0;
  }
  buf[*buflen] = 0;
  goto top;
}
```