#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 */
typedef int /*<<< orphan*/ yes;
struct sockaddr_storage {
  int dummy;
};
struct sockaddr {
  int dummy;
};
struct addrinfo {
  int ai_flags;
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  struct addrinfo *ai_next;
};
typedef scalar_t__ socklen_t;
typedef int /*<<< orphan*/ hints;
typedef int /*<<< orphan*/ caddr;

/* Variables and functions */
int AI_ADDRCONFIG;
int AI_NUMERICHOST;
int AI_NUMERICSERV;
int AI_PASSIVE;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ PF_UNSPEC;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, scalar_t__ *);
int bind(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
scalar_t__ getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int listen(int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, int);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int peer_wait(void) {
  int lfd, cfd;
  struct sockaddr_storage caddr;
  socklen_t caddr_size;
  int yes;
  struct addrinfo hints;
  struct addrinfo *servinfo;
  struct addrinfo *cur;
  memset((void *)&hints, 0, sizeof(hints));
  hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICHOST | AI_NUMERICSERV | AI_PASSIVE;
  hints.ai_family = PF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_protocol = IPPROTO_TCP;
  if (0 !=
      getaddrinfo(
          "l0.0.0.0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0a" + 1,
          "31337\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0p",
          &hints, &servinfo)) {
    return -5;
  }
  lfd = -1;
  for (cur = servinfo; NULL != cur; cur = cur->ai_next) {
    if (-1 ==
        (lfd = socket(cur->ai_family, cur->ai_socktype, cur->ai_protocol))) {
      continue;
    }
    yes = 1;
    if (setsockopt(lfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) == -1) {
      close(lfd);
      lfd = -1;
      continue;
    }
    if (-1 == bind(lfd, cur->ai_addr, cur->ai_addrlen)) {
      close(lfd);
      lfd = -1;
      continue;
    }
    if (-1 == listen(lfd, 0)) {
      close(lfd);
      lfd = -1;
      continue;
    }
  }
  freeaddrinfo(servinfo);
  if (-1 == lfd) {
    return -6;
  }
  caddr_size = (socklen_t)sizeof(caddr);
  if (-1 == (cfd = accept(lfd, (struct sockaddr *)&caddr, &caddr_size))) {
    return -7;
  }
  close(lfd);
  return cfd;
}


x86 assembly (clang, -O0):
<peer_wait>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%eax
mov    0x2e10(%rip),%rcx
or     (%rcx),%eax
mov    0x2e37(%rip),%rcx
or     (%rcx),%eax
mov    0x2e06(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x40(%rbp)
mov    0x2e02(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2dce(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2dd2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
lea    0xe06(%rip),%rdi
add    $0x1,%rdi
lea    0xe20(%rip),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1090 <getaddrinfo@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     122c <peer_wait+0x9c>
movl   $0xfffffffb,-0x4(%rbp)
jmp    13a3 <peer_wait+0x213>
movl   $0xffffffff,-0x8(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
xor    %eax,%eax
cmp    -0x50(%rbp),%rax
je     133c <peer_wait+0x1ac>
mov    -0x50(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x50(%rbp),%rax
mov    0x10(%rax),%esi
mov    -0x50(%rbp),%rax
mov    0xc(%rax),%edx
call   10b0 <socket@plt>
mov    %eax,%ecx
mov    %ecx,-0x8(%rbp)
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1278 <peer_wait+0xe8>
jmp    132b <peer_wait+0x19b>
movl   $0x1,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2d57(%rip),%rax
mov    (%rax),%esi
mov    0x2d16(%rip),%rax
mov    (%rax),%edx
lea    -0x1c(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    12c0 <peer_wait+0x130>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x8(%rbp)
jmp    132b <peer_wait+0x19b>
mov    -0x8(%rbp),%edi
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%esi
mov    -0x50(%rbp),%rax
mov    0x4(%rax),%edx
call   1070 <bind@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    12f9 <peer_wait+0x169>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x8(%rbp)
jmp    132b <peer_wait+0x19b>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1060 <listen@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1326 <peer_wait+0x196>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x8(%rbp)
jmp    132b <peer_wait+0x19b>
jmp    132b <peer_wait+0x19b>
mov    -0x50(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x50(%rbp)
jmp    123b <peer_wait+0xab>
mov    -0x48(%rbp),%rdi
call   10a0 <freeaddrinfo@plt>
mov    $0xffffffff,%eax
cmp    -0x8(%rbp),%eax
jne    135f <peer_wait+0x1cf>
movl   $0xfffffffa,-0x4(%rbp)
jmp    13a3 <peer_wait+0x213>
movq   $0x4,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1080 <accept@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1395 <peer_wait+0x205>
movl   $0xfffffff9,-0x4(%rbp)
jmp    13a3 <peer_wait+0x213>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<peer_wait>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0x28(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
mov    0x2ddf(%rip),%rax
mov    0x2e08(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e2d(%rip),%rax
or     (%rax),%ecx
mov    0x2dfc(%rip),%rax
or     (%rax),%ecx
mov    %ecx,0x28(%rsp)
mov    0x2df7(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x3c(%rsp)
mov    0x2dc2(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x38(%rsp)
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x34(%rsp)
lea    0xdf9(%rip),%rdi
lea    0xe16(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %rbx,%rdx
call   1090 <getaddrinfo@plt>
mov    $0xfffffffb,%ebp
test   %rax,%rax
jne    1314 <peer_wait+0x184>
mov    0x10(%rsp),%rbx
test   %rbx,%rbx
je     1301 <peer_wait+0x171>
mov    0x2da1(%rip),%r12
mov    0x2d62(%rip),%r13
lea    0xc(%rsp),%r14
jmp    1260 <peer_wait+0xd0>
nopl   (%rax)
mov    %ebp,%edi
call   1050 <close@plt>
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
je     12c5 <peer_wait+0x135>
mov    0x14(%rbx),%edi
mov    0xc(%rbx),%edx
mov    0x10(%rbx),%esi
call   10b0 <socket@plt>
mov    $0xffffffff,%r15d
cmp    $0xffffffff,%eax
je     1257 <peer_wait+0xc7>
mov    %eax,%ebp
movl   $0x1,0xc(%rsp)
mov    (%r12),%esi
mov    0x0(%r13),%edx
mov    %eax,%edi
mov    %r14,%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
je     1250 <peer_wait+0xc0>
mov    0x4(%rbx),%edx
mov    0x8(%rbx),%esi
mov    %ebp,%edi
call   1070 <bind@plt>
cmp    $0xffffffff,%eax
je     1250 <peer_wait+0xc0>
mov    %ebp,%edi
xor    %esi,%esi
call   1060 <listen@plt>
cmp    $0xffffffff,%eax
je     1250 <peer_wait+0xc0>
mov    %ebp,%r15d
jmp    1257 <peer_wait+0xc7>
mov    0x10(%rsp),%rdi
call   10a0 <freeaddrinfo@plt>
cmp    $0xffffffff,%r15d
je     1308 <peer_wait+0x178>
movq   $0x4,0x18(%rsp)
lea    0x20(%rsp),%rsi
lea    0x18(%rsp),%rdx
mov    %r15d,%edi
call   1080 <accept@plt>
cmp    $0xffffffff,%eax
je     130f <peer_wait+0x17f>
mov    %eax,%ebp
mov    %r15d,%edi
call   1050 <close@plt>
jmp    1314 <peer_wait+0x184>
xor    %edi,%edi
call   10a0 <freeaddrinfo@plt>
mov    $0xfffffffa,%ebp
jmp    1314 <peer_wait+0x184>
mov    $0xfffffff9,%ebp
mov    %ebp,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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