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

```asm
<getstr>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %ecx,%eax
  mov    %r8,-0x48(%rbp)
  mov    %al,-0x3c(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  je     L122
  cmpq   $0x0,-0x30(%rbp)
  je     L122
  cmpq   $0x0,-0x38(%rbp)
  jne    L38
L122:
  mov    $0xffffffff,%eax
  jmp    L14
L38:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L23
  mov    -0x30(%rbp),%rax
  movq   $0x40,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L23
  mov    $0xffffffff,%eax
  jmp    L14
L23:
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  mov    %eax,%edx
  mov    -0x48(%rbp),%rax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
L142:
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <getc@plt>
  mov    %eax,%ebx
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x20(%rbp),%edx
  movslq %edx,%rcx
  sub    %rcx,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rcx
  mov    -0x18(%rbp),%rax
  sub    %rcx,%rax
  cmp    %rax,%rdx
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  cmpl   $0x1,-0x20(%rbp)
  jg     L184
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  cmp    $0x40,%rax
  jbe    L153
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  lea    (%rax,%rax,1),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  jmp    L2
L153:
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  lea    0x40(%rax),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
L2:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  add    %rdx,%rax
  sub    -0x18(%rbp),%rax
  mov    %eax,-0x20(%rbp)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    -0x28(%rbp),%rdx
  mov    %rax,(%rdx)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L60
  mov    $0xffffffff,%eax
  jmp    L14
L60:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rcx
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x20(%rbp),%edx
  movslq %edx,%rdx
  sub    %rdx,%rax
  add    %rcx,%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x20(%rbp),%edx
  movslq %edx,%rcx
  sub    %rcx,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rcx
  mov    -0x18(%rbp),%rax
  sub    %rcx,%rax
  cmp    %rax,%rdx
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
L184:
  mov    D5(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,%ebx
  je     L0
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <ferror@plt>
  test   %rax,%rax
  je     L33
L0:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  cmp    %rax,-0x18(%rbp)
  jne    L126
  mov    $0xffffffff,%eax
  jmp    L14
L33:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  mov    %ebx,%edx
  mov    %dl,(%rax)
  subl   $0x1,-0x20(%rbp)
  movsbl -0x3c(%rbp),%eax
  cmp    %eax,%ebx
  je     L59
  jmp    L142
L126:
  nop
  jmp    L134
L59:
  nop
L134:
  mov    -0x18(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x48(%rbp),%rax
  add    %rax,%rdx
  mov    -0x18(%rbp),%rax
  sub    %rdx,%rax
  mov    %eax,-0x1c(%rbp)
  mov    -0x1c(%rbp),%eax
L14:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
int getstr(char **lineptr, size_t *n, FILE *stream, char terminator, size_t offset) {
  int nchars_avail;
  char *read_pos;
  int ret;
  if (!lineptr || !n || !stream)
    return -1;
  if (!*lineptr) {
    *n = 64;
    *lineptr = malloc(*n);
    if (!*lineptr)
      return -1;
  }
  nchars_avail = *n - offset;
  read_pos = *lineptr + offset;
  for (;;) {
    register int c = getc(stream);
    assert(*n - nchars_avail == read_pos - *lineptr);
    if (nchars_avail < 2) {
      if (*n > 64)
        *n *= 2;
      else
        *n += 64;
      nchars_avail = *n + *lineptr - read_pos;
      *lineptr = realloc(*lineptr, *n);
      if (!*lineptr)
        return -1;
      read_pos = *n - nchars_avail + *lineptr;
      assert(*n - nchars_avail == read_pos - *lineptr);
    }
    if (c == EOF || ferror(stream)) {
      if (read_pos == *lineptr)
        return -1;
      else
        break;
    }
    *read_pos++ = c;
    nchars_avail--;
    if (c == terminator)
      break;
  }
  *read_pos = '\0';
  ret = read_pos - (*lineptr + offset);
  return ret;
}
```