#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 {
  void *sin_port;
  void *sin_family;
  int /*<<< orphan*/ sin_addr;
  void *sin6_port;
  void *sin6_family;
  int /*<<< orphan*/ sin6_addr;
};
struct sockaddr_in {
  void *sin_port;
  void *sin_family;
  int /*<<< orphan*/ sin_addr;
  void *sin6_port;
  void *sin6_family;
  int /*<<< orphan*/ sin6_addr;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ in_addr;
typedef int /*<<< orphan*/ in6_addr;

/* Variables and functions */
void *AF_INET;
void *AF_INET6;
int PF_INET;
int PF_INET6;
int SOCK_STREAM;
int /*<<< orphan*/ atoi(char *);
void *htons(int /*<<< orphan*/);
int inet_pton(void *, char *, int /*<<< orphan*/ *);
struct sockaddr *malloc(int);
int /*<<< orphan*/ memcpy(struct sockaddr *, struct sockaddr_in6 *, int);
int /*<<< orphan*/ memset(struct sockaddr_in6 *, int /*<<< orphan*/, int);
int ret_err(char **, char *);
char *strchr(char *, char);
int etcp_getaddrinfo(char *address, int *family, int *type, int *protocol,
                     struct sockaddr **addr, socklen_t *addrlen,
                     char **errstr) {
  char *p;
  struct sockaddr_in in_addr;
  struct sockaddr_in6 in6_addr;
  if (address[0] == '[' && (p = strchr(&address[1], ']')) != NULL) {
    *p++ = '\0';
    memset(&in6_addr, 0, sizeof(in6_addr));
    if (inet_pton(AF_INET6, &address[1], &in6_addr.sin6_addr) == 1) {
      in6_addr.sin6_family = AF_INET6;
      if (*p != '\0')
        in6_addr.sin6_port = htons(atoi(p));
      else
        in6_addr.sin6_port = 0;
      *family = PF_INET6;
      *type = SOCK_STREAM;
      *protocol = 0;
      *addrlen = sizeof(in6_addr);
      *addr = malloc(*addrlen);
      memcpy(*addr, &in6_addr, *addrlen);
      return 0;
    }
  } else {
    if ((p = strchr(address, ':')) != NULL)
      *p++ = '\0';
    memset(&in_addr, 0, sizeof(in_addr));
    if (inet_pton(AF_INET, address, &in_addr.sin_addr) == 1) {
      in_addr.sin_family = AF_INET;
      if (p != NULL)
        in_addr.sin_port = htons(atoi(p));
      else
        in_addr.sin_port = 0;
      *family = PF_INET;
      *type = SOCK_STREAM;
      *protocol = 0;
      *addrlen = sizeof(in_addr);
      *addr = (struct sockaddr *)malloc(*addrlen);
      memcpy(*addr, &in_addr, *addrlen);
      return 0;
    }
  }
  return ret_err(errstr, "Invalid address");
}


x86 assembly (clang, -O0):
<etcp_getaddrinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    12dd <etcp_getaddrinfo+0x15d>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    $0x5d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
je     12dd <etcp_getaddrinfo+0x15d>
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x40(%rbp)
movb   $0x0,(%rax)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
mov    0x2dd5(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
lea    -0xa0(%rbp),%rdx
add    $0x28,%rdx
call   1070 <inet_pton@plt>
cmp    $0x1,%eax
jne    12d8 <etcp_getaddrinfo+0x158>
mov    0x2daa(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x80(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1261 <etcp_getaddrinfo+0xe1>
mov    -0x40(%rbp),%rdi
call   10a0 <atoi@plt>
mov    %eax,%edi
call   1030 <htons@plt>
mov    %rax,-0x88(%rbp)
jmp    126c <etcp_getaddrinfo+0xec>
movq   $0x0,-0x88(%rbp)
mov    0x2d75(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2d46(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x38(%rbp),%rax
movl   $0x30,(%rax)
mov    -0x38(%rbp),%rax
mov    (%rax),%edi
call   1080 <malloc@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x38(%rbp),%rax
mov    (%rax),%edx
lea    -0xa0(%rbp),%rsi
call   1060 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    13fa <etcp_getaddrinfo+0x27a>
jmp    13e7 <etcp_getaddrinfo+0x267>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
je     130b <etcp_getaddrinfo+0x18b>
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x40(%rbp)
movb   $0x0,(%rax)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
mov    0x2cbe(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x70(%rbp),%rdx
add    $0x10,%rdx
call   1070 <inet_pton@plt>
cmp    $0x1,%eax
jne    13e2 <etcp_getaddrinfo+0x262>
mov    0x2c9a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     1371 <etcp_getaddrinfo+0x1f1>
mov    -0x40(%rbp),%rdi
call   10a0 <atoi@plt>
mov    %eax,%edi
call   1030 <htons@plt>
mov    %rax,-0x70(%rbp)
jmp    1379 <etcp_getaddrinfo+0x1f9>
movq   $0x0,-0x70(%rbp)
mov    0x2c40(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2c39(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x38(%rbp),%rax
movl   $0x30,(%rax)
mov    -0x38(%rbp),%rax
mov    (%rax),%edi
call   1080 <malloc@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x38(%rbp),%rax
mov    (%rax),%edx
call   1060 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    13fa <etcp_getaddrinfo+0x27a>
jmp    13e7 <etcp_getaddrinfo+0x267>
mov    0x10(%rbp),%rdi
lea    0xc0e(%rip),%rsi
call   1090 <ret_err@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<etcp_getaddrinfo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,%r12
mov    %rcx,0x8(%rsp)
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%rbp
cmpb   $0x5b,(%rdi)
jne    1223 <etcp_getaddrinfo+0xa3>
lea    0x1(%rbp),%r14
mov    %r14,%rdi
mov    $0x5d,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1223 <etcp_getaddrinfo+0xa3>
mov    %rax,%rbx
movb   $0x0,(%rax)
lea    0x18(%rsp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
mov    0x2dfb(%rip),%rbp
mov    0x0(%rbp),%rdi
lea    0x40(%rsp),%rdx
mov    %r14,%rsi
call   1070 <inet_pton@plt>
cmp    $0x1,%eax
jne    1291 <etcp_getaddrinfo+0x111>
add    $0x1,%rbx
mov    0x0(%rbp),%rax
mov    %rax,0x38(%rsp)
xor    %ebp,%ebp
cmpb   $0x0,(%rbx)
je     12e4 <etcp_getaddrinfo+0x164>
mov    %rbx,%rdi
call   10a0 <atoi@plt>
mov    %eax,%edi
call   1030 <htons@plt>
jmp    12e6 <etcp_getaddrinfo+0x166>
mov    %rbp,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1241 <etcp_getaddrinfo+0xc1>
mov    %rax,%r14
add    $0x1,%r14
movb   $0x0,(%rax)
jmp    1244 <etcp_getaddrinfo+0xc4>
xor    %r14d,%r14d
lea    0x18(%rsp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
mov    0x2d84(%rip),%rbx
mov    (%rbx),%rdi
lea    0x28(%rsp),%rdx
mov    %rbp,%rsi
call   1070 <inet_pton@plt>
cmp    $0x1,%eax
jne    1291 <etcp_getaddrinfo+0x111>
mov    (%rbx),%rax
mov    %rax,0x20(%rsp)
xor    %ebp,%ebp
test   %r14,%r14
je     12ac <etcp_getaddrinfo+0x12c>
mov    %r14,%rdi
call   10a0 <atoi@plt>
mov    %eax,%edi
call   1030 <htons@plt>
jmp    12ae <etcp_getaddrinfo+0x12e>
mov    0x80(%rsp),%rdi
lea    0xd60(%rip),%rsi
call   1090 <ret_err@plt>
mov    %eax,%ebp
jmp    133a <etcp_getaddrinfo+0x1ba>
xor    %eax,%eax
mov    %rax,0x18(%rsp)
mov    0x2d06(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x0(%r13)
mov    0x2d01(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%r15)
mov    0x8(%rsp),%rax
movl   $0x0,(%rax)
mov    0x10(%rsp),%rax
movl   $0x30,(%rax)
jmp    131a <etcp_getaddrinfo+0x19a>
xor    %eax,%eax
mov    0x10(%rsp),%rcx
mov    0x8(%rsp),%rdx
mov    %rax,0x30(%rsp)
mov    0x2cec(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x0(%r13)
mov    0x2cbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%r15)
movl   $0x0,(%rdx)
movl   $0x30,(%rcx)
mov    $0x30,%edi
call   1080 <malloc@plt>
mov    %rax,(%r12)
lea    0x18(%rsp),%rsi
mov    %rax,%rdi
mov    $0x30,%edx
call   1060 <memcpy@plt>
mov    %ebp,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
%struct.sockaddr_in = type { i8*, i8*, i32, i8*, i8*, i32 }
%struct.sockaddr_in6 = type { i8*, i8*, i32, i8*, i8*, i32 }
@AF_INET6 = global i8* null
@PF_INET6 = global i32 0
@SOCK_STREAM = global i32 0
@AF_INET = global i8* null
@PF_INET = global i32 0
@.str = [16 x i8] c"Invalid address\00"
define i32 @etcp_getaddrinfo(i8* %0, i32* %1, i32* %2, i32* %3, %struct.sockaddr** %4, i32* %5, i8** %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca %struct.sockaddr**
%14 = alloca i32*
%15 = alloca i8**
%16 = alloca i8*
%17 = alloca %struct.sockaddr_in
%18 = alloca %struct.sockaddr_in6
store i8* %0, i8** %9
store i32* %1, i32** %10
store i32* %2, i32** %11
store i32* %3, i32** %12
store %struct.sockaddr** %4, %struct.sockaddr*** %13
store i32* %5, i32** %14
store i8** %6, i8*** %15
%19 = load i8*, i8** %9
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 91
br i1 %23, label %24, label %70
24: ; preds = %7
%25 = load i8*, i8** %9
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = call i8* @strchr(i8* %26, i8 signext 93)
store i8* %27, i8** %16
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %70
29: ; preds = %24
%30 = load i8*, i8** %16
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %16
store i8 0, i8* %30
%32 = call i32 @memset(%struct.sockaddr_in6* %18, i32 0, i32 48)
%33 = load i8*, i8** @AF_INET6
%34 = load i8*, i8** %9
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %18, i32 0, i32 5
%37 = call i32 @inet_pton(i8* %33, i8* %35, i32* %36)
%38 = icmp eq i32 %37, 1
br i1 %38, label %39, label %69
39: ; preds = %29
%40 = load i8*, i8** @AF_INET6
%41 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %18, i32 0, i32 4
store i8* %40, i8** %41
%42 = load i8*, i8** %16
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %51
46: ; preds = %39
%47 = load i8*, i8** %16
%48 = call i32 @atoi(i8* %47)
%49 = call i8* @htons(i32 %48)
%50 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %18, i32 0, i32 3
store i8* %49, i8** %50
br label %53
51: ; preds = %39
%52 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %18, i32 0, i32 3
store i8* null, i8** %52
br label %53
53: ; preds = %51, %46
%54 = load i32, i32* @PF_INET6
%55 = load i32*, i32** %10
store i32 %54, i32* %55
%56 = load i32, i32* @SOCK_STREAM
%57 = load i32*, i32** %11
store i32 %56, i32* %57
%58 = load i32*, i32** %12
store i32 0, i32* %58
%59 = load i32*, i32** %14
store i32 48, i32* %59
%60 = load i32*, i32** %14
%61 = load i32, i32* %60
%62 = call %struct.sockaddr* @malloc(i32 %61)
%63 = load %struct.sockaddr**, %struct.sockaddr*** %13
store %struct.sockaddr* %62, %struct.sockaddr** %63
%64 = load %struct.sockaddr**, %struct.sockaddr*** %13
%65 = load %struct.sockaddr*, %struct.sockaddr** %64
%66 = load i32*, i32** %14
%67 = load i32, i32* %66
%68 = call i32 @memcpy(%struct.sockaddr* %65, %struct.sockaddr_in6* %18, i32 %67)
store i32 0, i32* %8
br label %118
69: ; preds = %29
br label %115
70: ; preds = %24, %7
%71 = load i8*, i8** %9
%72 = call i8* @strchr(i8* %71, i8 signext 58)
store i8* %72, i8** %16
%73 = icmp ne i8* %72, null
br i1 %73, label %74, label %77
74: ; preds = %70
%75 = load i8*, i8** %16
%76 = getelementptr inbounds i8, i8* %75, i32 1
store i8* %76, i8** %16
store i8 0, i8* %75
br label %77
77: ; preds = %74, %70
%78 = bitcast %struct.sockaddr_in* %17 to %struct.sockaddr_in6*
%79 = call i32 @memset(%struct.sockaddr_in6* %78, i32 0, i32 48)
%80 = load i8*, i8** @AF_INET
%81 = load i8*, i8** %9
%82 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 2
%83 = call i32 @inet_pton(i8* %80, i8* %81, i32* %82)
%84 = icmp eq i32 %83, 1
br i1 %84, label %85, label %114
85: ; preds = %77
%86 = load i8*, i8** @AF_INET
%87 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 1
store i8* %86, i8** %87
%88 = load i8*, i8** %16
%89 = icmp ne i8* %88, null
br i1 %89, label %90, label %95
90: ; preds = %85
%91 = load i8*, i8** %16
%92 = call i32 @atoi(i8* %91)
%93 = call i8* @htons(i32 %92)
%94 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 0
store i8* %93, i8** %94
br label %97
95: ; preds = %85
%96 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 0
store i8* null, i8** %96
br label %97
97: ; preds = %95, %90
%98 = load i32, i32* @PF_INET
%99 = load i32*, i32** %10
store i32 %98, i32* %99
%100 = load i32, i32* @SOCK_STREAM
%101 = load i32*, i32** %11
store i32 %100, i32* %101
%102 = load i32*, i32** %12
store i32 0, i32* %102
%103 = load i32*, i32** %14
store i32 48, i32* %103
%104 = load i32*, i32** %14
%105 = load i32, i32* %104
%106 = call %struct.sockaddr* @malloc(i32 %105)
%107 = load %struct.sockaddr**, %struct.sockaddr*** %13
store %struct.sockaddr* %106, %struct.sockaddr** %107
%108 = load %struct.sockaddr**, %struct.sockaddr*** %13
%109 = load %struct.sockaddr*, %struct.sockaddr** %108
%110 = bitcast %struct.sockaddr_in* %17 to %struct.sockaddr_in6*
%111 = load i32*, i32** %14
%112 = load i32, i32* %111
%113 = call i32 @memcpy(%struct.sockaddr* %109, %struct.sockaddr_in6* %110, i32 %112)
store i32 0, i32* %8
br label %118
114: ; preds = %77
br label %115
115: ; preds = %114, %69
%116 = load i8**, i8*** %15
%117 = call i32 @ret_err(i8** %116, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 %117, i32* %8
br label %118
118: ; preds = %115, %97, %53
%119 = load i32, i32* %8
ret i32 %119
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
%struct.sockaddr_in = type { i8*, i8*, i32, i8*, i8*, i32 }
%struct.sockaddr_in6 = type { i8*, i8*, i32, i8*, i8*, i32 }
@AF_INET6 = global i8* null
@PF_INET6 = global i32 0
@SOCK_STREAM = global i32 0
@AF_INET = global i8* null
@PF_INET = global i32 0
@.str = [16 x i8] c"Invalid address\00"
define i32 @etcp_getaddrinfo(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, %struct.sockaddr** nocapture writeonly %4, i32* nocapture writeonly %5, i8** %6) {
%8 = alloca %struct.sockaddr_in
%9 = alloca %struct.sockaddr_in6
%10 = bitcast %struct.sockaddr_in* %8 to i8*
%11 = bitcast %struct.sockaddr_in6* %9 to i8*
%12 = load i8, i8* %0
%13 = icmp eq i8 %12, 91
br i1 %13, label %14, label %40
14: ; preds = %7
%15 = getelementptr inbounds i8, i8* %0, i64 1
%16 = tail call i8* @strchr(i8* %15, i8 signext 93)
%17 = icmp eq i8* %16, null
br i1 %17, label %40, label %18
18: ; preds = %14
%19 = getelementptr inbounds i8, i8* %16, i64 1
store i8 0, i8* %16
%20 = call i32 @memset(%struct.sockaddr_in6* %9, i32 0, i32 48)
%21 = load i8*, i8** @AF_INET6
%22 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %9, i64 0, i32 5
%23 = call i32 @inet_pton(i8* %21, i8* %15, i32* %22)
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %67
25: ; preds = %18
%26 = load i8*, i8** @AF_INET6
%27 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %9, i64 0, i32 4
store i8* %26, i8** %27
%28 = load i8, i8* %19
%29 = icmp eq i8 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %25
%31 = call i32 @atoi(i8* %19)
%32 = call i8* @htons(i32 %31)
br label %33
33: ; preds = %25, %30
%34 = phi i8* [ %32, %30 ], [ null, %25 ]
%35 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %9, i64 0, i32 3
store i8* %34, i8** %35
%36 = load i32, i32* @PF_INET6
store i32 %36, i32* %1
%37 = load i32, i32* @SOCK_STREAM
store i32 %37, i32* %2
store i32 0, i32* %3
store i32 48, i32* %5
%38 = call %struct.sockaddr* @malloc(i32 48)
store %struct.sockaddr* %38, %struct.sockaddr** %4
%39 = call i32 @memcpy(%struct.sockaddr* %38, %struct.sockaddr_in6* %9, i32 48)
br label %69
40: ; preds = %14, %7
%41 = tail call i8* @strchr(i8* %0, i8 signext 58)
%42 = icmp eq i8* %41, null
br i1 %42, label %45, label %43
43: ; preds = %40
%44 = getelementptr inbounds i8, i8* %41, i64 1
store i8 0, i8* %41
br label %45
45: ; preds = %43, %40
%46 = phi i8* [ %44, %43 ], [ null, %40 ]
%47 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr_in6*
%48 = call i32 @memset(%struct.sockaddr_in6* %47, i32 0, i32 48)
%49 = load i8*, i8** @AF_INET
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i64 0, i32 2
%51 = call i32 @inet_pton(i8* %49, i8* %0, i32* %50)
%52 = icmp eq i32 %51, 1
br i1 %52, label %53, label %67
53: ; preds = %45
%54 = load i8*, i8** @AF_INET
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i64 0, i32 1
store i8* %54, i8** %55
%56 = icmp eq i8* %46, null
br i1 %56, label %60, label %57
57: ; preds = %53
%58 = call i32 @atoi(i8* %46)
%59 = call i8* @htons(i32 %58)
br label %60
60: ; preds = %53, %57
%61 = phi i8* [ %59, %57 ], [ null, %53 ]
%62 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i64 0, i32 0
store i8* %61, i8** %62
%63 = load i32, i32* @PF_INET
store i32 %63, i32* %1
%64 = load i32, i32* @SOCK_STREAM
store i32 %64, i32* %2
store i32 0, i32* %3
store i32 48, i32* %5
%65 = call %struct.sockaddr* @malloc(i32 48)
store %struct.sockaddr* %65, %struct.sockaddr** %4
%66 = call i32 @memcpy(%struct.sockaddr* %65, %struct.sockaddr_in6* %47, i32 48)
br label %69
67: ; preds = %45, %18
%68 = call i32 @ret_err(i8** %6, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %69
69: ; preds = %67, %60, %33
%70 = phi i32 [ 0, %33 ], [ %68, %67 ], [ 0, %60 ]
ret i32 %70
}