user: Converte this assembly snippet into its equivalent C code:

```asm
<fgetln>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    D126(%rip),%rax
  test   %rax,%rax
  jne    L25
  mov    D121(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,D163(%rip)
  mov    D163(%rip),%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,D243(%rip)
  mov    D243(%rip),%rax
  test   %rax,%rax
  jne    L25
  mov    $0x0,%eax
  jmp    L68
L25:
  mov    D163(%rip),%rcx
  mov    D243(%rip),%rax
  mov    -0x28(%rbp),%rdx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L109
  mov    $0x0,%eax
  jmp    L68
L109:
  mov    -0x30(%rbp),%rax
  movq   $0x0,(%rax)
  jmp    L104
L51:
  mov    D163(%rip),%rdx
  mov    D121(%rip),%rax
  mov    (%rax),%rax
  add    %rdx,%rax
  mov    %rax,-0x10(%rbp)
  mov    D243(%rip),%rax
  mov    -0x10(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L108
  mov    D243(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x1c(%rbp)
  mov    D243(%rip),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    D243(%rip),%rax
  mov    -0x1c(%rbp),%edx
  mov    %edx,(%rax)
  movq   $0x0,D243(%rip)
  mov    $0x0,%eax
  jmp    L68
L108:
  mov    -0x8(%rbp),%rax
  mov    %rax,D196(%rip)
  mov    D121(%rip),%rax
  mov    (%rax),%rax
  mov    D196(%rip),%rcx
  mov    D163(%rip),%rdx
  add    %rdx,%rcx
  mov    -0x28(%rbp),%rdx
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L10
  mov    D196(%rip),%rdx
  mov    D163(%rip),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    D196(%rip),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    -0x30(%rbp),%rdx
  mov    %rax,(%rdx)
  mov    D196(%rip),%rax
  jmp    L68
L10:
  mov    D163(%rip),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x10(%rbp),%rax
  mov    %rax,D196(%rip)
L104:
  mov    D196(%rip),%rdx
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  add    %rdx,%rax
  mov    $0xa,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  je     L51
  mov    D196(%rip),%rdx
  mov    -0x18(%rbp),%rax
  sub    %rdx,%rax
  add    $0x1,%rax
  mov    %rax,%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    D196(%rip),%rax
L68:
  leave
  ret
```

assistant: ```c
char *fgetln(FILE *fp, size_t *len) {
  static char *buf = NULL;
  static size_t bufsiz = 0;
  char *ptr;
  if (buf == NULL) {
    bufsiz = BUFSIZ;
    if ((buf = malloc(bufsiz)) == NULL)
      return NULL;
  }
  if (fgets(buf, bufsiz, fp) == NULL)
    return NULL;
  *len = 0;
  while ((ptr = strchr(&buf[*len], '\n')) == NULL) {
    size_t nbufsiz = bufsiz + BUFSIZ;
    char *nbuf = realloc(buf, nbufsiz);
    if (nbuf == NULL) {
      int oerrno = errno;
      free(buf);
      errno = oerrno;
      buf = NULL;
      return NULL;
    } else
      buf = nbuf;
    if (fgets(&buf[bufsiz], BUFSIZ, fp) == NULL) {
      buf[bufsiz] = '\0';
      *len = strlen(buf);
      return buf;
    }
    *len = bufsiz;
    bufsiz = nbufsiz;
  }
  *len = (ptr - buf) + 1;
  return buf;
}
```