#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 {
  scalar_t__ sin_family;
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_port;
};
struct sockaddr {
  int dummy;
};
struct servent {
  char *s_name;
};
struct in_addr {
  int dummy;
};
struct hostent {
  char *h_name;
};
typedef scalar_t__ socklen_t;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ PF_INET;
struct hostent *gethostbyaddr(char *, int, int /*<<< orphan*/);
struct servent *getservbyport(int /*<<< orphan*/, char *);
int h_errno;
char *inet_ntoa(int /*<<< orphan*/);
scalar_t__ itoa_length(int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int ebnet_getnameinfo(const struct sockaddr *sa, socklen_t salen, char *node,
                      socklen_t nodelen, char *serv, socklen_t servlen,
                      int flags) {
  const struct sockaddr_in *sa_in = (const struct sockaddr_in *)sa;
  struct hostent *hostent;
  struct servent *servent;
  char *ntoa_address;
  int saved_h_errno;
  int result = 0;
  saved_h_errno = h_errno;
  if (sa_in->sin_family != PF_INET) {
    result = 5;
    goto end;
  } else if (node == NULL && serv == NULL) {
    result = 7;
    goto end;
  }
  if (serv != NULL && servlen > 0) {
    if (flags & 0x0020)
      servent = NULL;
    else if (flags & 0x0001)
      servent = getservbyport(sa_in->sin_port, "udp");
    else
      servent = getservbyport(sa_in->sin_port, "tcp");
    if (servent != NULL) {
      if (servlen <= strlen(servent->s_name)) {
        result = 8;
        goto end;
      }
      strcpy(serv, servent->s_name);
    } else {
      if (servlen <= itoa_length(ntohs(sa_in->sin_port))) {
        result = 8;
        goto end;
      }
      sprintf(serv, "%d", ntohs(sa_in->sin_port));
    }
  }
  if (node != NULL && nodelen > 0) {
    if (flags & 0x0008)
      hostent = NULL;
    else {
      hostent = gethostbyaddr((char *)&sa_in->sin_addr, sizeof(struct in_addr),
                              AF_INET);
    }
    if (hostent != NULL) {
      if (nodelen <= strlen(hostent->h_name)) {
        result = 8;
        goto end;
      }
      strcpy(node, hostent->h_name);
    } else {
      if (flags & 0x0002) {
        result = 7;
        goto end;
      }
      ntoa_address = inet_ntoa(sa_in->sin_addr);
      if (nodelen <= strlen(ntoa_address)) {
        result = 8;
        goto end;
      }
      strcpy(node, ntoa_address);
    }
  }
end:
  h_errno = saved_h_errno;
  return result;
}


x86 assembly (clang, -O0):
<ebnet_getnameinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-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),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x58(%rbp)
mov    0x2e24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    0x2e01(%rip),%rcx
cmp    (%rcx),%rax
je     11e4 <ebnet_getnameinfo+0x64>
movl   $0x5,-0x58(%rbp)
jmp    1446 <ebnet_getnameinfo+0x2c6>
cmpq   $0x0,-0x18(%rbp)
jne    1206 <ebnet_getnameinfo+0x86>
cmpq   $0x0,-0x28(%rbp)
jne    1206 <ebnet_getnameinfo+0x86>
movl   $0x7,-0x58(%rbp)
jmp    1446 <ebnet_getnameinfo+0x2c6>
jmp    120b <ebnet_getnameinfo+0x8b>
cmpq   $0x0,-0x28(%rbp)
je     1336 <ebnet_getnameinfo+0x1b6>
cmpq   $0x0,-0x30(%rbp)
jle    1336 <ebnet_getnameinfo+0x1b6>
mov    0x10(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     123d <ebnet_getnameinfo+0xbd>
movq   $0x0,-0x48(%rbp)
jmp    1284 <ebnet_getnameinfo+0x104>
mov    0x10(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1268 <ebnet_getnameinfo+0xe8>
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%edi
lea    0xda6(%rip),%rsi
call   10a0 <getservbyport@plt>
mov    %rax,-0x48(%rbp)
jmp    127f <ebnet_getnameinfo+0xff>
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%edi
lea    0xd8e(%rip),%rsi
call   10a0 <getservbyport@plt>
mov    %rax,-0x48(%rbp)
jmp    1284 <ebnet_getnameinfo+0x104>
cmpq   $0x0,-0x48(%rbp)
je     12d4 <ebnet_getnameinfo+0x154>
mov    -0x30(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x48(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x60(%rbp),%rax
cmp    %rcx,%rax
jg     12bf <ebnet_getnameinfo+0x13f>
movl   $0x8,-0x58(%rbp)
jmp    1446 <ebnet_getnameinfo+0x2c6>
mov    -0x28(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
jmp    1331 <ebnet_getnameinfo+0x1b1>
mov    -0x30(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%edi
call   1070 <ntohs@plt>
mov    %eax,%edi
call   1060 <itoa_length@plt>
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
cmp    %rcx,%rax
jg     130b <ebnet_getnameinfo+0x18b>
movl   $0x8,-0x58(%rbp)
jmp    1446 <ebnet_getnameinfo+0x2c6>
mov    -0x28(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%edi
call   1070 <ntohs@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,%edx
lea    0xcdc(%rip),%rsi
call   1090 <sprintf@plt>
jmp    1336 <ebnet_getnameinfo+0x1b6>
cmpq   $0x0,-0x18(%rbp)
je     1441 <ebnet_getnameinfo+0x2c1>
cmpq   $0x0,-0x20(%rbp)
jle    1441 <ebnet_getnameinfo+0x2c1>
mov    0x10(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1368 <ebnet_getnameinfo+0x1e8>
movq   $0x0,-0x40(%rbp)
jmp    1387 <ebnet_getnameinfo+0x207>
mov    -0x38(%rbp),%rdi
add    $0x8,%rdi
mov    0x2c71(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%esi
call   1080 <gethostbyaddr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     13d7 <ebnet_getnameinfo+0x257>
mov    -0x20(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x78(%rbp),%rax
cmp    %rcx,%rax
jg     13c2 <ebnet_getnameinfo+0x242>
movl   $0x8,-0x58(%rbp)
jmp    1446 <ebnet_getnameinfo+0x2c6>
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
jmp    143c <ebnet_getnameinfo+0x2bc>
mov    0x10(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     13f2 <ebnet_getnameinfo+0x272>
movl   $0x7,-0x58(%rbp)
jmp    1446 <ebnet_getnameinfo+0x2c6>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x50(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x80(%rbp),%rax
cmp    %rcx,%rax
jg     142f <ebnet_getnameinfo+0x2af>
movl   $0x8,-0x58(%rbp)
jmp    1446 <ebnet_getnameinfo+0x2c6>
mov    -0x18(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1441 <ebnet_getnameinfo+0x2c1>
jmp    1446 <ebnet_getnameinfo+0x2c6>
mov    -0x54(%rbp),%ecx
mov    0x2b90(%rip),%rax
mov    %ecx,(%rax)
mov    -0x58(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ebnet_getnameinfo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r15
mov    0x2e48(%rip),%rbp
mov    0x0(%rbp),%r14d
mov    (%rdi),%rsi
mov    0x2e2a(%rip),%rdx
mov    $0x5,%eax
cmp    (%rdx),%rsi
jne    11c0 <ebnet_getnameinfo+0x40>
mov    %r8,%rbx
mov    $0x7,%eax
mov    %r15,%rdx
or     %r8,%rdx
jne    11d3 <ebnet_getnameinfo+0x53>
mov    %r14d,0x0(%rbp)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rdi,%r12
mov    0x50(%rsp),%edx
test   %rbx,%rbx
je     128c <ebnet_getnameinfo+0x10c>
mov    %r9,%r13
test   %r9,%r9
jle    128c <ebnet_getnameinfo+0x10c>
mov    %rcx,0x8(%rsp)
test   $0x20,%dl
jne    1246 <ebnet_getnameinfo+0xc6>
test   $0x1,%dl
mov    0xc(%r12),%edi
lea    0xdfc(%rip),%rax
lea    0xdf1(%rip),%rsi
cmove  %rax,%rsi
call   10a0 <getservbyport@plt>
test   %rax,%rax
je     1246 <ebnet_getnameinfo+0xc6>
mov    (%rax),%rdi
mov    %rdi,0x10(%rsp)
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    $0x8,%eax
cmp    %r13,%rcx
jge    11c0 <ebnet_getnameinfo+0x40>
mov    %rbx,%rdi
mov    0x10(%rsp),%rsi
call   1030 <strcpy@plt>
jmp    1283 <ebnet_getnameinfo+0x103>
mov    0xc(%r12),%edi
call   1070 <ntohs@plt>
mov    %eax,%edi
call   1060 <itoa_length@plt>
mov    %rax,%rcx
mov    $0x8,%eax
cmp    %r13,%rcx
jge    11c0 <ebnet_getnameinfo+0x40>
mov    0xc(%r12),%edi
call   1070 <ntohs@plt>
lea    0xd8f(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
call   1090 <sprintf@plt>
mov    0x8(%rsp),%rcx
mov    0x50(%rsp),%edx
xor    %eax,%eax
test   %r15,%r15
je     11c0 <ebnet_getnameinfo+0x40>
test   %rcx,%rcx
jle    11c0 <ebnet_getnameinfo+0x40>
test   $0x8,%dl
jne    12d9 <ebnet_getnameinfo+0x159>
lea    0x8(%r12),%rdi
mov    0x2d37(%rip),%rax
mov    %edx,%r13d
mov    (%rax),%edx
mov    %rcx,%rbx
mov    $0x4,%esi
call   1080 <gethostbyaddr@plt>
mov    %r13d,%edx
mov    %rbx,%rcx
test   %rax,%rax
je     12d9 <ebnet_getnameinfo+0x159>
mov    (%rax),%rbx
mov    %rbx,%rdi
mov    %rcx,%r12
jmp    12fa <ebnet_getnameinfo+0x17a>
mov    $0x7,%eax
test   $0x2,%dl
jne    11c0 <ebnet_getnameinfo+0x40>
mov    0x8(%r12),%edi
mov    %rcx,%r12
call   1040 <inet_ntoa@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    $0x8,%eax
cmp    %r12,%rcx
jge    11c0 <ebnet_getnameinfo+0x40>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
jmp    11c0 <ebnet_getnameinfo+0x40>

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
%struct.sockaddr_in = type { i64, i32, i32 }
%struct.hostent = type { i8* }
%struct.servent = type { i8* }
@h_errno = global i32 0
@PF_INET = global i64 0
@.str = [4 x i8] c"udp\00"
@.str.1 = [4 x i8] c"tcp\00"
@.str.2 = [3 x i8] c"%d\00"
@AF_INET = global i32 0
define i32 @ebnet_getnameinfo(%struct.sockaddr* %0, i64 %1, i8* %2, i64 %3, i8* %4, i64 %5, i32 %6) {
%8 = alloca %struct.sockaddr*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i32
%15 = alloca %struct.sockaddr_in*
%16 = alloca %struct.hostent*
%17 = alloca %struct.servent*
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i32
store %struct.sockaddr* %0, %struct.sockaddr** %8
store i64 %1, i64* %9
store i8* %2, i8** %10
store i64 %3, i64* %11
store i8* %4, i8** %12
store i64 %5, i64* %13
store i32 %6, i32* %14
%21 = load %struct.sockaddr*, %struct.sockaddr** %8
%22 = bitcast %struct.sockaddr* %21 to %struct.sockaddr_in*
store %struct.sockaddr_in* %22, %struct.sockaddr_in** %15
store i32 0, i32* %20
%23 = load i32, i32* @h_errno
store i32 %23, i32* %19
%24 = load %struct.sockaddr_in*, %struct.sockaddr_in** %15
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %24, i32 0, i32 0
%26 = load i64, i64* %25
%27 = load i64, i64* @PF_INET
%28 = icmp ne i64 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %7
store i32 5, i32* %20
br label %153
30: ; preds = %7
%31 = load i8*, i8** %10
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load i8*, i8** %12
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %37
36: ; preds = %33
store i32 7, i32* %20
br label %153
37: ; preds = %33, %30
br label %38
38: ; preds = %37
%39 = load i8*, i8** %12
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %98
41: ; preds = %38
%42 = load i64, i64* %13
%43 = icmp sgt i64 %42, 0
br i1 %43, label %44, label %98
44: ; preds = %41
%45 = load i32, i32* %14
%46 = and i32 %45, 32
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %44
store %struct.servent* null, %struct.servent** %17
br label %64
49: ; preds = %44
%50 = load i32, i32* %14
%51 = and i32 %50, 1
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %58
53: ; preds = %49
%54 = load %struct.sockaddr_in*, %struct.sockaddr_in** %15
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %54, i32 0, i32 2
%56 = load i32, i32* %55
%57 = call %struct.servent* @getservbyport(i32 %56, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store %struct.servent* %57, %struct.servent** %17
br label %63
58: ; preds = %49
%59 = load %struct.sockaddr_in*, %struct.sockaddr_in** %15
%60 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %59, i32 0, i32 2
%61 = load i32, i32* %60
%62 = call %struct.servent* @getservbyport(i32 %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store %struct.servent* %62, %struct.servent** %17
br label %63
63: ; preds = %58, %53
br label %64
64: ; preds = %63, %48
%65 = load %struct.servent*, %struct.servent** %17
%66 = icmp ne %struct.servent* %65, null
br i1 %66, label %67, label %81
67: ; preds = %64
%68 = load i64, i64* %13
%69 = load %struct.servent*, %struct.servent** %17
%70 = getelementptr inbounds %struct.servent, %struct.servent* %69, i32 0, i32 0
%71 = load i8*, i8** %70
%72 = call i64 @strlen(i8* %71)
%73 = icmp sle i64 %68, %72
br i1 %73, label %74, label %75
74: ; preds = %67
store i32 8, i32* %20
br label %153
75: ; preds = %67
%76 = load i8*, i8** %12
%77 = load %struct.servent*, %struct.servent** %17
%78 = getelementptr inbounds %struct.servent, %struct.servent* %77, i32 0, i32 0
%79 = load i8*, i8** %78
%80 = call i32 @strcpy(i8* %76, i8* %79)
br label %97
81: ; preds = %64
%82 = load i64, i64* %13
%83 = load %struct.sockaddr_in*, %struct.sockaddr_in** %15
%84 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %83, i32 0, i32 2
%85 = load i32, i32* %84
%86 = call i32 @ntohs(i32 %85)
%87 = call i64 @itoa_length(i32 %86)
%88 = icmp sle i64 %82, %87
br i1 %88, label %89, label %90
89: ; preds = %81
store i32 8, i32* %20
br label %153
90: ; preds = %81
%91 = load i8*, i8** %12
%92 = load %struct.sockaddr_in*, %struct.sockaddr_in** %15
%93 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %92, i32 0, i32 2
%94 = load i32, i32* %93
%95 = call i32 @ntohs(i32 %94)
%96 = call i32 @sprintf(i8* %91, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %95)
br label %97
97: ; preds = %90, %75
br label %98
98: ; preds = %97, %41, %38
%99 = load i8*, i8** %10
%100 = icmp ne i8* %99, null
br i1 %100, label %101, label %152
101: ; preds = %98
%102 = load i64, i64* %11
%103 = icmp sgt i64 %102, 0
br i1 %103, label %104, label %152
104: ; preds = %101
%105 = load i32, i32* %14
%106 = and i32 %105, 8
%107 = icmp ne i32 %106, 0
br i1 %107, label %108, label %109
108: ; preds = %104
store %struct.hostent* null, %struct.hostent** %16
br label %115
109: ; preds = %104
%110 = load %struct.sockaddr_in*, %struct.sockaddr_in** %15
%111 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %110, i32 0, i32 1
%112 = bitcast i32* %111 to i8*
%113 = load i32, i32* @AF_INET
%114 = call %struct.hostent* @gethostbyaddr(i8* %112, i32 4, i32 %113)
store %struct.hostent* %114, %struct.hostent** %16
br label %115
115: ; preds = %109, %108
%116 = load %struct.hostent*, %struct.hostent** %16
%117 = icmp ne %struct.hostent* %116, null
br i1 %117, label %118, label %132
118: ; preds = %115
%119 = load i64, i64* %11
%120 = load %struct.hostent*, %struct.hostent** %16
%121 = getelementptr inbounds %struct.hostent, %struct.hostent* %120, i32 0, i32 0
%122 = load i8*, i8** %121
%123 = call i64 @strlen(i8* %122)
%124 = icmp sle i64 %119, %123
br i1 %124, label %125, label %126
125: ; preds = %118
store i32 8, i32* %20
br label %153
126: ; preds = %118
%127 = load i8*, i8** %10
%128 = load %struct.hostent*, %struct.hostent** %16
%129 = getelementptr inbounds %struct.hostent, %struct.hostent* %128, i32 0, i32 0
%130 = load i8*, i8** %129
%131 = call i32 @strcpy(i8* %127, i8* %130)
br label %151
132: ; preds = %115
%133 = load i32, i32* %14
%134 = and i32 %133, 2
%135 = icmp ne i32 %134, 0
br i1 %135, label %136, label %137
136: ; preds = %132
store i32 7, i32* %20
br label %153
137: ; preds = %132
%138 = load %struct.sockaddr_in*, %struct.sockaddr_in** %15
%139 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %138, i32 0, i32 1
%140 = load i32, i32* %139
%141 = call i8* @inet_ntoa(i32 %140)
store i8* %141, i8** %18
%142 = load i64, i64* %11
%143 = load i8*, i8** %18
%144 = call i64 @strlen(i8* %143)
%145 = icmp sle i64 %142, %144
br i1 %145, label %146, label %147
146: ; preds = %137
store i32 8, i32* %20
br label %153
147: ; preds = %137
%148 = load i8*, i8** %10
%149 = load i8*, i8** %18
%150 = call i32 @strcpy(i8* %148, i8* %149)
br label %151
151: ; preds = %147, %126
br label %152
152: ; preds = %151, %101, %98
br label %153
153: ; preds = %152, %146, %136, %125, %89, %74, %36, %29
%154 = load i32, i32* %19
store i32 %154, i32* @h_errno
%155 = load i32, i32* %20
ret i32 %155
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
%struct.servent = type { i8* }
%struct.hostent = type { i8* }
@h_errno = global i32 0
@PF_INET = global i64 0
@.str = [4 x i8] c"udp\00"
@.str.1 = [4 x i8] c"tcp\00"
@.str.2 = [3 x i8] c"%d\00"
@AF_INET = global i32 0
define i32 @ebnet_getnameinfo(%struct.sockaddr* %0, i64 %1, i8* %2, i64 %3, i8* %4, i64 %5, i32 %6) {
%8 = load i32, i32* @h_errno
%9 = bitcast %struct.sockaddr* %0 to i64*
%10 = load i64, i64* %9
%11 = load i64, i64* @PF_INET
%12 = icmp eq i64 %10, %11
br i1 %12, label %13, label %79
13: ; preds = %7
%14 = icmp eq i8* %2, null
%15 = icmp eq i8* %4, null
%16 = and i1 %14, %15
br i1 %16, label %79, label %17
17: ; preds = %13
%18 = icmp ne i8* %4, null
%19 = icmp sgt i64 %5, 0
%20 = and i1 %18, %19
br i1 %20, label %21, label %49
21: ; preds = %17
%22 = and i32 %6, 32
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %39
24: ; preds = %21
%25 = and i32 %6, 1
%26 = icmp eq i32 %25, 0
%27 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %0, i64 3, i32 0
%28 = load i32, i32* %27
%29 = select i1 %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0)
%30 = tail call %struct.servent* @getservbyport(i32 %28, i8* %29)
%31 = icmp eq %struct.servent* %30, null
br i1 %31, label %39, label %32
32: ; preds = %24
%33 = getelementptr inbounds %struct.servent, %struct.servent* %30, i64 0, i32 0
%34 = load i8*, i8** %33
%35 = tail call i64 @strlen(i8* dereferenceable(1) %34)
%36 = icmp slt i64 %35, %5
br i1 %36, label %37, label %79
37: ; preds = %32
%38 = tail call i32 @strcpy(i8* %4, i8* %34)
br label %49
39: ; preds = %21, %24
%40 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %0, i64 3, i32 0
%41 = load i32, i32* %40
%42 = tail call i32 @ntohs(i32 %41)
%43 = tail call i64 @itoa_length(i32 %42)
%44 = icmp slt i64 %43, %5
br i1 %44, label %45, label %79
45: ; preds = %39
%46 = load i32, i32* %40
%47 = tail call i32 @ntohs(i32 %46)
%48 = tail call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %37, %45, %17
%50 = icmp ne i8* %2, null
%51 = icmp sgt i64 %3, 0
%52 = and i1 %50, %51
br i1 %52, label %53, label %79
53: ; preds = %49
%54 = and i32 %6, 8
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %67
56: ; preds = %53
%57 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %0, i64 2, i32 0
%58 = bitcast i32* %57 to i8*
%59 = load i32, i32* @AF_INET
%60 = tail call %struct.hostent* @gethostbyaddr(i8* %58, i32 4, i32 %59)
%61 = icmp eq %struct.hostent* %60, null
br i1 %61, label %67, label %62
62: ; preds = %56
%63 = getelementptr inbounds %struct.hostent, %struct.hostent* %60, i64 0, i32 0
%64 = load i8*, i8** %63
%65 = tail call i64 @strlen(i8* dereferenceable(1) %64)
%66 = icmp slt i64 %65, %3
br i1 %66, label %76, label %79
67: ; preds = %53, %56
%68 = and i32 %6, 2
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %79
70: ; preds = %67
%71 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %0, i64 2, i32 0
%72 = load i32, i32* %71
%73 = tail call i8* @inet_ntoa(i32 %72)
%74 = tail call i64 @strlen(i8* dereferenceable(1) %73)
%75 = icmp slt i64 %74, %3
br i1 %75, label %76, label %79
76: ; preds = %70, %62
%77 = phi i8* [ %64, %62 ], [ %73, %70 ]
%78 = tail call i32 @strcpy(i8* %2, i8* %77)
br label %79
79: ; preds = %76, %70, %67, %62, %39, %32, %13, %7, %49
%80 = phi i32 [ 0, %49 ], [ 5, %7 ], [ 7, %13 ], [ 8, %32 ], [ 8, %39 ], [ 8, %62 ], [ 7, %67 ], [ 8, %70 ], [ 0, %76 ]
store i32 %8, i32* @h_errno
ret i32 %80
}