#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 sin_port;
  int /*<<< orphan*/ sin_family;
};
struct servent {
  int s_port;
  char *s_proto;
  char **s_aliases;
  char *s_name;
};

/* 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*/ NI_DGRAM;
int getnameinfo(void *, int, int /*<<< orphan*/, int /*<<< orphan*/, char *,
                size_t, int /*<<< orphan*/);
scalar_t__ ntohs(int);
scalar_t__ strcmp(char const *, char *);
scalar_t__ strtol(char *, int /*<<< orphan*/, int);
int getservbyport_r(int port, const char *prots, struct servent *se, char *buf,
                    size_t buflen, struct servent **res) {
  int i;
  struct sockaddr_in sin = {
      .sin_family = AF_INET,
      .sin_port = port,
  };
  if (!prots) {
    int r = getservbyport_r(port, "tcp", se, buf, buflen, res);
    if (r)
      r = getservbyport_r(port, "udp", se, buf, buflen, res);
    return r;
  }
  *res = 0;
  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") && strcmp(prots, "udp"))
    return EINVAL;
  se->s_port = port;
  se->s_proto = (char *)prots;
  se->s_aliases = (void *)buf;
  buf += 2 * sizeof(char *);
  buflen -= 2 * sizeof(char *);
  se->s_aliases[1] = 0;
  se->s_aliases[0] = se->s_name = buf;
  switch (getnameinfo((void *)&sin, sizeof sin, 0, 0, buf, buflen,
                      strcmp(prots, "udp") ? 0 : NI_DGRAM)) {
  case EAI_MEMORY:
  case EAI_SYSTEM:
    return ENOMEM;
  default:
    return ENOENT;
  case 0:
    break;
  }
  if (strtol(buf, 0, 10) == ntohs(port))
    return ENOENT;
  *res = se;
  return 0;
}


x86 assembly (clang, -O0):
<getservbyport_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11e8 <getservbyport_r+0x98>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
lea    0xe57(%rip),%rsi
call   1070 <getservbyport_r@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
je     11dd <getservbyport_r+0x8d>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
lea    0xe2f(%rip),%rsi
call   1070 <getservbyport_r@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    140f <getservbyport_r+0x2bf>
mov    -0x30(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rax
and    $0x7,%rax
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    120f <getservbyport_r+0xbf>
movl   $0x8,-0x34(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rdx
mov    $0x18,%ecx
sub    %rdx,%rcx
cmp    %rcx,%rax
jae    1239 <getservbyport_r+0xe9>
mov    0x2db1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    140f <getservbyport_r+0x2bf>
movslq -0x34(%rbp),%rcx
mov    $0x8,%eax
sub    %rcx,%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
movslq -0x34(%rbp),%rax
mov    $0x8,%ecx
sub    %rax,%rcx
mov    -0x28(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd91(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     12a9 <getservbyport_r+0x159>
mov    -0x10(%rbp),%rdi
lea    0xd7b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     12a9 <getservbyport_r+0x159>
mov    0x2d29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    140f <getservbyport_r+0x2bf>
mov    -0x8(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x20(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
sub    $0x10,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
movq   $0x0,0x8(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rcx,(%rax)
lea    -0x40(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xcd8(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1345 <getservbyport_r+0x1f5>
xor    %eax,%eax
mov    %eax,-0x64(%rbp)
jmp    1351 <getservbyport_r+0x201>
mov    0x2c64(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x50(%rbp),%r9
mov    -0x58(%rbp),%r8
mov    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%ecx
mov    %rsp,%rax
mov    %ecx,(%rax)
mov    $0x8,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <getnameinfo@plt>
mov    %eax,%ecx
mov    %ecx,-0x68(%rbp)
test   %eax,%eax
je     13bb <getservbyport_r+0x26b>
jmp    1385 <getservbyport_r+0x235>
mov    -0x68(%rbp),%eax
add    $0xffffff80,%eax
sub    $0x1,%eax
ja     13aa <getservbyport_r+0x25a>
jmp    1399 <getservbyport_r+0x249>
mov    0x2c30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    140f <getservbyport_r+0x2bf>
mov    0x2c07(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    140f <getservbyport_r+0x2bf>
jmp    13c0 <getservbyport_r+0x270>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,-0x70(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <ntohs@plt>
mov    %rax,%rcx
mov    -0x70(%rbp),%rax
cmp    %rcx,%rax
jne    13fd <getservbyport_r+0x2ad>
mov    0x2bc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    140f <getservbyport_r+0x2bf>
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getservbyport_r>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r13
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %edi,%r12d
mov    %edi,0x8(%rsp)
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
test   %rsi,%rsi
je     11b1 <getservbyport_r+0x61>
mov    %ebx,%eax
and    $0x7,%eax
mov    $0x8,%r14d
cmovne %eax,%r14d
movq   $0x0,(%r9)
mov    $0x18,%eax
sub    %r14,%rax
cmp    %r13,%rax
jbe    11fd <getservbyport_r+0xad>
mov    0x2e36(%rip),%rax
mov    (%rax),%ebp
jmp    12f8 <getservbyport_r+0x1a8>
lea    0xe48(%rip),%rsi
mov    %r12d,%edi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %r13,%r8
mov    %r9,%rbp
call   1070 <getservbyport_r@plt>
test   %eax,%eax
je     12bc <getservbyport_r+0x16c>
lea    0xe29(%rip),%rsi
mov    %r12d,%edi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %r13,%r8
mov    %rbp,%r9
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <getservbyport_r@plt>
mov    %rsi,%rbp
mov    %r9,0x10(%rsp)
lea    0xdf4(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     123b <getservbyport_r+0xeb>
lea    0xde4(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     123b <getservbyport_r+0xeb>
mov    0x2d94(%rip),%rax
mov    (%rax),%ebp
jmp    12f8 <getservbyport_r+0x1a8>
sub    %r14,%rbx
add    $0x8,%rbx
mov    %r12d,(%r15)
mov    %rbp,0x8(%r15)
mov    %rbx,0x10(%r15)
add    %r14,%r13
add    $0xffffffffffffffe8,%r13
movq   $0x0,0x8(%rbx)
add    $0x10,%rbx
mov    %rbx,0x18(%r15)
mov    0x10(%r15),%rax
mov    %rbx,(%rax)
lea    0xd92(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
mov    $0x0,%ecx
test   %rax,%rax
jne    128d <getservbyport_r+0x13d>
mov    0x2d25(%rip),%rax
mov    (%rax),%ecx
mov    %ecx,(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x8,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    %r13,%r9
call   1030 <getnameinfo@plt>
lea    -0x80(%rax),%ecx
cmp    $0x2,%ecx
jae    12c0 <getservbyport_r+0x170>
mov    0x2d18(%rip),%rax
mov    (%rax),%ebp
jmp    12f8 <getservbyport_r+0x1a8>
xor    %ebp,%ebp
jmp    12f8 <getservbyport_r+0x1a8>
test   %eax,%eax
jne    12e5 <getservbyport_r+0x195>
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,%rbx
mov    %r12d,%edi
call   1060 <ntohs@plt>
cmp    %rax,%rbx
jne    12f0 <getservbyport_r+0x1a0>
mov    0x2ccc(%rip),%rax
mov    (%rax),%ebp
jmp    12f8 <getservbyport_r+0x1a8>
mov    0x10(%rsp),%rax
mov    %r15,(%rax)
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.servent = type { i32, i8*, i8**, i8* }
%struct.sockaddr_in = type { i32, 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
@EINVAL = global i32 0
@NI_DGRAM = global i32 0
@ENOMEM = global i32 0
@ENOENT = global i32 0
define i32 @getservbyport_r(i32 %0, i8* %1, %struct.servent* %2, i8* %3, i64 %4, %struct.servent** %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca %struct.servent*
%11 = alloca i8*
%12 = alloca i64
%13 = alloca %struct.servent**
%14 = alloca i32
%15 = alloca %struct.sockaddr_in
%16 = alloca i32
store i32 %0, i32* %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
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
%18 = load i32, i32* %8
store i32 %18, i32* %17
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 1
%20 = load i32, i32* @AF_INET
store i32 %20, i32* %19
%21 = load i8*, i8** %9
%22 = icmp ne i8* %21, null
br i1 %22, label %41, label %23
23: ; preds = %6
%24 = load i32, i32* %8
%25 = load %struct.servent*, %struct.servent** %10
%26 = load i8*, i8** %11
%27 = load i64, i64* %12
%28 = load %struct.servent**, %struct.servent*** %13
%29 = call i32 @getservbyport_r(i32 %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %struct.servent* %25, i8* %26, i64 %27, %struct.servent** %28)
store i32 %29, i32* %16
%30 = load i32, i32* %16
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %23
%33 = load i32, i32* %8
%34 = load %struct.servent*, %struct.servent** %10
%35 = load i8*, i8** %11
%36 = load i64, i64* %12
%37 = load %struct.servent**, %struct.servent*** %13
%38 = call i32 @getservbyport_r(i32 %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %struct.servent* %34, i8* %35, i64 %36, %struct.servent** %37)
store i32 %38, i32* %16
br label %39
39: ; preds = %32, %23
%40 = load i32, i32* %16
store i32 %40, i32* %7
br label %132
41: ; preds = %6
%42 = load %struct.servent**, %struct.servent*** %13
store %struct.servent* null, %struct.servent** %42
%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* %14
%47 = load i32, i32* %14
%48 = icmp ne i32 %47, 0
br i1 %48, label %50, label %49
49: ; preds = %41
store i32 8, i32* %14
br label %50
50: ; preds = %49, %41
%51 = load i64, i64* %12
%52 = load i32, i32* %14
%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 %132
58: ; preds = %50
%59 = load i32, i32* %14
%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* %14
%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 i64 @strcmp(i8* %69, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%71 = icmp ne i64 %70, 0
br i1 %71, label %72, label %78
72: ; preds = %58
%73 = load i8*, i8** %9
%74 = call i64 @strcmp(i8* %73, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %72
%77 = load i32, i32* @EINVAL
store i32 %77, i32* %7
br label %132
78: ; preds = %72, %58
%79 = load i32, i32* %8
%80 = load %struct.servent*, %struct.servent** %10
%81 = getelementptr inbounds %struct.servent, %struct.servent* %80, i32 0, i32 0
store i32 %79, i32* %81
%82 = load i8*, i8** %9
%83 = load %struct.servent*, %struct.servent** %10
%84 = getelementptr inbounds %struct.servent, %struct.servent* %83, i32 0, i32 1
store i8* %82, i8** %84
%85 = load i8*, i8** %11
%86 = bitcast i8* %85 to i8**
%87 = load %struct.servent*, %struct.servent** %10
%88 = getelementptr inbounds %struct.servent, %struct.servent* %87, i32 0, i32 2
store i8** %86, i8*** %88
%89 = load i8*, i8** %11
%90 = getelementptr inbounds i8, i8* %89, i64 16
store i8* %90, i8** %11
%91 = load i64, i64* %12
%92 = sub i64 %91, 16
store i64 %92, i64* %12
%93 = load %struct.servent*, %struct.servent** %10
%94 = getelementptr inbounds %struct.servent, %struct.servent* %93, i32 0, i32 2
%95 = load i8**, i8*** %94
%96 = getelementptr inbounds i8*, i8** %95, i64 1
store i8* null, i8** %96
%97 = load i8*, i8** %11
%98 = load %struct.servent*, %struct.servent** %10
%99 = getelementptr inbounds %struct.servent, %struct.servent* %98, i32 0, i32 3
store i8* %97, i8** %99
%100 = load %struct.servent*, %struct.servent** %10
%101 = getelementptr inbounds %struct.servent, %struct.servent* %100, i32 0, i32 2
%102 = load i8**, i8*** %101
%103 = getelementptr inbounds i8*, i8** %102, i64 0
store i8* %97, i8** %103
%104 = bitcast %struct.sockaddr_in* %15 to i8*
%105 = load i8*, i8** %11
%106 = load i64, i64* %12
%107 = load i8*, i8** %9
%108 = call i64 @strcmp(i8* %107, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%109 = icmp ne i64 %108, 0
br i1 %109, label %110, label %111
110: ; preds = %78
br label %113
111: ; preds = %78
%112 = load i32, i32* @NI_DGRAM
br label %113
113: ; preds = %111, %110
%114 = phi i32 [ 0, %110 ], [ %112, %111 ]
%115 = call i32 @getnameinfo(i8* %104, i32 8, i32 0, i32 0, i8* %105, i64 %106, i32 %114)
switch i32 %115, label %118 [
i32 129, label %116
i32 128, label %116
i32 0, label %120
]
116: ; preds = %113, %113
%117 = load i32, i32* @ENOMEM
store i32 %117, i32* %7
br label %132
118: ; preds = %113
%119 = load i32, i32* @ENOENT
store i32 %119, i32* %7
br label %132
120: ; preds = %113
br label %121
121: ; preds = %120
%122 = load i8*, i8** %11
%123 = call i64 @strtol(i8* %122, i32 0, i32 10)
%124 = load i32, i32* %8
%125 = call i64 @ntohs(i32 %124)
%126 = icmp eq i64 %123, %125
br i1 %126, label %127, label %129
127: ; preds = %121
%128 = load i32, i32* @ENOENT
store i32 %128, i32* %7
br label %132
129: ; preds = %121
%130 = load %struct.servent*, %struct.servent** %10
%131 = load %struct.servent**, %struct.servent*** %13
store %struct.servent* %130, %struct.servent** %131
store i32 0, i32* %7
br label %132
132: ; preds = %129, %127, %118, %116, %76, %56, %39
%133 = load i32, i32* %7
ret i32 %133
}

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