#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 {
  int dummy;
};
struct addrinfo {
  struct sockaddr *ai_addr;
  int /*<<< orphan*/ ai_flags;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
};

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ AI_PASSIVE;
int /*<<< orphan*/ MSG_DONTWAIT;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int getaddrinfo(int /*<<< orphan*/ *, char *, struct addrinfo *,
                struct addrinfo **);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int recv(int, char **, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int sockslist_add(struct sockaddr *, int);
int sockslist_addConnect(char *, char *);
int /*<<< orphan*/ sockslist_free();
int sockslist_getfd(int);
int sockslist_init(int);
int sockslist_isConnected(int);
int sockslist_remove(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ verify(int, char *);
int main(void) {
  int test;
  int i;
  char *buf[14 * 1024];
  int status;
  struct addrinfo hints;
  struct addrinfo *servinfo;
  struct sockaddr *dummy_socket;
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = AI_PASSIVE;
  if ((status = getaddrinfo(NULL, "3490", &hints, &servinfo)) != 0) {
    fprintf(stderr, "getaddrinfo error: %s\n", gai_strerror(status));
    return 1;
  }
  dummy_socket = servinfo->ai_addr;
  test = sockslist_init(2);
  verify(test == 0, "sockslist_init() is sane");
  for (test = 1, i = 0; i < 2; i++) {
    test = sockslist_add(dummy_socket, 20) > 0;
  }
  verify(test, "sockslist_add() returns successfully");
  for (test = 0, i = 0; i < 2; i++) {
    test += sockslist_getfd(i);
  }
  verify(test = 20 * 2,
         "sockslist_getfd() works and all sockets were in array");
  test = sockslist_add(dummy_socket, 20);
  verify(test, "sockslist_grow() doesn't kill everybody");
  test = sockslist_getfd(2);
  verify(test == 20, "sockslist_grow() works");
  test = sockslist_remove(2);
  verify(test > 0, "sockslist_remove() is sane");
  sockslist_free();
  sockslist_init(1);
  test = sockslist_addConnect("google.com", "80");
  verify(test >= 0, "sockslist_addConnect() is sane");
  verify(sockslist_isConnected(test),
         "sockslist_addConnect() *thinks* it works.");
  test = sockslist_getfd(test);
  verify(send(test, "GET / HTTP/1.0\r\n\r\n", 18, MSG_DONTWAIT),
         "sockslist_addConnect() actually works");
  test = recv(test, buf, 13 * 1024, 0);
  verify(test > 0, "reply also works");
  freeaddrinfo(servinfo);
  sockslist_free();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c050,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1c030(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    0x2dc4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c020(%rbp)
mov    0x2d9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c024(%rbp)
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c028(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdb3(%rip),%rsi
lea    -0x1c030(%rbp),%rdx
lea    -0x1c038(%rbp),%rcx
call   10f0 <getaddrinfo@plt>
mov    %eax,-0x1c014(%rbp)
cmp    $0x0,%eax
je     12aa <main+0xba>
mov    0x2d5a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c044(%rbp)
mov    -0x1c014(%rbp),%edi
call   1060 <gai_strerror@plt>
mov    -0x1c044(%rbp),%edi
mov    %rax,%rdx
lea    0xd6c(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14c3 <main+0x2d3>
mov    -0x1c038(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x1c040(%rbp)
mov    $0x2,%edi
call   10e0 <sockslist_init@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
lea    0xd41(%rip),%rsi
call   10c0 <verify@plt>
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jge    1325 <main+0x135>
mov    -0x1c040(%rbp),%rdi
mov    $0x14,%esi
call   10b0 <sockslist_add@plt>
cmp    $0x0,%eax
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12ee <main+0xfe>
mov    -0x8(%rbp),%edi
lea    0xd06(%rip),%rsi
call   10c0 <verify@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jge    1368 <main+0x178>
mov    -0xc(%rbp),%edi
call   10d0 <sockslist_getfd@plt>
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1342 <main+0x152>
movl   $0x28,-0x8(%rbp)
mov    $0x28,%edi
lea    0xcdf(%rip),%rsi
call   10c0 <verify@plt>
mov    -0x1c040(%rbp),%rdi
mov    $0x14,%esi
call   10b0 <sockslist_add@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    0xcf2(%rip),%rsi
call   10c0 <verify@plt>
mov    $0x2,%edi
call   10d0 <sockslist_getfd@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
lea    0xcf5(%rip),%rsi
call   10c0 <verify@plt>
mov    $0x2,%edi
call   1070 <sockslist_remove@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
lea    0xce7(%rip),%rsi
call   10c0 <verify@plt>
mov    $0x0,%al
call   1040 <sockslist_free@plt>
mov    $0x1,%edi
call   10e0 <sockslist_init@plt>
lea    0xce5(%rip),%rdi
lea    0xce9(%rip),%rsi
call   1100 <sockslist_addConnect@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
lea    0xcd1(%rip),%rsi
call   10c0 <verify@plt>
mov    -0x8(%rbp),%edi
call   10a0 <sockslist_isConnected@plt>
mov    %eax,%edi
lea    0xcda(%rip),%rsi
call   10c0 <verify@plt>
mov    -0x8(%rbp),%edi
call   10d0 <sockslist_getfd@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2b69(%rip),%rax
mov    (%rax),%ecx
lea    0xce1(%rip),%rsi
mov    $0x12,%edx
call   1050 <send@plt>
mov    %eax,%edi
lea    0xce1(%rip),%rsi
call   10c0 <verify@plt>
mov    -0x8(%rbp),%edi
lea    -0x1c010(%rbp),%rsi
mov    $0x3400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
lea    0xcd6(%rip),%rsi
call   10c0 <verify@plt>
mov    -0x1c038(%rbp),%rdi
call   1110 <freeaddrinfo@plt>
mov    $0x0,%al
call   1040 <sockslist_free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1c050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x1c028,%rsp
lea    0x8(%rsp),%rbx
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    0x2dc8(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
mov    0x2db6(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
lea    0xdc1(%rip),%rsi
mov    %rsp,%rcx
xor    %edi,%edi
mov    %rbx,%rdx
call   10f0 <getaddrinfo@plt>
test   %eax,%eax
je     127c <main+0x8c>
mov    0x2d79(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1060 <gai_strerror@plt>
lea    0xd9e(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1090 <fprintf@plt>
mov    $0x1,%r14d
jmp    1401 <main+0x211>
mov    (%rsp),%rax
mov    (%rax),%rbx
mov    $0x2,%edi
call   10e0 <sockslist_init@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xd80(%rip),%rsi
call   10c0 <verify@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   10b0 <sockslist_add@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   10b0 <sockslist_add@plt>
xor    %edi,%edi
test   %eax,%eax
setg   %dil
lea    0xd6b(%rip),%rsi
call   10c0 <verify@plt>
xor    %edi,%edi
call   10d0 <sockslist_getfd@plt>
mov    $0x1,%edi
call   10d0 <sockslist_getfd@plt>
lea    0xd73(%rip),%rsi
mov    $0x28,%edi
call   10c0 <verify@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   10b0 <sockslist_add@plt>
lea    0xd8b(%rip),%rsi
mov    %eax,%edi
call   10c0 <verify@plt>
mov    $0x2,%edi
call   10d0 <sockslist_getfd@plt>
xor    %edi,%edi
cmp    $0x14,%eax
sete   %dil
lea    0xd92(%rip),%rsi
call   10c0 <verify@plt>
mov    $0x2,%edi
call   1070 <sockslist_remove@plt>
xor    %edi,%edi
test   %eax,%eax
setg   %dil
lea    0xd8b(%rip),%rsi
call   10c0 <verify@plt>
xor    %eax,%eax
call   1040 <sockslist_free@plt>
mov    $0x1,%edi
call   10e0 <sockslist_init@plt>
lea    0xd89(%rip),%rdi
lea    0xd8d(%rip),%rsi
call   1100 <sockslist_addConnect@plt>
mov    %eax,%ebx
mov    %eax,%edi
not    %edi
shr    $0x1f,%edi
lea    0xd7b(%rip),%rsi
call   10c0 <verify@plt>
mov    %ebx,%edi
call   10a0 <sockslist_isConnected@plt>
lea    0xd87(%rip),%rsi
mov    %eax,%edi
call   10c0 <verify@plt>
mov    %ebx,%edi
call   10d0 <sockslist_getfd@plt>
mov    %eax,%ebx
mov    0x2c19(%rip),%rax
mov    (%rax),%ecx
lea    0xd91(%rip),%rsi
mov    %ebx,%edi
mov    $0x12,%edx
call   1050 <send@plt>
lea    0xd91(%rip),%rsi
mov    %eax,%edi
call   10c0 <verify@plt>
lea    0x20(%rsp),%rsi
mov    %ebx,%edi
mov    $0x3400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
xor    %edi,%edi
test   %eax,%eax
setg   %dil
lea    0xd8e(%rip),%rsi
call   10c0 <verify@plt>
mov    (%rsp),%rdi
call   1110 <freeaddrinfo@plt>
xor    %eax,%eax
call   1040 <sockslist_free@plt>
mov    %r14d,%eax
add    $0x1c028,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.addrinfo = type { %struct.sockaddr*, i32, i32, i32 }
%struct.sockaddr = type { i32 }
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@.str = [5 x i8] c"3490\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"getaddrinfo error: %s\0A\00"
@.str.2 = [25 x i8] c"sockslist_init() is sane\00"
@.str.3 = [37 x i8] c"sockslist_add() returns successfully\00"
@.str.4 = [54 x i8] c"sockslist_getfd() works and all sockets were in array\00"
@.str.5 = [40 x i8] c"sockslist_grow() doesn't kill everybody\00"
@.str.6 = [23 x i8] c"sockslist_grow() works\00"
@.str.7 = [27 x i8] c"sockslist_remove() is sane\00"
@.str.8 = [11 x i8] c"google.com\00"
@.str.9 = [3 x i8] c"80\00"
@.str.10 = [31 x i8] c"sockslist_addConnect() is sane\00"
@.str.11 = [42 x i8] c"sockslist_addConnect() *thinks* it works.\00"
@.str.12 = [19 x i8] c"GET / HTTP/1.0\0D\0A\0D\0A\00"
@MSG_DONTWAIT = global i32 0
@.str.13 = [38 x i8] c"sockslist_addConnect() actually works\00"
@.str.14 = [17 x i8] c"reply also works\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [14336 x i8*]
%5 = alloca i32
%6 = alloca %struct.addrinfo
%7 = alloca %struct.addrinfo*
%8 = alloca %struct.sockaddr*
store i32 0, i32* %1
%9 = call i32 @memset(%struct.addrinfo* %6, i32 0, i32 24)
%10 = load i32, i32* @AF_UNSPEC
%11 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 3
store i32 %10, i32* %11
%12 = load i32, i32* @SOCK_STREAM
%13 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 2
store i32 %12, i32* %13
%14 = load i32, i32* @AI_PASSIVE
%15 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 1
store i32 %14, i32* %15
%16 = call i32 @getaddrinfo(i32* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.addrinfo* %6, %struct.addrinfo** %7)
store i32 %16, i32* %5
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %0
%19 = load i32, i32* @stderr
%20 = load i32, i32* %5
%21 = call i8* @gai_strerror(i32 %20)
%22 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %21)
store i32 1, i32* %1
br label %99
23: ; preds = %0
%24 = load %struct.addrinfo*, %struct.addrinfo** %7
%25 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %24, i32 0, i32 0
%26 = load %struct.sockaddr*, %struct.sockaddr** %25
store %struct.sockaddr* %26, %struct.sockaddr** %8
%27 = call i32 @sockslist_init(i32 2)
store i32 %27, i32* %2
%28 = load i32, i32* %2
%29 = icmp eq i32 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 @verify(i32 %30, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %2
store i32 0, i32* %3
br label %32
32: ; preds = %40, %23
%33 = load i32, i32* %3
%34 = icmp slt i32 %33, 2
br i1 %34, label %35, label %43
35: ; preds = %32
%36 = load %struct.sockaddr*, %struct.sockaddr** %8
%37 = call i32 @sockslist_add(%struct.sockaddr* %36, i32 20)
%38 = icmp sgt i32 %37, 0
%39 = zext i1 %38 to i32
store i32 %39, i32* %2
br label %40
40: ; preds = %35
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %32
43: ; preds = %32
%44 = load i32, i32* %2
%45 = call i32 @verify(i32 %44, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
store i32 0, i32* %3
br label %46
46: ; preds = %54, %43
%47 = load i32, i32* %3
%48 = icmp slt i32 %47, 2
br i1 %48, label %49, label %57
49: ; preds = %46
%50 = load i32, i32* %3
%51 = call i32 @sockslist_getfd(i32 %50)
%52 = load i32, i32* %2
%53 = add nsw i32 %52, %51
store i32 %53, i32* %2
br label %54
54: ; preds = %49
%55 = load i32, i32* %3
%56 = add nsw i32 %55, 1
store i32 %56, i32* %3
br label %46
57: ; preds = %46
store i32 40, i32* %2
%58 = call i32 @verify(i32 40, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
%59 = load %struct.sockaddr*, %struct.sockaddr** %8
%60 = call i32 @sockslist_add(%struct.sockaddr* %59, i32 20)
store i32 %60, i32* %2
%61 = load i32, i32* %2
%62 = call i32 @verify(i32 %61, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
%63 = call i32 @sockslist_getfd(i32 2)
store i32 %63, i32* %2
%64 = load i32, i32* %2
%65 = icmp eq i32 %64, 20
%66 = zext i1 %65 to i32
%67 = call i32 @verify(i32 %66, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%68 = call i32 @sockslist_remove(i32 2)
store i32 %68, i32* %2
%69 = load i32, i32* %2
%70 = icmp sgt i32 %69, 0
%71 = zext i1 %70 to i32
%72 = call i32 @verify(i32 %71, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%73 = call i32 (...) @sockslist_free()
%74 = call i32 @sockslist_init(i32 1)
%75 = call i32 @sockslist_addConnect(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
store i32 %75, i32* %2
%76 = load i32, i32* %2
%77 = icmp sge i32 %76, 0
%78 = zext i1 %77 to i32
%79 = call i32 @verify(i32 %78, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0))
%80 = load i32, i32* %2
%81 = call i32 @sockslist_isConnected(i32 %80)
%82 = call i32 @verify(i32 %81, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.11, i64 0, i64 0))
%83 = load i32, i32* %2
%84 = call i32 @sockslist_getfd(i32 %83)
store i32 %84, i32* %2
%85 = load i32, i32* %2
%86 = load i32, i32* @MSG_DONTWAIT
%87 = call i32 @send(i32 %85, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i32 18, i32 %86)
%88 = call i32 @verify(i32 %87, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.13, i64 0, i64 0))
%89 = load i32, i32* %2
%90 = getelementptr inbounds [14336 x i8*], [14336 x i8*]* %4, i64 0, i64 0
%91 = call i32 @recv(i32 %89, i8** %90, i32 13312, i32 0)
store i32 %91, i32* %2
%92 = load i32, i32* %2
%93 = icmp sgt i32 %92, 0
%94 = zext i1 %93 to i32
%95 = call i32 @verify(i32 %94, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0))
%96 = load %struct.addrinfo*, %struct.addrinfo** %7
%97 = call i32 @freeaddrinfo(%struct.addrinfo* %96)
%98 = call i32 (...) @sockslist_free()
store i32 0, i32* %1
br label %99
99: ; preds = %57, %18
%100 = load i32, i32* %1
ret i32 %100
}

LLVM IR (-O2):
%struct.addrinfo = type { %struct.sockaddr*, i32, i32, i32 }
%struct.sockaddr = type { i32 }
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@.str = [5 x i8] c"3490\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"getaddrinfo error: %s\0A\00"
@.str.2 = [25 x i8] c"sockslist_init() is sane\00"
@.str.3 = [37 x i8] c"sockslist_add() returns successfully\00"
@.str.4 = [54 x i8] c"sockslist_getfd() works and all sockets were in array\00"
@.str.5 = [40 x i8] c"sockslist_grow() doesn't kill everybody\00"
@.str.6 = [23 x i8] c"sockslist_grow() works\00"
@.str.7 = [27 x i8] c"sockslist_remove() is sane\00"
@.str.8 = [11 x i8] c"google.com\00"
@.str.9 = [3 x i8] c"80\00"
@.str.10 = [31 x i8] c"sockslist_addConnect() is sane\00"
@.str.11 = [42 x i8] c"sockslist_addConnect() *thinks* it works.\00"
@.str.12 = [19 x i8] c"GET / HTTP/1.0\0D\0A\0D\0A\00"
@MSG_DONTWAIT = global i32 0
@.str.13 = [38 x i8] c"sockslist_addConnect() actually works\00"
@.str.14 = [17 x i8] c"reply also works\00"
define i32 @main() {
%1 = alloca [14336 x i8*]
%2 = alloca %struct.addrinfo
%3 = alloca %struct.addrinfo*
%4 = bitcast [14336 x i8*]* %1 to i8*
%5 = bitcast %struct.addrinfo* %2 to i8*
%6 = bitcast %struct.addrinfo** %3 to i8*
%7 = call i32 @memset(%struct.addrinfo* %2, i32 0, i32 24)
%8 = load i32, i32* @AF_UNSPEC
%9 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %2, i64 0, i32 3
store i32 %8, i32* %9
%10 = load i32, i32* @SOCK_STREAM
%11 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %2, i64 0, i32 2
store i32 %10, i32* %11
%12 = load i32, i32* @AI_PASSIVE
%13 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %2, i64 0, i32 1
store i32 %12, i32* %13
%14 = call i32 @getaddrinfo(i32* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.addrinfo* %2, %struct.addrinfo** %3)
%15 = icmp eq i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %0
%17 = load i32, i32* @stderr
%18 = call i8* @gai_strerror(i32 %14)
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %66
20: ; preds = %0
%21 = load %struct.addrinfo*, %struct.addrinfo** %3
%22 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %21, i64 0, i32 0
%23 = load %struct.sockaddr*, %struct.sockaddr** %22
%24 = call i32 @sockslist_init(i32 2)
%25 = icmp eq i32 %24, 0
%26 = zext i1 %25 to i32
%27 = call i32 @verify(i32 %26, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @sockslist_add(%struct.sockaddr* %23, i32 20)
%29 = call i32 @sockslist_add(%struct.sockaddr* %23, i32 20)
%30 = icmp sgt i32 %29, 0
%31 = zext i1 %30 to i32
%32 = call i32 @verify(i32 %31, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 @sockslist_getfd(i32 0)
%34 = call i32 @sockslist_getfd(i32 1)
%35 = call i32 @verify(i32 40, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
%36 = call i32 @sockslist_add(%struct.sockaddr* %23, i32 20)
%37 = call i32 @verify(i32 %36, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
%38 = call i32 @sockslist_getfd(i32 2)
%39 = icmp eq i32 %38, 20
%40 = zext i1 %39 to i32
%41 = call i32 @verify(i32 %40, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%42 = call i32 @sockslist_remove(i32 2)
%43 = icmp sgt i32 %42, 0
%44 = zext i1 %43 to i32
%45 = call i32 @verify(i32 %44, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%46 = call i32 (...) @sockslist_free()
%47 = call i32 @sockslist_init(i32 1)
%48 = call i32 @sockslist_addConnect(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%49 = xor i32 %48, -1
%50 = lshr i32 %49, 31
%51 = call i32 @verify(i32 %50, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0))
%52 = call i32 @sockslist_isConnected(i32 %48)
%53 = call i32 @verify(i32 %52, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.11, i64 0, i64 0))
%54 = call i32 @sockslist_getfd(i32 %48)
%55 = load i32, i32* @MSG_DONTWAIT
%56 = call i32 @send(i32 %54, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i32 18, i32 %55)
%57 = call i32 @verify(i32 %56, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.13, i64 0, i64 0))
%58 = getelementptr inbounds [14336 x i8*], [14336 x i8*]* %1, i64 0, i64 0
%59 = call i32 @recv(i32 %54, i8** %58, i32 13312, i32 0)
%60 = icmp sgt i32 %59, 0
%61 = zext i1 %60 to i32
%62 = call i32 @verify(i32 %61, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0))
%63 = load %struct.addrinfo*, %struct.addrinfo** %3
%64 = call i32 @freeaddrinfo(%struct.addrinfo* %63)
%65 = call i32 (...) @sockslist_free()
br label %66
66: ; preds = %20, %16
%67 = phi i32 [ 1, %16 ], [ 0, %20 ]
ret i32 %67
}