#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_in {
  int /*<<< orphan*/ sin_port;
};
struct servent {
  char *s_name;
  char **s_aliases;
  char *s_proto;
  int /*<<< orphan*/ s_port;
};
struct addrinfo {
  scalar_t__ ai_addr;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_family;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
#define EAI_MEMORY 129
#define EAI_SYSTEM 128
int EINVAL;
int ENOENT;
int ENOMEM;
int ERANGE;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int getaddrinfo(int /*<<< orphan*/, char const *, struct addrinfo *,
                struct addrinfo **);
int /*<<< orphan*/ strcmp(char const *, char *);
int getservbyname_r(const char *name, const char *prots, struct servent *se,
                    char *buf, size_t buflen, struct servent **res) {
  struct addrinfo *ai, hint = {.ai_family = AF_INET};
  int i;
  if (!prots) {
    int r = getservbyname_r(name, "tcp", se, buf, buflen, res);
    if (r)
      r = getservbyname_r(name, "udp", se, buf, buflen, res);
    return r;
  }
  i = (uintptr_t)buf & sizeof(char *) - 1;
  if (!i)
    i = sizeof(char *);
  if (buflen < 3 * sizeof(char *) - i)
    return ERANGE;
  buf += sizeof(char *) - i;
  buflen -= sizeof(char *) - i;
  if (!strcmp(prots, "tcp"))
    hint.ai_protocol = IPPROTO_TCP;
  else if (!strcmp(prots, "udp"))
    hint.ai_protocol = IPPROTO_UDP;
  else
    return EINVAL;
  switch (getaddrinfo(0, name, &hint, &ai)) {
  case EAI_MEMORY:
  case EAI_SYSTEM:
    return ENOMEM;
  default:
    return ENOENT;
  case 0:
    break;
  }
  se->s_name = (char *)name;
  se->s_aliases = (void *)buf;
  se->s_aliases[0] = se->s_name;
  se->s_aliases[1] = 0;
  se->s_port = ((struct sockaddr_in *)ai->ai_addr)->sin_port;
  se->s_proto = (char *)prots;
  freeaddrinfo(ai);
  *res = se;
  return 0;
}


x86 assembly (clang, -O0):
<getservbyname_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movq   $0x0,-0x50(%rbp)
movl   $0x0,-0x48(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e1 <getservbyname_r+0xa1>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
lea    0xe5f(%rip),%rsi
call   1040 <getservbyname_r@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
je     11d6 <getservbyname_r+0x96>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
lea    0xe36(%rip),%rsi
call   1040 <getservbyname_r@plt>
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    138c <getservbyname_r+0x24c>
mov    -0x28(%rbp),%rax
and    $0x7,%rax
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jne    11fd <getservbyname_r+0xbd>
movl   $0x8,-0x54(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x54(%rbp),%rdx
mov    $0x18,%ecx
sub    %rdx,%rcx
cmp    %rcx,%rax
jae    1227 <getservbyname_r+0xe7>
mov    0x2dbb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    138c <getservbyname_r+0x24c>
movslq -0x54(%rbp),%rcx
mov    $0x8,%eax
sub    %rcx,%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
movslq -0x54(%rbp),%rax
mov    $0x8,%ecx
sub    %rax,%rcx
mov    -0x30(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xda3(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    127c <getservbyname_r+0x13c>
mov    0x2d6e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
jmp    12bc <getservbyname_r+0x17c>
mov    -0x18(%rbp),%rdi
lea    0xd7d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    12a6 <getservbyname_r+0x166>
mov    0x2d0c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
jmp    12b7 <getservbyname_r+0x177>
mov    0x2d13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    138c <getservbyname_r+0x24c>
jmp    12bc <getservbyname_r+0x17c>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
lea    -0x50(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   1050 <getaddrinfo@plt>
mov    %eax,%ecx
mov    %ecx,-0x5c(%rbp)
test   %eax,%eax
je     1317 <getservbyname_r+0x1d7>
jmp    12e1 <getservbyname_r+0x1a1>
mov    -0x5c(%rbp),%eax
add    $0xffffff80,%eax
sub    $0x1,%eax
ja     1306 <getservbyname_r+0x1c6>
jmp    12f5 <getservbyname_r+0x1b5>
mov    0x2ccc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    138c <getservbyname_r+0x24c>
mov    0x2ca3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    138c <getservbyname_r+0x24c>
jmp    131c <getservbyname_r+0x1dc>
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%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    -0x40(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x40(%rbp),%rdi
call   1060 <freeaddrinfo@plt>
mov    -0x20(%rbp),%rcx
mov    -0x38(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getservbyname_r>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%r14
mov    %r8,%r12
mov    %rcx,%r13
mov    %rdx,%rbp
mov    %rdi,%rbx
movq   $0x0,0x10(%rsp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
test   %rsi,%rsi
je     11a6 <getservbyname_r+0x66>
mov    %r14,0x8(%rsp)
mov    %r13d,%eax
and    $0x7,%eax
mov    $0x8,%r14d
cmovne %eax,%r14d
mov    $0x18,%eax
sub    %r14,%rax
cmp    %r12,%rax
jbe    11f2 <getservbyname_r+0xb2>
mov    0x2e37(%rip),%rax
jmp    12ae <getservbyname_r+0x16e>
lea    0xe53(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %r13,%rcx
mov    %r12,%r8
mov    %r14,%r9
call   1040 <getservbyname_r@plt>
test   %eax,%eax
je     12a3 <getservbyname_r+0x163>
lea    0xe34(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %r13,%rcx
mov    %r12,%r8
mov    %r14,%r9
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <getservbyname_r@plt>
mov    %rsi,%r15
lea    0xe04(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1227 <getservbyname_r+0xe7>
lea    0xdf5(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1230 <getservbyname_r+0xf0>
mov    0x2d9e(%rip),%rax
jmp    12ae <getservbyname_r+0x16e>
mov    0x2db2(%rip),%rax
jmp    1237 <getservbyname_r+0xf7>
mov    0x2d71(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
lea    0x10(%rsp),%rdx
lea    0x20(%rsp),%rcx
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <getaddrinfo@plt>
lea    -0x80(%rax),%ecx
cmp    $0x2,%ecx
jae    1262 <getservbyname_r+0x122>
mov    0x2d68(%rip),%rax
jmp    12ae <getservbyname_r+0x16e>
test   %eax,%eax
jne    12a7 <getservbyname_r+0x167>
sub    %r14,%r13
add    $0x8,%r13
mov    %rbx,0x0(%rbp)
mov    %r13,0x8(%rbp)
mov    %rbx,0x0(%r13)
mov    0x8(%rbp),%rax
movq   $0x0,0x8(%rax)
mov    0x20(%rsp),%rdi
mov    (%rdi),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rbp)
mov    %r15,0x10(%rbp)
call   1060 <freeaddrinfo@plt>
mov    0x8(%rsp),%rax
mov    %rbp,(%rax)
xor    %eax,%eax
jmp    12b0 <getservbyname_r+0x170>
mov    0x2d02(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.servent = type { i8*, i8**, i8*, i32 }
%struct.addrinfo = type { i64, i32, i32 }
%struct.sockaddr_in = type { i32 }
@AF_INET = global i32 0
@.str = [4 x i8] c"tcp\00"
@.str.1 = [4 x i8] c"udp\00"
@ERANGE = global i32 0
@IPPROTO_TCP = global i32 0
@IPPROTO_UDP = global i32 0
@EINVAL = global i32 0
@ENOMEM = global i32 0
@ENOENT = global i32 0
define i32 @getservbyname_r(i8* %0, i8* %1, %struct.servent* %2, i8* %3, i64 %4, %struct.servent** %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca %struct.servent*
%11 = alloca i8*
%12 = alloca i64
%13 = alloca %struct.servent**
%14 = alloca %struct.addrinfo*
%15 = alloca %struct.addrinfo
%16 = alloca i32
%17 = alloca i32
store i8* %0, i8** %8
store i8* %1, i8** %9
store %struct.servent* %2, %struct.servent** %10
store i8* %3, i8** %11
store i64 %4, i64* %12
store %struct.servent** %5, %struct.servent*** %13
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %15, i32 0, i32 0
store i64 0, i64* %18
%19 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %15, i32 0, i32 1
store i32 0, i32* %19
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %15, i32 0, i32 2
%21 = load i32, i32* @AF_INET
store i32 %21, i32* %20
%22 = load i8*, i8** %9
%23 = icmp ne i8* %22, null
br i1 %23, label %42, label %24
24: ; preds = %6
%25 = load i8*, i8** %8
%26 = load %struct.servent*, %struct.servent** %10
%27 = load i8*, i8** %11
%28 = load i64, i64* %12
%29 = load %struct.servent**, %struct.servent*** %13
%30 = call i32 @getservbyname_r(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %struct.servent* %26, i8* %27, i64 %28, %struct.servent** %29)
store i32 %30, i32* %17
%31 = load i32, i32* %17
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %40
33: ; preds = %24
%34 = load i8*, i8** %8
%35 = load %struct.servent*, %struct.servent** %10
%36 = load i8*, i8** %11
%37 = load i64, i64* %12
%38 = load %struct.servent**, %struct.servent*** %13
%39 = call i32 @getservbyname_r(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %struct.servent* %35, i8* %36, i64 %37, %struct.servent** %38)
store i32 %39, i32* %17
br label %40
40: ; preds = %33, %24
%41 = load i32, i32* %17
store i32 %41, i32* %7
br label %127
42: ; preds = %6
%43 = load i8*, i8** %11
%44 = ptrtoint i8* %43 to i64
%45 = and i64 %44, 7
%46 = trunc i64 %45 to i32
store i32 %46, i32* %16
%47 = load i32, i32* %16
%48 = icmp ne i32 %47, 0
br i1 %48, label %50, label %49
49: ; preds = %42
store i32 8, i32* %16
br label %50
50: ; preds = %49, %42
%51 = load i64, i64* %12
%52 = load i32, i32* %16
%53 = sext i32 %52 to i64
%54 = sub i64 24, %53
%55 = icmp ult i64 %51, %54
br i1 %55, label %56, label %58
56: ; preds = %50
%57 = load i32, i32* @ERANGE
store i32 %57, i32* %7
br label %127
58: ; preds = %50
%59 = load i32, i32* %16
%60 = sext i32 %59 to i64
%61 = sub i64 8, %60
%62 = load i8*, i8** %11
%63 = getelementptr inbounds i8, i8* %62, i64 %61
store i8* %63, i8** %11
%64 = load i32, i32* %16
%65 = sext i32 %64 to i64
%66 = sub i64 8, %65
%67 = load i64, i64* %12
%68 = sub i64 %67, %66
store i64 %68, i64* %12
%69 = load i8*, i8** %9
%70 = call i32 @strcmp(i8* %69, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%71 = icmp ne i32 %70, 0
br i1 %71, label %75, label %72
72: ; preds = %58
%73 = load i32, i32* @IPPROTO_TCP
%74 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %15, i32 0, i32 1
store i32 %73, i32* %74
br label %85
75: ; preds = %58
%76 = load i8*, i8** %9
%77 = call i32 @strcmp(i8* %76, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%78 = icmp ne i32 %77, 0
br i1 %78, label %82, label %79
79: ; preds = %75
%80 = load i32, i32* @IPPROTO_UDP
%81 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %15, i32 0, i32 1
store i32 %80, i32* %81
br label %84
82: ; preds = %75
%83 = load i32, i32* @EINVAL
store i32 %83, i32* %7
br label %127
84: ; preds = %79
br label %85
85: ; preds = %84, %72
%86 = load i8*, i8** %8
%87 = call i32 @getaddrinfo(i32 0, i8* %86, %struct.addrinfo* %15, %struct.addrinfo** %14)
switch i32 %87, label %90 [
i32 129, label %88
i32 128, label %88
i32 0, label %92
]
88: ; preds = %85, %85
%89 = load i32, i32* @ENOMEM
store i32 %89, i32* %7
br label %127
90: ; preds = %85
%91 = load i32, i32* @ENOENT
store i32 %91, i32* %7
br label %127
92: ; preds = %85
br label %93
93: ; preds = %92
%94 = load i8*, i8** %8
%95 = load %struct.servent*, %struct.servent** %10
%96 = getelementptr inbounds %struct.servent, %struct.servent* %95, i32 0, i32 0
store i8* %94, i8** %96
%97 = load i8*, i8** %11
%98 = bitcast i8* %97 to i8**
%99 = load %struct.servent*, %struct.servent** %10
%100 = getelementptr inbounds %struct.servent, %struct.servent* %99, i32 0, i32 1
store i8** %98, i8*** %100
%101 = load %struct.servent*, %struct.servent** %10
%102 = getelementptr inbounds %struct.servent, %struct.servent* %101, i32 0, i32 0
%103 = load i8*, i8** %102
%104 = load %struct.servent*, %struct.servent** %10
%105 = getelementptr inbounds %struct.servent, %struct.servent* %104, i32 0, i32 1
%106 = load i8**, i8*** %105
%107 = getelementptr inbounds i8*, i8** %106, i64 0
store i8* %103, i8** %107
%108 = load %struct.servent*, %struct.servent** %10
%109 = getelementptr inbounds %struct.servent, %struct.servent* %108, i32 0, i32 1
%110 = load i8**, i8*** %109
%111 = getelementptr inbounds i8*, i8** %110, i64 1
store i8* null, i8** %111
%112 = load %struct.addrinfo*, %struct.addrinfo** %14
%113 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %112, i32 0, i32 0
%114 = load i64, i64* %113
%115 = inttoptr i64 %114 to %struct.sockaddr_in*
%116 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %115, i32 0, i32 0
%117 = load i32, i32* %116
%118 = load %struct.servent*, %struct.servent** %10
%119 = getelementptr inbounds %struct.servent, %struct.servent* %118, i32 0, i32 3
store i32 %117, i32* %119
%120 = load i8*, i8** %9
%121 = load %struct.servent*, %struct.servent** %10
%122 = getelementptr inbounds %struct.servent, %struct.servent* %121, i32 0, i32 2
store i8* %120, i8** %122
%123 = load %struct.addrinfo*, %struct.addrinfo** %14
%124 = call i32 @freeaddrinfo(%struct.addrinfo* %123)
%125 = load %struct.servent*, %struct.servent** %10
%126 = load %struct.servent**, %struct.servent*** %13
store %struct.servent* %125, %struct.servent** %126
store i32 0, i32* %7
br label %127
127: ; preds = %93, %90, %88, %82, %56, %40
%128 = load i32, i32* %7
ret i32 %128
}

LLVM IR (-O2):
%struct.servent = type { i8*, i8**, i8*, i32 }
%struct.addrinfo = type { i64, i32, i32 }
%struct.sockaddr_in = type { i32 }
@AF_INET = global i32 0
@.str = [4 x i8] c"tcp\00"
@.str.1 = [4 x i8] c"udp\00"
@ERANGE = global i32 0
@IPPROTO_TCP = global i32 0
@IPPROTO_UDP = global i32 0
@EINVAL = global i32 0
@ENOMEM = global i32 0
@ENOENT = global i32 0
define i32 @getservbyname_r(i8* %0, i8* %1, %struct.servent* %2, i8* %3, i64 %4, %struct.servent** %5) {
%7 = alloca %struct.addrinfo*
%8 = alloca %struct.addrinfo
%9 = bitcast %struct.addrinfo** %7 to i8*
%10 = bitcast %struct.addrinfo* %8 to i8*
%11 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i64 0, i32 0
store i64 0, i64* %11
%12 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i64 0, i32 1
%13 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i64 0, i32 2
%14 = load i32, i32* @AF_INET
store i32 %14, i32* %13
%15 = icmp eq i8* %1, null
br i1 %15, label %16, label %21
16: ; preds = %6
%17 = tail call i32 @getservbyname_r(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %struct.servent* %2, i8* %3, i64 %4, %struct.servent** %5)
%18 = icmp eq i32 %17, 0
br i1 %18, label %66, label %19
19: ; preds = %16
%20 = tail call i32 @getservbyname_r(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %struct.servent* %2, i8* %3, i64 %4, %struct.servent** %5)
br label %66
21: ; preds = %6
%22 = ptrtoint i8* %3 to i64
%23 = trunc i64 %22 to i32
%24 = and i32 %23, 7
%25 = icmp eq i32 %24, 0
%26 = select i1 %25, i32 8, i32 %24
%27 = zext i32 %26 to i64
%28 = sub nuw nsw i64 24, %27
%29 = icmp ugt i64 %28, %4
br i1 %29, label %30, label %32
30: ; preds = %21
%31 = load i32, i32* @ERANGE
br label %66
32: ; preds = %21
%33 = sub nuw nsw i64 8, %27
%34 = getelementptr inbounds i8, i8* %3, i64 %33
%35 = tail call i32 @strcmp(i8* %1, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%36 = icmp eq i32 %35, 0
br i1 %36, label %42, label %37
37: ; preds = %32
%38 = tail call i32 @strcmp(i8* %1, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%39 = icmp eq i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %37
%41 = load i32, i32* @EINVAL
br label %66
42: ; preds = %37, %32
%43 = phi i32* [ @IPPROTO_TCP, %32 ], [ @IPPROTO_UDP, %37 ]
%44 = load i32, i32* %43
store i32 %44, i32* %12
%45 = call i32 @getaddrinfo(i32 0, i8* %0, %struct.addrinfo* %8, %struct.addrinfo** %7)
switch i32 %45, label %48 [
i32 129, label %46
i32 128, label %46
i32 0, label %50
]
46: ; preds = %42, %42
%47 = load i32, i32* @ENOMEM
br label %66
48: ; preds = %42
%49 = load i32, i32* @ENOENT
br label %66
50: ; preds = %42
%51 = getelementptr inbounds %struct.servent, %struct.servent* %2, i64 0, i32 0
store i8* %0, i8** %51
%52 = bitcast i8* %34 to i8**
%53 = getelementptr inbounds %struct.servent, %struct.servent* %2, i64 0, i32 1
%54 = bitcast i8*** %53 to i8**
store i8* %34, i8** %54
store i8* %0, i8** %52
%55 = load i8**, i8*** %53
%56 = getelementptr inbounds i8*, i8** %55, i64 1
store i8* null, i8** %56
%57 = load %struct.addrinfo*, %struct.addrinfo** %7
%58 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %57, i64 0, i32 0
%59 = load i64, i64* %58
%60 = inttoptr i64 %59 to %struct.sockaddr_in*
%61 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %60, i64 0, i32 0
%62 = load i32, i32* %61
%63 = getelementptr inbounds %struct.servent, %struct.servent* %2, i64 0, i32 3
store i32 %62, i32* %63
%64 = getelementptr inbounds %struct.servent, %struct.servent* %2, i64 0, i32 2
store i8* %1, i8** %64
%65 = call i32 @freeaddrinfo(%struct.addrinfo* %57)
store %struct.servent* %2, %struct.servent** %5
br label %66
66: ; preds = %16, %19, %50, %48, %46, %40, %30
%67 = phi i32 [ %31, %30 ], [ %41, %40 ], [ %49, %48 ], [ 0, %50 ], [ %47, %46 ], [ %20, %19 ], [ 0, %16 ]
ret i32 %67
}