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

```asm
<res_search>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%rbp
  mov    %esi,%r14d
  mov    %edx,%r15d
  mov    %rcx,%r13
  mov    %r8d,0xc(%rsp)
  mov    D219(%rip),%rax
  mov    (%rax),%eax
  mov    D74(%rip),%rdx
  and    (%rdx),%eax
  je     L391
L196:
  mov    D121(%rip),%rax
  movq   $0x0,(%rax)
  mov    D139(%rip),%rax
  movl   $0x82,(%rax)
  movzbl 0x0(%rbp),%edx
  test   %dl,%dl
  je     L159
  mov    %rbp,%rax
  mov    $0x0,%ebx
L529:
  cmp    $0x2e,%dl
  sete   %dl
  movzbl %dl,%edx
  add    %rdx,%rbx
  add    $0x1,%rax
  movzbl (%rax),%edx
  test   %dl,%dl
  jne    L529
  mov    $0x0,%r12d
  cmp    %rax,%rbp
  jae    L438
  cmpb   $0x2e,-0x1(%rax)
  sete   %r12b
  movzbl %r12b,%r12d
L438:
  test   %rbx,%rbx
  je     L41
  mov    D219(%rip),%rax
  cmp    0x8(%rax),%rbx
  jge    L176
  test   %rbx,%rbx
  je     L414
  movl   $0x0,0x1c(%rsp)
  movl   $0xffffffff,0x10(%rsp)
  test   %r12d,%r12d
  jne    L414
L492:
  mov    D219(%rip),%rax
  mov    (%rax),%eax
  mov    D101(%rip),%rdx
  and    (%rdx),%eax
  je     L449
L99:
  mov    D219(%rip),%rax
  mov    0x10(%rax),%r12
  mov    (%r12),%rsi
  test   %rsi,%rsi
  je     L276
  movl   $0x0,0x18(%rsp)
  movl   $0x0,0x14(%rsp)
  jmp    L15
L391:
  call   <res_init@plt>
  mov    %eax,0x10(%rsp)
  cmp    $0xffffffff,%eax
  jne    L196
  mov    D120(%rip),%rax
  mov    (%rax),%edx
  mov    D139(%rip),%rax
  mov    %edx,(%rax)
  jmp    L496
L159:
  mov    $0x0,%ebx
  mov    $0x0,%r12d
L41:
  mov    %rbp,%rdi
  call   <hostalias@plt>
  test   %rax,%rax
  jne    L229
  mov    D219(%rip),%rax
  cmpq   $0x0,0x8(%rax)
  jle    L176
  mov    D141(%rip),%rax
  mov    D219(%rip),%rdx
  mov    (%rdx),%edx
  and    (%rax),%edx
  mov    %edx,0x14(%rsp)
  jne    L486
  mov    %edx,0x18(%rsp)
  movl   $0xffffffff,0x10(%rsp)
L281:
  mov    D219(%rip),%rax
  mov    (%rax),%eax
  mov    D216(%rip),%rdx
  and    (%rdx),%eax
  jne    L266
L384:
  mov    0xc(%rsp),%r9d
  mov    %r13,%r8
  mov    %r15d,%ecx
  mov    %r14d,%edx
  mov    $0x0,%esi
  mov    %rbp,%rdi
  call   <res_querydomain@plt>
  test   %eax,%eax
  jle    L266
  mov    %eax,0x10(%rsp)
  jmp    L496
L229:
  mov    0xc(%rsp),%r8d
  mov    %r13,%rcx
  mov    %r15d,%edx
  mov    %r14d,%esi
  mov    %rax,%rdi
  call   <res_query@plt>
  mov    %eax,0x10(%rsp)
  jmp    L496
L176:
  mov    0xc(%rsp),%r9d
  mov    %r13,%r8
  mov    %r15d,%ecx
  mov    %r14d,%edx
  mov    $0x0,%esi
  mov    %rbp,%rdi
  call   <res_querydomain@plt>
  mov    %eax,0x10(%rsp)
  test   %eax,%eax
  jg     L496
  mov    D139(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,0x10(%rsp)
  test   %rbx,%rbx
  jne    L200
  mov    D141(%rip),%rax
  mov    D219(%rip),%rdx
  mov    (%rdx),%edx
  and    (%rax),%edx
  mov    %edx,0x14(%rsp)
  jne    L3
  mov    %edx,0x18(%rsp)
  jmp    L266
L486:
  movl   $0x0,0x1c(%rsp)
  movl   $0xffffffff,0x10(%rsp)
  jmp    L99
L3:
  movl   $0x1,0x1c(%rsp)
  jmp    L99
L224:
  mov    D139(%rip),%rax
  movl   $0x80,(%rax)
  movl   $0xffffffff,0x10(%rsp)
  jmp    L496
L436:
  addl   $0x1,0x14(%rsp)
L527:
  mov    D219(%rip),%rax
  mov    (%rax),%eax
  mov    D101(%rip),%rdx
  and    (%rdx),%eax
  je     L484
  add    $0x8,%r12
  mov    (%r12),%rsi
  test   %rsi,%rsi
  je     L484
L15:
  mov    0xc(%rsp),%r9d
  mov    %r13,%r8
  mov    %r15d,%ecx
  mov    %r14d,%edx
  mov    %rbp,%rdi
  call   <res_querydomain@plt>
  test   %eax,%eax
  jg     L147
  mov    D121(%rip),%rdx
  mov    D270(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  je     L224
  mov    D139(%rip),%rax
  mov    (%rax),%eax
  cmp    $0x81,%eax
  je     L436
  cmp    $0x82,%eax
  je     L527
  cmp    $0x80,%eax
  je     L454
L484:
  cmpl   $0x0,0x1c(%rsp)
  je     L318
L266:
  cmpl   $0xffffffff,0x10(%rsp)
  jne    L487
  cmpl   $0x0,0x14(%rsp)
  jne    L512
  cmpl   $0x0,0x18(%rsp)
  je     L496
  mov    D139(%rip),%rax
  movl   $0x80,(%rax)
L496:
  mov    0x10(%rsp),%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L454:
  mov    D186(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,0x0(%r13)
  jne    L484
  addl   $0x1,0x18(%rsp)
  jmp    L527
L276:
  movl   $0x0,0x18(%rsp)
  movl   $0x0,0x14(%rsp)
  jmp    L484
L318:
  test   %rbx,%rbx
  je     L281
  jmp    L384
L79:
  mov    0x1c(%rsp),%eax
  mov    %eax,0x18(%rsp)
  mov    %eax,0x14(%rsp)
  jmp    L384
L512:
  mov    D139(%rip),%rax
  movl   $0x81,(%rax)
  jmp    L496
L147:
  mov    %eax,0x10(%rsp)
  jmp    L496
L449:
  cmpl   $0x0,0x1c(%rsp)
  je     L79
  cmpl   $0xffffffff,0x10(%rsp)
  je     L496
L487:
  mov    D139(%rip),%rax
  mov    0x10(%rsp),%ecx
  mov    %ecx,(%rax)
  movl   $0xffffffff,0x10(%rsp)
  jmp    L496
L414:
  movl   $0x0,0x18(%rsp)
  movl   $0x0,0x14(%rsp)
  movl   $0xffffffff,0x10(%rsp)
  jmp    L384
L200:
  je     L473
  movl   $0x1,0x1c(%rsp)
  test   %r12d,%r12d
  je     L492
L473:
  movl   $0x0,0x18(%rsp)
  movl   $0x0,0x14(%rsp)
  jmp    L266
```

assistant: ```c
int res_search(const char *name, int class, int type, u_char *answer, int anslen) {
  const char *cp, *const *domain;
  HEADER *hp = (HEADER *)answer;
  u_int dots;
  int trailing_dot, ret, saved_herrno;
  int got_nodata = 0, got_servfail = 0, tried_as_is = 0;
  if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
    h_errno = NETDB_INTERNAL;
    return (-1);
  }
  errno = 0;
  h_errno = HOST_NOT_FOUND;
  dots = 0;
  for (cp = name; *cp; cp++)
    dots += (*cp == '.');
  trailing_dot = 0;
  if (cp > name && *--cp == '.')
    trailing_dot++;
  if (!dots && (cp = hostalias(name)) != NULL)
    return (res_query(cp, class, type, answer, anslen));
  saved_herrno = -1;
  if (dots >= _res.ndots) {
    ret = res_querydomain(name, NULL, class, type, answer, anslen);
    if (ret > 0)
      return (ret);
    saved_herrno = h_errno;
    tried_as_is++;
  }
  if ((!dots && (_res.options & RES_DEFNAMES)) || (dots && !trailing_dot && (_res.options & RES_DNSRCH))) {
    int done = 0;
    for (domain = (const char *const *)_res.dnsrch; *domain && !done; domain++) {
      ret = res_querydomain(name, *domain, class, type, answer, anslen);
      if (ret > 0)
        return (ret);
      if (errno == ECONNREFUSED) {
        h_errno = TRY_AGAIN;
        return (-1);
      }
      switch (h_errno) {
      case NO_DATA:
        got_nodata++;
      case HOST_NOT_FOUND:
        break;
      case TRY_AGAIN:
        if (hp->rcode == SERVFAIL) {
          got_servfail++;
          break;
        }
      default:
        done++;
      }
      if (!(_res.options & RES_DNSRCH))
        done++;
    }
  }
  if (!tried_as_is && (dots || !(_res.options & RES_NOTLDQUERY))) {
    ret = res_querydomain(name, NULL, class, type, answer, anslen);
    if (ret > 0)
      return (ret);
  }
  if (saved_herrno != -1)
    h_errno = saved_herrno;
  else if (got_nodata)
    h_errno = NO_DATA;
  else if (got_servfail)
    h_errno = TRY_AGAIN;
  return (-1);
}
```