#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */
typedef struct TYPE_10__ TYPE_2__;
typedef struct TYPE_9__ TYPE_1__;

/* Type definitions */
typedef scalar_t__ u_int;
typedef int /*<<< orphan*/ u_char;
typedef TYPE_1__ *res_state;
struct TYPE_10__ {
  int /*<<< orphan*/ rcode;
};
struct TYPE_9__ {
  scalar_t__ ndots;
  int res_h_errno;
  unsigned int options;
  scalar_t__ dnsrch;
};
typedef TYPE_2__ HEADER;

/* Variables and functions */
scalar_t__ ECONNREFUSED;
#define HOST_NOT_FOUND 130
#define NO_DATA 129
int NS_MAXDNAME;
unsigned int RES_DEFNAMES;
unsigned int RES_DNSRCH;
unsigned int RES_NOTLDQUERY;
int /*<<< orphan*/ RES_SET_H_ERRNO(TYPE_1__ *, int const);
int /*<<< orphan*/ SERVFAIL;
#define TRY_AGAIN 128
int /*<<< orphan*/ _resolv_populate_res_for_net(TYPE_1__ *);
scalar_t__ errno;
char *res_hostalias(TYPE_1__ *, char const *, char *, int);
int res_nquery(TYPE_1__ *, char const *, int, int, int /*<<< orphan*/ *, int);
int res_nquerydomain(TYPE_1__ *, char const *, char const *, int, int,
                     int /*<<< orphan*/ *, int);
int res_nsearch(res_state statp, const char *name, int class, int type,
                u_char *answer, int anslen) {
  const char *cp, *const *domain;
  HEADER *hp = (HEADER *)(void *)answer;
  char tmp[NS_MAXDNAME];
  u_int dots;
  int trailing_dot, ret, saved_herrno;
  int got_nodata = 0, got_servfail = 0, root_on_list = 0;
  int tried_as_is = 0;
  int searched = 0;
  errno = 0;
  RES_SET_H_ERRNO(statp, HOST_NOT_FOUND);
  dots = 0;
  for (cp = name; *cp != '\0'; cp++)
    dots += (*cp == '.');
  trailing_dot = 0;
  if (cp > name && *--cp == '.')
    trailing_dot++;
  if (!dots && (cp = res_hostalias(statp, name, tmp, sizeof tmp)) != NULL)
    return (res_nquery(statp, cp, class, type, answer, anslen));
  saved_herrno = -1;
  if (dots >= statp->ndots || trailing_dot) {
    ret = res_nquerydomain(statp, name, NULL, class, type, answer, anslen);
    if (ret > 0 || trailing_dot)
      return (ret);
    saved_herrno = statp->res_h_errno;
    tried_as_is++;
  }
  if ((!dots && (statp->options & RES_DEFNAMES) != 0U) ||
      (dots && !trailing_dot && (statp->options & RES_DNSRCH) != 0U)) {
    int done = 0;
    _resolv_populate_res_for_net(statp);
    for (domain = (const char *const *)statp->dnsrch; *domain && !done;
         domain++) {
      searched = 1;
      if (domain[0][0] == '\0' || (domain[0][0] == '.' && domain[0][1] == '\0'))
        root_on_list++;
      ret = res_nquerydomain(statp, name, *domain, class, type, answer, anslen);
      if (ret > 0)
        return (ret);
      if (errno == ECONNREFUSED) {
        RES_SET_H_ERRNO(statp, TRY_AGAIN);
        return (-1);
      }
      switch (statp->res_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 ((statp->options & RES_DNSRCH) == 0U)
        done++;
    }
  }
  if ((dots || !searched || (statp->options & RES_NOTLDQUERY) == 0U) &&
      !(tried_as_is || root_on_list)) {
    ret = res_nquerydomain(statp, name, NULL, class, type, answer, anslen);
    if (ret > 0)
      return (ret);
  }
  if (saved_herrno != -1)
    RES_SET_H_ERRNO(statp, saved_herrno);
  else if (got_nodata)
    RES_SET_H_ERRNO(statp, NO_DATA);
  else if (got_servfail)
    RES_SET_H_ERRNO(statp, TRY_AGAIN);
  return (-1);
}


x86 assembly (clang, -O0):
<res_nsearch>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2e68(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x98(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x90(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x70(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
movl   $0x0,-0x80(%rbp)
mov    0x2def(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x82,%esi
call   1030 <RES_SET_H_ERRNO@plt>
movq   $0x0,-0x60(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     123b <res_nsearch+0xeb>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
cltq
add    -0x60(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11fe <res_nsearch+0xae>
movl   $0x0,-0x64(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    1275 <res_nsearch+0x125>
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x38(%rbp)
movsbl -0x1(%rax),%eax
cmp    $0x2e,%eax
jne    1275 <res_nsearch+0x125>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    12d8 <res_nsearch+0x188>
mov    -0x90(%rbp),%rdx
mov    -0x98(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %eax,%ecx
call   1050 <res_hostalias@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     12d8 <res_nsearch+0x188>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x28(%rbp),%r8
mov    -0x2c(%rbp),%r9d
call   1040 <res_nquery@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x84(%rbp)
jmp    16b1 <res_nsearch+0x561>
movl   $0xffffffff,-0x6c(%rbp)
mov    -0x60(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jge    12fa <res_nsearch+0x1aa>
cmpl   $0x0,-0x64(%rbp)
je     1361 <res_nsearch+0x211>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x28(%rbp),%r9
mov    -0x2c(%rbp),%eax
xor    %edx,%edx
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1070 <res_nquerydomain@plt>
add    $0x10,%rsp
mov    %eax,-0x68(%rbp)
cmpl   $0x0,-0x68(%rbp)
jg     1339 <res_nsearch+0x1e9>
cmpl   $0x0,-0x64(%rbp)
je     134e <res_nsearch+0x1fe>
mov    -0x68(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x84(%rbp)
jmp    16b1 <res_nsearch+0x561>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    1385 <res_nsearch+0x235>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
mov    0x2c36(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    13b3 <res_nsearch+0x263>
cmpq   $0x0,-0x60(%rbp)
je     15b5 <res_nsearch+0x465>
cmpl   $0x0,-0x64(%rbp)
jne    15b5 <res_nsearch+0x465>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
mov    0x2c10(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     15b5 <res_nsearch+0x465>
movl   $0x0,-0x88(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <_resolv_populate_res_for_net@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rcx
xor    %eax,%eax
cmpq   $0x0,(%rcx)
mov    %al,-0x99(%rbp)
je     13fa <res_nsearch+0x2aa>
cmpl   $0x0,-0x88(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x99(%rbp)
mov    -0x99(%rbp),%al
test   $0x1,%al
jne    140d <res_nsearch+0x2bd>
jmp    15b0 <res_nsearch+0x460>
movl   $0x1,-0x80(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     144e <res_nsearch+0x2fe>
mov    -0x40(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1457 <res_nsearch+0x307>
mov    -0x40(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    1457 <res_nsearch+0x307>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x40(%rbp),%rax
mov    (%rax),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x28(%rbp),%r9
mov    -0x2c(%rbp),%eax
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1070 <res_nquerydomain@plt>
add    $0x10,%rsp
mov    %eax,-0x68(%rbp)
cmpl   $0x0,-0x68(%rbp)
jle    14a6 <res_nsearch+0x356>
mov    -0x68(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x84(%rbp)
jmp    16b1 <res_nsearch+0x561>
mov    0x2b1b(%rip),%rax
mov    (%rax),%rax
mov    0x2b29(%rip),%rcx
cmp    (%rcx),%rax
jne    14e4 <res_nsearch+0x394>
mov    -0x10(%rbp),%rdi
mov    $0x80,%esi
call   1030 <RES_SET_H_ERRNO@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x84(%rbp)
jmp    16b1 <res_nsearch+0x561>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0xa0(%rbp)
sub    $0x80,%eax
je     153b <res_nsearch+0x3eb>
jmp    1501 <res_nsearch+0x3b1>
mov    -0xa0(%rbp),%eax
sub    $0x81,%eax
je     152d <res_nsearch+0x3dd>
jmp    1517 <res_nsearch+0x3c7>
mov    -0xa0(%rbp),%eax
sub    $0x82,%eax
je     1536 <res_nsearch+0x3e6>
jmp    1563 <res_nsearch+0x413>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    1572 <res_nsearch+0x422>
mov    -0x48(%rbp),%rax
mov    (%rax),%eax
mov    0x2a88(%rip),%rcx
cmp    (%rcx),%eax
jne    155e <res_nsearch+0x40e>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1572 <res_nsearch+0x422>
jmp    1563 <res_nsearch+0x413>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
mov    0x2a38(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    159a <res_nsearch+0x44a>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    159f <res_nsearch+0x44f>
mov    -0x40(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x40(%rbp)
jmp    13d2 <res_nsearch+0x282>
jmp    15b5 <res_nsearch+0x465>
cmpq   $0x0,-0x60(%rbp)
jne    15e3 <res_nsearch+0x493>
cmpl   $0x0,-0x80(%rbp)
je     15e3 <res_nsearch+0x493>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
mov    0x29e8(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    1646 <res_nsearch+0x4f6>
cmpl   $0x0,-0x7c(%rbp)
jne    1646 <res_nsearch+0x4f6>
cmpl   $0x0,-0x78(%rbp)
jne    1646 <res_nsearch+0x4f6>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x28(%rbp),%r9
mov    -0x2c(%rbp),%eax
xor    %edx,%edx
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1070 <res_nquerydomain@plt>
add    $0x10,%rsp
mov    %eax,-0x68(%rbp)
cmpl   $0x0,-0x68(%rbp)
jle    1641 <res_nsearch+0x4f1>
mov    -0x68(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x84(%rbp)
jmp    16b1 <res_nsearch+0x561>
jmp    1646 <res_nsearch+0x4f6>
cmpl   $0xffffffff,-0x6c(%rbp)
je     1661 <res_nsearch+0x511>
mov    -0x10(%rbp),%rdi
mov    -0x6c(%rbp),%esi
call   1030 <RES_SET_H_ERRNO@plt>
jmp    16a0 <res_nsearch+0x550>
cmpl   $0x0,-0x70(%rbp)
je     167e <res_nsearch+0x52e>
mov    -0x10(%rbp),%rdi
mov    $0x81,%esi
call   1030 <RES_SET_H_ERRNO@plt>
jmp    169b <res_nsearch+0x54b>
cmpl   $0x0,-0x74(%rbp)
je     1696 <res_nsearch+0x546>
mov    -0x10(%rbp),%rdi
mov    $0x80,%esi
call   1030 <RES_SET_H_ERRNO@plt>
jmp    169b <res_nsearch+0x54b>
jmp    16a0 <res_nsearch+0x550>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x84(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<res_nsearch>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9d,%r14d
mov    %r8,-0x58(%rbp)
mov    %ecx,-0x40(%rbp)
mov    %edx,-0x3c(%rbp)
mov    %rsi,%rbx
mov    %rdi,%r15
mov    0x2e6d(%rip),%rax
mov    (%rax),%r12d
mov    %rsp,%r13
lea    0xf(%r12),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    0x2e31(%rip),%rax
movq   $0x0,(%rax)
mov    $0x82,%esi
call   1030 <RES_SET_H_ERRNO@plt>
mov    %rbx,%rsi
mov    (%rbx),%dl
test   %dl,%dl
mov    %r14,-0x50(%rbp)
je     11ec <res_nsearch+0x9c>
xor    %eax,%eax
mov    %rsi,%rcx
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
cmp    $0x2e,%dl
sete   %dil
add    %rdi,%rax
movzbl 0x1(%rcx),%edx
add    $0x1,%rcx
test   %dl,%dl
jne    11c0 <res_nsearch+0x70>
cmp    %rsi,%rcx
jbe    11f1 <res_nsearch+0xa1>
cmpb   $0x2e,-0x1(%rcx)
sete   %r14b
test   %rax,%rax
jne    11f9 <res_nsearch+0xa9>
jmp    11fd <res_nsearch+0xad>
xor    %r14d,%r14d
jmp    11fd <res_nsearch+0xad>
xor    %r14d,%r14d
test   %rax,%rax
je     11fd <res_nsearch+0xad>
xor    %edx,%edx
jmp    123a <res_nsearch+0xea>
mov    %r15,%rdi
mov    %r13,%rdx
mov    %r12d,%ecx
mov    %rsi,%rbx
call   1050 <res_hostalias@plt>
test   %rax,%rax
je     1233 <res_nsearch+0xe3>
mov    %r15,%rdi
mov    %rax,%rsi
mov    -0x3c(%rbp),%edx
mov    -0x40(%rbp),%ecx
mov    -0x58(%rbp),%r8
mov    -0x50(%rbp),%r9
call   1040 <res_nquery@plt>
mov    %eax,%ebx
jmp    14e6 <res_nsearch+0x396>
mov    $0x1,%dl
xor    %eax,%eax
mov    %rbx,%rsi
cmp    (%r15),%rax
setge  %cl
or     %r14b,%cl
mov    $0xffffffff,%r13d
cmp    $0x1,%cl
mov    %rsi,%r12
mov    %edx,-0x5c(%rbp)
jne    1294 <res_nsearch+0x144>
mov    %cl,-0x29(%rbp)
sub    $0x8,%rsp
mov    %r15,%rdi
xor    %edx,%edx
mov    -0x3c(%rbp),%ecx
mov    -0x40(%rbp),%r8d
mov    -0x58(%rbp),%r9
push   -0x50(%rbp)
call   1070 <res_nquerydomain@plt>
add    $0x10,%rsp
mov    %eax,%ebx
test   %eax,%eax
setg   %al
or     %r14b,%al
jne    14e6 <res_nsearch+0x396>
mov    %r12,%rsi
mov    0x8(%r15),%r13d
mov    -0x29(%rbp),%cl
mov    -0x5c(%rbp),%edx
test   %dl,%dl
je     12c3 <res_nsearch+0x173>
mov    0x2d11(%rip),%rax
mov    (%rax),%eax
test   %eax,0xc(%r15)
mov    -0x50(%rbp),%r14
jne    130c <res_nsearch+0x1bc>
xor    %eax,%eax
xor    %edx,%edx
movl   $0x0,-0x30(%rbp)
test   %cl,%cl
je     1485 <res_nsearch+0x335>
jmp    14b2 <res_nsearch+0x362>
xor    %eax,%eax
test   %r14b,%r14b
je     12e4 <res_nsearch+0x194>
xor    %edx,%edx
movl   $0x0,-0x30(%rbp)
mov    -0x50(%rbp),%r14
test   %cl,%cl
je     1485 <res_nsearch+0x335>
jmp    14b2 <res_nsearch+0x362>
mov    0x2ccd(%rip),%rax
mov    (%rax),%eax
mov    $0x0,%edx
movl   $0x0,-0x30(%rbp)
test   %eax,0xc(%r15)
mov    $0x0,%eax
mov    -0x50(%rbp),%r14
je     1481 <res_nsearch+0x331>
mov    %cl,-0x29(%rbp)
mov    %r13d,-0x34(%rbp)
mov    %r15,%rdi
call   1060 <_resolv_populate_res_for_net@plt>
mov    0x10(%r15),%r13
mov    0x0(%r13),%rdx
test   %rdx,%rdx
je     146c <res_nsearch+0x31c>
add    $0x8,%r13
movl   $0x0,-0x44(%rbp)
mov    %rdx,-0x68(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x30(%rbp)
mov    %r12,%rsi
nopl   0x0(%rax)
movzbl (%rdx),%eax
test   %al,%al
je     1361 <res_nsearch+0x211>
cmp    $0x2e,%al
jne    1365 <res_nsearch+0x215>
cmpb   $0x0,0x1(%rdx)
jne    1365 <res_nsearch+0x215>
addl   $0x1,-0x44(%rbp)
sub    $0x8,%rsp
mov    %r15,%rdi
mov    -0x3c(%rbp),%ecx
mov    -0x40(%rbp),%r8d
mov    -0x58(%rbp),%r9
push   %r14
call   1070 <res_nquerydomain@plt>
add    $0x10,%rsp
test   %eax,%eax
jg     14d0 <res_nsearch+0x380>
mov    0x2c37(%rip),%rax
mov    (%rax),%rax
mov    0x2c45(%rip),%rcx
cmp    (%rcx),%rax
je     14d4 <res_nsearch+0x384>
mov    0x8(%r15),%ecx
xor    %eax,%eax
cmp    $0x80,%ecx
je     13e0 <res_nsearch+0x290>
cmp    $0x82,%ecx
je     13d0 <res_nsearch+0x280>
cmp    $0x81,%ecx
mov    %r12,%rsi
jne    1400 <res_nsearch+0x2b0>
addl   $0x1,-0x30(%rbp)
jmp    1405 <res_nsearch+0x2b5>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rsi
jmp    1405 <res_nsearch+0x2b5>
cs nopw 0x0(%rax,%rax,1)
nop
mov    -0x58(%rbp),%rcx
mov    (%rcx),%ecx
mov    0x2be3(%rip),%rdx
cmp    (%rdx),%ecx
mov    %r12,%rsi
jne    1400 <res_nsearch+0x2b0>
addl   $0x1,-0x38(%rbp)
jmp    1405 <res_nsearch+0x2b5>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%eax
mov    0x2bac(%rip),%rcx
mov    (%rcx),%ecx
and    0xc(%r15),%ecx
cmp    $0x1,%ecx
sbb    %ecx,%ecx
mov    0x0(%r13),%rdx
test   %rdx,%rdx
je     142c <res_nsearch+0x2dc>
add    $0x8,%r13
cmp    %ecx,%eax
je     1350 <res_nsearch+0x200>
cmpq   $0x0,-0x68(%rbp)
setne  %al
mov    -0x5c(%rbp),%ecx
and    %al,%cl
cmp    $0x1,%cl
jne    150f <res_nsearch+0x3bf>
mov    0x2b77(%rip),%rax
mov    (%rax),%eax
test   %eax,0xc(%r15)
setne  %al
or     -0x29(%rbp),%al
cmp    $0x1,%al
je     1526 <res_nsearch+0x3d6>
cmpl   $0x0,-0x44(%rbp)
mov    -0x34(%rbp),%r13d
mov    -0x38(%rbp),%edx
je     1489 <res_nsearch+0x339>
jmp    14b2 <res_nsearch+0x362>
xor    %eax,%eax
xor    %edx,%edx
movl   $0x0,-0x30(%rbp)
mov    %r12,%rsi
mov    -0x34(%rbp),%r13d
mov    -0x29(%rbp),%cl
test   %cl,%cl
jne    14b2 <res_nsearch+0x362>
test   %eax,%eax
jne    14b2 <res_nsearch+0x362>
sub    $0x8,%rsp
mov    %r15,%rdi
mov    %edx,%ebx
xor    %edx,%edx
mov    -0x3c(%rbp),%ecx
mov    -0x40(%rbp),%r8d
mov    -0x58(%rbp),%r9
push   %r14
call   1070 <res_nquerydomain@plt>
mov    %ebx,%edx
add    $0x10,%rsp
mov    %eax,%ebx
test   %eax,%eax
jg     14e6 <res_nsearch+0x396>
cmp    $0xffffffff,%r13d
je     14c0 <res_nsearch+0x370>
mov    %r15,%rdi
mov    %r13d,%esi
jmp    14dc <res_nsearch+0x38c>
cmpl   $0x0,-0x30(%rbp)
je     14f7 <res_nsearch+0x3a7>
mov    %r15,%rdi
mov    $0x81,%esi
jmp    14dc <res_nsearch+0x38c>
mov    %eax,%ebx
jmp    14e6 <res_nsearch+0x396>
mov    %r15,%rdi
mov    $0x80,%esi
call   1030 <RES_SET_H_ERRNO@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffff,%ebx
test   %edx,%edx
je     14e6 <res_nsearch+0x396>
mov    %r15,%rdi
mov    $0x80,%esi
call   1030 <RES_SET_H_ERRNO@plt>
jmp    14e6 <res_nsearch+0x396>
mov    -0x34(%rbp),%r13d
mov    -0x29(%rbp),%cl
mov    -0x38(%rbp),%edx
mov    -0x44(%rbp),%eax
test   %cl,%cl
je     1485 <res_nsearch+0x335>
jmp    14b2 <res_nsearch+0x362>
mov    -0x34(%rbp),%r13d
mov    -0x38(%rbp),%edx
jmp    14b2 <res_nsearch+0x362>

LLVM IR (-O0):
%struct.TYPE_9__ = type { i64, i32, i32, i64 }
%struct.TYPE_10__ = type { i32 }
@NS_MAXDNAME = global i32 0
@errno = global i64 0
@RES_DEFNAMES = global i32 0
@RES_DNSRCH = global i32 0
@ECONNREFUSED = global i64 0
@SERVFAIL = global i32 0
@RES_NOTLDQUERY = global i32 0
define i32 @res_nsearch(%struct.TYPE_9__* %0, i8* %1, i32 %2, i32 %3, i32* %4, i32 %5) {
%7 = alloca i32
%8 = alloca %struct.TYPE_9__*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i8**
%16 = alloca %struct.TYPE_10__*
%17 = alloca i8*
%18 = alloca i64
%19 = alloca i64
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
store %struct.TYPE_9__* %0, %struct.TYPE_9__** %8
store i8* %1, i8** %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32* %4, i32** %12
store i32 %5, i32* %13
%30 = load i32*, i32** %12
%31 = bitcast i32* %30 to i8*
%32 = bitcast i8* %31 to %struct.TYPE_10__*
store %struct.TYPE_10__* %32, %struct.TYPE_10__** %16
%33 = load i32, i32* @NS_MAXDNAME
%34 = zext i32 %33 to i64
%35 = call i8* @llvm.stacksave()
store i8* %35, i8** %17
%36 = alloca i8, i64 %34
store i64 %34, i64* %18
store i32 0, i32* %23
store i32 0, i32* %24
store i32 0, i32* %25
store i32 0, i32* %26
store i32 0, i32* %27
store i64 0, i64* @errno
%37 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%38 = call i32 @RES_SET_H_ERRNO(%struct.TYPE_9__* %37, i32 130)
store i64 0, i64* %19
%39 = load i8*, i8** %9
store i8* %39, i8** %14
br label %40
40: ; preds = %54, %6
%41 = load i8*, i8** %14
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %57
45: ; preds = %40
%46 = load i8*, i8** %14
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 46
%50 = zext i1 %49 to i32
%51 = sext i32 %50 to i64
%52 = load i64, i64* %19
%53 = add nsw i64 %52, %51
store i64 %53, i64* %19
br label %54
54: ; preds = %45
%55 = load i8*, i8** %14
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %14
br label %40
57: ; preds = %40
store i32 0, i32* %20
%58 = load i8*, i8** %14
%59 = load i8*, i8** %9
%60 = icmp ugt i8* %58, %59
br i1 %60, label %61, label %70
61: ; preds = %57
%62 = load i8*, i8** %14
%63 = getelementptr inbounds i8, i8* %62, i32 -1
store i8* %63, i8** %14
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 46
br i1 %66, label %67, label %70
67: ; preds = %61
%68 = load i32, i32* %20
%69 = add nsw i32 %68, 1
store i32 %69, i32* %20
br label %70
70: ; preds = %67, %61, %57
%71 = load i64, i64* %19
%72 = icmp ne i64 %71, 0
br i1 %72, label %87, label %73
73: ; preds = %70
%74 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%75 = load i8*, i8** %9
%76 = trunc i64 %34 to i32
%77 = call i8* @res_hostalias(%struct.TYPE_9__* %74, i8* %75, i8* %36, i32 %76)
store i8* %77, i8** %14
%78 = icmp ne i8* %77, null
br i1 %78, label %79, label %87
79: ; preds = %73
%80 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%81 = load i8*, i8** %14
%82 = load i32, i32* %10
%83 = load i32, i32* %11
%84 = load i32*, i32** %12
%85 = load i32, i32* %13
%86 = call i32 @res_nquery(%struct.TYPE_9__* %80, i8* %81, i32 %82, i32 %83, i32* %84, i32 %85)
store i32 %86, i32* %7
store i32 1, i32* %28
br label %295
87: ; preds = %73, %70
store i32 -1, i32* %22
%88 = load i64, i64* %19
%89 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%90 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %89, i32 0, i32 0
%91 = load i64, i64* %90
%92 = icmp sge i64 %88, %91
br i1 %92, label %96, label %93
93: ; preds = %87
%94 = load i32, i32* %20
%95 = icmp ne i32 %94, 0
br i1 %95, label %96, label %117
96: ; preds = %93, %87
%97 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%98 = load i8*, i8** %9
%99 = load i32, i32* %10
%100 = load i32, i32* %11
%101 = load i32*, i32** %12
%102 = load i32, i32* %13
%103 = call i32 @res_nquerydomain(%struct.TYPE_9__* %97, i8* %98, i8* null, i32 %99, i32 %100, i32* %101, i32 %102)
store i32 %103, i32* %21
%104 = load i32, i32* %21
%105 = icmp sgt i32 %104, 0
br i1 %105, label %109, label %106
106: ; preds = %96
%107 = load i32, i32* %20
%108 = icmp ne i32 %107, 0
br i1 %108, label %109, label %111
109: ; preds = %106, %96
%110 = load i32, i32* %21
store i32 %110, i32* %7
store i32 1, i32* %28
br label %295
111: ; preds = %106
%112 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%113 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %112, i32 0, i32 1
%114 = load i32, i32* %113
store i32 %114, i32* %22
%115 = load i32, i32* %26
%116 = add nsw i32 %115, 1
store i32 %116, i32* %26
br label %117
117: ; preds = %111, %93
%118 = load i64, i64* %19
%119 = icmp ne i64 %118, 0
br i1 %119, label %127, label %120
120: ; preds = %117
%121 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%122 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %121, i32 0, i32 2
%123 = load i32, i32* %122
%124 = load i32, i32* @RES_DEFNAMES
%125 = and i32 %123, %124
%126 = icmp ne i32 %125, 0
br i1 %126, label %140, label %127
127: ; preds = %120, %117
%128 = load i64, i64* %19
%129 = icmp ne i64 %128, 0
br i1 %129, label %130, label %241
130: ; preds = %127
%131 = load i32, i32* %20
%132 = icmp ne i32 %131, 0
br i1 %132, label %241, label %133
133: ; preds = %130
%134 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%135 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %134, i32 0, i32 2
%136 = load i32, i32* %135
%137 = load i32, i32* @RES_DNSRCH
%138 = and i32 %136, %137
%139 = icmp ne i32 %138, 0
br i1 %139, label %140, label %241
140: ; preds = %133, %120
store i32 0, i32* %29
%141 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%142 = call i32 @_resolv_populate_res_for_net(%struct.TYPE_9__* %141)
%143 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%144 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %143, i32 0, i32 3
%145 = load i64, i64* %144
%146 = inttoptr i64 %145 to i8**
store i8** %146, i8*** %15
br label %147
147: ; preds = %237, %140
%148 = load i8**, i8*** %15
%149 = load i8*, i8** %148
%150 = icmp ne i8* %149, null
br i1 %150, label %151, label %155
151: ; preds = %147
%152 = load i32, i32* %29
%153 = icmp ne i32 %152, 0
%154 = xor i1 %153, true
br label %155
155: ; preds = %151, %147
%156 = phi i1 [ false, %147 ], [ %154, %151 ]
br i1 %156, label %157, label %240
157: ; preds = %155
store i32 1, i32* %27
%158 = load i8**, i8*** %15
%159 = getelementptr inbounds i8*, i8** %158, i64 0
%160 = load i8*, i8** %159
%161 = getelementptr inbounds i8, i8* %160, i64 0
%162 = load i8, i8* %161
%163 = sext i8 %162 to i32
%164 = icmp eq i32 %163, 0
br i1 %164, label %181, label %165
165: ; preds = %157
%166 = load i8**, i8*** %15
%167 = getelementptr inbounds i8*, i8** %166, i64 0
%168 = load i8*, i8** %167
%169 = getelementptr inbounds i8, i8* %168, i64 0
%170 = load i8, i8* %169
%171 = sext i8 %170 to i32
%172 = icmp eq i32 %171, 46
br i1 %172, label %173, label %184
173: ; preds = %165
%174 = load i8**, i8*** %15
%175 = getelementptr inbounds i8*, i8** %174, i64 0
%176 = load i8*, i8** %175
%177 = getelementptr inbounds i8, i8* %176, i64 1
%178 = load i8, i8* %177
%179 = sext i8 %178 to i32
%180 = icmp eq i32 %179, 0
br i1 %180, label %181, label %184
181: ; preds = %173, %157
%182 = load i32, i32* %25
%183 = add nsw i32 %182, 1
store i32 %183, i32* %25
br label %184
184: ; preds = %181, %173, %165
%185 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%186 = load i8*, i8** %9
%187 = load i8**, i8*** %15
%188 = load i8*, i8** %187
%189 = load i32, i32* %10
%190 = load i32, i32* %11
%191 = load i32*, i32** %12
%192 = load i32, i32* %13
%193 = call i32 @res_nquerydomain(%struct.TYPE_9__* %185, i8* %186, i8* %188, i32 %189, i32 %190, i32* %191, i32 %192)
store i32 %193, i32* %21
%194 = load i32, i32* %21
%195 = icmp sgt i32 %194, 0
br i1 %195, label %196, label %198
196: ; preds = %184
%197 = load i32, i32* %21
store i32 %197, i32* %7
store i32 1, i32* %28
br label %295
198: ; preds = %184
%199 = load i64, i64* @errno
%200 = load i64, i64* @ECONNREFUSED
%201 = icmp eq i64 %199, %200
br i1 %201, label %202, label %205
202: ; preds = %198
%203 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%204 = call i32 @RES_SET_H_ERRNO(%struct.TYPE_9__* %203, i32 128)
store i32 -1, i32* %7
store i32 1, i32* %28
br label %295
205: ; preds = %198
%206 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%207 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %206, i32 0, i32 1
%208 = load i32, i32* %207
switch i32 %208, label %223 [
i32 129, label %209
i32 130, label %212
i32 128, label %213
]
209: ; preds = %205
%210 = load i32, i32* %23
%211 = add nsw i32 %210, 1
store i32 %211, i32* %23
br label %212
212: ; preds = %205, %209
br label %226
213: ; preds = %205
%214 = load %struct.TYPE_10__*, %struct.TYPE_10__** %16
%215 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %214, i32 0, i32 0
%216 = load i32, i32* %215
%217 = load i32, i32* @SERVFAIL
%218 = icmp eq i32 %216, %217
br i1 %218, label %219, label %222
219: ; preds = %213
%220 = load i32, i32* %24
%221 = add nsw i32 %220, 1
store i32 %221, i32* %24
br label %226
222: ; preds = %213
br label %223
223: ; preds = %205, %222
%224 = load i32, i32* %29
%225 = add nsw i32 %224, 1
store i32 %225, i32* %29
br label %226
226: ; preds = %223, %219, %212
%227 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%228 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %227, i32 0, i32 2
%229 = load i32, i32* %228
%230 = load i32, i32* @RES_DNSRCH
%231 = and i32 %229, %230
%232 = icmp eq i32 %231, 0
br i1 %232, label %233, label %236
233: ; preds = %226
%234 = load i32, i32* %29
%235 = add nsw i32 %234, 1
store i32 %235, i32* %29
br label %236
236: ; preds = %233, %226
br label %237
237: ; preds = %236
%238 = load i8**, i8*** %15
%239 = getelementptr inbounds i8*, i8** %238, i32 1
store i8** %239, i8*** %15
br label %147
240: ; preds = %155
br label %241
241: ; preds = %240, %133, %130, %127
%242 = load i64, i64* %19
%243 = icmp ne i64 %242, 0
br i1 %243, label %254, label %244
244: ; preds = %241
%245 = load i32, i32* %27
%246 = icmp ne i32 %245, 0
br i1 %246, label %247, label %254
247: ; preds = %244
%248 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%249 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %248, i32 0, i32 2
%250 = load i32, i32* %249
%251 = load i32, i32* @RES_NOTLDQUERY
%252 = and i32 %250, %251
%253 = icmp eq i32 %252, 0
br i1 %253, label %254, label %273
254: ; preds = %247, %244, %241
%255 = load i32, i32* %26
%256 = icmp ne i32 %255, 0
br i1 %256, label %273, label %257
257: ; preds = %254
%258 = load i32, i32* %25
%259 = icmp ne i32 %258, 0
br i1 %259, label %273, label %260
260: ; preds = %257
%261 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%262 = load i8*, i8** %9
%263 = load i32, i32* %10
%264 = load i32, i32* %11
%265 = load i32*, i32** %12
%266 = load i32, i32* %13
%267 = call i32 @res_nquerydomain(%struct.TYPE_9__* %261, i8* %262, i8* null, i32 %263, i32 %264, i32* %265, i32 %266)
store i32 %267, i32* %21
%268 = load i32, i32* %21
%269 = icmp sgt i32 %268, 0
br i1 %269, label %270, label %272
270: ; preds = %260
%271 = load i32, i32* %21
store i32 %271, i32* %7
store i32 1, i32* %28
br label %295
272: ; preds = %260
br label %273
273: ; preds = %272, %257, %254, %247
%274 = load i32, i32* %22
%275 = icmp ne i32 %274, -1
br i1 %275, label %276, label %280
276: ; preds = %273
%277 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%278 = load i32, i32* %22
%279 = call i32 @RES_SET_H_ERRNO(%struct.TYPE_9__* %277, i32 %278)
br label %294
280: ; preds = %273
%281 = load i32, i32* %23
%282 = icmp ne i32 %281, 0
br i1 %282, label %283, label %286
283: ; preds = %280
%284 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%285 = call i32 @RES_SET_H_ERRNO(%struct.TYPE_9__* %284, i32 129)
br label %293
286: ; preds = %280
%287 = load i32, i32* %24
%288 = icmp ne i32 %287, 0
br i1 %288, label %289, label %292
289: ; preds = %286
%290 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%291 = call i32 @RES_SET_H_ERRNO(%struct.TYPE_9__* %290, i32 128)
br label %292
292: ; preds = %289, %286
br label %293
293: ; preds = %292, %283
br label %294
294: ; preds = %293, %276
store i32 -1, i32* %7
store i32 1, i32* %28
br label %295
295: ; preds = %294, %270, %202, %196, %109, %79
%296 = load i8*, i8** %17
%297 = load i32, i32* %7
ret i32 %297
}

LLVM IR (-O2):
%struct.TYPE_9__ = type { i64, i32, i32, i64 }
@NS_MAXDNAME = global i32 0
@errno = global i64 0
@RES_DEFNAMES = global i32 0
@RES_DNSRCH = global i32 0
@ECONNREFUSED = global i64 0
@SERVFAIL = global i32 0
@RES_NOTLDQUERY = global i32 0
define i32 @res_nsearch(%struct.TYPE_9__* %0, i8* %1, i32 %2, i32 %3, i32* %4, i32 %5) {
%7 = load i32, i32* @NS_MAXDNAME
%8 = zext i32 %7 to i64
%9 = alloca i8, i64 %8
store i64 0, i64* @errno
%10 = tail call i32 @RES_SET_H_ERRNO(%struct.TYPE_9__* %0, i32 130)
%11 = load i8, i8* %1
%12 = icmp eq i8 %11, 0
br i1 %12, label %31, label %13
13: ; preds = %6, %13
%14 = phi i8 [ %21, %13 ], [ %11, %6 ]
%15 = phi i64 [ %19, %13 ], [ 0, %6 ]
%16 = phi i8* [ %20, %13 ], [ %1, %6 ]
%17 = icmp eq i8 %14, 46
%18 = zext i1 %17 to i64
%19 = add nuw nsw i64 %15, %18
%20 = getelementptr inbounds i8, i8* %16, i64 1
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %13
23: ; preds = %13
%24 = icmp ugt i8* %20, %1
br i1 %24, label %25, label %28
25: ; preds = %23
%26 = load i8, i8* %16
%27 = icmp eq i8 %26, 46
br label %28
28: ; preds = %25, %23
%29 = phi i1 [ false, %23 ], [ %27, %25 ]
%30 = icmp eq i64 %19, 0
br i1 %30, label %31, label %37
31: ; preds = %6, %28
%32 = phi i1 [ %29, %28 ], [ false, %6 ]
%33 = call i8* @res_hostalias(%struct.TYPE_9__* %0, i8* %1, i8* %9, i32 %7)
%34 = icmp eq i8* %33, null
br i1 %34, label %37, label %35
35: ; preds = %31
%36 = call i32 @res_nquery(%struct.TYPE_9__* %0, i8* %33, i32 %2, i32 %3, i32* %4, i32 %5)
br label %164
37: ; preds = %31, %28
%38 = phi i1 [ true, %31 ], [ false, %28 ]
%39 = phi i1 [ %32, %31 ], [ %29, %28 ]
%40 = phi i64 [ 0, %31 ], [ %19, %28 ]
%41 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %0, i64 0, i32 0
%42 = load i64, i64* %41
%43 = icmp sge i64 %40, %42
%44 = or i1 %39, %43
br i1 %44, label %45, label %52
45: ; preds = %37
%46 = call i32 @res_nquerydomain(%struct.TYPE_9__* %0, i8* %1, i8* null, i32 %2, i32 %3, i32* %4, i32 %5)
%47 = icmp sgt i32 %46, 0
%48 = or i1 %39, %47
br i1 %48, label %164, label %49
49: ; preds = %45
%50 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %0, i64 0, i32 1
%51 = load i32, i32* %50
br label %52
52: ; preds = %37, %49
%53 = phi i32 [ %51, %49 ], [ -1, %37 ]
br i1 %38, label %54, label %60
54: ; preds = %52
%55 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %0, i64 0, i32 2
%56 = load i32, i32* %55
%57 = load i32, i32* @RES_DEFNAMES
%58 = and i32 %57, %56
%59 = icmp eq i32 %58, 0
br i1 %59, label %138, label %67
60: ; preds = %52
br i1 %39, label %138, label %61
61: ; preds = %60
%62 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %0, i64 0, i32 2
%63 = load i32, i32* %62
%64 = load i32, i32* @RES_DNSRCH
%65 = and i32 %64, %63
%66 = icmp eq i32 %65, 0
br i1 %66, label %138, label %67
67: ; preds = %61, %54
%68 = call i32 @_resolv_populate_res_for_net(%struct.TYPE_9__* %0)
%69 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %0, i64 0, i32 3
%70 = load i64, i64* %69
%71 = inttoptr i64 %70 to i8**
%72 = load i8*, i8** %71
%73 = icmp eq i8* %72, null
br i1 %73, label %138, label %74
74: ; preds = %67
%75 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %0, i64 0, i32 1
%76 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %0, i64 0, i32 2
br label %77
77: ; preds = %74, %111
%78 = phi i8* [ %72, %74 ], [ %121, %111 ]
%79 = phi i32 [ 0, %74 ], [ %91, %111 ]
%80 = phi i32 [ 0, %74 ], [ %113, %111 ]
%81 = phi i32 [ 0, %74 ], [ %112, %111 ]
%82 = phi i8** [ %71, %74 ], [ %120, %111 ]
%83 = load i8, i8* %78
switch i8 %83, label %90 [
i8 0, label %88
i8 46, label %84
]
84: ; preds = %77
%85 = getelementptr inbounds i8, i8* %78, i64 1
%86 = load i8, i8* %85
%87 = icmp eq i8 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %77, %84
%89 = add nsw i32 %79, 1
br label %90
90: ; preds = %77, %88, %84
%91 = phi i32 [ %89, %88 ], [ %79, %84 ], [ %79, %77 ]
%92 = call i32 @res_nquerydomain(%struct.TYPE_9__* %0, i8* %1, i8* %78, i32 %2, i32 %3, i32* %4, i32 %5)
%93 = icmp sgt i32 %92, 0
br i1 %93, label %164, label %94
94: ; preds = %90
%95 = load i64, i64* @errno
%96 = load i64, i64* @ECONNREFUSED
%97 = icmp eq i64 %95, %96
br i1 %97, label %98, label %100
98: ; preds = %94
%99 = call i32 @RES_SET_H_ERRNO(%struct.TYPE_9__* %0, i32 128)
br label %164
100: ; preds = %94
%101 = load i32, i32* %75
switch i32 %101, label %110 [
i32 129, label %102
i32 130, label %111
i32 128, label %104
]
102: ; preds = %100
%103 = add nsw i32 %81, 1
br label %111
104: ; preds = %100
%105 = load i32, i32* %4
%106 = load i32, i32* @SERVFAIL
%107 = icmp eq i32 %105, %106
br i1 %107, label %108, label %110
108: ; preds = %104
%109 = add nsw i32 %80, 1
br label %111
110: ; preds = %104, %100
br label %111
111: ; preds = %110, %108, %102, %100
%112 = phi i32 [ %81, %110 ], [ %81, %108 ], [ %81, %100 ], [ %103, %102 ]
%113 = phi i32 [ %80, %110 ], [ %109, %108 ], [ %80, %100 ], [ %80, %102 ]
%114 = phi i32 [ 1, %110 ], [ 0, %108 ], [ 0, %100 ], [ 0, %102 ]
%115 = load i32, i32* %76
%116 = load i32, i32* @RES_DNSRCH
%117 = and i32 %116, %115
%118 = icmp eq i32 %117, 0
%119 = sext i1 %118 to i32
%120 = getelementptr inbounds i8*, i8** %82, i64 1
%121 = load i8*, i8** %120
%122 = icmp ne i8* %121, null
%123 = icmp eq i32 %114, %119
%124 = select i1 %122, i1 %123, i1 false
br i1 %124, label %77, label %125
125: ; preds = %111
%126 = xor i1 %73, true
%127 = and i1 %38, %126
br i1 %127, label %128, label %138
128: ; preds = %125
%129 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %0, i64 0, i32 2
%130 = load i32, i32* %129
%131 = load i32, i32* @RES_NOTLDQUERY
%132 = and i32 %131, %130
%133 = icmp ne i32 %132, 0
%134 = select i1 %133, i1 true, i1 %44
%135 = xor i1 %134, true
%136 = icmp eq i32 %91, 0
%137 = select i1 %135, i1 %136, i1 false
br i1 %137, label %145, label %150
138: ; preds = %67, %54, %60, %61, %125
%139 = phi i32 [ %91, %125 ], [ 0, %61 ], [ 0, %60 ], [ 0, %54 ], [ 0, %67 ]
%140 = phi i32 [ %113, %125 ], [ 0, %61 ], [ 0, %60 ], [ 0, %54 ], [ 0, %67 ]
%141 = phi i32 [ %112, %125 ], [ 0, %61 ], [ 0, %60 ], [ 0, %54 ], [ 0, %67 ]
%142 = xor i1 %44, true
%143 = icmp eq i32 %139, 0
%144 = select i1 %142, i1 %143, i1 false
br i1 %144, label %145, label %150
145: ; preds = %138, %128
%146 = phi i32 [ %140, %138 ], [ %113, %128 ]
%147 = phi i32 [ %141, %138 ], [ %112, %128 ]
%148 = call i32 @res_nquerydomain(%struct.TYPE_9__* %0, i8* %1, i8* null, i32 %2, i32 %3, i32* %4, i32 %5)
%149 = icmp sgt i32 %148, 0
br i1 %149, label %164, label %150
150: ; preds = %145, %138, %128
%151 = phi i32 [ %146, %145 ], [ %140, %138 ], [ %113, %128 ]
%152 = phi i32 [ %147, %145 ], [ %141, %138 ], [ %112, %128 ]
%153 = icmp eq i32 %53, -1
br i1 %153, label %156, label %154
154: ; preds = %150
%155 = call i32 @RES_SET_H_ERRNO(%struct.TYPE_9__* %0, i32 %53)
br label %164
156: ; preds = %150
%157 = icmp eq i32 %152, 0
br i1 %157, label %160, label %158
158: ; preds = %156
%159 = call i32 @RES_SET_H_ERRNO(%struct.TYPE_9__* %0, i32 129)
br label %164
160: ; preds = %156
%161 = icmp eq i32 %151, 0
br i1 %161, label %164, label %162
162: ; preds = %160
%163 = call i32 @RES_SET_H_ERRNO(%struct.TYPE_9__* %0, i32 128)
br label %164
164: ; preds = %90, %98, %154, %160, %162, %158, %145, %45, %35
%165 = phi i32 [ %36, %35 ], [ %46, %45 ], [ %148, %145 ], [ -1, %158 ], [ -1, %162 ], [ -1, %160 ], [ -1, %154 ], [ -1, %98 ], [ %92, %90 ]
ret i32 %165
}