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

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ AI_PASSIVE;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
scalar_t__ bind(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ bzero(struct addrinfo *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int getaddrinfo(char const *, char const *, struct addrinfo *,
                struct addrinfo **);
scalar_t__ listen(int, int);
int /*<<< orphan*/ perror(char *);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int const *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int tcp_listen(const char *hostname, const char *service, socklen_t *addrlenp) {
  int listenfd;
  int ret;
  struct addrinfo hints, *res, *ressave;
  bzero(&hints, sizeof(struct addrinfo));
  hints.ai_flags = AI_PASSIVE;
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  if ((ret = getaddrinfo(hostname, service, &hints, &res)) != 0) {
    fprintf(stderr, "tcp_connect() error for %s, %s: %s", hostname, service,
            gai_strerror(ret));
    return (-1);
  }
  ressave = res;
  do {
    if ((listenfd =
             socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) {
      continue;
    } else {
      const int on = 1;
      if ((ret = setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on,
                            sizeof(on))) < 0) {
        fprintf(stderr, "setsockopt() error");
        return (-1);
      }
      if (bind(listenfd, res->ai_addr, res->ai_addrlen) == 0)
        break;
      else {
        close(listenfd);
        continue;
      }
    }
  } while ((res = res->ai_next) != NULL);
  if (res == NULL) {
    fprintf(stderr, "tcp_listen() error for %s, %s\n", hostname, service);
    return -1;
  }
  if (listen(listenfd, 128) < 0) {
    perror("listen() error");
    return -1;
  }
  if (addrlenp)
    *addrlenp = res->ai_addrlen;
  freeaddrinfo(ressave);
  return listenfd;
}


x86 assembly (clang, -O0):
<tcp_listen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x28,%esi
call   10a0 <bzero@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2df0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2dcc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x58(%rbp),%rcx
call   10b0 <getaddrinfo@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
je     1266 <tcp_listen+0xb6>
mov    0x2da7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x28(%rbp),%edi
call   1040 <gai_strerror@plt>
mov    -0x7c(%rbp),%edi
mov    -0x78(%rbp),%rdx
mov    -0x70(%rbp),%rcx
mov    %rax,%r8
lea    0xdad(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13c0 <tcp_listen+0x210>
mov    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x58(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x58(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%edx
call   10d0 <socket@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    1299 <tcp_listen+0xe9>
jmp    131f <tcp_listen+0x16f>
movl   $0x1,-0x64(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2d3e(%rip),%rax
mov    (%rax),%esi
mov    0x2d05(%rip),%rax
mov    (%rax),%edx
lea    -0x64(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jge    12f3 <tcp_listen+0x143>
mov    0x2cf1(%rip),%rax
mov    (%rax),%edi
lea    0xd43(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13c0 <tcp_listen+0x210>
mov    -0x24(%rbp),%edi
mov    -0x58(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x58(%rbp),%rax
mov    (%rax),%edx
call   1080 <bind@plt>
cmp    $0x0,%rax
jne    1317 <tcp_listen+0x167>
jmp    1335 <tcp_listen+0x185>
mov    -0x24(%rbp),%edi
call   1050 <close@plt>
mov    -0x58(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    126e <tcp_listen+0xbe>
cmpq   $0x0,-0x58(%rbp)
jne    136b <tcp_listen+0x1bb>
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xcde(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13c0 <tcp_listen+0x210>
mov    -0x24(%rbp),%edi
mov    $0x80,%esi
call   1070 <listen@plt>
cmp    $0x0,%rax
jge    139a <tcp_listen+0x1ea>
lea    0xccc(%rip),%rdi
call   1090 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13c0 <tcp_listen+0x210>
cmpq   $0x0,-0x20(%rbp)
je     13b1 <tcp_listen+0x201>
mov    -0x58(%rbp),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x60(%rbp),%rdi
call   10c0 <freeaddrinfo@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcp_listen>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdx,%rbp
mov    %rsi,%r14
mov    %rdi,%r13
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x28,%esi
call   10a0 <bzero@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x40(%rsp)
mov    0x2deb(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x30(%rsp)
mov    0x2dc6(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x2c(%rsp)
mov    %rsp,%rcx
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   10b0 <getaddrinfo@plt>
test   %eax,%eax
je     1243 <tcp_listen+0x93>
mov    0x2dac(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1040 <gai_strerror@plt>
lea    0xdd4(%rip),%rsi
mov    %ebx,%edi
mov    %r13,%rdx
mov    %r14,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1346 <tcp_listen+0x196>
mov    %rbp,0x18(%rsp)
mov    (%rsp),%rax
mov    0x2d95(%rip),%r12
mov    0x2d5e(%rip),%r15
lea    0xc(%rsp),%rbx
mov    %rax,0x10(%rsp)
jmp    1285 <tcp_listen+0xd5>
cs nopw 0x0(%rax,%rax,1)
mov    (%rsp),%rax
mov    0x18(%rax),%rax
mov    %rax,(%rsp)
test   %rax,%rax
je     1329 <tcp_listen+0x179>
mov    0x10(%rax),%edi
mov    0x8(%rax),%edx
mov    0xc(%rax),%esi
call   10d0 <socket@plt>
test   %eax,%eax
js     1270 <tcp_listen+0xc0>
mov    %eax,%ebp
movl   $0x1,0xc(%rsp)
mov    (%r12),%esi
mov    (%r15),%edx
mov    %eax,%edi
mov    %rbx,%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %eax,%eax
js     12da <tcp_listen+0x12a>
mov    (%rsp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %ebp,%edi
call   1080 <bind@plt>
test   %rax,%rax
je     12f3 <tcp_listen+0x143>
mov    %ebp,%edi
call   1050 <close@plt>
jmp    1270 <tcp_listen+0xc0>
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
lea    0xd39(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1346 <tcp_listen+0x196>
cmpq   $0x0,(%rsp)
je     1329 <tcp_listen+0x179>
mov    %ebp,%edi
mov    $0x80,%esi
call   1070 <listen@plt>
test   %rax,%rax
js     135c <tcp_listen+0x1ac>
mov    0x18(%rsp),%rcx
test   %rcx,%rcx
je     131d <tcp_listen+0x16d>
mov    (%rsp),%rax
mov    (%rax),%eax
mov    %eax,(%rcx)
mov    0x10(%rsp),%rdi
call   10c0 <freeaddrinfo@plt>
jmp    134b <tcp_listen+0x19b>
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
lea    0xcfd(%rip),%rsi
mov    %r13,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcf2(%rip),%rdi
call   1090 <perror@plt>
jmp    1346 <tcp_listen+0x196>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo*, i32 }
@AI_PASSIVE = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [35 x i8] c"tcp_connect() error for %s, %s: %s\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.1 = [19 x i8] c"setsockopt() error\00"
@.str.2 = [31 x i8] c"tcp_listen() error for %s, %s\0A\00"
@.str.3 = [15 x i8] c"listen() error\00"
define i32 @tcp_listen(i8* %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.addrinfo
%11 = alloca %struct.addrinfo*
%12 = alloca %struct.addrinfo*
%13 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
%14 = call i32 @bzero(%struct.addrinfo* %10, i32 40)
%15 = load i32, i32* @AI_PASSIVE
%16 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 6
store i32 %15, i32* %16
%17 = load i32, i32* @AF_UNSPEC
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 4
store i32 %17, i32* %18
%19 = load i32, i32* @SOCK_STREAM
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 3
store i32 %19, i32* %20
%21 = load i8*, i8** %5
%22 = load i8*, i8** %6
%23 = call i32 @getaddrinfo(i8* %21, i8* %22, %struct.addrinfo* %10, %struct.addrinfo** %11)
store i32 %23, i32* %9
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %3
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %5
%28 = load i8*, i8** %6
%29 = load i32, i32* %9
%30 = call i8* @gai_strerror(i32 %29)
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %27, i8* %28, i8* %30)
store i32 -1, i32* %4
br label %101
32: ; preds = %3
%33 = load %struct.addrinfo*, %struct.addrinfo** %11
store %struct.addrinfo* %33, %struct.addrinfo** %12
br label %34
34: ; preds = %70, %32
%35 = load %struct.addrinfo*, %struct.addrinfo** %11
%36 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %35, i32 0, i32 4
%37 = load i32, i32* %36
%38 = load %struct.addrinfo*, %struct.addrinfo** %11
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i32 0, i32 3
%40 = load i32, i32* %39
%41 = load %struct.addrinfo*, %struct.addrinfo** %11
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i32 0, i32 2
%43 = load i32, i32* %42
%44 = call i32 @socket(i32 %37, i32 %40, i32 %43)
store i32 %44, i32* %8
%45 = icmp slt i32 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %34
br label %70
47: ; preds = %34
store i32 1, i32* %13
%48 = load i32, i32* %8
%49 = load i32, i32* @SOL_SOCKET
%50 = load i32, i32* @SO_REUSEADDR
%51 = call i32 @setsockopt(i32 %48, i32 %49, i32 %50, i32* %13, i32 4)
store i32 %51, i32* %9
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %47
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %101
56: ; preds = %47
%57 = load i32, i32* %8
%58 = load %struct.addrinfo*, %struct.addrinfo** %11
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %58, i32 0, i32 1
%60 = load i32, i32* %59
%61 = load %struct.addrinfo*, %struct.addrinfo** %11
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %61, i32 0, i32 0
%63 = load i32, i32* %62
%64 = call i64 @bind(i32 %57, i32 %60, i32 %63)
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %56
br label %75
67: ; preds = %56
%68 = load i32, i32* %8
%69 = call i32 @close(i32 %68)
br label %70
70: ; preds = %67, %46
%71 = load %struct.addrinfo*, %struct.addrinfo** %11
%72 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %71, i32 0, i32 5
%73 = load %struct.addrinfo*, %struct.addrinfo** %72
store %struct.addrinfo* %73, %struct.addrinfo** %11
%74 = icmp ne %struct.addrinfo* %73, null
br i1 %74, label %34, label %75
75: ; preds = %70, %66
%76 = load %struct.addrinfo*, %struct.addrinfo** %11
%77 = icmp eq %struct.addrinfo* %76, null
br i1 %77, label %78, label %83
78: ; preds = %75
%79 = load i32, i32* @stderr
%80 = load i8*, i8** %5
%81 = load i8*, i8** %6
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %80, i8* %81)
store i32 -1, i32* %4
br label %101
83: ; preds = %75
%84 = load i32, i32* %8
%85 = call i64 @listen(i32 %84, i32 128)
%86 = icmp slt i64 %85, 0
br i1 %86, label %87, label %89
87: ; preds = %83
%88 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %4
br label %101
89: ; preds = %83
%90 = load i32*, i32** %7
%91 = icmp ne i32* %90, null
br i1 %91, label %92, label %97
92: ; preds = %89
%93 = load %struct.addrinfo*, %struct.addrinfo** %11
%94 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %93, i32 0, i32 0
%95 = load i32, i32* %94
%96 = load i32*, i32** %7
store i32 %95, i32* %96
br label %97
97: ; preds = %92, %89
%98 = load %struct.addrinfo*, %struct.addrinfo** %12
%99 = call i32 @freeaddrinfo(%struct.addrinfo* %98)
%100 = load i32, i32* %8
store i32 %100, i32* %4
br label %101
101: ; preds = %97, %87, %78, %53, %25
%102 = load i32, i32* %4
ret i32 %102
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo*, i32 }
@AI_PASSIVE = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [35 x i8] c"tcp_connect() error for %s, %s: %s\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.1 = [19 x i8] c"setsockopt() error\00"
@.str.2 = [31 x i8] c"tcp_listen() error for %s, %s\0A\00"
@.str.3 = [15 x i8] c"listen() error\00"
define i32 @tcp_listen(i8* %0, i8* %1, i32* writeonly %2) {
%4 = alloca %struct.addrinfo
%5 = alloca %struct.addrinfo*
%6 = alloca i32
%7 = bitcast %struct.addrinfo* %4 to i8*
%8 = bitcast %struct.addrinfo** %5 to i8*
%9 = call i32 @bzero(%struct.addrinfo* %4, i32 40)
%10 = load i32, i32* @AI_PASSIVE
%11 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 6
store i32 %10, i32* %11
%12 = load i32, i32* @AF_UNSPEC
%13 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 4
store i32 %12, i32* %13
%14 = load i32, i32* @SOCK_STREAM
%15 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 3
store i32 %14, i32* %15
%16 = call i32 @getaddrinfo(i8* %0, i8* %1, %struct.addrinfo* %4, %struct.addrinfo** %5)
%17 = icmp eq i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %3
%19 = load i32, i32* @stderr
%20 = call i8* @gai_strerror(i32 %16)
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i8* %20)
br label %77
22: ; preds = %3
%23 = load %struct.addrinfo*, %struct.addrinfo** %5
%24 = bitcast i32* %6 to i8*
br label %25
25: ; preds = %53, %22
%26 = phi %struct.addrinfo* [ %56, %53 ], [ %23, %22 ]
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %26, i64 0, i32 4
%28 = load i32, i32* %27
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %26, i64 0, i32 3
%30 = load i32, i32* %29
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %26, i64 0, i32 2
%32 = load i32, i32* %31
%33 = call i32 @socket(i32 %28, i32 %30, i32 %32)
%34 = icmp slt i32 %33, 0
br i1 %34, label %53, label %35
35: ; preds = %25
store i32 1, i32* %6
%36 = load i32, i32* @SOL_SOCKET
%37 = load i32, i32* @SO_REUSEADDR
%38 = call i32 @setsockopt(i32 %33, i32 %36, i32 %37, i32* %6, i32 4)
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %77
43: ; preds = %35
%44 = load %struct.addrinfo*, %struct.addrinfo** %5
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i64 0, i32 1
%46 = load i32, i32* %45
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i64 0, i32 0
%48 = load i32, i32* %47
%49 = call i64 @bind(i32 %33, i32 %46, i32 %48)
%50 = icmp eq i64 %49, 0
br i1 %50, label %58, label %51
51: ; preds = %43
%52 = call i32 @close(i32 %33)
br label %53
53: ; preds = %51, %25
%54 = load %struct.addrinfo*, %struct.addrinfo** %5
%55 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %54, i64 0, i32 5
%56 = load %struct.addrinfo*, %struct.addrinfo** %55
store %struct.addrinfo* %56, %struct.addrinfo** %5
%57 = icmp eq %struct.addrinfo* %56, null
br i1 %57, label %61, label %25
58: ; preds = %43
%59 = load %struct.addrinfo*, %struct.addrinfo** %5
%60 = icmp eq %struct.addrinfo* %59, null
br i1 %60, label %61, label %64
61: ; preds = %53, %58
%62 = load i32, i32* @stderr
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1)
br label %77
64: ; preds = %58
%65 = call i64 @listen(i32 %33, i32 128)
%66 = icmp slt i64 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %64
%68 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %77
69: ; preds = %64
%70 = icmp eq i32* %2, null
br i1 %70, label %75, label %71
71: ; preds = %69
%72 = load %struct.addrinfo*, %struct.addrinfo** %5
%73 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %72, i64 0, i32 0
%74 = load i32, i32* %73
store i32 %74, i32* %2
br label %75
75: ; preds = %71, %69
%76 = call i32 @freeaddrinfo(%struct.addrinfo* %23)
br label %77
77: ; preds = %40, %75, %67, %61, %18
%78 = phi i32 [ -1, %18 ], [ -1, %61 ], [ -1, %67 ], [ %33, %75 ], [ -1, %40 ]
ret i32 %78
}