user: Please show me the C implementation that matches the assembly code listed below:

```asm
<getdelims>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  je     L49
  cmpq   $0x0,-0x30(%rbp)
  je     L49
  cmpq   $0x0,-0x38(%rbp)
  je     L49
  cmpq   $0x0,-0x40(%rbp)
  jne    L63
L49:
  mov    D17(%rip),%rax
  mov    (%rax),%edx
  mov    D45(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L193
L63:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L199
  mov    -0x30(%rbp),%rax
  movq   $0x0,(%rax)
L199:
  movq   $0x0,-0x10(%rbp)
  jmp    L106
L125:
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jb     L95
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  lea    0x80(%rax),%rdx
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L0
  mov    D2(%rip),%rax
  mov    (%rax),%edx
  mov    D45(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L193
L0:
  mov    -0x28(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  lea    0x80(%rax),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
L95:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rcx
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x10(%rbp)
  add    %rcx,%rax
  mov    -0x1c(%rbp),%edx
  mov    %dl,(%rax)
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  jmp    L171
L80:
  mov    -0x1c(%rbp),%eax
  movzbl %al,%ecx
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  movsbl %al,%eax
  cmp    %eax,%ecx
  je     L14
L171:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L80
  jmp    L91
L14:
  nop
L91:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L128
L106:
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <fgetc@plt>
  mov    %eax,-0x1c(%rbp)
  mov    D30(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x1c(%rbp)
  jne    L125
  jmp    L67
L128:
  nop
L67:
  cmpq   $0x0,-0x10(%rbp)
  je     L114
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
L114:
  cmpq   $0x0,-0x10(%rbp)
  je     L47
  mov    -0x10(%rbp),%rax
  jmp    L193
L47:
  mov    $0xffffffff,%eax
L193:
  leave
  ret
```

assistant: ```c
ssize_t getdelims(char **lineptr, size_t *n, const char *delims, FILE *stream) {
  void *tmp;
  const char *d;
  int c;
  size_t i;
  if (!lineptr || !n || !delims || !stream) {
    errno = EINVAL;
    return -1;
  }
  if (!*lineptr)
    *n = 0;
  i = 0;
  while ((c = fgetc(stream)) != EOF) {
    if (i + 1 >= *n) {
      if ((tmp = realloc(*lineptr, *n + 128)) == NULL) {
        errno = ENOMEM;
        return -1;
      }
      *lineptr = tmp;
      *n += 128;
    }
    (*lineptr)[i++] = (unsigned char)c;
    d = delims;
    while (*d) {
      if ((unsigned char)c == *d++)
        break;
    }
    if (*d != '\0')
      break;
  }
  if (i != 0)
    (*lineptr)[i] = '\0';
  return (i == 0) ? -1 : (ssize_t)i;
}
```