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

```asm
<nl_getmsg>:
  endbr64
  push   %r15
  push   %r14
  xor    %r14d,%r14d
  push   %r13
  mov    $0x10000,%r13d
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %edi,0x8(%rsp)
  lea    0x24(%rsp),%r15
  mov    %esi,0xc(%rsp)
  mov    %rcx,0x10(%rsp)
  mov    %r8,0x18(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  call   <getpid@plt>
  movq   $0x0,(%rsp)
  mov    %rax,%rbp
L100:
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   <realloc@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L124
  cmp    (%rsp),%r13
  jb     L124
  mov    0xc(%rsp),%esi
  mov    0x8(%rsp),%edi
  mov    %r15,%r9
  mov    %r13,%r8
  mov    %rax,%rcx
  mov    %r12d,%edx
  call   <nl_recvmsg@plt>
  mov    %eax,%r14d
  test   %eax,%eax
  js     L151
  mov    D26(%rip),%rdx
  mov    0x24(%rsp),%eax
  and    (%rdx),%eax
  jne    L151
  mov    %rbx,%r13
  test   %r14d,%r14d
  jne    L103
L142:
  mov    0x10(%rsp),%rax
  mov    %rbx,(%rax)
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L175
  add    $0x38,%rsp
  mov    %r14d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L89:
  cmp    %rbp,0x0(%r13)
  jne    L19
  cmp    %r12d,0x8(%r13)
  jne    L19
  mov    D27(%rip),%rdx
  mov    0x10(%r13),%rax
  cmp    (%rdx),%rax
  je     L0
  mov    D24(%rip),%rdx
  cmp    (%rdx),%rax
  je     L137
L19:
  mov    %r13,%rdi
  mov    %r14d,%esi
  call   <NLMSG_NEXT@plt>
  mov    %rax,%r13
L103:
  mov    %r14d,%esi
  mov    %r13,%rdi
  call   <NLMSG_OK@plt>
  test   %rax,%rax
  jne    L89
  jmp    L142
L151:
  mov    %r13,(%rsp)
  mov    %rbx,%r14
  add    %r13,%r13
  jmp    L100
  nop
L124:
  test   %r14,%r14
  jne    L99
  xor    %ebx,%ebx
  mov    $0xffffffff,%r14d
  jmp    L142
  nopw   0x0(%rax,%rax,1)
L99:
  mov    D23(%rip),%rbp
  mov    %r14,%rbx
  mov    0x0(%rbp),%r12d
L102:
  mov    %rbx,%rdi
  mov    $0xffffffff,%r14d
  call   <free@plt>
  mov    %r12d,0x0(%rbp)
  jmp    L142
L0:
  mov    0x18(%rsp),%rax
  addl   $0x1,(%rax)
  jmp    L142
L137:
  mov    %r13,%rdi
  call   <NLMSG_DATA@plt>
  mov    0x18(%r13),%r12
  mov    $0x4,%edi
  mov    %rax,%rbp
  call   <NLMSG_LENGTH@plt>
  cmp    %rax,%r12
  jl     L47
  mov    0x0(%rbp),%r12d
  neg    %r12d
L111:
  mov    D23(%rip),%rbp
  mov    %r12d,0x0(%rbp)
  jmp    L102
L47:
  mov    D31(%rip),%rax
  mov    (%rax),%r12d
  jmp    L111
L175:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int nl_getmsg(int sd, int request, int seq, struct nlmsghdr **nlhp, int *done) {
  struct nlmsghdr *nh;
  size_t bufsize = 65536, lastbufsize = 0;
  void *buff = NULL;
  int result = 0, read_size;
  int msg_flags;
  pid_t pid = getpid();
  for (;;) {
    void *newbuff = realloc(buff, bufsize);
    if (newbuff == NULL || bufsize < lastbufsize) {
      result = -1;
      break;
    }
    buff = newbuff;
    result = read_size = nl_recvmsg(sd, request, seq, buff, bufsize, &msg_flags);
    if (read_size < 0 || (msg_flags & MSG_TRUNC)) {
      lastbufsize = bufsize;
      bufsize *= 2;
      continue;
    }
    if (read_size == 0)
      break;
    nh = (struct nlmsghdr *)buff;
    for (nh = (struct nlmsghdr *)buff; NLMSG_OK(nh, read_size); nh = (struct nlmsghdr *)NLMSG_NEXT(nh, read_size)) {
      if (nh->nlmsg_pid != pid || nh->nlmsg_seq != seq)
        continue;
      if (nh->nlmsg_type == NLMSG_DONE) {
        (*done)++;
        break;
      }
      if (nh->nlmsg_type == NLMSG_ERROR) {
        struct nlmsgerr *nlerr = (struct nlmsgerr *)NLMSG_DATA(nh);
        result = -1;
        if (nh->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr)))
          errno = (EIO);
        else
          errno = (-nlerr->error);
        break;
      }
    }
    break;
  }
  if (result < 0)
    if (buff) {
      int saved_errno = errno;
      free(buff);
      errno = (saved_errno);
    }
  *nlhp = (struct nlmsghdr *)buff;
  return result;
}
```