#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 addrinfo {
  int ai_family;
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  struct addrinfo *ai_next;
  int /*<<< orphan*/ ai_flags;
};
typedef int /*<<< orphan*/ hints;

/* Variables and functions */
int AF_INET6;
int /*<<< orphan*/ AI_PASSIVE;
int /*<<< orphan*/ SOCK_STREAM;
int anetListen(char *, int, int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ anetSetError(char *, char *, int /*<<< orphan*/);
int anetSetReuseAddr(char *, int);
int anetV6Only(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int /*<<< orphan*/ gai_strerror(int);
int getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int socket(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcmp(char *, char *);
int _anetTcpServer(char *err, int port, char *bindaddr, int af, int backlog) {
  int s = -1, rv;
  char _port[6];
  struct addrinfo hints, *servinfo, *p;
  snprintf(_port, 6, "%d", port);
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = af;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = AI_PASSIVE;
  if (bindaddr && !strcmp("*", bindaddr))
    bindaddr = NULL;
  if (af == AF_INET6 && bindaddr && !strcmp("::*", bindaddr))
    bindaddr = NULL;
  if ((rv = getaddrinfo(bindaddr, _port, &hints, &servinfo)) != 0) {
    anetSetError(err, "%s", gai_strerror(rv));
    return -1;
  }
  for (p = servinfo; p != NULL; p = p->ai_next) {
    if ((s = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1)
      continue;
    if (af == AF_INET6 && anetV6Only(err, s) == -1)
      goto error;
    if (anetSetReuseAddr(err, s) == -1)
      goto error;
    if (anetListen(err, s, p->ai_addr, p->ai_addrlen, backlog) == -1)
      s = -1;
    goto end;
  }
  if (p == NULL) {
    anetSetError(err, "unable to bind socket, errno: %d", errno);
    goto error;
  }
error:
  if (s != -1)
    close(s);
  s = -1;
end:
  freeaddrinfo(servinfo);
  return s;
}


x86 assembly (clang, -O0):
<_anetTcpServer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
lea    -0x36(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    $0x6,%esi
lea    0xe2e(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1060 <memset@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    0x2db7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2dc3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1256 <_anetTcpServer+0x96>
mov    -0x20(%rbp),%rsi
lea    0xdc2(%rip),%rdi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1256 <_anetTcpServer+0x96>
movq   $0x0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2d80(%rip),%rcx
cmp    (%rcx),%eax
jne    1294 <_anetTcpServer+0xd4>
cmpq   $0x0,-0x20(%rbp)
je     1294 <_anetTcpServer+0xd4>
mov    -0x20(%rbp),%rsi
lea    0xd82(%rip),%rdi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1294 <_anetTcpServer+0xd4>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x36(%rbp),%rsi
lea    -0x60(%rbp),%rdx
lea    -0x68(%rbp),%rcx
call   10c0 <getaddrinfo@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
je     12e3 <_anetTcpServer+0x123>
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x30(%rbp),%edi
call   1050 <gai_strerror@plt>
mov    -0x78(%rbp),%rdi
mov    %eax,%edx
lea    0xd32(%rip),%rsi
call   10a0 <anetSetError@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1400 <_anetTcpServer+0x240>
mov    -0x68(%rbp),%rax
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
je     13aa <_anetTcpServer+0x1ea>
mov    -0x70(%rbp),%rax
mov    (%rax),%edi
mov    -0x70(%rbp),%rax
mov    0x10(%rax),%esi
mov    -0x70(%rbp),%rax
mov    0xc(%rax),%edx
call   10e0 <socket@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
jne    1320 <_anetTcpServer+0x160>
jmp    1399 <_anetTcpServer+0x1d9>
mov    -0x24(%rbp),%eax
mov    0x2cb6(%rip),%rcx
cmp    (%rcx),%eax
jne    134c <_anetTcpServer+0x18c>
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1090 <anetV6Only@plt>
cmp    $0xffffffff,%eax
jne    134c <_anetTcpServer+0x18c>
jmp    13d8 <_anetTcpServer+0x218>
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   10b0 <anetSetReuseAddr@plt>
cmp    $0xffffffff,%eax
jne    1366 <_anetTcpServer+0x1a6>
jmp    13d8 <_anetTcpServer+0x218>
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x70(%rbp),%rax
mov    0x8(%rax),%edx
mov    -0x70(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x28(%rbp),%r8d
call   1030 <anetListen@plt>
cmp    $0xffffffff,%eax
jne    1394 <_anetTcpServer+0x1d4>
movl   $0xffffffff,-0x2c(%rbp)
jmp    13f1 <_anetTcpServer+0x231>
mov    -0x70(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x70(%rbp)
jmp    12eb <_anetTcpServer+0x12b>
cmpq   $0x0,-0x70(%rbp)
jne    13d3 <_anetTcpServer+0x213>
mov    -0x10(%rbp),%rdi
mov    0x2c08(%rip),%rax
mov    (%rax),%edx
lea    0xc3e(%rip),%rsi
call   10a0 <anetSetError@plt>
jmp    13d8 <_anetTcpServer+0x218>
jmp    13d8 <_anetTcpServer+0x218>
cmpl   $0xffffffff,-0x2c(%rbp)
je     13ea <_anetTcpServer+0x22a>
mov    -0x2c(%rbp),%edi
call   1070 <close@plt>
movl   $0xffffffff,-0x2c(%rbp)
mov    -0x68(%rbp),%rdi
call   10d0 <freeaddrinfo@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_anetTcpServer>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %r8d,%r14d
mov    %ecx,%r12d
mov    %rdx,%rbp
mov    %esi,%ecx
mov    %rdi,%r15
lea    0xe44(%rip),%rdx
lea    0x12(%rsp),%rdi
mov    $0x6,%esi
call   1040 <snprintf@plt>
lea    0x18(%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x28,%edx
call   1060 <memset@plt>
mov    %r12d,0x18(%rsp)
mov    0x2dc1(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
mov    0x2dcc(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x38(%rsp)
test   %rbp,%rbp
je     1266 <_anetTcpServer+0xa6>
lea    0xdd4(%rip),%rdi
mov    %rbp,%rsi
call   1080 <strcmp@plt>
xor    %ebx,%ebx
test   %eax,%eax
cmovne %rbp,%rbx
mov    0x2d9b(%rip),%rax
cmp    %r12d,(%rax)
jne    1266 <_anetTcpServer+0xa6>
test   %rbx,%rbx
je     1266 <_anetTcpServer+0xa6>
lea    0xdaa(%rip),%rdi
mov    %rbx,%rsi
call   1080 <strcmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
cmove  %rcx,%rbx
lea    0x12(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
call   10c0 <getaddrinfo@plt>
test   %eax,%eax
je     12a3 <_anetTcpServer+0xe3>
mov    %eax,%edi
call   1050 <gai_strerror@plt>
lea    0xd75(%rip),%rsi
mov    %r15,%rdi
mov    %eax,%edx
call   10a0 <anetSetError@plt>
mov    $0xffffffff,%ebx
jmp    1343 <_anetTcpServer+0x183>
mov    0x8(%rsp),%rbp
test   %rbp,%rbp
je     12cc <_anetTcpServer+0x10c>
nopl   (%rax)
mov    0x10(%rbp),%esi
mov    0x0(%rbp),%edi
mov    0xc(%rbp),%edx
call   10e0 <socket@plt>
cmp    $0xffffffff,%eax
jne    12e6 <_anetTcpServer+0x126>
mov    0x18(%rbp),%rbp
test   %rbp,%rbp
jne    12b0 <_anetTcpServer+0xf0>
mov    0x2cf5(%rip),%rax
mov    (%rax),%edx
lea    0xd2b(%rip),%rsi
mov    %r15,%rdi
call   10a0 <anetSetError@plt>
jmp    1334 <_anetTcpServer+0x174>
mov    %eax,%ebx
mov    0x2cf1(%rip),%rax
cmp    %r12d,(%rax)
jne    1303 <_anetTcpServer+0x143>
mov    %r15,%rdi
mov    %ebx,%esi
call   1090 <anetV6Only@plt>
cmp    $0xffffffff,%eax
je     132d <_anetTcpServer+0x16d>
mov    %r15,%rdi
mov    %ebx,%esi
call   10b0 <anetSetReuseAddr@plt>
cmp    $0xffffffff,%eax
je     132d <_anetTcpServer+0x16d>
mov    0x4(%rbp),%ecx
mov    0x8(%rbp),%edx
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r14d,%r8d
call   1030 <anetListen@plt>
cmp    $0xffffffff,%eax
cmove  %eax,%ebx
jmp    1339 <_anetTcpServer+0x179>
mov    %ebx,%edi
call   1070 <close@plt>
mov    $0xffffffff,%ebx
mov    0x8(%rsp),%rdi
call   10d0 <freeaddrinfo@plt>
mov    %ebx,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo*, i32 }
@.str = [3 x i8] c"%d\00"
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@.str.1 = [2 x i8] c"*\00"
@AF_INET6 = global i32 0
@.str.2 = [4 x i8] c"::*\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [33 x i8] c"unable to bind socket, errno: %d\00"
@errno = global i32 0
define i32 @_anetTcpServer(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca [6 x i8]
%7 = alloca %struct.addrinfo
%8 = alloca %struct.addrinfo*
%9 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%10 = bitcast %struct.addrinfo* %7 to i8*
%11 = bitcast %struct.addrinfo** %8 to i8*
%12 = call i32 @snprintf(i8* %9, i32 6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %1)
%13 = call i32 @memset(%struct.addrinfo* %7, i32 0, i32 40)
%14 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i64 0, i32 0
store i32 %3, i32* %14
%15 = load i32, i32* @SOCK_STREAM
%16 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i64 0, i32 4
store i32 %15, i32* %16
%17 = load i32, i32* @AI_PASSIVE
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i64 0, i32 6
store i32 %17, i32* %18
%19 = icmp eq i8* %2, null
br i1 %19, label %32, label %20
20: ; preds = %5
%21 = call i32 @strcmp(i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%22 = icmp eq i32 %21, 0
%23 = select i1 %22, i8* null, i8* %2
%24 = load i32, i32* @AF_INET6
%25 = icmp eq i32 %24, %3
%26 = icmp ne i8* %23, null
%27 = select i1 %25, i1 %26, i1 false
br i1 %27, label %28, label %32
28: ; preds = %20
%29 = call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%30 = icmp eq i32 %29, 0
%31 = select i1 %30, i8* null, i8* %23
br label %32
32: ; preds = %5, %28, %20
%33 = phi i8* [ %31, %28 ], [ %23, %20 ], [ null, %5 ]
%34 = call i32 @getaddrinfo(i8* %33, i8* %9, %struct.addrinfo* %7, %struct.addrinfo** %8)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load %struct.addrinfo*, %struct.addrinfo** %8
%38 = icmp eq %struct.addrinfo* %37, null
br i1 %38, label %73, label %42
39: ; preds = %32
%40 = call i32 @gai_strerror(i32 %34)
%41 = call i32 @anetSetError(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %40)
br label %82
42: ; preds = %36, %69
%43 = phi %struct.addrinfo* [ %71, %69 ], [ %37, %36 ]
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %43, i64 0, i32 0
%45 = load i32, i32* %44
%46 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %43, i64 0, i32 4
%47 = load i32, i32* %46
%48 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %43, i64 0, i32 3
%49 = load i32, i32* %48
%50 = call i32 @socket(i32 %45, i32 %47, i32 %49)
%51 = icmp eq i32 %50, -1
br i1 %51, label %69, label %52
52: ; preds = %42
%53 = load i32, i32* @AF_INET6
%54 = icmp eq i32 %53, %3
br i1 %54, label %55, label %58
55: ; preds = %52
%56 = call i32 @anetV6Only(i8* %0, i32 %50)
%57 = icmp eq i32 %56, -1
br i1 %57, label %76, label %58
58: ; preds = %55, %52
%59 = call i32 @anetSetReuseAddr(i8* %0, i32 %50)
%60 = icmp eq i32 %59, -1
br i1 %60, label %76, label %61
61: ; preds = %58
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %43, i64 0, i32 2
%63 = load i32, i32* %62
%64 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %43, i64 0, i32 1
%65 = load i32, i32* %64
%66 = call i32 @anetListen(i8* %0, i32 %50, i32 %63, i32 %65, i32 %4)
%67 = icmp eq i32 %66, -1
%68 = select i1 %67, i32 -1, i32 %50
br label %78
69: ; preds = %42
%70 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %43, i64 0, i32 5
%71 = load %struct.addrinfo*, %struct.addrinfo** %70
%72 = icmp eq %struct.addrinfo* %71, null
br i1 %72, label %73, label %42
73: ; preds = %69, %36
%74 = load i32, i32* @errno
%75 = call i32 @anetSetError(i8* %0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %74)
br label %78
76: ; preds = %55, %58
%77 = call i32 @close(i32 %50)
br label %78
78: ; preds = %73, %61, %76
%79 = phi i32 [ %68, %61 ], [ -1, %76 ], [ -1, %73 ]
%80 = load %struct.addrinfo*, %struct.addrinfo** %8
%81 = call i32 @freeaddrinfo(%struct.addrinfo* %80)
br label %82
82: ; preds = %78, %39
%83 = phi i32 [ -1, %39 ], [ %79, %78 ]
ret i32 %83
}