user: Demonstrate the C code that generates the assembly output below:

```asm
<getdelim>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %edx,-0x44(%rbp)
  mov    %rcx,-0x50(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L9
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L21
L9:
  mov    D7(%rip),%rax
  mov    (%rax),%rdx
  mov    -0x40(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L21
  mov    $0xffffffff,%eax
  jmp    L142
L21:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rax
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
L105:
  mov    -0x50(%rbp),%rax
  mov    %rax,%rdi
  call   <fgetc@plt>
  mov    %eax,-0x2c(%rbp)
  cmpl   $0xffffffff,-0x2c(%rbp)
  jne    L132
  mov    -0x50(%rbp),%rax
  mov    %rax,%rdi
  call   <feof@plt>
  test   %rax,%rax
  je     L125
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%rax
  sub    %rdx,%rax
  mov    %eax,-0x24(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  je     L125
  mov    -0x20(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x24(%rbp),%eax
  jmp    L142
L125:
  mov    $0xffffffff,%eax
  jmp    L142
L132:
  mov    -0x20(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x20(%rbp)
  mov    -0x2c(%rbp),%edx
  mov    %dl,(%rax)
  mov    -0x2c(%rbp),%eax
  cmp    -0x44(%rbp),%eax
  jne    L69
  mov    -0x20(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%rax
  sub    %rdx,%rax
  jmp    L142
L69:
  mov    -0x20(%rbp),%rax
  add    $0x2,%rax
  cmp    %rax,-0x18(%rbp)
  ja     L105
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rax
  add    %rax,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%rax
  sub    %rdx,%rax
  mov    %eax,-0x28(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x10(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L52
  mov    $0xffffffff,%eax
  jmp    L142
L52:
  mov    -0x38(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0x40(%rbp),%rax
  mov    -0x10(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0x8(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x28(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x20(%rbp)
  jmp    L105
L142:
  leave
  ret
```

assistant: ```c
ssize_t getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp) {
  char *ptr, *eptr;
  if (*buf == NULL || *bufsiz == 0) {
    *bufsiz = BUFSIZ;
    if ((*buf = malloc(*bufsiz)) == NULL)
      return -1;
  }
  for (ptr = *buf, eptr = *buf + *bufsiz;;) {
    int c = fgetc(fp);
    if (c == -1) {
      if (feof(fp)) {
        ssize_t diff = (ssize_t)(ptr - *buf);
        if (diff != 0) {
          *ptr = '\0';
          return diff;
        }
      }
      return -1;
    }
    *ptr++ = c;
    if (c == delimiter) {
      *ptr = '\0';
      return ptr - *buf;
    }
    if (ptr + 2 >= eptr) {
      char *nbuf;
      size_t nbufsiz = *bufsiz * 2;
      ssize_t d = ptr - *buf;
      if ((nbuf = realloc(*buf, nbufsiz)) == NULL)
        return -1;
      *buf = nbuf;
      *bufsiz = nbufsiz;
      eptr = nbuf + nbufsiz;
      ptr = nbuf + d;
    }
  }
}
```