#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;
};

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ AI_PASSIVE;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ bind(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, int /*<<< orphan*/, int /*<<< orphan*/);
int getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
scalar_t__ listen(int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int start_networking(int mode, char *hostname, char *port, int *sock_out) {
  int sock, conn;
  int status;
  struct addrinfo hints;
  struct addrinfo *servinfo, *p;
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = AI_PASSIVE;
  status = getaddrinfo(hostname, port, &hints, &servinfo);
  for (p = servinfo; p != NULL; p = p->ai_next) {
    if ((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
      perror("socket");
      close(sock);
      return -1;
    }
    if (mode == 0) {
      if (connect(sock, p->ai_addr, p->ai_addrlen)) {
        perror("connect");
        close(sock);
        return -1;
      }
      *sock_out = sock;
      return 0;
    } else if (mode == 1) {
      int optval = 1;
      setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof optval);
      if (!bind(sock, p->ai_addr, p->ai_addrlen)) {
        puts("waiting for a connection...");
        if (listen(sock, 0)) {
          perror("listen");
          close(sock);
          return -1;
        }
        if ((conn = accept(sock, NULL, NULL)) == -1) {
          perror("accept");
          close(sock);
          return -1;
        }
        close(sock);
        *sock_out = conn;
        return 0;
      }
    }
  }
  close(sock);
  return -1;
}


x86 assembly (clang, -O0):
<start_networking>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2dde(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2dea(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x58(%rbp),%rdx
lea    -0x60(%rbp),%rcx
call   10c0 <getaddrinfo@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     13d5 <start_networking+0x225>
mov    -0x68(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x68(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x68(%rbp),%rax
mov    0x8(%rax),%edx
call   10d0 <socket@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    126c <start_networking+0xbc>
lea    0xdad(%rip),%rdi
call   1090 <perror@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13e4 <start_networking+0x234>
cmpl   $0x0,-0x8(%rbp)
jne    12ca <start_networking+0x11a>
mov    -0x24(%rbp),%edi
mov    -0x68(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x68(%rbp),%rax
mov    (%rax),%edx
call   10b0 <connect@plt>
cmp    $0x0,%rax
je     12b5 <start_networking+0x105>
lea    0xd6b(%rip),%rdi
call   1090 <perror@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13e4 <start_networking+0x234>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    13e4 <start_networking+0x234>
cmpl   $0x1,-0x8(%rbp)
jne    13ba <start_networking+0x20a>
movl   $0x1,-0x6c(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2d03(%rip),%rax
mov    (%rax),%esi
mov    0x2cd2(%rip),%rax
mov    (%rax),%edx
lea    -0x6c(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
mov    -0x24(%rbp),%edi
mov    -0x68(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x68(%rbp),%rax
mov    (%rax),%edx
call   1080 <bind@plt>
cmp    $0x0,%eax
jne    13b5 <start_networking+0x205>
lea    0xceb(%rip),%rdi
call   1030 <puts@plt>
mov    -0x24(%rbp),%edi
xor    %esi,%esi
call   1070 <listen@plt>
cmp    $0x0,%rax
je     135d <start_networking+0x1ad>
lea    0xce7(%rip),%rdi
call   1090 <perror@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13e4 <start_networking+0x234>
mov    -0x24(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   10a0 <accept@plt>
mov    %eax,-0x28(%rbp)
cmp    $0xffffffff,%eax
jne    1398 <start_networking+0x1e8>
lea    0xcb3(%rip),%rdi
call   1090 <perror@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13e4 <start_networking+0x234>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x28(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    13e4 <start_networking+0x234>
jmp    13ba <start_networking+0x20a>
jmp    13bf <start_networking+0x20f>
jmp    13c4 <start_networking+0x214>
mov    -0x68(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x68(%rbp)
jmp    121b <start_networking+0x6b>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_networking>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,0x8(%rsp)
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %edi,%ebx
lea    0x20(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x30(%rsp)
mov    0x2dd5(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x2c(%rsp)
mov    0x2de0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x40(%rsp)
lea    0x18(%rsp),%rcx
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   10c0 <getaddrinfo@plt>
mov    0x18(%rsp),%r12
mov    0x2dc3(%rip),%r13
mov    0x2d94(%rip),%r14
lea    0x4(%rsp),%r15
mov    %r12,0x10(%rsp)
jmp    1281 <start_networking+0xd1>
nopl   0x0(%rax,%rax,1)
movl   $0x1,0x4(%rsp)
mov    0x0(%r13),%esi
mov    (%r14),%edx
mov    %ebp,%edi
mov    %r15,%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
mov    (%r12),%edx
mov    0x4(%r12),%esi
mov    %ebp,%edi
call   1080 <bind@plt>
test   %eax,%eax
je     12c9 <start_networking+0x119>
mov    0x18(%r12),%r12
test   %r12,%r12
je     1344 <start_networking+0x194>
mov    0x10(%r12),%edi
mov    0x8(%r12),%edx
mov    0xc(%r12),%esi
call   10d0 <socket@plt>
cmp    $0xffffffff,%eax
je     1309 <start_networking+0x159>
mov    %eax,%ebp
cmp    $0x1,%ebx
je     1240 <start_networking+0x90>
test   %ebx,%ebx
jne    1273 <start_networking+0xc3>
mov    0x10(%rsp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %ebp,%edi
call   10b0 <connect@plt>
test   %rax,%rax
jne    1326 <start_networking+0x176>
mov    0x8(%rsp),%rax
mov    %ebp,(%rax)
xor    %ebx,%ebx
jmp    1350 <start_networking+0x1a0>
lea    0xd3f(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   1070 <listen@plt>
test   %rax,%rax
jne    132f <start_networking+0x17f>
xor    %ebx,%ebx
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <accept@plt>
cmp    $0xffffffff,%eax
je     1338 <start_networking+0x188>
mov    %eax,%r15d
mov    %ebp,%edi
call   1060 <close@plt>
mov    0x8(%rsp),%rax
mov    %r15d,(%rax)
jmp    1350 <start_networking+0x1a0>
lea    0xcf0(%rip),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%ebx
mov    $0xffffffff,%edi
call   1060 <close@plt>
jmp    1350 <start_networking+0x1a0>
lea    0xcda(%rip),%rdi
jmp    133f <start_networking+0x18f>
lea    0xcf5(%rip),%rdi
jmp    133f <start_networking+0x18f>
lea    0xcf3(%rip),%rdi
call   1090 <perror@plt>
mov    %ebp,%edi
call   1060 <close@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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