user: 请将这段汇编代码片段转换成等效的C代码：

```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)
  movq   $0x0,-0x20(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  je     L48
  cmpq   $0x0,-0x40(%rbp)
  je     L48
  cmpq   $0x0,-0x50(%rbp)
  jne    L167
L48:
  mov    D18(%rip),%rax
  mov    (%rax),%edx
  mov    D6(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L32
L167:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L136
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L40
L136:
  mov    -0x40(%rbp),%rax
  movq   $0x78,(%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    L40
  movl   $0xffffffff,-0x28(%rbp)
  jmp    L81
L40:
  mov    -0x50(%rbp),%rax
  mov    %rax,%rdi
  call   <getc@plt>
  mov    %eax,-0x24(%rbp)
  mov    D28(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x24(%rbp)
  jne    L94
  movl   $0xffffffff,-0x28(%rbp)
  jmp    L10
L94:
  mov    -0x20(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jb     L170
  movq   $0xffffffffffffffff,-0x10(%rbp)
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rax
  add    %rax,%rax
  add    $0x1,%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x10(%rbp),%rax
  cmp    -0x18(%rbp),%rax
  jae    L60
  mov    -0x10(%rbp),%rax
  mov    %rax,-0x18(%rbp)
L60:
  mov    -0x20(%rbp),%rax
  add    $0x1,%rax
  cmp    %rax,-0x18(%rbp)
  ja     L168
  movl   $0xffffffff,-0x28(%rbp)
  jmp    L81
L168:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x18(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L9
  movl   $0xffffffff,-0x28(%rbp)
  jmp    L81
L9:
  mov    -0x38(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0x40(%rbp),%rax
  mov    -0x18(%rbp),%rdx
  mov    %rdx,(%rax)
L170:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    -0x24(%rbp),%edx
  mov    %dl,(%rax)
  addq   $0x1,-0x20(%rbp)
  mov    -0x24(%rbp),%eax
  cmp    -0x44(%rbp),%eax
  je     L65
  jmp    L40
L65:
  nop
L10:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  cmpq   $0x0,-0x20(%rbp)
  je     L23
  mov    -0x20(%rbp),%rax
  jmp    L54
L23:
  mov    -0x28(%rbp),%eax
L54:
  mov    %eax,-0x28(%rbp)
L81:
  mov    -0x28(%rbp),%eax
L32:
  leave
  ret
```

assistant: ```c
ssize_t getdelim(char **lineptr, size_t *n, int delimiter, FILE *fp) {
  ssize_t result;
  size_t cur_len = 0;
  if (lineptr == NULL || n == NULL || fp == NULL) {
    errno = EINVAL;
    return -1;
  }
  ((void)0);
  if (*lineptr == NULL || *n == 0) {
    *n = 120;
    *lineptr = (char *)malloc(*n);
    if (*lineptr == NULL) {
      result = -1;
      goto unlock_return;
    }
  }
  for (;;) {
    int i;
    i = getc(fp);
    if (i == EOF) {
      result = -1;
      break;
    }
    if (cur_len + 1 >= *n) {
      size_t needed_max = ((ssize_t)(((size_t)-1) / 2)) < ((size_t)-1) ? (size_t)((ssize_t)(((size_t)-1) / 2)) + 1 : ((size_t)-1);
      size_t needed = 2 * *n + 1;
      char *new_lineptr;
      if (needed_max < needed)
        needed = needed_max;
      if (cur_len + 1 >= needed) {
        result = -1;
        goto unlock_return;
      }
      new_lineptr = (char *)realloc(*lineptr, needed);
      if (new_lineptr == NULL) {
        result = -1;
        goto unlock_return;
      }
      *lineptr = new_lineptr;
      *n = needed;
    }
    (*lineptr)[cur_len] = i;
    cur_len++;
    if (i == delimiter)
      break;
  }
  (*lineptr)[cur_len] = '\0';
  result = cur_len ? (int)cur_len : (int)result;
unlock_return:
  ((void)0);
  return result;
}
```