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

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ AI_PASSIVE;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int *);
scalar_t__ bind(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ connect(int, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
scalar_t__ getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
scalar_t__ listen(int, int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int transfer_loop(int, int);
int main(int argc, char **argv) {
  srand(time(NULL));
  int server = 0;
  int do_fork = 0;
  if (*argv)
    for (++argv, --argc; *argv && (*argv)[0] == '-'; ++argv, --argc) {
      if (!strcmp("--server", *argv)) {
        server = 1;
      } else if (!strcmp("--fork", *argv)) {
        do_fork = 1;
      }
    }
  if (argc != 1) {
    printf("testclient --server [bind_addr:]bind_port\n"
           "testclient connect_addr:connect_port\n\n");
    printf("  [optons]\n");
    printf("  --server  : Demultiplex mode (rather than multiplex)\n");
    return 0;
  }
  char *str;
  char *addr = NULL;
  char *port = argv[0];
  for (str = argv[0]; *str; ++str) {
    if (*str == ':') {
      *str = 0;
      addr = argv[0];
      port = str + 1;
    }
  }
  struct addrinfo hints;
  struct addrinfo *baddrinfo;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_INET;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = AI_PASSIVE;
  if (getaddrinfo(addr, port, &hints, &baddrinfo)) {
    perror("getaddrinfo");
    return 1;
  }
  if (baddrinfo == NULL) {
    fprintf(stderr, "Could not get address\n");
    return 1;
  }
  if (server) {
    int sserv = socket(AF_INET, SOCK_STREAM, 0);
    if (sserv == -1) {
      perror("socket");
      return 1;
    }
    int one = 1;
    if (setsockopt(sserv, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one))) {
      perror("setsockopt");
      return 1;
    }
    if (bind(sserv, baddrinfo->ai_addr, baddrinfo->ai_addrlen)) {
      perror("bind");
      return 1;
    }
    freeaddrinfo(baddrinfo);
    if (listen(sserv, 16)) {
      perror("listen");
      return 1;
    }
    while (1) {
      union {
        struct sockaddr_in addrin;
        struct sockaddr addr;
      } cli_addr;
      socklen_t cli_len = sizeof(cli_addr.addrin);
      int cs = accept(sserv, &cli_addr.addr, &cli_len);
      if (cs == -1) {
        perror("accept");
        return 1;
      }
      if (!do_fork || fork()) {
        close(sserv);
        return transfer_loop(cs, server);
      }
      close(cs);
    }
  } else {
    int s = socket(AF_INET, SOCK_STREAM, 0);
    if (s == -1) {
      perror("socket");
      return 1;
    }
    struct addrinfo *rp;
    for (rp = baddrinfo; rp; rp = rp->ai_next) {
      if (!connect(s, rp->ai_addr, rp->ai_addrlen)) {
        freeaddrinfo(baddrinfo);
        return transfer_loop(s, server);
      }
    }
    freeaddrinfo(baddrinfo);
    fprintf(stderr, "Failed to connect\n");
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     132d <main+0x10d>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmpq   $0x0,(%rcx)
mov    %al,-0x81(%rbp)
je     12a6 <main+0x86>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
sete   %al
mov    %al,-0x81(%rbp)
mov    -0x81(%rbp),%al
test   $0x1,%al
jne    12b9 <main+0x99>
jmp    1328 <main+0x108>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd39(%rip),%rdi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    12e1 <main+0xc1>
movl   $0x1,-0x14(%rbp)
jmp    1309 <main+0xe9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd1a(%rip),%rdi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1304 <main+0xe4>
movl   $0x1,-0x18(%rbp)
jmp    1309 <main+0xe9>
jmp    130e <main+0xee>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    127a <main+0x5a>
jmp    132d <main+0x10d>
cmpl   $0x1,-0x8(%rbp)
je     1367 <main+0x147>
lea    0xcd2(%rip),%rdi
call   1040 <printf@plt>
lea    0xd17(%rip),%rdi
call   1040 <printf@plt>
lea    0xd17(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    16bb <main+0x49b>
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     13d6 <main+0x1b6>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    13c0 <main+0x1a0>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    13c5 <main+0x1a5>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1385 <main+0x165>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
mov    0x2beb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2bc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2bdb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x58(%rbp),%rcx
call   1110 <getaddrinfo@plt>
cmp    $0x0,%rax
je     1441 <main+0x221>
lea    0xc75(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    16bb <main+0x49b>
cmpq   $0x0,-0x58(%rbp)
jne    146d <main+0x24d>
mov    0x2b75(%rip),%rax
mov    (%rax),%edi
lea    0xc55(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    16bb <main+0x49b>
cmpl   $0x0,-0x14(%rbp)
je     15f5 <main+0x3d5>
mov    0x2b5a(%rip),%rax
mov    (%rax),%edi
mov    0x2b39(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0xffffffff,-0x5c(%rbp)
jne    14b5 <main+0x295>
lea    0xc24(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    16bb <main+0x49b>
movl   $0x1,-0x60(%rbp)
mov    -0x5c(%rbp),%edi
mov    0x2b22(%rip),%rax
mov    (%rax),%esi
mov    0x2ae9(%rip),%rax
mov    (%rax),%edx
lea    -0x60(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
je     1502 <main+0x2e2>
lea    0xbde(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    16bb <main+0x49b>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x58(%rbp),%rax
mov    (%rax),%edx
call   10c0 <bind@plt>
cmp    $0x0,%rax
je     1539 <main+0x319>
lea    0xbb2(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    16bb <main+0x49b>
mov    -0x58(%rbp),%rdi
call   1130 <freeaddrinfo@plt>
mov    -0x5c(%rbp),%edi
mov    $0x10,%esi
call   10b0 <listen@plt>
cmp    $0x0,%rax
je     1571 <main+0x351>
lea    0xb7f(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    16bb <main+0x49b>
jmp    1576 <main+0x356>
movl   $0x4,-0x6c(%rbp)
mov    -0x5c(%rbp),%edi
lea    -0x68(%rbp),%rsi
lea    -0x6c(%rbp),%rdx
call   10f0 <accept@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0xffffffff,-0x70(%rbp)
jne    15b2 <main+0x392>
lea    0xb45(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    16bb <main+0x49b>
cmpl   $0x0,-0x18(%rbp)
je     15cd <main+0x3ad>
mov    $0x0,%al
call   1120 <fork@plt>
cmp    $0x0,%rax
je     15e8 <main+0x3c8>
mov    -0x5c(%rbp),%edi
call   1060 <close@plt>
mov    -0x70(%rbp),%edi
mov    -0x14(%rbp),%esi
call   10d0 <transfer_loop@plt>
mov    %eax,-0x4(%rbp)
jmp    16bb <main+0x49b>
mov    -0x70(%rbp),%edi
call   1060 <close@plt>
jmp    1576 <main+0x356>
mov    0x29dc(%rip),%rax
mov    (%rax),%edi
mov    0x29bb(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0xffffffff,-0x74(%rbp)
jne    1633 <main+0x413>
lea    0xaa6(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    16bb <main+0x49b>
mov    -0x58(%rbp),%rax
mov    %rax,-0x80(%rbp)
cmpq   $0x0,-0x80(%rbp)
je     1696 <main+0x476>
mov    -0x74(%rbp),%edi
mov    -0x80(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x80(%rbp),%rax
mov    (%rax),%edx
call   1100 <connect@plt>
cmp    $0x0,%eax
jne    1680 <main+0x460>
mov    -0x58(%rbp),%rdi
call   1130 <freeaddrinfo@plt>
mov    -0x74(%rbp),%edi
mov    -0x14(%rbp),%esi
call   10d0 <transfer_loop@plt>
mov    %eax,-0x4(%rbp)
jmp    16bb <main+0x49b>
jmp    1685 <main+0x465>
mov    -0x80(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x80(%rbp)
jmp    163b <main+0x41b>
mov    -0x58(%rbp),%rdi
call   1130 <freeaddrinfo@plt>
mov    0x2922(%rip),%rax
mov    (%rax),%edi
lea    0xa3e(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
xor    %ebx,%ebx
xor    %edi,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
cmpq   $0x0,(%r14)
je     12c8 <main+0xa8>
add    $0xffffffff,%ebp
mov    0x8(%r14),%rbx
add    $0x8,%r14
test   %rbx,%rbx
je     12c6 <main+0xa6>
lea    0xda0(%rip),%r15
mov    $0x1,%r12d
xor    %r13d,%r13d
movl   $0x0,(%rsp)
jmp    12a9 <main+0x89>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xd82(%rip),%rdi
mov    %rbx,%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
cmove  %r12d,%r13d
add    $0xffffffff,%ebp
mov    0x8(%r14),%rbx
add    $0x8,%r14
test   %rbx,%rbx
je     147d <main+0x25d>
cmpb   $0x2d,(%rbx)
jne    12d2 <main+0xb2>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
jne    1280 <main+0x60>
movl   $0x1,(%rsp)
jmp    1295 <main+0x75>
xor    %ebx,%ebx
movl   $0x0,(%rsp)
xor    %r13d,%r13d
cmp    $0x1,%ebp
jne    1488 <main+0x268>
lea    0x1(%rbx),%rax
xor    %ebp,%ebp
jmp    12fe <main+0xde>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movb   $0x0,-0x1(%rax)
mov    (%r14),%rbp
mov    %rax,%rbx
add    $0x1,%rax
movzbl -0x1(%rax),%ecx
cmp    $0x3a,%cl
je     12f0 <main+0xd0>
test   %cl,%cl
jne    12fa <main+0xda>
lea    0x18(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
mov    0x2cb2(%rip),%r15
mov    (%r15),%eax
mov    %eax,0x30(%rsp)
mov    0x2c8c(%rip),%r12
mov    (%r12),%eax
mov    %eax,0x2c(%rsp)
mov    0x2c9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
lea    0x8(%rsp),%rcx
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1110 <getaddrinfo@plt>
test   %rax,%rax
jne    155f <main+0x33f>
cmpq   $0x0,0x8(%rsp)
je     14b3 <main+0x293>
mov    (%r15),%edi
mov    (%r12),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,%ebx
cmpl   $0x0,(%rsp)
je     14c5 <main+0x2a5>
cmp    $0xffffffff,%ebx
je     156d <main+0x34d>
movl   $0x1,0x14(%rsp)
mov    0x2c45(%rip),%rax
mov    (%rax),%esi
mov    0x2c0c(%rip),%rax
mov    (%rax),%edx
lea    0x14(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
jne    157b <main+0x35b>
mov    0x8(%rsp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %ebx,%edi
call   10c0 <bind@plt>
test   %rax,%rax
jne    1589 <main+0x369>
mov    0x8(%rsp),%rdi
call   1130 <freeaddrinfo@plt>
mov    %ebx,%edi
mov    $0x10,%esi
call   10b0 <listen@plt>
test   %rax,%rax
jne    1597 <main+0x377>
movl   $0x4,0x4(%rsp)
lea    0x10(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %ebx,%edi
call   10f0 <accept@plt>
cmp    $0xffffffff,%eax
je     146c <main+0x24c>
mov    %eax,%r14d
lea    0x10(%rsp),%r15
lea    0x4(%rsp),%r12
mov    %eax,%ebp
nop
test   %r13d,%r13d
je     1504 <main+0x2e4>
xor    %eax,%eax
call   1120 <fork@plt>
test   %rax,%rax
jne    1501 <main+0x2e1>
mov    %ebp,%edi
call   1060 <close@plt>
movl   $0x4,0x4(%rsp)
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   10f0 <accept@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    1430 <main+0x210>
lea    0xbde(%rip),%rdi
call   10e0 <perror@plt>
jmp    1536 <main+0x316>
xor    %ebx,%ebx
cmp    $0x1,%ebp
je     12db <main+0xbb>
lea    0xbdc(%rip),%rdi
call   1030 <puts@plt>
lea    0xc20(%rip),%rdi
call   1030 <puts@plt>
lea    0xc1f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
jmp    153b <main+0x31b>
mov    0x2b0e(%rip),%rax
mov    (%rax),%edi
lea    0xb59(%rip),%rsi
jmp    1531 <main+0x311>
cmp    $0xffffffff,%ebx
je     156d <main+0x34d>
mov    0x8(%rsp),%rbp
test   %rbp,%rbp
je     151a <main+0x2fa>
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp),%edx
mov    0x4(%rbp),%esi
mov    %ebx,%edi
call   1100 <connect@plt>
test   %eax,%eax
je     154a <main+0x32a>
mov    0x8(%rbp),%rbp
test   %rbp,%rbp
jne    14e0 <main+0x2c0>
mov    0x8(%rsp),%rdi
jmp    151c <main+0x2fc>
mov    %ebp,%r14d
mov    %ebx,%edi
call   1060 <close@plt>
mov    %r14d,%edi
mov    $0x1,%esi
call   10d0 <transfer_loop@plt>
jmp    153b <main+0x31b>
xor    %edi,%edi
call   1130 <freeaddrinfo@plt>
mov    0x2aa0(%rip),%rax
mov    (%rax),%edi
lea    0xb27(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%rdi
call   1130 <freeaddrinfo@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   10d0 <transfer_loop@plt>
jmp    153b <main+0x31b>
lea    0xaaa(%rip),%rdi
call   10e0 <perror@plt>
jmp    1536 <main+0x316>
lea    0xabf(%rip),%rdi
call   10e0 <perror@plt>
jmp    1536 <main+0x316>
lea    0xab8(%rip),%rdi
call   10e0 <perror@plt>
jmp    1536 <main+0x316>
lea    0xab5(%rip),%rdi
call   10e0 <perror@plt>
jmp    1536 <main+0x316>
lea    0xaac(%rip),%rdi
call   10e0 <perror@plt>
jmp    1536 <main+0x316>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, %struct.addrinfo*, i32, i32, i32 }
%union.anon = type { %struct.sockaddr_in }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [9 x i8] c"--server\00"
@.str.1 = [7 x i8] c"--fork\00"
@.str.2 = [81 x i8] c"testclient --server [bind_addr:]bind_port\0Atestclient connect_addr:connect_port\0A\0A\00"
@.str.3 = [12 x i8] c" [optons]\0A\00"
@.str.4 = [56 x i8] c" --server : Demultiplex mode (rather than multiplex)\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@.str.5 = [12 x i8] c"getaddrinfo\00"
@stderr = global i32 0
@.str.6 = [23 x i8] c"Could not get address\0A\00"
@.str.7 = [7 x i8] c"socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.8 = [11 x i8] c"setsockopt\00"
@.str.9 = [5 x i8] c"bind\00"
@.str.10 = [7 x i8] c"listen\00"
@.str.11 = [7 x i8] c"accept\00"
@.str.12 = [19 x i8] c"Failed to connect\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca %struct.addrinfo
%12 = alloca %struct.addrinfo*
%13 = alloca i32
%14 = alloca i32
%15 = alloca %union.anon
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca %struct.addrinfo*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = call i32 @time(i32* null)
%21 = call i32 @srand(i32 %20)
store i32 0, i32* %6
store i32 0, i32* %7
%22 = load i8**, i8*** %5
%23 = load i8*, i8** %22
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %63
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i32 1
store i8** %27, i8*** %5
%28 = load i32, i32* %4
%29 = add nsw i32 %28, -1
store i32 %29, i32* %4
br label %30
30: ; preds = %57, %25
%31 = load i8**, i8*** %5
%32 = load i8*, i8** %31
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %41
34: ; preds = %30
%35 = load i8**, i8*** %5
%36 = load i8*, i8** %35
%37 = getelementptr inbounds i8, i8* %36, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 45
br label %41
41: ; preds = %34, %30
%42 = phi i1 [ false, %30 ], [ %40, %34 ]
br i1 %42, label %43, label %62
43: ; preds = %41
%44 = load i8**, i8*** %5
%45 = load i8*, i8** %44
%46 = call i32 @strcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %49, label %48
48: ; preds = %43
store i32 1, i32* %6
br label %56
49: ; preds = %43
%50 = load i8**, i8*** %5
%51 = load i8*, i8** %50
%52 = call i32 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %51)
%53 = icmp ne i32 %52, 0
br i1 %53, label %55, label %54
54: ; preds = %49
store i32 1, i32* %7
br label %55
55: ; preds = %54, %49
br label %56
56: ; preds = %55, %48
br label %57
57: ; preds = %56
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i32 1
store i8** %59, i8*** %5
%60 = load i32, i32* %4
%61 = add nsw i32 %60, -1
store i32 %61, i32* %4
br label %30
62: ; preds = %41
br label %63
63: ; preds = %62, %2
%64 = load i32, i32* %4
%65 = icmp ne i32 %64, 1
br i1 %65, label %66, label %70
66: ; preds = %63
%67 = call i32 @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.2, i64 0, i64 0))
%68 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%69 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %219
70: ; preds = %63
store i8* null, i8** %9
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 0
%73 = load i8*, i8** %72
store i8* %73, i8** %10
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 0
%76 = load i8*, i8** %75
store i8* %76, i8** %8
br label %77
77: ; preds = %94, %70
%78 = load i8*, i8** %8
%79 = load i8, i8* %78
%80 = icmp ne i8 %79, 0
br i1 %80, label %81, label %97
81: ; preds = %77
%82 = load i8*, i8** %8
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = icmp eq i32 %84, 58
br i1 %85, label %86, label %93
86: ; preds = %81
%87 = load i8*, i8** %8
store i8 0, i8* %87
%88 = load i8**, i8*** %5
%89 = getelementptr inbounds i8*, i8** %88, i64 0
%90 = load i8*, i8** %89
store i8* %90, i8** %9
%91 = load i8*, i8** %8
%92 = getelementptr inbounds i8, i8* %91, i64 1
store i8* %92, i8** %10
br label %93
93: ; preds = %86, %81
br label %94
94: ; preds = %93
%95 = load i8*, i8** %8
%96 = getelementptr inbounds i8, i8* %95, i32 1
store i8* %96, i8** %8
br label %77
97: ; preds = %77
%98 = call i32 @memset(%struct.addrinfo* %11, i32 0, i32 32)
%99 = load i32, i32* @AF_INET
%100 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %11, i32 0, i32 5
store i32 %99, i32* %100
%101 = load i32, i32* @SOCK_STREAM
%102 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %11, i32 0, i32 4
store i32 %101, i32* %102
%103 = load i32, i32* @AI_PASSIVE
%104 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %11, i32 0, i32 3
store i32 %103, i32* %104
%105 = load i8*, i8** %9
%106 = load i8*, i8** %10
%107 = call i64 @getaddrinfo(i8* %105, i8* %106, %struct.addrinfo* %11, %struct.addrinfo** %12)
%108 = icmp ne i64 %107, 0
br i1 %108, label %109, label %111
109: ; preds = %97
%110 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %219
111: ; preds = %97
%112 = load %struct.addrinfo*, %struct.addrinfo** %12
%113 = icmp eq %struct.addrinfo* %112, null
br i1 %113, label %114, label %117
114: ; preds = %111
%115 = load i32, i32* @stderr
%116 = call i32 @fprintf(i32 %115, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %219
117: ; preds = %111
%118 = load i32, i32* %6
%119 = icmp ne i32 %118, 0
br i1 %119, label %120, label %180
120: ; preds = %117
%121 = load i32, i32* @AF_INET
%122 = load i32, i32* @SOCK_STREAM
%123 = call i32 @socket(i32 %121, i32 %122, i32 0)
store i32 %123, i32* %13
%124 = load i32, i32* %13
%125 = icmp eq i32 %124, -1
br i1 %125, label %126, label %128
126: ; preds = %120
%127 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %219
128: ; preds = %120
store i32 1, i32* %14
%129 = load i32, i32* %13
%130 = load i32, i32* @SOL_SOCKET
%131 = load i32, i32* @SO_REUSEADDR
%132 = call i64 @setsockopt(i32 %129, i32 %130, i32 %131, i32* %14, i32 4)
%133 = icmp ne i64 %132, 0
br i1 %133, label %134, label %136
134: ; preds = %128
%135 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
br label %219
136: ; preds = %128
%137 = load i32, i32* %13
%138 = load %struct.addrinfo*, %struct.addrinfo** %12
%139 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %138, i32 0, i32 1
%140 = load i32, i32* %139
%141 = load %struct.addrinfo*, %struct.addrinfo** %12
%142 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %141, i32 0, i32 0
%143 = load i32, i32* %142
%144 = call i64 @bind(i32 %137, i32 %140, i32 %143)
%145 = icmp ne i64 %144, 0
br i1 %145, label %146, label %148
146: ; preds = %136
%147 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %3
br label %219
148: ; preds = %136
%149 = load %struct.addrinfo*, %struct.addrinfo** %12
%150 = call i32 @freeaddrinfo(%struct.addrinfo* %149)
%151 = load i32, i32* %13
%152 = call i64 @listen(i32 %151, i32 16)
%153 = icmp ne i64 %152, 0
br i1 %153, label %154, label %156
154: ; preds = %148
%155 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %3
br label %219
156: ; preds = %148
br label %157
157: ; preds = %156, %177
store i32 4, i32* %16
%158 = load i32, i32* %13
%159 = bitcast %union.anon* %15 to %struct.sockaddr*
%160 = call i32 @accept(i32 %158, %struct.sockaddr* %159, i32* %16)
store i32 %160, i32* %17
%161 = load i32, i32* %17
%162 = icmp eq i32 %161, -1
br i1 %162, label %163, label %165
163: ; preds = %157
%164 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %3
br label %219
165: ; preds = %157
%166 = load i32, i32* %7
%167 = icmp ne i32 %166, 0
br i1 %167, label %168, label %171
168: ; preds = %165
%169 = call i64 (...) @fork()
%170 = icmp ne i64 %169, 0
br i1 %170, label %171, label %177
171: ; preds = %168, %165
%172 = load i32, i32* %13
%173 = call i32 @close(i32 %172)
%174 = load i32, i32* %17
%175 = load i32, i32* %6
%176 = call i32 @transfer_loop(i32 %174, i32 %175)
store i32 %176, i32* %3
br label %219
177: ; preds = %168
%178 = load i32, i32* %17
%179 = call i32 @close(i32 %178)
br label %157
180: ; preds = %117
%181 = load i32, i32* @AF_INET
%182 = load i32, i32* @SOCK_STREAM
%183 = call i32 @socket(i32 %181, i32 %182, i32 0)
store i32 %183, i32* %18
%184 = load i32, i32* %18
%185 = icmp eq i32 %184, -1
br i1 %185, label %186, label %188
186: ; preds = %180
%187 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %219
188: ; preds = %180
%189 = load %struct.addrinfo*, %struct.addrinfo** %12
store %struct.addrinfo* %189, %struct.addrinfo** %19
br label %190
190: ; preds = %210, %188
%191 = load %struct.addrinfo*, %struct.addrinfo** %19
%192 = icmp ne %struct.addrinfo* %191, null
br i1 %192, label %193, label %214
193: ; preds = %190
%194 = load i32, i32* %18
%195 = load %struct.addrinfo*, %struct.addrinfo** %19
%196 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %195, i32 0, i32 1
%197 = load i32, i32* %196
%198 = load %struct.addrinfo*, %struct.addrinfo** %19
%199 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %198, i32 0, i32 0
%200 = load i32, i32* %199
%201 = call i32 @connect(i32 %194, i32 %197, i32 %200)
%202 = icmp ne i32 %201, 0
br i1 %202, label %209, label %203
203: ; preds = %193
%204 = load %struct.addrinfo*, %struct.addrinfo** %12
%205 = call i32 @freeaddrinfo(%struct.addrinfo* %204)
%206 = load i32, i32* %18
%207 = load i32, i32* %6
%208 = call i32 @transfer_loop(i32 %206, i32 %207)
store i32 %208, i32* %3
br label %219
209: ; preds = %193
br label %210
210: ; preds = %209
%211 = load %struct.addrinfo*, %struct.addrinfo** %19
%212 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %211, i32 0, i32 2
%213 = load %struct.addrinfo*, %struct.addrinfo** %212
store %struct.addrinfo* %213, %struct.addrinfo** %19
br label %190
214: ; preds = %190
%215 = load %struct.addrinfo*, %struct.addrinfo** %12
%216 = call i32 @freeaddrinfo(%struct.addrinfo* %215)
%217 = load i32, i32* @stderr
%218 = call i32 @fprintf(i32 %217, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
store i32 1, i32* %3
br label %219
219: ; preds = %214, %203, %186, %171, %163, %154, %146, %134, %126, %114, %109, %66
%220 = load i32, i32* %3
ret i32 %220
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, %struct.addrinfo*, i32, i32, i32 }
%union.anon = type { %struct.sockaddr_in }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [9 x i8] c"--server\00"
@.str.1 = [7 x i8] c"--fork\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@.str.5 = [12 x i8] c"getaddrinfo\00"
@stderr = global i32 0
@.str.6 = [23 x i8] c"Could not get address\0A\00"
@.str.7 = [7 x i8] c"socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.8 = [11 x i8] c"setsockopt\00"
@.str.9 = [5 x i8] c"bind\00"
@.str.10 = [7 x i8] c"listen\00"
@.str.11 = [7 x i8] c"accept\00"
@.str.12 = [19 x i8] c"Failed to connect\0A\00"
@str = [80 x i8] c"testclient --server [bind_addr:]bind_port\0Atestclient connect_addr:connect_port\0A\00"
@str.13 = [11 x i8] c" [optons]\00"
@str.14 = [55 x i8] c" --server : Demultiplex mode (rather than multiplex)\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca i32
%6 = alloca %union.anon
%7 = alloca i32
%8 = tail call i32 @time(i32* null)
%9 = tail call i32 @srand(i32 %8)
%10 = load i8*, i8** %1
%11 = icmp eq i8* %10, null
br i1 %11, label %39, label %12
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = add nsw i32 %0, -1
%15 = load i8*, i8** %13
%16 = icmp eq i8* %15, null
br i1 %16, label %39, label %17
17: ; preds = %12, %32
%18 = phi i8* [ %37, %32 ], [ %15, %12 ]
%19 = phi i32 [ %36, %32 ], [ %14, %12 ]
%20 = phi i8** [ %35, %32 ], [ %13, %12 ]
%21 = phi i32 [ %34, %32 ], [ 0, %12 ]
%22 = phi i32 [ %33, %32 ], [ 0, %12 ]
%23 = load i8, i8* %18
%24 = icmp eq i8 %23, 45
br i1 %24, label %25, label %39
25: ; preds = %17
%26 = tail call i32 @strcmp(i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %18)
%27 = icmp eq i32 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %25
%29 = tail call i32 @strcmp(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%30 = icmp eq i32 %29, 0
%31 = select i1 %30, i32 1, i32 %21
br label %32
32: ; preds = %28, %25
%33 = phi i32 [ 1, %25 ], [ %22, %28 ]
%34 = phi i32 [ %21, %25 ], [ %31, %28 ]
%35 = getelementptr inbounds i8*, i8** %20, i64 1
%36 = add nsw i32 %19, -1
%37 = load i8*, i8** %35
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %17
39: ; preds = %32, %17, %12, %2
%40 = phi i8* [ null, %2 ], [ null, %12 ], [ null, %32 ], [ %18, %17 ]
%41 = phi i32 [ 0, %2 ], [ 0, %12 ], [ %33, %32 ], [ %22, %17 ]
%42 = phi i32 [ 0, %2 ], [ 0, %12 ], [ %34, %32 ], [ %21, %17 ]
%43 = phi i8** [ %1, %2 ], [ %13, %12 ], [ %35, %32 ], [ %20, %17 ]
%44 = phi i32 [ %0, %2 ], [ %14, %12 ], [ %36, %32 ], [ %19, %17 ]
%45 = icmp eq i32 %44, 1
br i1 %45, label %50, label %46
46: ; preds = %39
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str, i64 0, i64 0))
%48 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.13, i64 0, i64 0))
%49 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.14, i64 0, i64 0))
br label %174
50: ; preds = %39, %58
%51 = phi i8* [ %61, %58 ], [ %40, %39 ]
%52 = phi i8* [ %59, %58 ], [ null, %39 ]
%53 = phi i8* [ %60, %58 ], [ %40, %39 ]
%54 = load i8, i8* %51
switch i8 %54, label %58 [
i8 0, label %62
i8 58, label %55
]
55: ; preds = %50
store i8 0, i8* %51
%56 = load i8*, i8** %43
%57 = getelementptr inbounds i8, i8* %51, i64 1
br label %58
58: ; preds = %50, %55
%59 = phi i8* [ %56, %55 ], [ %52, %50 ]
%60 = phi i8* [ %57, %55 ], [ %53, %50 ]
%61 = getelementptr inbounds i8, i8* %51, i64 1
br label %50
62: ; preds = %50
%63 = bitcast %struct.addrinfo* %3 to i8*
%64 = bitcast %struct.addrinfo** %4 to i8*
%65 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 32)
%66 = load i32, i32* @AF_INET
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 5
store i32 %66, i32* %67
%68 = load i32, i32* @SOCK_STREAM
%69 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 4
store i32 %68, i32* %69
%70 = load i32, i32* @AI_PASSIVE
%71 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 3
store i32 %70, i32* %71
%72 = call i64 @getaddrinfo(i8* %52, i8* %53, %struct.addrinfo* %3, %struct.addrinfo** %4)
%73 = icmp eq i64 %72, 0
br i1 %73, label %76, label %74
74: ; preds = %62
%75 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %172
76: ; preds = %62
%77 = load %struct.addrinfo*, %struct.addrinfo** %4
%78 = icmp eq %struct.addrinfo* %77, null
br i1 %78, label %79, label %82
79: ; preds = %76
%80 = load i32, i32* @stderr
%81 = call i32 @fprintf(i32 %80, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %172
82: ; preds = %76
%83 = icmp eq i32 %41, 0
%84 = load i32, i32* @AF_INET
%85 = load i32, i32* @SOCK_STREAM
%86 = call i32 @socket(i32 %84, i32 %85, i32 0)
%87 = icmp eq i32 %86, -1
br i1 %83, label %143, label %88
88: ; preds = %82
br i1 %87, label %89, label %91
89: ; preds = %88
%90 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %172
91: ; preds = %88
%92 = bitcast i32* %5 to i8*
store i32 1, i32* %5
%93 = load i32, i32* @SOL_SOCKET
%94 = load i32, i32* @SO_REUSEADDR
%95 = call i64 @setsockopt(i32 %86, i32 %93, i32 %94, i32* %5, i32 4)
%96 = icmp eq i64 %95, 0
br i1 %96, label %99, label %97
97: ; preds = %91
%98 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
br label %141
99: ; preds = %91
%100 = load %struct.addrinfo*, %struct.addrinfo** %4
%101 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %100, i64 0, i32 1
%102 = load i32, i32* %101
%103 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %100, i64 0, i32 0
%104 = load i32, i32* %103
%105 = call i64 @bind(i32 %86, i32 %102, i32 %104)
%106 = icmp eq i64 %105, 0
br i1 %106, label %109, label %107
107: ; preds = %99
%108 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %141
109: ; preds = %99
%110 = load %struct.addrinfo*, %struct.addrinfo** %4
%111 = call i32 @freeaddrinfo(%struct.addrinfo* %110)
%112 = call i64 @listen(i32 %86, i32 16)
%113 = icmp eq i64 %112, 0
br i1 %113, label %114, label %122
114: ; preds = %109
%115 = bitcast %union.anon* %6 to i8*
%116 = bitcast i32* %7 to i8*
%117 = bitcast %union.anon* %6 to %struct.sockaddr*
store i32 4, i32* %7
%118 = call i32 @accept(i32 %86, %struct.sockaddr* %117, i32* %7)
%119 = icmp eq i32 %118, -1
br i1 %119, label %124, label %120
120: ; preds = %114
%121 = icmp eq i32 %42, 0
br label %126
122: ; preds = %109
%123 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
br label %141
124: ; preds = %137, %114
%125 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
br label %135
126: ; preds = %120, %137
%127 = phi i32 [ %118, %120 ], [ %139, %137 ]
br i1 %121, label %131, label %128
128: ; preds = %126
%129 = call i64 (...) @fork()
%130 = icmp eq i64 %129, 0
br i1 %130, label %137, label %131
131: ; preds = %128, %126
%132 = phi i32 [ %127, %128 ], [ %118, %126 ]
%133 = call i32 @close(i32 %86)
%134 = call i32 @transfer_loop(i32 %132, i32 1)
br label %135
135: ; preds = %131, %124
%136 = phi i32 [ 1, %124 ], [ %134, %131 ]
br label %141
137: ; preds = %128
%138 = call i32 @close(i32 %127)
store i32 4, i32* %7
%139 = call i32 @accept(i32 %86, %struct.sockaddr* %117, i32* %7)
%140 = icmp eq i32 %139, -1
br i1 %140, label %124, label %126
141: ; preds = %135, %122, %107, %97
%142 = phi i32 [ 1, %97 ], [ 1, %107 ], [ 1, %122 ], [ %136, %135 ]
br label %172
143: ; preds = %82
br i1 %87, label %147, label %144
144: ; preds = %143
%145 = load %struct.addrinfo*, %struct.addrinfo** %4
%146 = icmp eq %struct.addrinfo* %145, null
br i1 %146, label %167, label %153
147: ; preds = %143
%148 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %172
149: ; preds = %153
%150 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %154, i64 0, i32 2
%151 = load %struct.addrinfo*, %struct.addrinfo** %150
%152 = icmp eq %struct.addrinfo* %151, null
br i1 %152, label %165, label %153
153: ; preds = %144, %149
%154 = phi %struct.addrinfo* [ %151, %149 ], [ %145, %144 ]
%155 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %154, i64 0, i32 1
%156 = load i32, i32* %155
%157 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %154, i64 0, i32 0
%158 = load i32, i32* %157
%159 = call i32 @connect(i32 %86, i32 %156, i32 %158)
%160 = icmp eq i32 %159, 0
br i1 %160, label %161, label %149
161: ; preds = %153
%162 = load %struct.addrinfo*, %struct.addrinfo** %4
%163 = call i32 @freeaddrinfo(%struct.addrinfo* %162)
%164 = call i32 @transfer_loop(i32 %86, i32 0)
br label %172
165: ; preds = %149
%166 = load %struct.addrinfo*, %struct.addrinfo** %4
br label %167
167: ; preds = %165, %144
%168 = phi %struct.addrinfo* [ %166, %165 ], [ null, %144 ]
%169 = call i32 @freeaddrinfo(%struct.addrinfo* %168)
%170 = load i32, i32* @stderr
%171 = call i32 @fprintf(i32 %170, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %172
172: ; preds = %147, %167, %161, %89, %141, %79, %74
%173 = phi i32 [ 1, %74 ], [ 1, %79 ], [ 1, %89 ], [ %142, %141 ], [ 1, %147 ], [ %164, %161 ], [ 1, %167 ]
br label %174
174: ; preds = %172, %46
%175 = phi i32 [ 0, %46 ], [ %173, %172 ]
ret i32 %175
}