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

```asm
<getline>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x18,%rsp
  test   %rsi,%rsi
  sete   %al
  test   %rdx,%rdx
  mov    %rdi,0x8(%rsp)
  sete   %dl
  or     %dl,%al
  jne    L158
  test   %rdi,%rdi
  je     L158
  mov    0x8(%rsp),%rax
  mov    %rsi,%r14
  mov    (%rax),%rax
  mov    %rax,(%rsp)
  test   %rax,%rax
  je     L65
  mov    (%rsi),%r12
L134:
  mov    D10(%rip),%rbp
  nopl   0x0(%rax)
L15:
  mov    %rbx,%rdi
  call   <getc@plt>
  mov    0x0(%rbp),%r15d
  mov    %eax,%r13d
  cmp    $0xd,%eax
  je     L15
  mov    0x8(%rsp),%rcx
  mov    (%r14),%rax
  xor    %edi,%edi
  add    (%rcx),%rax
  mov    (%rsp),%rcx
  lea    (%rcx,%r12,1),%rsi
  cmp    %rsi,%rax
  sete   %dil
  call   <assert@plt>
  mov    (%rsp),%rax
  mov    %rax,%rdx
  cmp    $0x1,%r12
  jbe    L144
L105:
  mov    %rbx,%rdi
  mov    %rdx,(%rsp)
  call   <ferror@plt>
  mov    (%rsp),%rdx
  test   %rax,%rax
  jne    L146
  mov    D37(%rip),%rax
  cmp    %r13d,(%rax)
  je     L5
  lea    0x1(%rdx),%rax
  mov    %r13b,(%rdx)
  sub    $0x1,%r12
  mov    %rax,(%rsp)
  cmp    $0xa,%r13d
  jne    L15
  mov    %rax,%rdx
L73:
  mov    0x8(%rsp),%rsi
  movb   $0x0,(%rdx)
  mov    %edx,%eax
  sub    (%rsi),%eax
L102:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L144:
  mov    (%r14),%rsi
  mov    0x8(%rsp),%rcx
  add    %rsi,%rsi
  mov    (%rcx),%rdi
  mov    %rsi,(%r14)
  lea    (%rdi,%rsi,1),%r12
  sub    %rax,%r12
  call   <realloc@plt>
  mov    0x8(%rsp),%rcx
  mov    %rax,(%rcx)
  test   %rax,%rax
  je     L139
  sub    %r12,%rax
  mov    $0x1,%edi
  add    (%r14),%rax
  mov    %rax,(%rsp)
  call   <assert@plt>
  mov    (%rsp),%rdx
  jmp    L105
L146:
  mov    %r15d,0x0(%rbp)
  add    $0x18,%rsp
  mov    $0xffffffff,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L5:
  mov    0x8(%rsp),%rax
  cmp    %rdx,(%rax)
  jne    L73
  mov    $0xffffffff,%eax
  jmp    L102
  nopl   0x0(%rax,%rax,1)
L65:
  movq   $0x80,(%rsi)
  mov    $0x80,%edi
  call   <malloc@plt>
  mov    0x8(%rsp),%rsi
  mov    %rax,(%rsp)
  mov    %rax,(%rsi)
  test   %rax,%rax
  je     L152
  mov    $0x80,%r12d
  jmp    L134
L139:
  mov    D63(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,0x0(%rbp)
  add    $0x18,%rsp
  mov    $0xffffffff,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L158:
  mov    D32(%rip),%rax
  mov    (%rax),%edx
  mov    D10(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L102
L152:
  mov    D63(%rip),%rax
  mov    (%rax),%edx
  mov    D10(%rip),%rax
  mov    %edx,(%rax)
  or     $0xffffffff,%eax
  jmp    L102
```

assistant: ```c
ssize_t getline(char **lineptr, size_t *n, FILE *stream) {
  size_t nchars_avail;
  char *read_pos;
  int save_errno;
  ssize_t ret;
  register int c;
  if (!lineptr || !n || !stream) {
    errno = EINVAL;
    return -1;
  }
  if (!*lineptr) {
    *n = 128;
    *lineptr = malloc(*n);
    if (!*lineptr) {
      errno = ENOMEM;
      return -1;
    }
  }
  nchars_avail = *n;
  read_pos = *lineptr;
  for (;;) {
    c = getc(stream);
    save_errno = errno;
    if (c != '\r') {
      assert((*lineptr + *n) == (read_pos + nchars_avail));
      if (nchars_avail < 2) {
        *n *= 2;
        nchars_avail = *n + *lineptr - read_pos;
        *lineptr = realloc(*lineptr, *n);
        if (!*lineptr) {
          errno = ENOMEM;
          return -1;
        }
        read_pos = *n - nchars_avail + *lineptr;
        assert((*lineptr + *n) == (read_pos + nchars_avail));
      }
      if (ferror(stream)) {
        errno = save_errno;
        return -1;
      }
      if (c == EOF) {
        if (read_pos == *lineptr)
          return -1;
        else
          break;
      }
      *read_pos++ = c;
      nchars_avail--;
      if (c == '\n')
        break;
    }
  }
  *read_pos = '\0';
  ret = read_pos - *lineptr;
  return ret;
}
```