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

```asm
<res_nmkquery>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x120,%rsp
  mov    %rdi,-0xe8(%rbp)
  mov    %esi,-0xec(%rbp)
  mov    %rdx,-0xf8(%rbp)
  mov    %ecx,-0xf0(%rbp)
  mov    %r8d,-0xfc(%rbp)
  mov    %r9,-0x108(%rbp)
  mov    0x18(%rbp),%rax
  mov    %rax,-0x110(%rbp)
  mov    0x20(%rbp),%rax
  mov    %rax,-0x118(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpq   $0x0,-0x118(%rbp)
  je     L152
  mov    D9(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,0x28(%rbp)
  jge    L176
L152:
  mov    $0xffffffff,%eax
  jmp    L123
L176:
  mov    D9(%rip),%rax
  mov    (%rax),%edx
  mov    -0x118(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    -0x118(%rbp),%rax
  mov    %rax,-0xd0(%rbp)
L67:
  lea    -0xb8(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <__gettimeofday@plt>
  mov    -0xb8(%rbp),%eax
  shl    $0x8,%eax
  mov    %eax,%edx
  mov    -0xb4(%rbp),%eax
  xor    %edx,%eax
  mov    %eax,-0xe0(%rbp)
  mov    -0xe0(%rbp),%eax
  movzwl %ax,%eax
  test   %eax,%eax
  je     L67
  mov    -0xe8(%rbp),%rax
  mov    (%rax),%edx
  mov    -0xe0(%rbp),%eax
  add    %edx,%eax
  movzwl %ax,%edx
  mov    -0xe8(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0xe8(%rbp),%rax
  mov    (%rax),%edx
  mov    -0xd0(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0xd0(%rbp),%rax
  mov    -0xec(%rbp),%edx
  mov    %edx,0x4(%rax)
  mov    -0xe8(%rbp),%rax
  mov    0x4(%rax),%edx
  mov    D27(%rip),%rax
  mov    (%rax),%eax
  and    %edx,%eax
  test   %eax,%eax
  setne  %al
  movzbl %al,%edx
  mov    -0xd0(%rbp),%rax
  mov    %edx,0x8(%rax)
  mov    D74(%rip),%rax
  mov    (%rax),%edx
  mov    -0xd0(%rbp),%rax
  mov    %edx,0x28(%rax)
  mov    D9(%rip),%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x118(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0xd8(%rbp)
  mov    D9(%rip),%rax
  mov    (%rax),%eax
  sub    %eax,0x28(%rbp)
  lea    -0xb0(%rbp),%rax
  mov    %rax,-0xc8(%rbp)
  mov    -0xc8(%rbp),%rax
  lea    0x8(%rax),%rdx
  mov    %rdx,-0xc8(%rbp)
  mov    -0x118(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0xc8(%rbp),%rax
  lea    0x8(%rax),%rdx
  mov    %rdx,-0xc8(%rbp)
  movq   $0x0,(%rax)
  lea    -0xb0(%rbp),%rax
  add    $0xa0,%rax
  mov    %rax,-0xc0(%rbp)
  cmpl   $0x82,-0xec(%rbp)
  je     L237
  cmpl   $0x82,-0xec(%rbp)
  jg     L153
  cmpl   $0x80,-0xec(%rbp)
  je     L69
  cmpl   $0x81,-0xec(%rbp)
  jne    L153
  cmpq   $0x0,-0x108(%rbp)
  je     L84
  mov    D46(%rip),%rax
  mov    (%rax),%edx
  jmp    L164
L84:
  mov    $0x0,%edx
L164:
  mov    D12(%rip),%rax
  mov    (%rax),%eax
  add    %edx,%eax
  sub    %eax,0x28(%rbp)
  cmpl   $0x0,0x28(%rbp)
  jns    L274
  mov    $0xffffffff,%eax
  jmp    L123
L69:
  mov    D12(%rip),%rax
  mov    (%rax),%eax
  sub    %eax,0x28(%rbp)
  cmpl   $0x0,0x28(%rbp)
  jns    L30
  mov    $0xffffffff,%eax
  jmp    L123
L274:
  nop
  jmp    L15
L30:
  nop
L15:
  mov    -0xc0(%rbp),%rdi
  lea    -0xb0(%rbp),%rcx
  mov    0x28(%rbp),%edx
  mov    -0xd8(%rbp),%rsi
  mov    -0xf8(%rbp),%rax
  mov    %rdi,%r8
  mov    %rax,%rdi
  call   <ns_name_compress@plt>
  mov    %eax,-0xdc(%rbp)
  cmpl   $0x0,-0xdc(%rbp)
  jns    L29
  mov    $0xffffffff,%eax
  jmp    L123
L29:
  mov    -0xdc(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,-0xd8(%rbp)
  mov    -0xdc(%rbp),%eax
  sub    %eax,0x28(%rbp)
  mov    -0xd8(%rbp),%rdx
  mov    -0xfc(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <NS_PUT16@plt>
  mov    -0xd8(%rbp),%rdx
  mov    -0xf0(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <NS_PUT16@plt>
  mov    $0x1,%edi
  call   <htons@plt>
  mov    -0xd0(%rbp),%rdx
  mov    %rax,0x20(%rdx)
  cmpl   $0x80,-0xec(%rbp)
  je     L211
  cmpq   $0x0,-0x108(%rbp)
  je     L211
  mov    -0xc0(%rbp),%rdi
  lea    -0xb0(%rbp),%rcx
  mov    0x28(%rbp),%edx
  mov    -0xd8(%rbp),%rsi
  mov    -0x108(%rbp),%rax
  mov    %rdi,%r8
  mov    %rax,%rdi
  call   <ns_name_compress@plt>
  mov    %eax,-0xdc(%rbp)
  mov    -0xdc(%rbp),%eax
  shr    $0x1f,%eax
  movzbl %al,%eax
  mov    $0x0,%esi
  mov    %eax,%edi
  call   <__builtin_expect@plt>
  test   %eax,%eax
  je     L264
  mov    $0xffffffff,%eax
  jmp    L123
L264:
  mov    -0xdc(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,-0xd8(%rbp)
  mov    -0xdc(%rbp),%eax
  sub    %eax,0x28(%rbp)
  mov    D64(%rip),%rax
  mov    (%rax),%eax
  mov    -0xd8(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <NS_PUT16@plt>
  mov    -0xd8(%rbp),%rdx
  mov    -0xf0(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <NS_PUT16@plt>
  mov    -0xd8(%rbp),%rax
  mov    %rax,%rsi
  mov    $0x0,%edi
  call   <NS_PUT32@plt>
  mov    -0xd8(%rbp),%rax
  mov    %rax,%rsi
  mov    $0x0,%edi
  call   <NS_PUT16@plt>
  mov    $0x1,%edi
  call   <htons@plt>
  mov    -0xd0(%rbp),%rdx
  mov    %rax,0x18(%rdx)
  jmp    L211
L237:
  mov    D46(%rip),%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%edx
  mov    0x10(%rbp),%eax
  add    %edx,%eax
  cmp    %eax,0x28(%rbp)
  setl   %al
  movzbl %al,%eax
  mov    $0x0,%esi
  mov    %eax,%edi
  call   <__builtin_expect@plt>
  test   %eax,%eax
  je     L183
  mov    $0xffffffff,%eax
  jmp    L123
L183:
  mov    -0xd8(%rbp),%rax
  lea    0x4(%rax),%rdx
  mov    %rdx,-0xd8(%rbp)
  movl   $0x0,(%rax)
  mov    -0xd8(%rbp),%rdx
  mov    -0xfc(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <NS_PUT16@plt>
  mov    -0xd8(%rbp),%rdx
  mov    -0xf0(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <NS_PUT16@plt>
  mov    -0xd8(%rbp),%rax
  mov    %rax,%rsi
  mov    $0x0,%edi
  call   <NS_PUT32@plt>
  mov    -0xd8(%rbp),%rax
  mov    %rax,%rsi
  mov    0x10(%rbp),%edi
  call   <NS_PUT16@plt>
  cmpl   $0x0,0x10(%rbp)
  je     L111
  mov    -0x108(%rbp),%rcx
  mov    -0xd8(%rbp),%rax
  mov    0x10(%rbp),%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    0x10(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,-0xd8(%rbp)
L111:
  mov    $0x1,%edi
  call   <htons@plt>
  mov    -0xd0(%rbp),%rdx
  mov    %rax,0x10(%rdx)
  jmp    L211
L153:
  mov    $0xffffffff,%eax
  jmp    L123
L211:
  mov    -0xd8(%rbp),%rax
  sub    -0x118(%rbp),%rax
  sar    $0x2,%rax
L123:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L203
  call   <__stack_chk_fail@plt>
L203:
  leave
  ret
```

assistant: ```c
int res_nmkquery(res_state statp, int op, const char *dname, int class, int type, const u_char *data, int datalen, const u_char *newrr_in, u_char *buf, int buflen) {
  HEADER *hp;
  u_char *cp;
  int n;
  u_char *dnptrs[20], **dpp, **lastdnptr;
  if ((buf == NULL) || (buflen < HFIXEDSZ))
    return (-1);
  memset(buf, 0, HFIXEDSZ);
  hp = (HEADER *)buf;
  int randombits;
  do {
    struct timeval tv;
    __gettimeofday(&tv, NULL);
    randombits = (tv.tv_sec << 8) ^ tv.tv_usec;
  } while ((randombits & 0xffff) == 0);
  statp->id = (statp->id + randombits) & 0xffff;
  hp->id = statp->id;
  hp->opcode = op;
  hp->rd = (statp->options & RES_RECURSE) != 0;
  hp->rcode = NOERROR;
  cp = buf + HFIXEDSZ;
  buflen -= HFIXEDSZ;
  dpp = dnptrs;
  *dpp++ = buf;
  *dpp++ = NULL;
  lastdnptr = dnptrs + sizeof dnptrs / sizeof dnptrs[0];
  switch (op) {
  case NS_NOTIFY_OP:
    if ((buflen -= QFIXEDSZ + (data == NULL ? 0 : RRFIXEDSZ)) < 0)
      return (-1);
    goto compose;
  case QUERY:
    if ((buflen -= QFIXEDSZ) < 0)
      return (-1);
  compose:
    n = ns_name_compress(dname, cp, buflen, (const u_char **)dnptrs, (const u_char **)lastdnptr);
    if (n < 0)
      return (-1);
    cp += n;
    buflen -= n;
    NS_PUT16(type, cp);
    NS_PUT16(class, cp);
    hp->qdcount = htons(1);
    if (op == QUERY || data == NULL)
      break;
    n = ns_name_compress((char *)data, cp, buflen, (const u_char **)dnptrs, (const u_char **)lastdnptr);
    if (__builtin_expect(n < 0, 0))
      return (-1);
    cp += n;
    buflen -= n;
    NS_PUT16(T_NULL, cp);
    NS_PUT16(class, cp);
    NS_PUT32(0, cp);
    NS_PUT16(0, cp);
    hp->arcount = htons(1);
    break;
  case IQUERY:
    if (__builtin_expect(buflen < 1 + RRFIXEDSZ + datalen, 0))
      return (-1);
    *cp++ = '\0';
    NS_PUT16(type, cp);
    NS_PUT16(class, cp);
    NS_PUT32(0, cp);
    NS_PUT16(datalen, cp);
    if (datalen) {
      memcpy(cp, data, datalen);
      cp += datalen;
    }
    hp->ancount = htons(1);
    break;
  default:
    return (-1);
  }
  return (cp - buf);
}
```