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

```asm
<res_nmkquery>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x118,%rsp
  mov    %rdi,-0xf8(%rbp)
  mov    %esi,-0xfc(%rbp)
  mov    %rdx,-0x108(%rbp)
  mov    %ecx,-0x100(%rbp)
  mov    %r8d,-0x10c(%rbp)
  mov    %r9,-0x118(%rbp)
  mov    0x18(%rbp),%rax
  mov    %rax,-0x120(%rbp)
  mov    0x20(%rbp),%rax
  mov    %rax,-0x128(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x28(%rbp)
  xor    %eax,%eax
  cmpq   $0x0,-0x128(%rbp)
  je     L222
  mov    D100(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,0x28(%rbp)
  jge    L120
L222:
  mov    $0xffffffff,%eax
  jmp    L155
L120:
  mov    D100(%rip),%rax
  mov    (%rax),%edx
  mov    -0x128(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    -0x128(%rbp),%r12
L87:
  lea    -0xd8(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <__gettimeofday@plt>
  mov    -0xd8(%rbp),%eax
  shl    $0x8,%eax
  mov    %eax,%edx
  mov    -0xd4(%rbp),%eax
  xor    %edx,%eax
  mov    %eax,-0xec(%rbp)
  mov    -0xec(%rbp),%eax
  movzwl %ax,%eax
  test   %eax,%eax
  je     L87
  mov    -0xf8(%rbp),%rax
  mov    (%rax),%edx
  mov    -0xec(%rbp),%eax
  add    %edx,%eax
  movzwl %ax,%edx
  mov    -0xf8(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0xf8(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,(%r12)
  mov    -0xfc(%rbp),%eax
  mov    %eax,0x4(%r12)
  mov    -0xf8(%rbp),%rax
  mov    0x4(%rax),%edx
  mov    D77(%rip),%rax
  mov    (%rax),%eax
  and    %edx,%eax
  test   %eax,%eax
  setne  %al
  movzbl %al,%eax
  mov    %eax,0x8(%r12)
  mov    D20(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,0x28(%r12)
  mov    D100(%rip),%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x128(%rbp),%rax
  lea    (%rdx,%rax,1),%rbx
  mov    D100(%rip),%rax
  mov    (%rax),%eax
  sub    %eax,0x28(%rbp)
  lea    -0xd0(%rbp),%rax
  mov    %rax,-0xe8(%rbp)
  mov    -0xe8(%rbp),%rax
  lea    0x8(%rax),%rdx
  mov    %rdx,-0xe8(%rbp)
  mov    -0x128(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0xe8(%rbp),%rax
  lea    0x8(%rax),%rdx
  mov    %rdx,-0xe8(%rbp)
  movq   $0x0,(%rax)
  lea    -0xd0(%rbp),%rax
  add    $0xa0,%rax
  mov    %rax,-0xe0(%rbp)
  cmpl   $0x82,-0xfc(%rbp)
  je     L70
  cmpl   $0x82,-0xfc(%rbp)
  jg     L56
  cmpl   $0x80,-0xfc(%rbp)
  je     L105
  cmpl   $0x81,-0xfc(%rbp)
  jne    L56
  cmpq   $0x0,-0x118(%rbp)
  je     L151
  mov    D11(%rip),%rax
  mov    (%rax),%edx
  jmp    L29
L151:
  mov    $0x0,%edx
L29:
  mov    D69(%rip),%rax
  mov    (%rax),%eax
  add    %edx,%eax
  sub    %eax,0x28(%rbp)
  cmpl   $0x0,0x28(%rbp)
  jns    L0
  mov    $0xffffffff,%eax
  jmp    L155
L105:
  mov    D69(%rip),%rax
  mov    (%rax),%eax
  sub    %eax,0x28(%rbp)
  cmpl   $0x0,0x28(%rbp)
  jns    L181
  mov    $0xffffffff,%eax
  jmp    L155
L0:
  nop
  jmp    L194
L181:
  nop
L194:
  mov    -0xe0(%rbp),%rsi
  lea    -0xd0(%rbp),%rcx
  mov    0x28(%rbp),%edx
  mov    -0x108(%rbp),%rax
  mov    %rsi,%r8
  mov    %rbx,%rsi
  mov    %rax,%rdi
  call   <ns_name_compress@plt>
  mov    %eax,%r13d
  test   %r13d,%r13d
  jns    L9
  mov    $0xffffffff,%eax
  jmp    L155
L9:
  movslq %r13d,%rax
  shl    $0x2,%rax
  add    %rax,%rbx
  sub    %r13d,0x28(%rbp)
  mov    -0x10c(%rbp),%eax
  mov    %rbx,%rsi
  mov    %eax,%edi
  call   <NS_PUT16@plt>
  mov    -0x100(%rbp),%eax
  mov    %rbx,%rsi
  mov    %eax,%edi
  call   <NS_PUT16@plt>
  mov    $0x1,%edi
  call   <htons@plt>
  mov    %rax,0x20(%r12)
  cmpl   $0x80,-0xfc(%rbp)
  je     L230
  cmpq   $0x0,-0x118(%rbp)
  je     L230
  mov    -0xe0(%rbp),%rsi
  lea    -0xd0(%rbp),%rcx
  mov    0x28(%rbp),%edx
  mov    -0x118(%rbp),%rax
  mov    %rsi,%r8
  mov    %rbx,%rsi
  mov    %rax,%rdi
  call   <ns_name_compress@plt>
  mov    %eax,%r13d
  mov    %r13d,%eax
  shr    $0x1f,%eax
  movzbl %al,%eax
  mov    $0x0,%esi
  mov    %eax,%edi
  call   <__builtin_expect@plt>
  test   %eax,%eax
  je     L277
  mov    $0xffffffff,%eax
  jmp    L155
L277:
  movslq %r13d,%rax
  shl    $0x2,%rax
  add    %rax,%rbx
  sub    %r13d,0x28(%rbp)
  mov    D109(%rip),%rax
  mov    (%rax),%eax
  mov    %rbx,%rsi
  mov    %eax,%edi
  call   <NS_PUT16@plt>
  mov    -0x100(%rbp),%eax
  mov    %rbx,%rsi
  mov    %eax,%edi
  call   <NS_PUT16@plt>
  mov    %rbx,%rsi
  mov    $0x0,%edi
  call   <NS_PUT32@plt>
  mov    %rbx,%rsi
  mov    $0x0,%edi
  call   <NS_PUT16@plt>
  mov    $0x1,%edi
  call   <htons@plt>
  mov    %rax,0x18(%r12)
  jmp    L230
L70:
  mov    D11(%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     L71
  mov    $0xffffffff,%eax
  jmp    L155
L71:
  mov    %rbx,%rax
  lea    0x4(%rax),%rbx
  movl   $0x0,(%rax)
  mov    -0x10c(%rbp),%eax
  mov    %rbx,%rsi
  mov    %eax,%edi
  call   <NS_PUT16@plt>
  mov    -0x100(%rbp),%eax
  mov    %rbx,%rsi
  mov    %eax,%edi
  call   <NS_PUT16@plt>
  mov    %rbx,%rsi
  mov    $0x0,%edi
  call   <NS_PUT32@plt>
  mov    %rbx,%rsi
  mov    0x10(%rbp),%edi
  call   <NS_PUT16@plt>
  cmpl   $0x0,0x10(%rbp)
  je     L224
  mov    -0x118(%rbp),%rax
  mov    0x10(%rbp),%edx
  mov    %rax,%rsi
  mov    %rbx,%rdi
  call   <memcpy@plt>
  mov    0x10(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,%rbx
L224:
  mov    $0x1,%edi
  call   <htons@plt>
  mov    %rax,0x10(%r12)
  jmp    L230
L56:
  mov    $0xffffffff,%eax
  jmp    L155
L230:
  mov    %rbx,%rax
  sub    -0x128(%rbp),%rax
  sar    $0x2,%rax
L155:
  mov    -0x28(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L235
  call   <__stack_chk_fail@plt>
L235:
  add    $0x118,%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %rbp
  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) {
  register HEADER *hp;
  register u_char *cp;
  register 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);
}
```