user: 请将以下的汇编代码转换成C语言代码：

```asm
<getline>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdx,%rbp
  test   %rsi,%rsi
  sete   %al
  test   %rdx,%rdx
  sete   %dl
  or     %dl,%al
  jne    L103
  mov    %rdi,%r15
  mov    %rsi,%r14
  test   %rdi,%rdi
  je     L103
  cmpq   $0x0,(%rdi)
  je     L150
L116:
  mov    (%r14),%r13
  mov    (%r15),%rax
  mov    %rax,0x8(%rsp)
  jmp    L39
L103:
  mov    D45(%rip),%rax
  mov    (%rax),%edx
  mov    D30(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L25
L150:
  movq   $0x80,(%rsi)
  mov    $0x80,%edi
  call   <malloc@plt>
  mov    %rax,(%r15)
  test   %rax,%rax
  jne    L116
  mov    D26(%rip),%rax
  mov    (%rax),%edx
  mov    D30(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L25
L87:
  mov    D26(%rip),%rax
  mov    (%rax),%edx
  mov    D30(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L25
L4:
  mov    %rbp,%rdi
  call   <ferror@plt>
  test   %rax,%rax
  jne    L58
  mov    D2(%rip),%rax
  cmp    %ebx,(%rax)
  je     L46
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rcx
  mov    %rcx,0x8(%rsp)
  mov    %bl,(%rax)
  sub    $0x1,%r13
  cmp    $0xa,%ebx
  je     L38
L39:
  mov    %rbp,%rdi
  call   <getc@plt>
  mov    %eax,%ebx
  mov    D30(%rip),%rax
  mov    (%rax),%r12d
  cmp    $0xd,%ebx
  je     L39
  mov    (%r14),%rax
  add    (%r15),%rax
  mov    0x8(%rsp),%rcx
  lea    (%rcx,%r13,1),%rdx
  cmp    %rdx,%rax
  sete   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    0x8(%rsp),%rax
  cmp    $0x1,%r13
  ja     L4
  mov    (%r14),%rsi
  add    %rsi,%rsi
  mov    %rsi,(%r14)
  mov    (%r15),%rdi
  lea    (%rdi,%rsi,1),%r13
  sub    %rax,%r13
  call   <realloc@plt>
  mov    %rax,(%r15)
  test   %rax,%rax
  je     L87
  sub    %r13,%rax
  add    (%r14),%rax
  mov    %rax,0x8(%rsp)
  mov    $0x1,%edi
  call   <assert@plt>
  jmp    L4
L58:
  mov    D30(%rip),%rax
  mov    %r12d,(%rax)
  mov    $0xffffffff,%eax
  jmp    L25
L46:
  mov    0x8(%rsp),%rax
  cmp    %rax,(%r15)
  je     L172
L38:
  mov    0x8(%rsp),%rax
  movb   $0x0,(%rax)
  sub    (%r15),%eax
L25:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L172:
  mov    $0xffffffff,%eax
  jmp    L25
```

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;
}
```