#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 */

/* Type definitions */
struct hostent {
  int h_length;
  char **h_aliases;
  char **h_addr_list;
  char *h_name;
  int /*<<< orphan*/ h_addrtype;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ AF_INET6;
int /*<<< orphan*/ C_IN;
int HOST_NOT_FOUND;
int NO_DATA;
int NO_RECOVERY;
int __dns_decodename(unsigned char *, size_t, unsigned char *, int,
                     unsigned char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int res_query(char const *, int /*<<< orphan*/, int, unsigned char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int __dns_gethostbyx_r_inner(const char *name, struct hostent *result,
                             char *buf, size_t buflen, struct hostent **RESULT,
                             int *h_errnop, int lookfor) {
  int names, ips;
  char *cur;
  char *max;
  char inpkg[1500];
  char *tmp;
  int size;
  if (lookfor == 1) {
    result->h_addrtype = AF_INET;
    result->h_length = 4;
  } else {
    result->h_addrtype = AF_INET6;
    result->h_length = 16;
  }
  result->h_aliases = (char **)(buf + 9 * sizeof(char *));
  result->h_addr_list = (char **)buf;
  result->h_aliases[0] = 0;
  cur = buf + 18 * sizeof(char *);
  max = buf + buflen;
  names = ips = 0;
  if (buflen < 128)
    goto invalidpacket;
  if ((size = res_query(name, C_IN, lookfor, (unsigned char *)inpkg, 512)) <
      0) {
  invalidpacket:
    *h_errnop = HOST_NOT_FOUND;
    return -1;
  }
  {
    tmp = inpkg + 12;
    {
      unsigned char Name[257];
      unsigned short q = ((unsigned short)inpkg[4] << 8) + inpkg[5];
      while (q > 0) {
        if (tmp > (char *)inpkg + size)
          goto invalidpacket;
        while (*tmp) {
          tmp += *tmp + 1;
          if (tmp > (char *)inpkg + size)
            goto invalidpacket;
        }
        tmp += 5;
        --q;
      }
      if (tmp > inpkg + size)
        goto invalidpacket;
      q = ((unsigned short)inpkg[6] << 8) + inpkg[7];
      if (q < 1)
        goto nodata;
      if (q > 8)
        q = 8;
      while (q > 0) {
        int decofs = __dns_decodename((unsigned char *)inpkg,
                                      (size_t)(tmp - (char *)inpkg), Name, 256,
                                      (unsigned char *)inpkg + size);
        if (decofs < 0)
          break;
        tmp = inpkg + decofs;
        --q;
        if (tmp[0] != 0 || tmp[1] != lookfor || tmp[2] != 0 || tmp[3] != 1) {
          if (tmp[1] == 5) {
            tmp += 10;
            decofs = __dns_decodename((unsigned char *)inpkg,
                                      (size_t)(tmp - (char *)inpkg), Name, 256,
                                      (unsigned char *)inpkg + size);
            if (decofs < 0)
              break;
            tmp = inpkg + decofs;
          } else
            break;
          continue;
        }
        tmp += 10;
        {
          int slen;
          if (lookfor == 1 || lookfor == 28) {
            slen = strlen((char *)Name);
            if (cur + slen + 8 + (lookfor == 28 ? 12 : 0) >= max) {
              *h_errnop = NO_RECOVERY;
              return -1;
            }
          } else {
            if (lookfor == 12) {
              decofs = __dns_decodename((unsigned char *)inpkg,
                                        (size_t)(tmp - (char *)inpkg), Name,
                                        256, (unsigned char *)inpkg + size);
              if (decofs < 0)
                break;
              tmp = inpkg + decofs;
            }
            slen = strlen((char *)Name);
          }
          strcpy(cur, (char *)Name);
          if (names == 0)
            result->h_name = cur;
          else
            result->h_aliases[names - 1] = cur;
          if (!names || strcmp(cur, result->h_name)) {
            cur += (slen | 3) + 1;
            ++names;
          }
          result->h_aliases[names - 1] = 0;
          result->h_addr_list[ips++] = cur;
          if (lookfor == 1) {
            memcpy(cur, tmp, 4);
            cur += 4;
            tmp += 4;
            result->h_addr_list[ips] = 0;
          } else if (lookfor == 28) {
            memcpy(cur, tmp, 16);
            cur += 16;
            tmp += 16;
            result->h_addr_list[ips] = 0;
          }
        }
      }
    }
  }
  if (!names) {
  nodata:
    *h_errnop = NO_DATA;
    return -1;
  }
  *h_errnop = 0;
  *RESULT = result;
  return 0;
}


x86 assembly (clang, -O0):
<__dns_gethostbyx_r_inner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x750,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
cmpl   $0x1,0x10(%rbp)
jne    11af <__dns_gethostbyx_r_inner+0x4f>
mov    0x2e51(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0x18(%rbp),%rax
movl   $0x4,(%rax)
jmp    11c9 <__dns_gethostbyx_r_inner+0x69>
mov    0x2e22(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0x18(%rbp),%rax
movl   $0x10,(%rax)
mov    -0x20(%rbp),%rcx
add    $0x48,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x90,%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpq   $0x80,-0x28(%rbp)
jae    122f <__dns_gethostbyx_r_inner+0xcf>
jmp    1265 <__dns_gethostbyx_r_inner+0x105>
mov    -0x10(%rbp),%rdi
mov    0x2da6(%rip),%rax
mov    (%rax),%esi
mov    0x10(%rbp),%edx
lea    -0x630(%rbp),%rcx
mov    $0x200,%r8d
call   1070 <res_query@plt>
mov    %eax,-0x63c(%rbp)
cmp    $0x0,%eax
jge    1280 <__dns_gethostbyx_r_inner+0x120>
jmp    1265 <__dns_gethostbyx_r_inner+0x105>
mov    0x2d64(%rip),%rax
mov    (%rax),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1829 <__dns_gethostbyx_r_inner+0x6c9>
lea    -0x630(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x638(%rbp)
movsbl -0x62c(%rbp),%eax
movzwl %ax,%eax
shl    $0x8,%eax
movsbl -0x62b(%rbp),%ecx
add    %ecx,%eax
mov    %ax,-0x742(%rbp)
movzwl -0x742(%rbp),%eax
cmp    $0x0,%eax
jle    136f <__dns_gethostbyx_r_inner+0x20f>
mov    -0x638(%rbp),%rax
lea    -0x630(%rbp),%rcx
movslq -0x63c(%rbp),%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jbe    12e5 <__dns_gethostbyx_r_inner+0x185>
jmp    1265 <__dns_gethostbyx_r_inner+0x105>
jmp    12ea <__dns_gethostbyx_r_inner+0x18a>
mov    -0x638(%rbp),%rax
cmpb   $0x0,(%rax)
je     1346 <__dns_gethostbyx_r_inner+0x1e6>
mov    -0x638(%rbp),%rax
movsbl (%rax),%ecx
add    $0x1,%ecx
mov    -0x638(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x638(%rbp)
mov    -0x638(%rbp),%rax
lea    -0x630(%rbp),%rcx
movslq -0x63c(%rbp),%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jbe    1341 <__dns_gethostbyx_r_inner+0x1e1>
jmp    1265 <__dns_gethostbyx_r_inner+0x105>
jmp    12ea <__dns_gethostbyx_r_inner+0x18a>
mov    -0x638(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x638(%rbp)
mov    -0x742(%rbp),%ax
add    $0xffff,%ax
mov    %ax,-0x742(%rbp)
jmp    12af <__dns_gethostbyx_r_inner+0x14f>
mov    -0x638(%rbp),%rax
lea    -0x630(%rbp),%rcx
movslq -0x63c(%rbp),%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jbe    1395 <__dns_gethostbyx_r_inner+0x235>
jmp    1265 <__dns_gethostbyx_r_inner+0x105>
movsbl -0x62a(%rbp),%eax
movzwl %ax,%eax
shl    $0x8,%eax
movsbl -0x629(%rbp),%ecx
add    %ecx,%eax
mov    %ax,-0x742(%rbp)
movzwl -0x742(%rbp),%eax
cmp    $0x1,%eax
jge    13c7 <__dns_gethostbyx_r_inner+0x267>
jmp    17f2 <__dns_gethostbyx_r_inner+0x692>
movzwl -0x742(%rbp),%eax
cmp    $0x8,%eax
jle    13e0 <__dns_gethostbyx_r_inner+0x280>
movw   $0x8,-0x742(%rbp)
jmp    13e5 <__dns_gethostbyx_r_inner+0x285>
movzwl -0x742(%rbp),%eax
cmp    $0x0,%eax
jle    17e3 <__dns_gethostbyx_r_inner+0x683>
lea    -0x630(%rbp),%rdi
mov    -0x638(%rbp),%rsi
lea    -0x630(%rbp),%rax
sub    %rax,%rsi
lea    -0x740(%rbp),%rdx
lea    -0x630(%rbp),%r8
movslq -0x63c(%rbp),%rax
add    %rax,%r8
mov    $0x100,%ecx
call   1080 <__dns_decodename@plt>
mov    %eax,-0x748(%rbp)
cmpl   $0x0,-0x748(%rbp)
jge    1447 <__dns_gethostbyx_r_inner+0x2e7>
jmp    17e3 <__dns_gethostbyx_r_inner+0x683>
lea    -0x630(%rbp),%rax
movslq -0x748(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x638(%rbp)
mov    -0x742(%rbp),%ax
add    $0xffff,%ax
mov    %ax,-0x742(%rbp)
mov    -0x638(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    14c0 <__dns_gethostbyx_r_inner+0x360>
mov    -0x638(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    0x10(%rbp),%eax
jne    14c0 <__dns_gethostbyx_r_inner+0x360>
mov    -0x638(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x0,%eax
jne    14c0 <__dns_gethostbyx_r_inner+0x360>
mov    -0x638(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x1,%eax
je     155f <__dns_gethostbyx_r_inner+0x3ff>
mov    -0x638(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x5,%eax
jne    1555 <__dns_gethostbyx_r_inner+0x3f5>
mov    -0x638(%rbp),%rax
add    $0xa,%rax
mov    %rax,-0x638(%rbp)
lea    -0x630(%rbp),%rdi
mov    -0x638(%rbp),%rsi
lea    -0x630(%rbp),%rax
sub    %rax,%rsi
lea    -0x740(%rbp),%rdx
lea    -0x630(%rbp),%r8
movslq -0x63c(%rbp),%rax
add    %rax,%r8
mov    $0x100,%ecx
call   1080 <__dns_decodename@plt>
mov    %eax,-0x748(%rbp)
cmpl   $0x0,-0x748(%rbp)
jge    1538 <__dns_gethostbyx_r_inner+0x3d8>
jmp    17e3 <__dns_gethostbyx_r_inner+0x683>
lea    -0x630(%rbp),%rax
movslq -0x748(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x638(%rbp)
jmp    155a <__dns_gethostbyx_r_inner+0x3fa>
jmp    17e3 <__dns_gethostbyx_r_inner+0x683>
jmp    13e5 <__dns_gethostbyx_r_inner+0x285>
mov    -0x638(%rbp),%rax
add    $0xa,%rax
mov    %rax,-0x638(%rbp)
cmpl   $0x1,0x10(%rbp)
je     1585 <__dns_gethostbyx_r_inner+0x425>
cmpl   $0x1c,0x10(%rbp)
jne    15e9 <__dns_gethostbyx_r_inner+0x489>
lea    -0x740(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x74c(%rbp)
mov    -0x48(%rbp),%rax
movslq -0x74c(%rbp),%rcx
add    %rcx,%rax
add    $0x8,%rax
mov    0x10(%rbp),%esi
xor    %ecx,%ecx
mov    $0xc,%edx
cmp    $0x1c,%esi
cmove  %edx,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
cmp    -0x50(%rbp),%rax
jb     15e4 <__dns_gethostbyx_r_inner+0x484>
mov    0x29f0(%rip),%rax
mov    (%rax),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1829 <__dns_gethostbyx_r_inner+0x6c9>
jmp    166f <__dns_gethostbyx_r_inner+0x50f>
cmpl   $0xc,0x10(%rbp)
jne    165d <__dns_gethostbyx_r_inner+0x4fd>
lea    -0x630(%rbp),%rdi
mov    -0x638(%rbp),%rsi
lea    -0x630(%rbp),%rax
sub    %rax,%rsi
lea    -0x740(%rbp),%rdx
lea    -0x630(%rbp),%r8
movslq -0x63c(%rbp),%rax
add    %rax,%r8
mov    $0x100,%ecx
call   1080 <__dns_decodename@plt>
mov    %eax,-0x748(%rbp)
cmpl   $0x0,-0x748(%rbp)
jge    1645 <__dns_gethostbyx_r_inner+0x4e5>
jmp    17e3 <__dns_gethostbyx_r_inner+0x683>
lea    -0x630(%rbp),%rax
movslq -0x748(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x638(%rbp)
lea    -0x740(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x74c(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x740(%rbp),%rsi
call   1030 <strcpy@plt>
cmpl   $0x0,-0x3c(%rbp)
jne    169a <__dns_gethostbyx_r_inner+0x53a>
mov    -0x48(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x18(%rax)
jmp    16b3 <__dns_gethostbyx_r_inner+0x553>
mov    -0x48(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x3c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
cmpl   $0x0,-0x3c(%rbp)
je     16d8 <__dns_gethostbyx_r_inner+0x578>
mov    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     16fb <__dns_gethostbyx_r_inner+0x59b>
mov    -0x74c(%rbp),%ecx
or     $0x3,%ecx
add    $0x1,%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x3c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x48(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x40(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x40(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
cmpl   $0x1,0x10(%rbp)
jne    1788 <__dns_gethostbyx_r_inner+0x628>
mov    -0x48(%rbp),%rdi
mov    -0x638(%rbp),%rsi
mov    $0x4,%edx
call   1060 <memcpy@plt>
mov    -0x48(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x48(%rbp)
mov    -0x638(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x638(%rbp)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x40(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
jmp    17de <__dns_gethostbyx_r_inner+0x67e>
cmpl   $0x1c,0x10(%rbp)
jne    17d9 <__dns_gethostbyx_r_inner+0x679>
mov    -0x48(%rbp),%rdi
mov    -0x638(%rbp),%rsi
mov    $0x10,%edx
call   1060 <memcpy@plt>
mov    -0x48(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x48(%rbp)
mov    -0x638(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x638(%rbp)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x40(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
jmp    17de <__dns_gethostbyx_r_inner+0x67e>
jmp    13e5 <__dns_gethostbyx_r_inner+0x285>
cmpl   $0x0,-0x3c(%rbp)
jne    180d <__dns_gethostbyx_r_inner+0x6ad>
jmp    17f2 <__dns_gethostbyx_r_inner+0x692>
mov    0x27bf(%rip),%rax
mov    (%rax),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1829 <__dns_gethostbyx_r_inner+0x6c9>
mov    -0x38(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x750,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__dns_gethostbyx_r_inner>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x728,%rsp
mov    %r9,%rbp
mov    %rcx,%r12
mov    %rdx,%r13
mov    0x760(%rsp),%edx
cmp    $0x1,%edx
mov    $0x4,%eax
mov    $0x10,%ecx
cmove  %eax,%ecx
mov    0x2e40(%rip),%rax
cmove  0x2e48(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsi)
mov    %ecx,(%rsi)
lea    0x48(%r13),%rax
mov    %rax,0x8(%rsi)
mov    %r13,0x10(%rsi)
movq   $0x0,0x48(%r13)
cmp    $0x80,%r12
jb     1242 <__dns_gethostbyx_r_inner+0xe2>
mov    %r8,%r15
mov    %rsi,%rbx
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
lea    0x40(%rsp),%rcx
mov    $0x200,%r8d
call   1070 <res_query@plt>
test   %eax,%eax
js     1242 <__dns_gethostbyx_r_inner+0xe2>
lea    0x4c(%rsp),%r14
mov    0x44(%rsp),%edx
shl    $0x8,%edx
movsbl 0x45(%rsp),%ecx
mov    %eax,%eax
add    %dx,%cx
je     1231 <__dns_gethostbyx_r_inner+0xd1>
lea    (%rsp,%rax,1),%rdx
add    $0x40,%rdx
nopw   0x0(%rax,%rax,1)
cmp    %rdx,%r14
ja     1242 <__dns_gethostbyx_r_inner+0xe2>
movsbq (%r14),%rsi
test   %rsi,%rsi
je     1227 <__dns_gethostbyx_r_inner+0xc7>
add    %rsi,%r14
add    $0x1,%r14
jmp    1210 <__dns_gethostbyx_r_inner+0xb0>
add    $0x5,%r14
add    $0xffff,%cx
jne    1210 <__dns_gethostbyx_r_inner+0xb0>
add    %rsp,%rax
add    $0x40,%rax
mov    %rax,0x18(%rsp)
cmp    %rax,%r14
jbe    1265 <__dns_gethostbyx_r_inner+0x105>
mov    0x2d87(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x0(%rbp)
mov    $0xffffffff,%eax
add    $0x728,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movzbl 0x46(%rsp),%ecx
shl    $0x8,%ecx
movsbl 0x47(%rsp),%eax
add    %cx,%ax
je     1544 <__dns_gethostbyx_r_inner+0x3e4>
mov    %rbp,0x20(%rsp)
mov    %r15,0x38(%rsp)
add    %r13,%r12
cmp    $0x8,%ax
mov    $0x8,%ebp
cmovb  %eax,%ebp
lea    0x90(%r13),%rax
mov    %rax,0x8(%rsp)
xor    %ecx,%ecx
cmpl   $0x1c,0x760(%rsp)
1c
mov    $0xc,%edx
mov    $0x0,%eax
mov    %rax,0x10(%rsp)
cmovne %rcx,%rdx
mov    %rdx,0x30(%rsp)
lea    0x620(%rsp),%rdx
xor    %eax,%eax
mov    %rax,(%rsp)
mov    0x18(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x40(%rsp),%rdi
sub    %rdi,%r14
mov    %r14,%rsi
mov    %rdx,%r15
mov    $0x100,%ecx
mov    %r13,%r8
call   1080 <__dns_decodename@plt>
test   %eax,%eax
js     1522 <__dns_gethostbyx_r_inner+0x3c2>
mov    %eax,%eax
lea    (%rsp,%rax,1),%r14
add    $0x40,%r14
cmpb   $0x0,0x40(%rsp,%rax,1)
movzbl 0x41(%rsp,%rax,1),%eax
jne    1390 <__dns_gethostbyx_r_inner+0x230>
movsbl %al,%ecx
cmp    0x760(%rsp),%ecx
jne    1390 <__dns_gethostbyx_r_inner+0x230>
cmpb   $0x0,0x2(%r14)
jne    1390 <__dns_gethostbyx_r_inner+0x230>
cmpb   $0x1,0x3(%r14)
jne    1390 <__dns_gethostbyx_r_inner+0x230>
add    $0xa,%r14
mov    0x760(%rsp),%eax
cmp    $0x1c,%eax
je     1355 <__dns_gethostbyx_r_inner+0x1f5>
cmp    $0xc,%eax
je     13dd <__dns_gethostbyx_r_inner+0x27d>
cmp    $0x1,%eax
jne    140a <__dns_gethostbyx_r_inner+0x2aa>
mov    %r15,%rdi
call   1040 <strlen@plt>
movslq %eax,%rdx
mov    0x8(%rsp),%r13
mov    0x30(%rsp),%rcx
add    %r13,%rcx
add    %rdx,%rcx
add    $0x8,%rcx
cmp    %r12,%rcx
jb     1417 <__dns_gethostbyx_r_inner+0x2b7>
jmp    1550 <__dns_gethostbyx_r_inner+0x3f0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x5,%al
jne    1522 <__dns_gethostbyx_r_inner+0x3c2>
lea    0x40(%rsp),%rdi
sub    %rdi,%r14
add    $0xa,%r14
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x100,%ecx
mov    %r13,%r8
call   1080 <__dns_decodename@plt>
test   %eax,%eax
js     1522 <__dns_gethostbyx_r_inner+0x3c2>
mov    %eax,%eax
lea    (%rsp,%rax,1),%r14
add    $0x40,%r14
mov    %r15,%rdx
add    $0xffffffff,%ebp
test   %bp,%bp
jne    12e0 <__dns_gethostbyx_r_inner+0x180>
jmp    1522 <__dns_gethostbyx_r_inner+0x3c2>
lea    0x40(%rsp),%rdi
sub    %rdi,%r14
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x100,%ecx
mov    %r13,%r8
call   1080 <__dns_decodename@plt>
test   %eax,%eax
js     1522 <__dns_gethostbyx_r_inner+0x3c2>
mov    %eax,%eax
lea    (%rsp,%rax,1),%r14
add    $0x40,%r14
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    0x8(%rsp),%r13
mov    %eax,0x8(%rsp)
mov    %r13,%rdi
lea    0x620(%rsp),%rsi
call   1030 <strcpy@plt>
mov    0x10(%rsp),%rax
movslq %eax,%rdx
test   %eax,%eax
je     1465 <__dns_gethostbyx_r_inner+0x305>
mov    0x8(%rbx),%rax
mov    %r13,-0x8(%rax,%rdx,8)
mov    0x18(%rbx),%rsi
mov    %r13,%rdi
mov    %rdx,0x28(%rsp)
call   1050 <strcmp@plt>
mov    0x28(%rsp),%rdx
test   %rax,%rax
mov    (%rsp),%rcx
jne    146d <__dns_gethostbyx_r_inner+0x30d>
add    $0xffffffffffffffff,%rdx
jmp    148a <__dns_gethostbyx_r_inner+0x32a>
mov    %r13,0x18(%rbx)
mov    (%rsp),%rcx
mov    0x8(%rsp),%eax
or     $0x3,%eax
cltq
add    %rax,%r13
add    $0x1,%r13
mov    0x10(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x10(%rsp)
lea    0x1(%rcx),%esi
mov    0x8(%rbx),%rax
movq   $0x0,(%rax,%rdx,8)
mov    0x10(%rbx),%rax
movslq %ecx,%rcx
mov    %r13,(%rax,%rcx,8)
mov    0x760(%rsp),%eax
cmp    $0x1,%eax
jne    14d2 <__dns_gethostbyx_r_inner+0x372>
mov    %r13,%rdi
mov    %esi,(%rsp)
mov    %r14,%rsi
mov    $0x4,%edx
call   1060 <memcpy@plt>
add    $0x4,%r13
mov    %r13,0x8(%rsp)
add    $0x4,%r14
jmp    14f7 <__dns_gethostbyx_r_inner+0x397>
cmp    $0x1c,%eax
jne    150d <__dns_gethostbyx_r_inner+0x3ad>
mov    %r13,%rdi
mov    %esi,(%rsp)
mov    %r14,%rsi
mov    $0x10,%edx
call   1060 <memcpy@plt>
add    $0x10,%r13
mov    %r13,0x8(%rsp)
add    $0x10,%r14
mov    0x10(%rbx),%rax
mov    (%rsp),%edx
movslq %edx,%rcx
movq   $0x0,(%rax,%rcx,8)
mov    %edx,%eax
jmp    1514 <__dns_gethostbyx_r_inner+0x3b4>
mov    %r13,0x8(%rsp)
mov    %esi,%eax
mov    %rax,(%rsp)
mov    0x18(%rsp),%r13
jmp    13c9 <__dns_gethostbyx_r_inner+0x269>
cmpl   $0x0,0x10(%rsp)
mov    0x20(%rsp),%rbp
je     1544 <__dns_gethostbyx_r_inner+0x3e4>
movl   $0x0,0x0(%rbp)
mov    0x38(%rsp),%rax
mov    %rbx,(%rax)
xor    %eax,%eax
jmp    1253 <__dns_gethostbyx_r_inner+0xf3>
mov    0x2a6d(%rip),%rax
jmp    1249 <__dns_gethostbyx_r_inner+0xe9>
mov    0x2a69(%rip),%rax
mov    (%rax),%eax
mov    0x20(%rsp),%rcx
mov    %eax,(%rcx)
jmp    124e <__dns_gethostbyx_r_inner+0xee>

LLVM IR (-O0):
%struct.hostent = type { i32, i8**, i8**, i8*, i32 }
@AF_INET = global i32 0
@AF_INET6 = global i32 0
@C_IN = global i32 0
@HOST_NOT_FOUND = global i32 0
@NO_RECOVERY = global i32 0
@NO_DATA = global i32 0
define i32 @__dns_gethostbyx_r_inner(i8* %0, %struct.hostent* %1, i8* %2, i64 %3, %struct.hostent** %4, i32* %5, i32 %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca %struct.hostent*
%11 = alloca i8*
%12 = alloca i64
%13 = alloca %struct.hostent**
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca [1500 x i8]
%21 = alloca i8*
%22 = alloca i32
%23 = alloca [257 x i8]
%24 = alloca i16
%25 = alloca i32
%26 = alloca i32
store i8* %0, i8** %9
store %struct.hostent* %1, %struct.hostent** %10
store i8* %2, i8** %11
store i64 %3, i64* %12
store %struct.hostent** %4, %struct.hostent*** %13
store i32* %5, i32** %14
store i32 %6, i32* %15
%27 = load i32, i32* %15
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %35
29: ; preds = %7
%30 = load i32, i32* @AF_INET
%31 = load %struct.hostent*, %struct.hostent** %10
%32 = getelementptr inbounds %struct.hostent, %struct.hostent* %31, i32 0, i32 4
store i32 %30, i32* %32
%33 = load %struct.hostent*, %struct.hostent** %10
%34 = getelementptr inbounds %struct.hostent, %struct.hostent* %33, i32 0, i32 0
store i32 4, i32* %34
br label %41
35: ; preds = %7
%36 = load i32, i32* @AF_INET6
%37 = load %struct.hostent*, %struct.hostent** %10
%38 = getelementptr inbounds %struct.hostent, %struct.hostent* %37, i32 0, i32 4
store i32 %36, i32* %38
%39 = load %struct.hostent*, %struct.hostent** %10
%40 = getelementptr inbounds %struct.hostent, %struct.hostent* %39, i32 0, i32 0
store i32 16, i32* %40
br label %41
41: ; preds = %35, %29
%42 = load i8*, i8** %11
%43 = getelementptr inbounds i8, i8* %42, i64 72
%44 = bitcast i8* %43 to i8**
%45 = load %struct.hostent*, %struct.hostent** %10
%46 = getelementptr inbounds %struct.hostent, %struct.hostent* %45, i32 0, i32 1
store i8** %44, i8*** %46
%47 = load i8*, i8** %11
%48 = bitcast i8* %47 to i8**
%49 = load %struct.hostent*, %struct.hostent** %10
%50 = getelementptr inbounds %struct.hostent, %struct.hostent* %49, i32 0, i32 2
store i8** %48, i8*** %50
%51 = load %struct.hostent*, %struct.hostent** %10
%52 = getelementptr inbounds %struct.hostent, %struct.hostent* %51, i32 0, i32 1
%53 = load i8**, i8*** %52
%54 = getelementptr inbounds i8*, i8** %53, i64 0
store i8* null, i8** %54
%55 = load i8*, i8** %11
%56 = getelementptr inbounds i8, i8* %55, i64 144
store i8* %56, i8** %18
%57 = load i8*, i8** %11
%58 = load i64, i64* %12
%59 = getelementptr inbounds i8, i8* %57, i64 %58
store i8* %59, i8** %19
store i32 0, i32* %17
store i32 0, i32* %16
%60 = load i64, i64* %12
%61 = icmp ult i64 %60, 128
br i1 %61, label %62, label %63
62: ; preds = %41
br label %71
63: ; preds = %41
%64 = load i8*, i8** %9
%65 = load i32, i32* @C_IN
%66 = load i32, i32* %15
%67 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%68 = call i32 @res_query(i8* %64, i32 %65, i32 %66, i8* %67, i32 512)
store i32 %68, i32* %22
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %63
br label %71
71: ; preds = %132, %118, %98, %70, %62
%72 = load i32, i32* @HOST_NOT_FOUND
%73 = load i32*, i32** %14
store i32 %72, i32* %73
store i32 -1, i32* %8
br label %391
74: ; preds = %63
%75 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%76 = getelementptr inbounds i8, i8* %75, i64 12
store i8* %76, i8** %21
%77 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 4
%78 = load i8, i8* %77
%79 = sext i8 %78 to i16
%80 = zext i16 %79 to i32
%81 = shl i32 %80, 8
%82 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 5
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = add nsw i32 %81, %84
%86 = trunc i32 %85 to i16
store i16 %86, i16* %24
br label %87
87: ; preds = %120, %74
%88 = load i16, i16* %24
%89 = zext i16 %88 to i32
%90 = icmp sgt i32 %89, 0
br i1 %90, label %91, label %125
91: ; preds = %87
%92 = load i8*, i8** %21
%93 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%94 = load i32, i32* %22
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8, i8* %93, i64 %95
%97 = icmp ugt i8* %92, %96
br i1 %97, label %98, label %99
98: ; preds = %91
br label %71
99: ; preds = %91
br label %100
100: ; preds = %119, %99
%101 = load i8*, i8** %21
%102 = load i8, i8* %101
%103 = icmp ne i8 %102, 0
br i1 %103, label %104, label %120
104: ; preds = %100
%105 = load i8*, i8** %21
%106 = load i8, i8* %105
%107 = sext i8 %106 to i32
%108 = add nsw i32 %107, 1
%109 = load i8*, i8** %21
%110 = sext i32 %108 to i64
%111 = getelementptr inbounds i8, i8* %109, i64 %110
store i8* %111, i8** %21
%112 = load i8*, i8** %21
%113 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%114 = load i32, i32* %22
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8, i8* %113, i64 %115
%117 = icmp ugt i8* %112, %116
br i1 %117, label %118, label %119
118: ; preds = %104
br label %71
119: ; preds = %104
br label %100
120: ; preds = %100
%121 = load i8*, i8** %21
%122 = getelementptr inbounds i8, i8* %121, i64 5
store i8* %122, i8** %21
%123 = load i16, i16* %24
%124 = add i16 %123, -1
store i16 %124, i16* %24
br label %87
125: ; preds = %87
%126 = load i8*, i8** %21
%127 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%128 = load i32, i32* %22
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i8, i8* %127, i64 %129
%131 = icmp ugt i8* %126, %130
br i1 %131, label %132, label %133
132: ; preds = %125
br label %71
133: ; preds = %125
%134 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 6
%135 = load i8, i8* %134
%136 = sext i8 %135 to i16
%137 = zext i16 %136 to i32
%138 = shl i32 %137, 8
%139 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 7
%140 = load i8, i8* %139
%141 = sext i8 %140 to i32
%142 = add nsw i32 %138, %141
%143 = trunc i32 %142 to i16
store i16 %143, i16* %24
%144 = load i16, i16* %24
%145 = zext i16 %144 to i32
%146 = icmp slt i32 %145, 1
br i1 %146, label %147, label %148
147: ; preds = %133
br label %384
148: ; preds = %133
%149 = load i16, i16* %24
%150 = zext i16 %149 to i32
%151 = icmp sgt i32 %150, 8
br i1 %151, label %152, label %153
152: ; preds = %148
store i16 8, i16* %24
br label %153
153: ; preds = %152, %148
br label %154
154: ; preds = %379, %235, %153
%155 = load i16, i16* %24
%156 = zext i16 %155 to i32
%157 = icmp sgt i32 %156, 0
br i1 %157, label %158, label %380
158: ; preds = %154
%159 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%160 = load i8*, i8** %21
%161 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%162 = ptrtoint i8* %160 to i64
%163 = ptrtoint i8* %161 to i64
%164 = sub i64 %162, %163
%165 = getelementptr inbounds [257 x i8], [257 x i8]* %23, i64 0, i64 0
%166 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%167 = load i32, i32* %22
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds i8, i8* %166, i64 %168
%170 = call i32 @__dns_decodename(i8* %159, i64 %164, i8* %165, i32 256, i8* %169)
store i32 %170, i32* %25
%171 = load i32, i32* %25
%172 = icmp slt i32 %171, 0
br i1 %172, label %173, label %174
173: ; preds = %158
br label %380
174: ; preds = %158
%175 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%176 = load i32, i32* %25
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds i8, i8* %175, i64 %177
store i8* %178, i8** %21
%179 = load i16, i16* %24
%180 = add i16 %179, -1
store i16 %180, i16* %24
%181 = load i8*, i8** %21
%182 = getelementptr inbounds i8, i8* %181, i64 0
%183 = load i8, i8* %182
%184 = sext i8 %183 to i32
%185 = icmp ne i32 %184, 0
br i1 %185, label %205, label %186
186: ; preds = %174
%187 = load i8*, i8** %21
%188 = getelementptr inbounds i8, i8* %187, i64 1
%189 = load i8, i8* %188
%190 = sext i8 %189 to i32
%191 = load i32, i32* %15
%192 = icmp ne i32 %190, %191
br i1 %192, label %205, label %193
193: ; preds = %186
%194 = load i8*, i8** %21
%195 = getelementptr inbounds i8, i8* %194, i64 2
%196 = load i8, i8* %195
%197 = sext i8 %196 to i32
%198 = icmp ne i32 %197, 0
br i1 %198, label %205, label %199
199: ; preds = %193
%200 = load i8*, i8** %21
%201 = getelementptr inbounds i8, i8* %200, i64 3
%202 = load i8, i8* %201
%203 = sext i8 %202 to i32
%204 = icmp ne i32 %203, 1
br i1 %204, label %205, label %236
205: ; preds = %199, %193, %186, %174
%206 = load i8*, i8** %21
%207 = getelementptr inbounds i8, i8* %206, i64 1
%208 = load i8, i8* %207
%209 = sext i8 %208 to i32
%210 = icmp eq i32 %209, 5
br i1 %210, label %211, label %234
211: ; preds = %205
%212 = load i8*, i8** %21
%213 = getelementptr inbounds i8, i8* %212, i64 10
store i8* %213, i8** %21
%214 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%215 = load i8*, i8** %21
%216 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%217 = ptrtoint i8* %215 to i64
%218 = ptrtoint i8* %216 to i64
%219 = sub i64 %217, %218
%220 = getelementptr inbounds [257 x i8], [257 x i8]* %23, i64 0, i64 0
%221 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%222 = load i32, i32* %22
%223 = sext i32 %222 to i64
%224 = getelementptr inbounds i8, i8* %221, i64 %223
%225 = call i32 @__dns_decodename(i8* %214, i64 %219, i8* %220, i32 256, i8* %224)
store i32 %225, i32* %25
%226 = load i32, i32* %25
%227 = icmp slt i32 %226, 0
br i1 %227, label %228, label %229
228: ; preds = %211
br label %380
229: ; preds = %211
%230 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%231 = load i32, i32* %25
%232 = sext i32 %231 to i64
%233 = getelementptr inbounds i8, i8* %230, i64 %232
store i8* %233, i8** %21
br label %235
234: ; preds = %205
br label %380
235: ; preds = %229
br label %154
236: ; preds = %199
%237 = load i8*, i8** %21
%238 = getelementptr inbounds i8, i8* %237, i64 10
store i8* %238, i8** %21
%239 = load i32, i32* %15
%240 = icmp eq i32 %239, 1
br i1 %240, label %244, label %241
241: ; preds = %236
%242 = load i32, i32* %15
%243 = icmp eq i32 %242, 28
br i1 %243, label %244, label %264
244: ; preds = %241, %236
%245 = getelementptr inbounds [257 x i8], [257 x i8]* %23, i64 0, i64 0
%246 = call i32 @strlen(i8* %245)
store i32 %246, i32* %26
%247 = load i8*, i8** %18
%248 = load i32, i32* %26
%249 = sext i32 %248 to i64
%250 = getelementptr inbounds i8, i8* %247, i64 %249
%251 = getelementptr inbounds i8, i8* %250, i64 8
%252 = load i32, i32* %15
%253 = icmp eq i32 %252, 28
%254 = zext i1 %253 to i64
%255 = select i1 %253, i32 12, i32 0
%256 = sext i32 %255 to i64
%257 = getelementptr inbounds i8, i8* %251, i64 %256
%258 = load i8*, i8** %19
%259 = icmp uge i8* %257, %258
br i1 %259, label %260, label %263
260: ; preds = %244
%261 = load i32, i32* @NO_RECOVERY
%262 = load i32*, i32** %14
store i32 %261, i32* %262
store i32 -1, i32* %8
br label %391
263: ; preds = %244
br label %291
264: ; preds = %241
%265 = load i32, i32* %15
%266 = icmp eq i32 %265, 12
br i1 %266, label %267, label %288
267: ; preds = %264
%268 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%269 = load i8*, i8** %21
%270 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%271 = ptrtoint i8* %269 to i64
%272 = ptrtoint i8* %270 to i64
%273 = sub i64 %271, %272
%274 = getelementptr inbounds [257 x i8], [257 x i8]* %23, i64 0, i64 0
%275 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%276 = load i32, i32* %22
%277 = sext i32 %276 to i64
%278 = getelementptr inbounds i8, i8* %275, i64 %277
%279 = call i32 @__dns_decodename(i8* %268, i64 %273, i8* %274, i32 256, i8* %278)
store i32 %279, i32* %25
%280 = load i32, i32* %25
%281 = icmp slt i32 %280, 0
br i1 %281, label %282, label %283
282: ; preds = %267
br label %380
283: ; preds = %267
%284 = getelementptr inbounds [1500 x i8], [1500 x i8]* %20, i64 0, i64 0
%285 = load i32, i32* %25
%286 = sext i32 %285 to i64
%287 = getelementptr inbounds i8, i8* %284, i64 %286
store i8* %287, i8** %21
br label %288
288: ; preds = %283, %264
%289 = getelementptr inbounds [257 x i8], [257 x i8]* %23, i64 0, i64 0
%290 = call i32 @strlen(i8* %289)
store i32 %290, i32* %26
br label %291
291: ; preds = %288, %263
%292 = load i8*, i8** %18
%293 = getelementptr inbounds [257 x i8], [257 x i8]* %23, i64 0, i64 0
%294 = call i32 @strcpy(i8* %292, i8* %293)
%295 = load i32, i32* %16
%296 = icmp eq i32 %295, 0
br i1 %296, label %297, label %301
297: ; preds = %291
%298 = load i8*, i8** %18
%299 = load %struct.hostent*, %struct.hostent** %10
%300 = getelementptr inbounds %struct.hostent, %struct.hostent* %299, i32 0, i32 3
store i8* %298, i8** %300
br label %310
301: ; preds = %291
%302 = load i8*, i8** %18
%303 = load %struct.hostent*, %struct.hostent** %10
%304 = getelementptr inbounds %struct.hostent, %struct.hostent* %303, i32 0, i32 1
%305 = load i8**, i8*** %304
%306 = load i32, i32* %16
%307 = sub nsw i32 %306, 1
%308 = sext i32 %307 to i64
%309 = getelementptr inbounds i8*, i8** %305, i64 %308
store i8* %302, i8** %309
br label %310
310: ; preds = %301, %297
%311 = load i32, i32* %16
%312 = icmp ne i32 %311, 0
br i1 %312, label %313, label %320
313: ; preds = %310
%314 = load i8*, i8** %18
%315 = load %struct.hostent*, %struct.hostent** %10
%316 = getelementptr inbounds %struct.hostent, %struct.hostent* %315, i32 0, i32 3
%317 = load i8*, i8** %316
%318 = call i64 @strcmp(i8* %314, i8* %317)
%319 = icmp ne i64 %318, 0
br i1 %319, label %320, label %329
320: ; preds = %313, %310
%321 = load i32, i32* %26
%322 = or i32 %321, 3
%323 = add nsw i32 %322, 1
%324 = load i8*, i8** %18
%325 = sext i32 %323 to i64
%326 = getelementptr inbounds i8, i8* %324, i64 %325
store i8* %326, i8** %18
%327 = load i32, i32* %16
%328 = add nsw i32 %327, 1
store i32 %328, i32* %16
br label %329
329: ; preds = %320, %313
%330 = load %struct.hostent*, %struct.hostent** %10
%331 = getelementptr inbounds %struct.hostent, %struct.hostent* %330, i32 0, i32 1
%332 = load i8**, i8*** %331
%333 = load i32, i32* %16
%334 = sub nsw i32 %333, 1
%335 = sext i32 %334 to i64
%336 = getelementptr inbounds i8*, i8** %332, i64 %335
store i8* null, i8** %336
%337 = load i8*, i8** %18
%338 = load %struct.hostent*, %struct.hostent** %10
%339 = getelementptr inbounds %struct.hostent, %struct.hostent* %338, i32 0, i32 2
%340 = load i8**, i8*** %339
%341 = load i32, i32* %17
%342 = add nsw i32 %341, 1
store i32 %342, i32* %17
%343 = sext i32 %341 to i64
%344 = getelementptr inbounds i8*, i8** %340, i64 %343
store i8* %337, i8** %344
%345 = load i32, i32* %15
%346 = icmp eq i32 %345, 1
br i1 %346, label %347, label %361
347: ; preds = %329
%348 = load i8*, i8** %18
%349 = load i8*, i8** %21
%350 = call i32 @memcpy(i8* %348, i8* %349, i32 4)
%351 = load i8*, i8** %18
%352 = getelementptr inbounds i8, i8* %351, i64 4
store i8* %352, i8** %18
%353 = load i8*, i8** %21
%354 = getelementptr inbounds i8, i8* %353, i64 4
store i8* %354, i8** %21
%355 = load %struct.hostent*, %struct.hostent** %10
%356 = getelementptr inbounds %struct.hostent, %struct.hostent* %355, i32 0, i32 2
%357 = load i8**, i8*** %356
%358 = load i32, i32* %17
%359 = sext i32 %358 to i64
%360 = getelementptr inbounds i8*, i8** %357, i64 %359
store i8* null, i8** %360
br label %379
361: ; preds = %329
%362 = load i32, i32* %15
%363 = icmp eq i32 %362, 28
br i1 %363, label %364, label %378
364: ; preds = %361
%365 = load i8*, i8** %18
%366 = load i8*, i8** %21
%367 = call i32 @memcpy(i8* %365, i8* %366, i32 16)
%368 = load i8*, i8** %18
%369 = getelementptr inbounds i8, i8* %368, i64 16
store i8* %369, i8** %18
%370 = load i8*, i8** %21
%371 = getelementptr inbounds i8, i8* %370, i64 16
store i8* %371, i8** %21
%372 = load %struct.hostent*, %struct.hostent** %10
%373 = getelementptr inbounds %struct.hostent, %struct.hostent* %372, i32 0, i32 2
%374 = load i8**, i8*** %373
%375 = load i32, i32* %17
%376 = sext i32 %375 to i64
%377 = getelementptr inbounds i8*, i8** %374, i64 %376
store i8* null, i8** %377
br label %378
378: ; preds = %364, %361
br label %379
379: ; preds = %378, %347
br label %154
380: ; preds = %282, %234, %228, %173, %154
%381 = load i32, i32* %16
%382 = icmp ne i32 %381, 0
br i1 %382, label %387, label %383
383: ; preds = %380
br label %384
384: ; preds = %383, %147
%385 = load i32, i32* @NO_DATA
%386 = load i32*, i32** %14
store i32 %385, i32* %386
store i32 -1, i32* %8
br label %391
387: ; preds = %380
%388 = load i32*, i32** %14
store i32 0, i32* %388
%389 = load %struct.hostent*, %struct.hostent** %10
%390 = load %struct.hostent**, %struct.hostent*** %13
store %struct.hostent* %389, %struct.hostent** %390
store i32 0, i32* %8
br label %391
391: ; preds = %387, %384, %260, %71
%392 = load i32, i32* %8
ret i32 %392
}

LLVM IR (-O2):
%struct.hostent = type { i32, i8**, i8**, i8*, i32 }
@AF_INET = global i32 0
@AF_INET6 = global i32 0
@C_IN = global i32 0
@HOST_NOT_FOUND = global i32 0
@NO_RECOVERY = global i32 0
@NO_DATA = global i32 0
define i32 @__dns_gethostbyx_r_inner(i8* %0, %struct.hostent* %1, i8* %2, i64 %3, %struct.hostent** nocapture writeonly %4, i32* nocapture writeonly %5, i32 %6) {
%8 = alloca [1500 x i8]
%9 = alloca [257 x i8]
%10 = getelementptr inbounds [1500 x i8], [1500 x i8]* %8, i64 0, i64 0
%11 = icmp eq i32 %6, 1
%12 = select i1 %11, i32 4, i32 16
%13 = load i32, i32* @AF_INET
%14 = load i32, i32* @AF_INET6
%15 = select i1 %11, i32 %13, i32 %14
%16 = getelementptr inbounds %struct.hostent, %struct.hostent* %1, i64 0, i32 4
store i32 %15, i32* %16
%17 = getelementptr inbounds %struct.hostent, %struct.hostent* %1, i64 0, i32 0
store i32 %12, i32* %17
%18 = getelementptr inbounds i8, i8* %2, i64 72
%19 = getelementptr inbounds %struct.hostent, %struct.hostent* %1, i64 0, i32 1
%20 = bitcast i8*** %19 to i8**
store i8* %18, i8** %20
%21 = getelementptr inbounds %struct.hostent, %struct.hostent* %1, i64 0, i32 2
%22 = bitcast i8*** %21 to i8**
store i8* %2, i8** %22
%23 = bitcast i8* %18 to i8**
store i8* null, i8** %23
%24 = getelementptr inbounds i8, i8* %2, i64 144
%25 = getelementptr inbounds i8, i8* %2, i64 %3
%26 = icmp ult i64 %3, 128
br i1 %26, label %31, label %27
27: ; preds = %7
%28 = load i32, i32* @C_IN
%29 = call i32 @res_query(i8* %0, i32 %28, i32 %6, i8* %10, i32 512)
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %200, %27, %7
%32 = load i32, i32* @HOST_NOT_FOUND
store i32 %32, i32* %5
br label %208
33: ; preds = %27
%34 = getelementptr inbounds [1500 x i8], [1500 x i8]* %8, i64 0, i64 12
%35 = getelementptr inbounds [257 x i8], [257 x i8]* %9, i64 0, i64 0
%36 = getelementptr inbounds [1500 x i8], [1500 x i8]* %8, i64 0, i64 4
%37 = load i8, i8* %36
%38 = zext i8 %37 to i16
%39 = shl nuw i16 %38, 8
%40 = getelementptr inbounds [1500 x i8], [1500 x i8]* %8, i64 0, i64 5
%41 = load i8, i8* %40
%42 = sext i8 %41 to i16
%43 = add i16 %39, %42
%44 = icmp eq i16 %43, 0
%45 = zext i32 %29 to i64
br i1 %44, label %65, label %46
46: ; preds = %33
%47 = getelementptr inbounds [1500 x i8], [1500 x i8]* %8, i64 0, i64 %45
br label %48
48: ; preds = %46, %61
%49 = phi i16 [ %43, %46 ], [ %63, %61 ]
%50 = phi i8* [ %34, %46 ], [ %62, %61 ]
%51 = icmp ugt i8* %50, %47
br i1 %51, label %200, label %52
52: ; preds = %48, %56
%53 = phi i8* [ %59, %56 ], [ %50, %48 ]
%54 = load i8, i8* %53
%55 = icmp eq i8 %54, 0
br i1 %55, label %61, label %56
56: ; preds = %52
%57 = sext i8 %54 to i64
%58 = add nsw i64 %57, 1
%59 = getelementptr inbounds i8, i8* %53, i64 %58
%60 = icmp ugt i8* %59, %47
br i1 %60, label %200, label %52
61: ; preds = %52
%62 = getelementptr inbounds i8, i8* %53, i64 5
%63 = add i16 %49, -1
%64 = icmp eq i16 %63, 0
br i1 %64, label %65, label %48
65: ; preds = %61, %33
%66 = phi i8* [ %34, %33 ], [ %62, %61 ]
%67 = getelementptr inbounds [1500 x i8], [1500 x i8]* %8, i64 0, i64 %45
%68 = icmp ugt i8* %66, %67
br i1 %68, label %200, label %69
69: ; preds = %65
%70 = getelementptr inbounds [1500 x i8], [1500 x i8]* %8, i64 0, i64 6
%71 = load i8, i8* %70
%72 = zext i8 %71 to i16
%73 = shl nuw i16 %72, 8
%74 = getelementptr inbounds [1500 x i8], [1500 x i8]* %8, i64 0, i64 7
%75 = load i8, i8* %74
%76 = sext i8 %75 to i16
%77 = add i16 %73, %76
%78 = icmp eq i16 %77, 0
br i1 %78, label %201, label %79
79: ; preds = %69
%80 = icmp ult i16 %77, 8
%81 = select i1 %80, i16 %77, i16 8
%82 = ptrtoint [1500 x i8]* %8 to i64
%83 = icmp eq i32 %6, 28
%84 = select i1 %83, i64 12, i64 0
%85 = getelementptr inbounds %struct.hostent, %struct.hostent* %1, i64 0, i32 3
br label %86
86: ; preds = %79, %194
%87 = phi i16 [ %81, %79 ], [ %99, %194 ]
%88 = phi i8* [ %66, %79 ], [ %198, %194 ]
%89 = phi i32 [ 0, %79 ], [ %197, %194 ]
%90 = phi i8* [ %24, %79 ], [ %196, %194 ]
%91 = phi i32 [ 0, %79 ], [ %195, %194 ]
%92 = ptrtoint i8* %88 to i64
%93 = sub i64 %92, %82
%94 = call i32 @__dns_decodename(i8* %10, i64 %93, i8* %35, i32 256, i8* %67)
%95 = icmp slt i32 %94, 0
br i1 %95, label %202, label %96
96: ; preds = %86
%97 = zext i32 %94 to i64
%98 = getelementptr inbounds [1500 x i8], [1500 x i8]* %8, i64 0, i64 %97
%99 = add i16 %87, -1
%100 = load i8, i8* %98
%101 = icmp eq i8 %100, 0
%102 = getelementptr inbounds i8, i8* %98, i64 1
%103 = load i8, i8* %102
%104 = sext i8 %103 to i32
%105 = icmp eq i32 %104, %6
%106 = select i1 %101, i1 %105, i1 false
br i1 %106, label %107, label %115
107: ; preds = %96
%108 = getelementptr inbounds i8, i8* %98, i64 2
%109 = load i8, i8* %108
%110 = icmp eq i8 %109, 0
br i1 %110, label %111, label %115
111: ; preds = %107
%112 = getelementptr inbounds i8, i8* %98, i64 3
%113 = load i8, i8* %112
%114 = icmp eq i8 %113, 1
br i1 %114, label %126, label %115
115: ; preds = %96, %111, %107
%116 = icmp eq i8 %103, 5
br i1 %116, label %117, label %202
117: ; preds = %115
%118 = getelementptr inbounds i8, i8* %98, i64 10
%119 = ptrtoint i8* %118 to i64
%120 = sub i64 %119, %82
%121 = call i32 @__dns_decodename(i8* %10, i64 %120, i8* %35, i32 256, i8* %67)
%122 = icmp slt i32 %121, 0
br i1 %122, label %202, label %123
123: ; preds = %117
%124 = zext i32 %121 to i64
%125 = getelementptr inbounds [1500 x i8], [1500 x i8]* %8, i64 0, i64 %124
br label %194
126: ; preds = %111
%127 = getelementptr inbounds i8, i8* %98, i64 10
switch i32 %6, label %145 [
i32 28, label %128
i32 1, label %128
i32 12, label %137
]
128: ; preds = %126, %126
%129 = call i32 @strlen(i8* %35)
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds i8, i8* %90, i64 8
%132 = getelementptr inbounds i8, i8* %131, i64 %84
%133 = getelementptr inbounds i8, i8* %132, i64 %130
%134 = icmp ult i8* %133, %25
br i1 %134, label %148, label %135
135: ; preds = %128
%136 = load i32, i32* @NO_RECOVERY
store i32 %136, i32* %5
br label %208
137: ; preds = %126
%138 = ptrtoint i8* %127 to i64
%139 = sub i64 %138, %82
%140 = call i32 @__dns_decodename(i8* %10, i64 %139, i8* %35, i32 256, i8* %67)
%141 = icmp slt i32 %140, 0
br i1 %141, label %202, label %142
142: ; preds = %137
%143 = zext i32 %140 to i64
%144 = getelementptr inbounds [1500 x i8], [1500 x i8]* %8, i64 0, i64 %143
br label %145
145: ; preds = %126, %142
%146 = phi i8* [ %144, %142 ], [ %127, %126 ]
%147 = call i32 @strlen(i8* %35)
br label %148
148: ; preds = %128, %145
%149 = phi i8* [ %127, %128 ], [ %146, %145 ]
%150 = phi i32 [ %129, %128 ], [ %147, %145 ]
%151 = call i32 @strcpy(i8* %90, i8* %35)
%152 = icmp eq i32 %89, 0
br i1 %152, label %153, label %154
153: ; preds = %148
store i8* %90, i8** %85
br label %162
154: ; preds = %148
%155 = load i8**, i8*** %19
%156 = add nsw i32 %89, -1
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds i8*, i8** %155, i64 %157
store i8* %90, i8** %158
%159 = load i8*, i8** %85
%160 = call i64 @strcmp(i8* %90, i8* %159)
%161 = icmp eq i64 %160, 0
br i1 %161, label %169, label %162
162: ; preds = %153, %154
%163 = or i32 %150, 3
%164 = add nsw i32 %163, 1
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds i8, i8* %90, i64 %165
%167 = add nsw i32 %89, 1
%168 = sext i32 %89 to i64
br label %169
169: ; preds = %162, %154
%170 = phi i64 [ %168, %162 ], [ %157, %154 ]
%171 = phi i8* [ %166, %162 ], [ %90, %154 ]
%172 = phi i32 [ %167, %162 ], [ %89, %154 ]
%173 = load i8**, i8*** %19
%174 = getelementptr inbounds i8*, i8** %173, i64 %170
store i8* null, i8** %174
%175 = load i8**, i8*** %21
%176 = add nsw i32 %91, 1
%177 = sext i32 %91 to i64
%178 = getelementptr inbounds i8*, i8** %175, i64 %177
store i8* %171, i8** %178
br i1 %11, label %179, label %186
179: ; preds = %169
%180 = call i32 @memcpy(i8* %171, i8* %149, i32 4)
%181 = getelementptr inbounds i8, i8* %171, i64 4
%182 = getelementptr inbounds i8, i8* %149, i64 4
%183 = load i8**, i8*** %21
%184 = sext i32 %176 to i64
%185 = getelementptr inbounds i8*, i8** %183, i64 %184
store i8* null, i8** %185
br label %194
186: ; preds = %169
br i1 %83, label %187, label %194
187: ; preds = %186
%188 = call i32 @memcpy(i8* %171, i8* %149, i32 16)
%189 = getelementptr inbounds i8, i8* %171, i64 16
%190 = getelementptr inbounds i8, i8* %149, i64 16
%191 = load i8**, i8*** %21
%192 = sext i32 %176 to i64
%193 = getelementptr inbounds i8*, i8** %191, i64 %192
store i8* null, i8** %193
br label %194
194: ; preds = %186, %187, %179, %123
%195 = phi i32 [ %91, %123 ], [ %176, %186 ], [ %176, %187 ], [ %176, %179 ]
%196 = phi i8* [ %90, %123 ], [ %171, %186 ], [ %189, %187 ], [ %181, %179 ]
%197 = phi i32 [ %89, %123 ], [ %172, %186 ], [ %172, %187 ], [ %172, %179 ]
%198 = phi i8* [ %125, %123 ], [ %149, %186 ], [ %190, %187 ], [ %182, %179 ]
%199 = icmp eq i16 %99, 0
br i1 %199, label %202, label %86
200: ; preds = %48, %56, %65
br label %31
201: ; preds = %69
br label %205
202: ; preds = %137, %115, %117, %86, %194
%203 = phi i32 [ %89, %137 ], [ %89, %115 ], [ %89, %117 ], [ %89, %86 ], [ %197, %194 ]
%204 = icmp eq i32 %203, 0
br i1 %204, label %205, label %207
205: ; preds = %201, %202
%206 = load i32, i32* @NO_DATA
store i32 %206, i32* %5
br label %208
207: ; preds = %202
store i32 0, i32* %5
store %struct.hostent* %1, %struct.hostent** %4
br label %208
208: ; preds = %135, %207, %205, %31
%209 = phi i32 [ -1, %31 ], [ -1, %205 ], [ 0, %207 ], [ -1, %135 ]
ret i32 %209
}