#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;
#define EAI_AGAIN 132
#define EAI_FAIL 131
#define EAI_MEMORY 130
#define EAI_OVERFLOW 129
#define EAI_SYSTEM 128
int /*<<< orphan*/ ERANGE;
int NO_RECOVERY;
int TRY_AGAIN;
int /*<<< orphan*/ 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 -1;
  }
  i = (uintptr_t)buf & sizeof(char *) - 1;
  if (!i)
    i = sizeof(char *);
  if (buflen <= 5 * sizeof(char *) - i + l) {
    errno = ERANGE;
    return -1;
  }
  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 -1;
  case EAI_OVERFLOW:
    errno = ERANGE;
  default:
  case EAI_MEMORY:
  case EAI_SYSTEM:
  case EAI_FAIL:
    *err = NO_RECOVERY;
    return -1;
  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    11f9 <gethostbyaddr_r+0xd9>
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    11f4 <gethostbyaddr_r+0xd4>
mov    0x2de0(%rip),%rax
mov    (%rax),%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1413 <gethostbyaddr_r+0x2f3>
jmp    11f9 <gethostbyaddr_r+0xd9>
mov    -0x28(%rbp),%rax
and    $0x7,%rax
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jne    1215 <gethostbyaddr_r+0xf5>
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     1253 <gethostbyaddr_r+0x133>
mov    0x2d9c(%rip),%rax
mov    (%rax),%ecx
mov    0x2d73(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1413 <gethostbyaddr_r+0x2f3>
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     13df <gethostbyaddr_r+0x2bf>
jmp    1343 <gethostbyaddr_r+0x223>
mov    -0x44(%rbp),%eax
sub    $0x80,%eax
je     13c4 <gethostbyaddr_r+0x2a4>
jmp    1356 <gethostbyaddr_r+0x236>
mov    -0x44(%rbp),%eax
sub    $0x81,%eax
je     13ad <gethostbyaddr_r+0x28d>
jmp    1369 <gethostbyaddr_r+0x249>
mov    -0x44(%rbp),%eax
add    $0xffffff7e,%eax
sub    $0x2,%eax
jb     13c4 <gethostbyaddr_r+0x2a4>
jmp    137f <gethostbyaddr_r+0x25f>
mov    -0x44(%rbp),%eax
sub    $0x84,%eax
jne    13bf <gethostbyaddr_r+0x29f>
jmp    1392 <gethostbyaddr_r+0x272>
mov    0x2c2f(%rip),%rax
mov    (%rax),%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1413 <gethostbyaddr_r+0x2f3>
mov    0x2c24(%rip),%rax
mov    (%rax),%ecx
mov    0x2bfb(%rip),%rax
mov    %ecx,(%rax)
jmp    13c4 <gethostbyaddr_r+0x2a4>
mov    0x2bf5(%rip),%rax
mov    (%rax),%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1413 <gethostbyaddr_r+0x2f3>
jmp    13e4 <gethostbyaddr_r+0x2c4>
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    129f <gethostbyaddr_r+0x17f>
mov    0x2e50(%rip),%rax
cmp    %r13d,(%rax)
jne    129f <gethostbyaddr_r+0x17f>
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    128d <gethostbyaddr_r+0x16d>
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     12ac <gethostbyaddr_r+0x18c>
cmp    $0x81,%eax
je     12c5 <gethostbyaddr_r+0x1a5>
cmp    $0x84,%eax
mov    0x68(%rsp),%rcx
jne    12dc <gethostbyaddr_r+0x1bc>
mov    0x2d3d(%rip),%rax
jmp    12e3 <gethostbyaddr_r+0x1c3>
mov    0x2d44(%rip),%rax
mov    (%rax),%eax
mov    0x2d1b(%rip),%rcx
jmp    12e5 <gethostbyaddr_r+0x1c5>
mov    0x2d1a(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rdx)
jmp    12e7 <gethostbyaddr_r+0x1c7>
mov    0x60(%rsp),%rax
mov    %r13d,0x10(%rbp)
mov    0x8(%rbp),%rcx
mov    (%rcx),%rcx
mov    %rcx,0x18(%rbp)
mov    %rbp,(%rax)
jmp    12ec <gethostbyaddr_r+0x1cc>
mov    0x2d0c(%rip),%rax
mov    (%rax),%eax
mov    0x2ce3(%rip),%rcx
mov    %eax,(%rcx)
mov    0x68(%rsp),%rcx
mov    0x2cdd(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rcx)
mov    $0xffffffff,%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
@ERANGE = global i32 0
@errno = global i32 0
@TRY_AGAIN = 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 %58
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 %57
54: ; preds = %46, %42
%55 = load i32, i32* @NO_RECOVERY
%56 = load i32*, i32** %17
store i32 %55, i32* %56
store i32 -1, i32* %9
br label %161
57: ; preds = %49
br label %58
58: ; preds = %57, %37
%59 = load i8*, i8** %14
%60 = ptrtoint i8* %59 to i64
%61 = and i64 %60, 7
%62 = trunc i64 %61 to i32
store i32 %62, i32* %20
%63 = load i32, i32* %20
%64 = icmp ne i32 %63, 0
br i1 %64, label %66, label %65
65: ; preds = %58
store i32 8, i32* %20
br label %66
66: ; preds = %65, %58
%67 = load i64, i64* %15
%68 = load i32, i32* %20
%69 = sext i32 %68 to i64
%70 = sub i64 40, %69
%71 = load i32, i32* %11
%72 = sext i32 %71 to i64
%73 = add i64 %70, %72
%74 = icmp ule i64 %67, %73
br i1 %74, label %75, label %77
75: ; preds = %66
%76 = load i32, i32* @ERANGE
store i32 %76, i32* @errno
store i32 -1, i32* %9
br label %161
77: ; preds = %66
%78 = load i32, i32* %20
%79 = sext i32 %78 to i64
%80 = sub i64 8, %79
%81 = load i8*, i8** %14
%82 = getelementptr inbounds i8, i8* %81, i64 %80
store i8* %82, i8** %14
%83 = load i32, i32* %20
%84 = sext i32 %83 to i64
%85 = sub i64 40, %84
%86 = load i32, i32* %11
%87 = sext i32 %86 to i64
%88 = add i64 %85, %87
%89 = load i64, i64* %15
%90 = sub i64 %89, %88
store i64 %90, i64* %15
%91 = load i8*, i8** %14
%92 = bitcast i8* %91 to i8**
%93 = load %struct.hostent*, %struct.hostent** %13
%94 = getelementptr inbounds %struct.hostent, %struct.hostent* %93, i32 0, i32 0
store i8** %92, i8*** %94
%95 = load i8*, i8** %14
%96 = getelementptr inbounds i8, i8* %95, i64 16
store i8* %96, i8** %14
%97 = load i8*, i8** %14
%98 = bitcast i8* %97 to i8**
%99 = load %struct.hostent*, %struct.hostent** %13
%100 = getelementptr inbounds %struct.hostent, %struct.hostent* %99, i32 0, i32 1
store i8** %98, i8*** %100
%101 = load i8*, i8** %14
%102 = getelementptr inbounds i8, i8* %101, i64 16
store i8* %102, i8** %14
%103 = load i8*, i8** %14
%104 = load %struct.hostent*, %struct.hostent** %13
%105 = getelementptr inbounds %struct.hostent, %struct.hostent* %104, i32 0, i32 0
%106 = load i8**, i8*** %105
%107 = getelementptr inbounds i8*, i8** %106, i64 0
store i8* %103, i8** %107
%108 = load %struct.hostent*, %struct.hostent** %13
%109 = getelementptr inbounds %struct.hostent, %struct.hostent* %108, i32 0, i32 0
%110 = load i8**, i8*** %109
%111 = getelementptr inbounds i8*, i8** %110, i64 0
%112 = load i8*, i8** %111
%113 = load i8*, i8** %10
%114 = load i32, i32* %11
%115 = call i32 @memcpy(i8* %112, i8* %113, i32 %114)
%116 = load i32, i32* %11
%117 = load i8*, i8** %14
%118 = sext i32 %116 to i64
%119 = getelementptr inbounds i8, i8* %117, i64 %118
store i8* %119, i8** %14
%120 = load %struct.hostent*, %struct.hostent** %13
%121 = getelementptr inbounds %struct.hostent, %struct.hostent* %120, i32 0, i32 0
%122 = load i8**, i8*** %121
%123 = getelementptr inbounds i8*, i8** %122, i64 1
store i8* null, i8** %123
%124 = load i8*, i8** %14
%125 = load %struct.hostent*, %struct.hostent** %13
%126 = getelementptr inbounds %struct.hostent, %struct.hostent* %125, i32 0, i32 1
%127 = load i8**, i8*** %126
%128 = getelementptr inbounds i8*, i8** %127, i64 0
store i8* %124, i8** %128
%129 = load %struct.hostent*, %struct.hostent** %13
%130 = getelementptr inbounds %struct.hostent, %struct.hostent* %129, i32 0, i32 1
%131 = load i8**, i8*** %130
%132 = getelementptr inbounds i8*, i8** %131, i64 1
store i8* null, i8** %132
%133 = bitcast %union.anon* %18 to i8*
%134 = load i32, i32* %19
%135 = load i8*, i8** %14
%136 = load i64, i64* %15
%137 = call i32 @getnameinfo(i8* %133, i32 %134, i8* %135, i64 %136, i32 0, i32 0, i32 0)
switch i32 %137, label %143 [
i32 132, label %138
i32 129, label %141
i32 130, label %144
i32 128, label %144
i32 131, label %144
i32 0, label %147
]
138: ; preds = %77
%139 = load i32, i32* @TRY_AGAIN
%140 = load i32*, i32** %17
store i32 %139, i32* %140
store i32 -1, i32* %9
br label %161
141: ; preds = %77
%142 = load i32, i32* @ERANGE
store i32 %142, i32* @errno
br label %143
143: ; preds = %77, %141
br label %144
144: ; preds = %77, %77, %77, %143
%145 = load i32, i32* @NO_RECOVERY
%146 = load i32*, i32** %17
store i32 %145, i32* %146
store i32 -1, i32* %9
br label %161
147: ; preds = %77
br label %148
148: ; preds = %147
%149 = load i32, i32* %12
%150 = load %struct.hostent*, %struct.hostent** %13
%151 = getelementptr inbounds %struct.hostent, %struct.hostent* %150, i32 0, i32 2
store i32 %149, i32* %151
%152 = load %struct.hostent*, %struct.hostent** %13
%153 = getelementptr inbounds %struct.hostent, %struct.hostent* %152, i32 0, i32 1
%154 = load i8**, i8*** %153
%155 = getelementptr inbounds i8*, i8** %154, i64 0
%156 = load i8*, i8** %155
%157 = load %struct.hostent*, %struct.hostent** %13
%158 = getelementptr inbounds %struct.hostent, %struct.hostent* %157, i32 0, i32 3
store i8* %156, i8** %158
%159 = load %struct.hostent*, %struct.hostent** %13
%160 = load %struct.hostent**, %struct.hostent*** %16
store %struct.hostent* %159, %struct.hostent** %160
store i32 0, i32* %9
br label %161
161: ; preds = %148, %144, %138, %75, %54
%162 = load i32, i32* %9
ret i32 %162
}

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
@ERANGE = global i32 0
@errno = global i32 0
@TRY_AGAIN = 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 %29
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 %29
27: ; preds = %20
%28 = load i32, i32* @NO_RECOVERY
store i32 %28, i32* %7
br label %74
29: ; preds = %25, %18
%30 = ptrtoint i8* %4 to i64
%31 = trunc i64 %30 to i32
%32 = and i32 %31, 7
%33 = icmp eq i32 %32, 0
%34 = select i1 %33, i32 8, i32 %32
%35 = zext i32 %34 to i64
%36 = sub nuw nsw i64 40, %35
%37 = zext i32 %1 to i64
%38 = add nuw nsw i64 %36, %37
%39 = icmp ult i64 %38, %5
br i1 %39, label %42, label %40
40: ; preds = %29
%41 = load i32, i32* @ERANGE
store i32 %41, i32* @errno
br label %74
42: ; preds = %29
%43 = sub nuw nsw i64 8, %35
%44 = getelementptr inbounds i8, i8* %4, i64 %43
%45 = sub i64 %5, %38
%46 = getelementptr inbounds %struct.hostent, %struct.hostent* %3, i64 0, i32 0
%47 = bitcast %struct.hostent* %3 to i8**
store i8* %44, i8** %47
%48 = getelementptr inbounds i8, i8* %44, i64 16
%49 = getelementptr inbounds %struct.hostent, %struct.hostent* %3, i64 0, i32 1
%50 = bitcast i8*** %49 to i8**
store i8* %48, i8** %50
%51 = getelementptr inbounds i8, i8* %48, i64 16
%52 = bitcast i8* %44 to i8**
store i8* %51, i8** %52
%53 = load i8**, i8*** %46
%54 = load i8*, i8** %53
%55 = call i32 @memcpy(i8* %54, i8* %0, i32 %1)
%56 = getelementptr inbounds i8, i8* %51, i64 %37
%57 = load i8**, i8*** %46
%58 = getelementptr inbounds i8*, i8** %57, i64 1
store i8* null, i8** %58
%59 = load i8**, i8*** %49
store i8* %56, i8** %59
%60 = load i8**, i8*** %49
%61 = getelementptr inbounds i8*, i8** %60, i64 1
store i8* null, i8** %61
%62 = call i32 @getnameinfo(i8* %10, i32 %15, i8* %56, i64 %45, i32 0, i32 0, i32 0)
switch i32 %62, label %67 [
i32 132, label %63
i32 129, label %65
i32 0, label %69
]
63: ; preds = %42
%64 = load i32, i32* @TRY_AGAIN
store i32 %64, i32* %7
br label %74
65: ; preds = %42
%66 = load i32, i32* @ERANGE
store i32 %66, i32* @errno
br label %67
67: ; preds = %65, %42
%68 = load i32, i32* @NO_RECOVERY
store i32 %68, i32* %7
br label %74
69: ; preds = %42
%70 = getelementptr inbounds %struct.hostent, %struct.hostent* %3, i64 0, i32 2
store i32 %2, i32* %70
%71 = load i8**, i8*** %49
%72 = load i8*, i8** %71
%73 = getelementptr inbounds %struct.hostent, %struct.hostent* %3, i64 0, i32 3
store i8* %72, i8** %73
store %struct.hostent* %3, %struct.hostent** %6
br label %74
74: ; preds = %69, %67, %63, %40, %27
%75 = phi i32 [ -1, %40 ], [ -1, %67 ], [ 0, %69 ], [ -1, %63 ], [ -1, %27 ]
ret i32 %75
}