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

```asm
<getstr>:
  endbr64
  push   %r15
  mov    %rdx,%r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  test   %rsi,%rsi
  sete   %al
  test   %rdx,%rdx
  mov    %r8,0x18(%rsp)
  sete   %dl
  or     %dl,%al
  jne    L32
  mov    %rdi,%r14
  test   %rdi,%rdi
  je     L32
  mov    (%rdi),%r12
  mov    %rsi,%r13
  test   %r12,%r12
  je     L3
  mov    (%rsi),%ebp
  mov    %r8,%rax
L77:
  sub    %eax,%ebp
  add    %rax,%r12
  movsbl %cl,%eax
  mov    %eax,0x14(%rsp)
  jmp    L26
  nopl   0x0(%rax)
L17:
  mov    D5(%rip),%rax
  cmp    %ebx,(%rax)
  je     L85
L34:
  mov    %r15,%rdi
  mov    %rdx,0x8(%rsp)
  call   <ferror@plt>
  mov    0x8(%rsp),%rdx
  test   %rax,%rax
  jne    L85
  mov    %bl,(%rdx)
  lea    0x1(%rdx),%r12
  sub    $0x1,%ebp
  cmp    %ebx,0x14(%rsp)
  je     L86
L26:
  mov    %r15,%rdi
  call   <getc@plt>
  movslq %ebp,%rdx
  xor    %edi,%edi
  mov    %eax,%ebx
  mov    0x0(%r13),%rax
  sub    %rdx,%rax
  mov    %r12,%rdx
  sub    (%r14),%rdx
  cmp    %rdx,%rax
  sete   %dil
  call   <assert@plt>
  mov    %r12,%rdx
  cmp    $0x1,%ebp
  jg     L17
  mov    0x0(%r13),%rax
  mov    (%r14),%rdi
  cmp    $0x41,%rax
  lea    (%rax,%rax,1),%rcx
  lea    0x40(%rax),%rsi
  cmovae %rcx,%rsi
  mov    %rsi,0x0(%r13)
  lea    (%rdi,%rsi,1),%r12
  sub    %rdx,%r12
  mov    %r12d,%ebp
  call   <realloc@plt>
  mov    %rax,(%r14)
  mov    %rax,%rdx
  test   %rax,%rax
  je     L32
  movslq %r12d,%r12
  mov    $0x1,%edi
  sub    %r12,%rdx
  add    0x0(%r13),%rdx
  mov    %rdx,0x8(%rsp)
  call   <assert@plt>
  mov    D5(%rip),%rax
  mov    0x8(%rsp),%rdx
  cmp    %ebx,(%rax)
  jne    L34
L85:
  cmp    %rdx,(%r14)
  je     L32
L61:
  movb   $0x0,(%rdx)
  mov    0x18(%rsp),%rcx
  mov    %edx,%eax
  add    (%r14),%rcx
  add    $0x28,%rsp
  pop    %rbx
  sub    %ecx,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L86:
  mov    %r12,%rdx
  jmp    L61
  nopl   (%rax)
L3:
  movq   $0x40,(%rsi)
  mov    $0x40,%edi
  mov    %cl,0x8(%rsp)
  call   <malloc@plt>
  mov    %rax,(%r14)
  mov    %rax,%r12
  test   %rax,%rax
  je     L32
  movzbl 0x8(%rsp),%ecx
  mov    0x18(%rsp),%rax
  mov    $0x40,%ebp
  jmp    L77
  nopl   0x0(%rax)
L32:
  add    $0x28,%rsp
  mov    $0xffffffff,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  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;
}
```