#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 sockaddr_in6 {
  char sin6_addr;
};
struct sockaddr_in {
  int sin_family;
  char sin_addr;
};
struct hostent {
  char **h_addr_list;
  char **h_aliases;
  int h_addrtype;
  char *h_name;
};
typedef int socklen_t;

/* Variables and functions */
int AF_INET;
int AF_INET6;
int EAGAIN;
#define EAI_AGAIN 132
#define EAI_FAIL 131
#define EAI_MEMORY 130
#define EAI_OVERFLOW 129
#define EAI_SYSTEM 128
int EINVAL;
int ERANGE;
int NO_RECOVERY;
int TRY_AGAIN;
int errno;
int getnameinfo(void *, int, char *, size_t, int /*<<< orphan*/,
                int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(char *, void const *, int);
int gethostbyaddr_r(const void *a, socklen_t l, int af, struct hostent *h,
                    char *buf, size_t buflen, struct hostent **res, int *err) {
  union {
    struct sockaddr_in sin;
    struct sockaddr_in6 sin6;
  } sa = {.sin.sin_family = af};
  socklen_t sl = af == AF_INET6 ? sizeof sa.sin6 : sizeof sa.sin;
  int i;
  if (af == AF_INET6 && l == 16)
    memcpy(&sa.sin6.sin6_addr, a, 16);
  else if (af == AF_INET && l == 4)
    memcpy(&sa.sin.sin_addr, a, 4);
  else {
    *err = NO_RECOVERY;
    return EINVAL;
  }
  i = (uintptr_t)buf & sizeof(char *) - 1;
  if (!i)
    i = sizeof(char *);
  if (buflen <= 5 * sizeof(char *) - i + l)
    return ERANGE;
  buf += sizeof(char *) - i;
  buflen -= 5 * sizeof(char *) - i + l;
  h->h_addr_list = (void *)buf;
  buf += 2 * sizeof(char *);
  h->h_aliases = (void *)buf;
  buf += 2 * sizeof(char *);
  h->h_addr_list[0] = buf;
  memcpy(h->h_addr_list[0], a, l);
  buf += l;
  h->h_addr_list[1] = 0;
  h->h_aliases[0] = buf;
  h->h_aliases[1] = 0;
  switch (getnameinfo((void *)&sa, sl, buf, buflen, 0, 0, 0)) {
  case EAI_AGAIN:
    *err = TRY_AGAIN;
    return EAGAIN;
  case EAI_OVERFLOW:
    return ERANGE;
  default:
  case EAI_MEMORY:
  case EAI_SYSTEM:
  case EAI_FAIL:
    *err = NO_RECOVERY;
    return errno;
  case 0:
    break;
  }
  h->h_addrtype = af;
  h->h_name = h->h_aliases[0];
  *res = h;
  return 0;
}


x86 assembly (clang, -O0):
<gethostbyaddr_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x38(%rbp)
movb   $0x0,-0x34(%rbp)
mov    -0x18(%rbp),%edx
mov    0x2e86(%rip),%rax
mov    (%rax),%esi
mov    $0x8,%eax
mov    $0x1,%ecx
cmp    %esi,%edx
cmove  %rcx,%rax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e67(%rip),%rcx
cmp    (%rcx),%eax
jne    11a2 <gethostbyaddr_r+0x82>
cmpl   $0x10,-0x14(%rbp)
jne    11a2 <gethostbyaddr_r+0x82>
lea    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
jmp    11fe <gethostbyaddr_r+0xde>
mov    -0x18(%rbp),%eax
mov    0x2e3c(%rip),%rcx
cmp    (%rcx),%eax
jne    11d9 <gethostbyaddr_r+0xb9>
cmpl   $0x4,-0x14(%rbp)
jne    11d9 <gethostbyaddr_r+0xb9>
lea    -0x38(%rbp),%rdi
add    $0x4,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
jmp    11f9 <gethostbyaddr_r+0xd9>
mov    0x2de0(%rip),%rax
mov    (%rax),%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2dc1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1414 <gethostbyaddr_r+0x2f4>
jmp    11fe <gethostbyaddr_r+0xde>
mov    -0x28(%rbp),%rax
and    $0x7,%rax
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jne    121a <gethostbyaddr_r+0xfa>
movl   $0x8,-0x40(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x40(%rbp),%rdx
mov    $0x28,%ecx
sub    %rdx,%rcx
movslq -0x14(%rbp),%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
ja     124b <gethostbyaddr_r+0x12b>
mov    0x2d97(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1414 <gethostbyaddr_r+0x2f4>
movslq -0x40(%rbp),%rcx
mov    -0x28(%rbp),%rax
sub    %rcx,%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
movslq -0x40(%rbp),%rcx
movslq -0x14(%rbp),%rdx
mov    -0x30(%rbp),%rax
sub    %rdx,%rcx
lea    -0x28(%rax,%rcx,1),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x28(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <memcpy@plt>
movslq -0x14(%rbp),%rcx
mov    -0x28(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movq   $0x0,0x8(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
movq   $0x0,0x8(%rax)
mov    -0x3c(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    %rsp,%rax
movl   $0x0,(%rax)
lea    -0x38(%rbp),%rdi
xor    %r9d,%r9d
mov    %r9d,%r8d
call   1030 <getnameinfo@plt>
mov    %eax,%ecx
mov    %ecx,-0x44(%rbp)
test   %eax,%eax
je     13e0 <gethostbyaddr_r+0x2c0>
jmp    133b <gethostbyaddr_r+0x21b>
mov    -0x44(%rbp),%eax
sub    $0x80,%eax
je     13c0 <gethostbyaddr_r+0x2a0>
jmp    134e <gethostbyaddr_r+0x22e>
mov    -0x44(%rbp),%eax
sub    $0x81,%eax
je     13aa <gethostbyaddr_r+0x28a>
jmp    1361 <gethostbyaddr_r+0x241>
mov    -0x44(%rbp),%eax
add    $0xffffff7e,%eax
sub    $0x2,%eax
jb     13c0 <gethostbyaddr_r+0x2a0>
jmp    1377 <gethostbyaddr_r+0x257>
mov    -0x44(%rbp),%eax
sub    $0x84,%eax
jne    13bb <gethostbyaddr_r+0x29b>
jmp    138a <gethostbyaddr_r+0x26a>
mov    0x2c37(%rip),%rax
mov    (%rax),%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2c00(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1414 <gethostbyaddr_r+0x2f4>
mov    0x2c27(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1414 <gethostbyaddr_r+0x2f4>
jmp    13c0 <gethostbyaddr_r+0x2a0>
mov    0x2bf9(%rip),%rax
mov    (%rax),%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2be2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1414 <gethostbyaddr_r+0x2f4>
jmp    13e5 <gethostbyaddr_r+0x2c5>
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x20(%rbp),%rcx
mov    0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gethostbyaddr_r>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r12
mov    %edx,%r13d
mov    %esi,%r15d
mov    %rdi,%rsi
mov    0x68(%rsp),%rdx
mov    %r13d,0x10(%rsp)
movb   $0x0,0x14(%rsp)
mov    0x2e90(%rip),%rax
mov    (%rax),%eax
cmp    %r13d,%eax
mov    $0x1,%ebp
mov    $0x8,%edi
cmove  %ebp,%edi
cmp    $0x10,%r15d
jne    1187 <gethostbyaddr_r+0x67>
cmp    %r13d,%eax
jne    1187 <gethostbyaddr_r+0x67>
mov    %edi,0xc(%rsp)
mov    %rcx,0x20(%rsp)
lea    0x10(%rsp),%rdi
mov    %rsi,0x18(%rsp)
mov    $0x10,%edx
jmp    11b9 <gethostbyaddr_r+0x99>
cmp    $0x4,%r15d
jne    12a1 <gethostbyaddr_r+0x181>
mov    0x2e50(%rip),%rax
cmp    %r13d,(%rax)
jne    12a1 <gethostbyaddr_r+0x181>
mov    %edi,0xc(%rsp)
mov    %rcx,0x20(%rsp)
lea    0x14(%rsp),%rdi
mov    %rsi,0x18(%rsp)
mov    $0x4,%edx
mov    %r9,%rbp
call   1040 <memcpy@plt>
mov    %rbp,%rbx
mov    %r12d,%ecx
and    $0x7,%ecx
mov    $0x8,%eax
cmovne %ecx,%eax
mov    %r15d,%r14d
mov    %r14,%rcx
sub    %rax,%rcx
add    $0x28,%rcx
cmp    %rbp,%rcx
jae    1298 <gethostbyaddr_r+0x178>
sub    %rax,%r12
lea    0x8(%r12),%rax
sub    %rcx,%rbx
mov    0x20(%rsp),%rbp
mov    %rax,0x0(%rbp)
lea    0x18(%r12),%rax
mov    %rax,0x8(%rbp)
lea    0x28(%r12),%rax
mov    %rax,0x8(%r12)
mov    0x0(%rbp),%rax
mov    (%rax),%rdi
mov    0x18(%rsp),%rsi
mov    %r15d,%edx
mov    %rbx,%r15
call   1040 <memcpy@plt>
lea    (%r12,%r14,1),%rdx
add    $0x28,%rdx
mov    0x0(%rbp),%rax
movq   $0x0,0x8(%rax)
mov    0x8(%rbp),%rax
mov    %rdx,(%rax)
mov    0x8(%rbp),%rax
movq   $0x0,0x8(%rax)
movl   $0x0,(%rsp)
lea    0x10(%rsp),%rdi
xor    %ebx,%ebx
mov    0xc(%rsp),%esi
mov    %r15,%rcx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <getnameinfo@plt>
test   %eax,%eax
je     12b5 <gethostbyaddr_r+0x195>
cmp    $0x81,%eax
je     1298 <gethostbyaddr_r+0x178>
cmp    $0x84,%eax
mov    0x68(%rsp),%rcx
jne    12ce <gethostbyaddr_r+0x1ae>
mov    0x2d3d(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rcx)
mov    0x2d0a(%rip),%rax
jmp    12e0 <gethostbyaddr_r+0x1c0>
mov    0x2d39(%rip),%rax
jmp    12e0 <gethostbyaddr_r+0x1c0>
mov    0x2d18(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rdx)
mov    0x2cfd(%rip),%rax
jmp    12e0 <gethostbyaddr_r+0x1c0>
mov    0x60(%rsp),%rax
mov    %r13d,0x10(%rbp)
mov    0x8(%rbp),%rcx
mov    (%rcx),%rcx
mov    %rcx,0x18(%rbp)
mov    %rbp,(%rax)
jmp    12e2 <gethostbyaddr_r+0x1c2>
mov    0x2ceb(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rcx)
mov    0x2cd8(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.hostent = type { i8**, i8**, i32, i8* }
%union.anon = type { %struct.sockaddr_in }
%struct.sockaddr_in = type { i32, i8 }
@AF_INET6 = global i32 0
@AF_INET = global i32 0
@NO_RECOVERY = global i32 0
@EINVAL = global i32 0
@ERANGE = global i32 0
@TRY_AGAIN = global i32 0
@EAGAIN = global i32 0
@errno = global i32 0
define i32 @gethostbyaddr_r(i8* %0, i32 %1, i32 %2, %struct.hostent* %3, i8* %4, i64 %5, %struct.hostent** nocapture writeonly %6, i32* nocapture writeonly %7) {
%9 = alloca %union.anon
%10 = bitcast %union.anon* %9 to i8*
%11 = getelementptr inbounds %union.anon, %union.anon* %9, i64 0, i32 0, i32 0
store i32 %2, i32* %11
%12 = getelementptr inbounds %union.anon, %union.anon* %9, i64 0, i32 0, i32 1
store i8 0, i8* %12
%13 = load i32, i32* @AF_INET6
%14 = icmp eq i32 %13, %2
%15 = select i1 %14, i32 1, i32 8
%16 = icmp eq i32 %1, 16
%17 = and i1 %16, %14
br i1 %17, label %18, label %20
18: ; preds = %8
%19 = call i32 @memcpy(i8* %10, i8* %0, i32 16)
br label %30
20: ; preds = %8
%21 = load i32, i32* @AF_INET
%22 = icmp eq i32 %21, %2
%23 = icmp eq i32 %1, 4
%24 = and i1 %23, %22
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 @memcpy(i8* %12, i8* %0, i32 4)
br label %30
27: ; preds = %20
%28 = load i32, i32* @NO_RECOVERY
store i32 %28, i32* %7
%29 = load i32, i32* @EINVAL
br label %77
30: ; preds = %25, %18
%31 = ptrtoint i8* %4 to i64
%32 = trunc i64 %31 to i32
%33 = and i32 %32, 7
%34 = icmp eq i32 %33, 0
%35 = select i1 %34, i32 8, i32 %33
%36 = zext i32 %35 to i64
%37 = sub nuw nsw i64 40, %36
%38 = zext i32 %1 to i64
%39 = add nuw nsw i64 %37, %38
%40 = icmp ult i64 %39, %5
br i1 %40, label %43, label %41
41: ; preds = %30
%42 = load i32, i32* @ERANGE
br label %77
43: ; preds = %30
%44 = sub nuw nsw i64 8, %36
%45 = getelementptr inbounds i8, i8* %4, i64 %44
%46 = sub i64 %5, %39
%47 = getelementptr inbounds %struct.hostent, %struct.hostent* %3, i64 0, i32 0
%48 = bitcast %struct.hostent* %3 to i8**
store i8* %45, i8** %48
%49 = getelementptr inbounds i8, i8* %45, i64 16
%50 = getelementptr inbounds %struct.hostent, %struct.hostent* %3, i64 0, i32 1
%51 = bitcast i8*** %50 to i8**
store i8* %49, i8** %51
%52 = getelementptr inbounds i8, i8* %49, i64 16
%53 = bitcast i8* %45 to i8**
store i8* %52, i8** %53
%54 = load i8**, i8*** %47
%55 = load i8*, i8** %54
%56 = call i32 @memcpy(i8* %55, i8* %0, i32 %1)
%57 = getelementptr inbounds i8, i8* %52, i64 %38
%58 = load i8**, i8*** %47
%59 = getelementptr inbounds i8*, i8** %58, i64 1
store i8* null, i8** %59
%60 = load i8**, i8*** %50
store i8* %57, i8** %60
%61 = load i8**, i8*** %50
%62 = getelementptr inbounds i8*, i8** %61, i64 1
store i8* null, i8** %62
%63 = call i32 @getnameinfo(i8* %10, i32 %15, i8* %57, i64 %46, i32 0, i32 0, i32 0)
switch i32 %63, label %69 [
i32 132, label %64
i32 129, label %67
i32 0, label %72
]
64: ; preds = %43
%65 = load i32, i32* @TRY_AGAIN
store i32 %65, i32* %7
%66 = load i32, i32* @EAGAIN
br label %77
67: ; preds = %43
%68 = load i32, i32* @ERANGE
br label %77
69: ; preds = %43
%70 = load i32, i32* @NO_RECOVERY
store i32 %70, i32* %7
%71 = load i32, i32* @errno
br label %77
72: ; preds = %43
%73 = getelementptr inbounds %struct.hostent, %struct.hostent* %3, i64 0, i32 2
store i32 %2, i32* %73
%74 = load i8**, i8*** %50
%75 = load i8*, i8** %74
%76 = getelementptr inbounds %struct.hostent, %struct.hostent* %3, i64 0, i32 3
store i8* %75, i8** %76
store %struct.hostent* %3, %struct.hostent** %6
br label %77
77: ; preds = %72, %69, %67, %64, %41, %27
%78 = phi i32 [ %42, %41 ], [ %71, %69 ], [ 0, %72 ], [ %68, %67 ], [ %66, %64 ], [ %29, %27 ]
ret i32 %78
}