#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 in_addr {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  short sin_port;
  struct in_addr sin_addr;
  scalar_t__ sin_family;
};
struct servent {
  scalar_t__ s_port;
};
struct hostent {
  scalar_t__ h_addrtype;
  scalar_t__ *h_addr_list;
};

/* Variables and functions */
scalar_t__ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ free(char *);
struct hostent *gethostbyname(char *);
struct servent *getservbyname(char *, char *);
short htons(short);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ inet_aton(char *, struct in_addr *);
scalar_t__ isdigit(char);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
scalar_t__ strcmp(char *, char *);
char *strdup(char *);
char *strtok(char *, char *);
long strtol(char *, char **, int);
int mkaddr(void *addr, int *addrlen, char *str_addr, char *protocol) {
  char *inp_addr = strdup(str_addr);
  char *host_part = strtok(inp_addr, ":");
  char *port_part = strtok(NULL, "\n");
  struct sockaddr_in *ap = (struct sockaddr_in *)addr;
  struct hostent *hp = NULL;
  struct servent *sp = NULL;
  char *cp;
  long lv;
  if (!host_part)
    host_part = "*";
  if (!port_part)
    port_part = "*";
  if (!protocol)
    protocol = "tcp";
  memset(ap, 0, *addrlen);
  ap->sin_family = AF_INET;
  ap->sin_port = 0;
  ap->sin_addr.s_addr = INADDR_ANY;
  if (strcmp(host_part, "*") == 0)
    ;
  else if (isdigit(*host_part)) {
    ap->sin_addr.s_addr = inet_addr(host_part);
    if (!inet_aton(host_part, &ap->sin_addr))
      return -1;
  } else {
    hp = gethostbyname(host_part);
    if (!hp)
      return -1;
    if (hp->h_addrtype != AF_INET)
      return -1;
    ap->sin_addr = *(struct in_addr *)hp->h_addr_list[0];
  }
  if (!strcmp(port_part, "*"))
    ;
  else if (isdigit(*port_part)) {
    lv = strtol(port_part, &cp, 10);
    if (cp != NULL && *cp)
      return -2;
    if (lv < 0L || lv >= 32768)
      return -2;
    ap->sin_port = htons((short)lv);
  } else {
    sp = getservbyname(port_part, protocol);
    if (!sp) {
      return -2;
    }
    ap->sin_port = (short)sp->s_port;
  }
  *addrlen = sizeof *ap;
  free(inp_addr);
  return 0;
}


x86 assembly (clang, -O0):
<mkaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   10e0 <strdup@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe10(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0x38(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdfe(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    123b <mkaddr+0x7b>
lea    0xdcd(%rip),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1251 <mkaddr+0x91>
lea    0xdb7(%rip),%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1267 <mkaddr+0xa7>
lea    0xda3(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    0x2d69(%rip),%rax
mov    (%rax),%rcx
mov    -0x48(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x48(%rbp),%rax
movw   $0x0,(%rax)
mov    0x2d46(%rip),%rax
mov    (%rax),%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x38(%rbp),%rdi
lea    0xd56(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    12c2 <mkaddr+0x102>
jmp    1375 <mkaddr+0x1b5>
mov    -0x38(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     1315 <mkaddr+0x155>
mov    -0x38(%rbp),%rdi
call   1080 <inet_addr@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%rsi
add    $0x4,%rsi
call   10c0 <inet_aton@plt>
cmp    $0x0,%eax
jne    1310 <mkaddr+0x150>
movl   $0xffffffff,-0x4(%rbp)
jmp    147f <mkaddr+0x2bf>
jmp    1370 <mkaddr+0x1b0>
mov    -0x38(%rbp),%rdi
call   10a0 <gethostbyname@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1339 <mkaddr+0x179>
movl   $0xffffffff,-0x4(%rbp)
jmp    147f <mkaddr+0x2bf>
mov    -0x50(%rbp),%rax
mov    (%rax),%rax
mov    0x2ca1(%rip),%rcx
cmp    (%rcx),%rax
je     135c <mkaddr+0x19c>
movl   $0xffffffff,-0x4(%rbp)
jmp    147f <mkaddr+0x2bf>
mov    -0x48(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    0x8(%rcx),%rcx
mov    (%rcx),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x4(%rax)
jmp    1375 <mkaddr+0x1b5>
mov    -0x40(%rbp),%rdi
lea    0xc84(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1394 <mkaddr+0x1d4>
jmp    1465 <mkaddr+0x2a5>
mov    -0x40(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     1427 <mkaddr+0x267>
mov    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0xa,%edx
call   10b0 <strtol@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     13e7 <mkaddr+0x227>
mov    -0x60(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     13e7 <mkaddr+0x227>
movl   $0xfffffffe,-0x4(%rbp)
jmp    147f <mkaddr+0x2bf>
cmpq   $0x0,-0x68(%rbp)
jl     1400 <mkaddr+0x240>
cmpq   $0x8000,-0x68(%rbp)
jl     140c <mkaddr+0x24c>
movl   $0xfffffffe,-0x4(%rbp)
jmp    147f <mkaddr+0x2bf>
mov    -0x68(%rbp),%rax
movswl %ax,%edi
call   1050 <htons@plt>
mov    %ax,%cx
mov    -0x48(%rbp),%rax
mov    %cx,(%rax)
jmp    1460 <mkaddr+0x2a0>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <getservbyname@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    144f <mkaddr+0x28f>
movl   $0xfffffffe,-0x4(%rbp)
jmp    147f <mkaddr+0x2bf>
mov    -0x58(%rbp),%rax
mov    (%rax),%rax
mov    %ax,%cx
mov    -0x48(%rbp),%rax
mov    %cx,(%rax)
jmp    1465 <mkaddr+0x2a5>
mov    -0x18(%rbp),%rax
movl   $0x10,(%rax)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mkaddr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%rbx
mov    %rsi,%r13
mov    %rdi,%r12
mov    %rdx,%rdi
call   10e0 <strdup@plt>
lea    0xe1a(%rip),%rsi
mov    %rax,0x10(%rsp)
mov    %rax,%rdi
call   10d0 <strtok@plt>
mov    %rax,%rbp
lea    0xe05(%rip),%rsi
xor    %edi,%edi
call   10d0 <strtok@plt>
mov    %rax,%r15
test   %rbp,%rbp
lea    0xdf3(%rip),%r14
cmove  %r14,%rbp
test   %rax,%rax
cmove  %r14,%r15
test   %rbx,%rbx
lea    0xde0(%rip),%rax
cmovne %rbx,%rax
mov    %rax,0x8(%rsp)
mov    %r13,0x18(%rsp)
mov    0x0(%r13),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1070 <memset@plt>
mov    0x2d9f(%rip),%rbx
mov    (%rbx),%rax
mov    %rax,0x8(%r12)
movw   $0x0,(%r12)
mov    0x2d81(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%r12)
mov    %rbp,%rdi
mov    %r14,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     12de <mkaddr+0x11e>
lea    0x4(%r12),%r14
movsbl 0x0(%rbp),%edi
call   1040 <isdigit@plt>
test   %rax,%rax
je     12ad <mkaddr+0xed>
mov    %rbp,%rdi
call   1080 <inet_addr@plt>
mov    %eax,(%r14)
mov    %rbp,%rdi
mov    %r14,%rsi
call   10c0 <inet_aton@plt>
test   %eax,%eax
jne    12de <mkaddr+0x11e>
mov    $0xffffffff,%eax
jmp    137d <mkaddr+0x1bd>
mov    %rbp,%rdi
call   10a0 <gethostbyname@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
je     137d <mkaddr+0x1bd>
mov    (%rcx),%rdx
cmp    (%rbx),%rdx
jne    137d <mkaddr+0x1bd>
mov    0x8(%rcx),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,(%r14)
lea    0xd1f(%rip),%rsi
mov    %r15,%rdi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1366 <mkaddr+0x1a6>
movsbl (%r15),%edi
call   1040 <isdigit@plt>
test   %rax,%rax
je     1334 <mkaddr+0x174>
lea    0x20(%rsp),%rsi
mov    %r15,%rdi
mov    $0xa,%edx
call   10b0 <strtol@plt>
mov    %rax,%rcx
mov    0x20(%rsp),%rax
test   %rax,%rax
je     134b <mkaddr+0x18b>
cmpb   $0x0,(%rax)
mov    $0xfffffffe,%eax
jne    137d <mkaddr+0x1bd>
cmp    $0x7fff,%rcx
jbe    1359 <mkaddr+0x199>
jmp    137d <mkaddr+0x1bd>
mov    %r15,%rdi
mov    0x8(%rsp),%rsi
call   1060 <getservbyname@plt>
test   %rax,%rax
je     138c <mkaddr+0x1cc>
movzwl (%rax),%eax
jmp    1361 <mkaddr+0x1a1>
mov    $0xfffffffe,%eax
cmp    $0x7fff,%rcx
ja     137d <mkaddr+0x1bd>
movswl %cx,%edi
call   1050 <htons@plt>
mov    %ax,(%r12)
mov    0x18(%rsp),%rax
movl   $0x10,(%rax)
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xfffffffe,%eax
jmp    137d <mkaddr+0x1bd>

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

LLVM IR (-O2):
%struct.sockaddr_in = type { i16, %struct.in_addr, i64 }
%struct.in_addr = type { i32 }
%struct.hostent = type { i64, i64* }
%struct.servent = type { i64 }
@.str = [2 x i8] c":\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [2 x i8] c"*\00"
@.str.3 = [4 x i8] c"tcp\00"
@AF_INET = global i64 0
@INADDR_ANY = global i32 0
define i32 @mkaddr(i8* %0, i32* nocapture %1, i8* nocapture %2, i8* %3) {
%5 = alloca i8*
%6 = tail call i8* @strdup(i8* %2)
%7 = tail call i8* @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = bitcast i8* %0 to %struct.sockaddr_in*
%10 = bitcast i8** %5 to i8*
%11 = icmp eq i8* %7, null
%12 = select i1 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %7
%13 = icmp eq i8* %8, null
%14 = select i1 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %8
%15 = icmp eq i8* %3, null
%16 = select i1 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %3
%17 = load i32, i32* %1
%18 = tail call i32 @memset(%struct.sockaddr_in* %9, i32 0, i32 %17)
%19 = load i64, i64* @AF_INET
%20 = getelementptr inbounds i8, i8* %0, i64 8
%21 = bitcast i8* %20 to i64*
store i64 %19, i64* %21
%22 = bitcast i8* %0 to i16*
store i16 0, i16* %22
%23 = load i32, i32* @INADDR_ANY
%24 = getelementptr inbounds i8, i8* %0, i64 4
%25 = bitcast i8* %24 to %struct.in_addr*
%26 = bitcast i8* %24 to i32*
store i32 %23, i32* %26
%27 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %51, label %29
29: ; preds = %4
%30 = load i8, i8* %12
%31 = tail call i64 @isdigit(i8 signext %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = tail call i32 @inet_addr(i8* %12)
store i32 %34, i32* %26
%35 = tail call i32 @inet_aton(i8* %12, %struct.in_addr* %25)
%36 = icmp eq i32 %35, 0
br i1 %36, label %83, label %51
37: ; preds = %29
%38 = tail call %struct.hostent* @gethostbyname(i8* %12)
%39 = icmp eq %struct.hostent* %38, null
br i1 %39, label %83, label %40
40: ; preds = %37
%41 = getelementptr inbounds %struct.hostent, %struct.hostent* %38, i64 0, i32 0
%42 = load i64, i64* %41
%43 = load i64, i64* @AF_INET
%44 = icmp eq i64 %42, %43
br i1 %44, label %45, label %83
45: ; preds = %40
%46 = getelementptr inbounds %struct.hostent, %struct.hostent* %38, i64 0, i32 1
%47 = load i64*, i64** %46
%48 = load i64, i64* %47
%49 = inttoptr i64 %48 to i32*
%50 = load i32, i32* %49
store i32 %50, i32* %26
br label %51
51: ; preds = %45, %33, %4
%52 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %81, label %54
54: ; preds = %51
%55 = load i8, i8* %14
%56 = tail call i64 @isdigit(i8 signext %55)
%57 = icmp eq i64 %56, 0
br i1 %57, label %72, label %58
58: ; preds = %54
%59 = call i64 @strtol(i8* %14, i8** %5, i32 10)
%60 = load i8*, i8** %5
%61 = icmp eq i8* %60, null
br i1 %61, label %67, label %62
62: ; preds = %58
%63 = load i8, i8* %60
%64 = icmp ne i8 %63, 0
%65 = icmp ugt i64 %59, 32767
%66 = select i1 %64, i1 true, i1 %65
br i1 %66, label %83, label %69
67: ; preds = %58
%68 = icmp ugt i64 %59, 32767
br i1 %68, label %83, label %69
69: ; preds = %62, %67
%70 = trunc i64 %59 to i16
%71 = tail call signext i16 @htons(i16 signext %70)
br label %79
72: ; preds = %54
%73 = tail call %struct.servent* @getservbyname(i8* %14, i8* %16)
%74 = icmp eq %struct.servent* %73, null
br i1 %74, label %83, label %75
75: ; preds = %72
%76 = getelementptr inbounds %struct.servent, %struct.servent* %73, i64 0, i32 0
%77 = load i64, i64* %76
%78 = trunc i64 %77 to i16
br label %79
79: ; preds = %75, %69
%80 = phi i16 [ %71, %69 ], [ %78, %75 ]
store i16 %80, i16* %22
br label %81
81: ; preds = %79, %51
store i32 16, i32* %1
%82 = tail call i32 @free(i8* %6)
br label %83
83: ; preds = %72, %67, %62, %40, %37, %33, %81
%84 = phi i32 [ 0, %81 ], [ -1, %33 ], [ -1, %37 ], [ -1, %40 ], [ -2, %62 ], [ -2, %67 ], [ -2, %72 ]
ret i32 %84
}