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

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
void *AI_PASSIVE;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
int chat(int, char *, char *, char *, char *);
int client(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ connect(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int /*<<< orphan*/ getaddrinfo(char *, char *, struct addrinfo *,
                               struct addrinfo **);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ input(char *, char *);
char *malloc(int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int server(int, int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
           int /*<<< orphan*/, int /*<<< orphan*/, int, struct sockaddr_storage,
           int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  struct sockaddr_storage client_addr;
  socklen_t addr_size;
  struct addrinfo hints, *res;
  int sock, client_sock, listencount, backlog, chatval, clientcount;
  char ip[17], port[7];
  char *recv_buffer;
  recv_buffer = malloc(256 * sizeof(char));
  char *buffer;
  buffer = malloc(256 * sizeof(char));
  char *name;
  name = malloc(32 * sizeof(char));
  char *recv_name;
  recv_name = malloc(32 * sizeof(char));
  if (argc < 2) {
    fprintf(stderr, "Too few arguments. Usage: ./main $PORT or ./main -c "
                    "$IP_ADDRESS $PORT\n");
    exit(1);
  } else if (argc == 3) {
    fprintf(stderr, "Bad number of arguments. Usage: ./main $PORT or ./main -c "
                    "$IP_ADDRESS $PORT\n");
    exit(1);
  } else if (argc > 4) {
    fprintf(stderr, "Too many arguments. Usage: ./main $PORT or ./main -c "
                    "$IP_ADDRESS $PORT\n");
    exit(1);
  } else {
    input(name, buffer);
  }
  if ((strcmp(argv[1], "-c")) == 0) {
    clientcount = 1;
  } else {
    clientcount = 0;
  }
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  if (clientcount == 1) {
    getaddrinfo(argv[2], argv[3], &hints, &res);
  } else {
    hints.ai_flags = AI_PASSIVE;
    getaddrinfo(NULL, argv[1], &hints, &res);
  }
  if (clientcount == 1) {
    client_sock = client(res->ai_family, res->ai_socktype, res->ai_protocol,
                         res->ai_addr, res->ai_addrlen);
    listencount = 0;
  } else {
    client_sock =
        server(sock, res->ai_family, res->ai_socktype, res->ai_protocol,
               res->ai_addr, res->ai_addrlen, backlog, client_addr, addr_size);
    listencount = 1;
  }
  chatval = chat(client_sock, name, recv_name, buffer, recv_buffer);
  while (chatval != 0) {
    close(client_sock);
    if (chatval == 1) {
      if (listencount == 0) {
        freeaddrinfo(res);
        hints.ai_flags = AI_PASSIVE;
        getaddrinfo(NULL, argv[1], &hints, &res);
        client_sock = server(sock, res->ai_family, res->ai_socktype,
                             res->ai_protocol, res->ai_addr, res->ai_addrlen,
                             backlog, client_addr, addr_size);
        listencount = 1;
      } else {
        client_sock = accept(sock, (struct sockaddr *)&client_addr, &addr_size);
      }
    } else {
      freeaddrinfo(res);
      printf("IP ADDRESS:");
      gets(ip);
      printf("PORT:");
      gets(port);
      getaddrinfo(ip, port, &hints, &res);
      if (clientcount == 0) {
        client_sock = client(res->ai_family, res->ai_socktype, res->ai_protocol,
                             res->ai_addr, res->ai_addrlen);
      } else {
        connect(client_sock, res->ai_addr, res->ai_addrlen);
      }
    }
    printf("%s: ", name);
    fgets(buffer, 250, stdin);
    chatval = chat(client_sock, name, recv_name, buffer, recv_buffer);
  }
  if ((strcmp(recv_buffer, "/quit\n")) == 0) {
    printf("Other side quit. Hopefully they had the common courtesy to say "
           "good bye first. The very last message was not relayed.\n");
  } else {
    send(client_sock, buffer, 256, 0);
  }
  freeaddrinfo(res);
  close(client_sock);
  if (listencount == 1)
    close(sock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x100,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x90(%rbp)
mov    $0x100,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x98(%rbp)
mov    $0x20,%edi
call   10e0 <malloc@plt>
mov    %rax,-0xa0(%rbp)
mov    $0x20,%edi
call   10e0 <malloc@plt>
mov    %rax,-0xa8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    12a6 <main+0x86>
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
lea    0xd69(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
cmpl   $0x3,-0x8(%rbp)
jne    12cf <main+0xaf>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
lea    0xd87(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jle    12f8 <main+0xd8>
mov    0x2ce8(%rip),%rax
mov    (%rax),%edi
lea    0xdab(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1030 <input@plt>
jmp    1310 <main+0xf0>
jmp    1315 <main+0xf5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdb8(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    133f <main+0x11f>
movl   $0x1,-0x60(%rbp)
jmp    1346 <main+0x126>
movl   $0x0,-0x60(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
mov    0x2c83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2c57(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x1,-0x60(%rbp)
jne    139a <main+0x17a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1130 <getaddrinfo@plt>
jmp    13c1 <main+0x1a1>
mov    0x2c47(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1130 <getaddrinfo@plt>
cmpl   $0x1,-0x60(%rbp)
jne    1402 <main+0x1e2>
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x48(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%edx
mov    -0x48(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x48(%rbp),%rax
mov    (%rax),%r8d
call   1100 <client@plt>
mov    %eax,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
jmp    1450 <main+0x230>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%esi
mov    -0x48(%rbp),%rax
mov    0xc(%rax),%edx
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x48(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x48(%rbp),%rax
mov    (%rax),%r9d
mov    -0x58(%rbp),%r11d
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%r10d
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   10d0 <server@plt>
mov    %eax,-0x50(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x50(%rbp),%edi
mov    -0xa0(%rbp),%rsi
mov    -0xa8(%rbp),%rdx
mov    -0x98(%rbp),%rcx
mov    -0x90(%rbp),%r8
call   1040 <chat@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
je     1639 <main+0x419>
mov    -0x50(%rbp),%edi
call   1080 <close@plt>
cmpl   $0x1,-0x5c(%rbp)
jne    1538 <main+0x318>
cmpl   $0x0,-0x54(%rbp)
jne    1520 <main+0x300>
mov    -0x48(%rbp),%rdi
call   1140 <freeaddrinfo@plt>
mov    0x2b3b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1130 <getaddrinfo@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%esi
mov    -0x48(%rbp),%rax
mov    0xc(%rax),%edx
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x48(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x48(%rbp),%rax
mov    (%rax),%r9d
mov    -0x58(%rbp),%r11d
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%r10d
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   10d0 <server@plt>
mov    %eax,-0x50(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    1533 <main+0x313>
mov    -0x4c(%rbp),%edi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   10f0 <accept@plt>
mov    %eax,-0x50(%rbp)
jmp    15de <main+0x3be>
mov    -0x48(%rbp),%rdi
call   1140 <freeaddrinfo@plt>
lea    0xb97(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x80(%rbp),%rdi
call   10c0 <gets@plt>
lea    0xb8c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x87(%rbp),%rdi
call   10c0 <gets@plt>
lea    -0x80(%rbp),%rdi
lea    -0x87(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1130 <getaddrinfo@plt>
cmpl   $0x0,-0x60(%rbp)
jne    15c4 <main+0x3a4>
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x48(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%edx
mov    -0x48(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x48(%rbp),%rax
mov    (%rax),%r8d
call   1100 <client@plt>
mov    %eax,-0x50(%rbp)
jmp    15d9 <main+0x3b9>
mov    -0x50(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x48(%rbp),%rax
mov    (%rax),%edx
call   1120 <connect@plt>
jmp    15de <main+0x3be>
mov    -0xa0(%rbp),%rsi
lea    0xb05(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x98(%rbp),%rdi
mov    0x29d7(%rip),%rax
mov    (%rax),%edx
mov    $0xfa,%esi
call   1090 <fgets@plt>
mov    -0x50(%rbp),%edi
mov    -0xa0(%rbp),%rsi
mov    -0xa8(%rbp),%rdx
mov    -0x98(%rbp),%rcx
mov    -0x90(%rbp),%r8
call   1040 <chat@plt>
mov    %eax,-0x5c(%rbp)
jmp    1477 <main+0x257>
mov    -0x90(%rbp),%rdi
lea    0xaaf(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1669 <main+0x449>
lea    0xaa0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    167f <main+0x45f>
mov    -0x50(%rbp),%edi
mov    -0x98(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    -0x48(%rbp),%rdi
call   1140 <freeaddrinfo@plt>
mov    -0x50(%rbp),%edi
call   1080 <close@plt>
cmpl   $0x1,-0x54(%rbp)
jne    16a2 <main+0x482>
mov    -0x4c(%rbp),%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%r15
mov    %edi,%ebp
mov    $0x100,%edi
call   10f0 <malloc@plt>
mov    %rax,0x20(%rsp)
mov    $0x100,%edi
call   10f0 <malloc@plt>
mov    %rax,%r14
mov    $0x20,%edi
call   10f0 <malloc@plt>
mov    %rax,%rbx
mov    $0x20,%edi
call   10f0 <malloc@plt>
cmp    $0x1,%ebp
jle    1577 <main+0x347>
cmp    $0x3,%ebp
je     1589 <main+0x359>
cmp    $0x5,%ebp
jae    159b <main+0x36b>
mov    %rax,%r13
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <input@plt>
mov    0x8(%r15),%rdi
lea    0xe2f(%rip),%rsi
call   10b0 <strcmp@plt>
mov    %rax,%rbp
lea    0x38(%rsp),%rdi
xor    %r12d,%r12d
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
mov    0x2d10(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x48(%rsp)
mov    0x2ce3(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x44(%rsp)
mov    %rbp,0x60(%rsp)
test   %rbp,%rbp
mov    %r15,0x58(%rsp)
je     133b <main+0x10b>
mov    0x2cef(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x50(%rsp)
mov    0x8(%r15),%rsi
lea    0x38(%rsp),%rdx
lea    0x18(%rsp),%rcx
xor    %edi,%edi
call   1140 <getaddrinfo@plt>
mov    0x18(%rsp),%rax
mov    0x10(%rax),%esi
mov    0xc(%rax),%edx
mov    0x8(%rax),%ecx
mov    (%rax),%r9d
mov    0x4(%rax),%r8d
call   10e0 <server@plt>
mov    %eax,%r15d
mov    $0x1,%r12d
jmp    136e <main+0x13e>
mov    0x10(%r15),%rdi
mov    0x18(%r15),%rsi
lea    0x38(%rsp),%rdx
lea    0x18(%rsp),%rcx
call   1140 <getaddrinfo@plt>
mov    0x18(%rsp),%rax
mov    0x10(%rax),%edi
mov    0xc(%rax),%esi
mov    0x8(%rax),%edx
mov    (%rax),%r8d
mov    0x4(%rax),%ecx
call   1110 <client@plt>
mov    %eax,%r15d
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %r14,%rcx
mov    0x20(%rsp),%r8
call   1050 <chat@plt>
test   %eax,%eax
je     1510 <main+0x2e0>
mov    %eax,%ebp
mov    %rbx,0x30(%rsp)
jmp    13f1 <main+0x1c1>
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %r15d,%edi
call   1130 <connect@plt>
mov    %rbx,%r13
mov    0x30(%rsp),%rbx
lea    0xd40(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2c16(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0xfa,%esi
call   10a0 <fgets@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %r14,%rcx
mov    0x20(%rsp),%r8
call   1050 <chat@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1510 <main+0x2e0>
mov    %r15d,%edi
call   1090 <close@plt>
cmp    $0x1,%ebp
jne    1420 <main+0x1f0>
test   %r12d,%r12d
je     14a5 <main+0x275>
lea    0x28(%rsp),%rsi
lea    0x2c(%rsp),%rdx
call   1100 <accept@plt>
jmp    1502 <main+0x2d2>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rbx
mov    0x18(%rsp),%rdi
call   1150 <freeaddrinfo@plt>
lea    0xcab(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x70(%rsp),%rbp
mov    %rbp,%rdi
call   10d0 <gets@plt>
lea    0xc9c(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x69(%rsp),%r13
mov    %r13,%rdi
call   10d0 <gets@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
lea    0x38(%rsp),%rdx
lea    0x18(%rsp),%rcx
call   1140 <getaddrinfo@plt>
mov    0x18(%rsp),%rax
cmpq   $0x0,0x60(%rsp)
je     1395 <main+0x165>
mov    0x10(%rax),%edi
mov    0xc(%rax),%esi
mov    0x8(%rax),%edx
mov    (%rax),%r8d
mov    0x4(%rax),%ecx
call   1110 <client@plt>
mov    %eax,%r15d
jmp    13a2 <main+0x172>
mov    0x18(%rsp),%rdi
call   1150 <freeaddrinfo@plt>
mov    0x2b32(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x50(%rsp)
mov    0x58(%rsp),%rax
mov    0x8(%rax),%rsi
xor    %edi,%edi
lea    0x38(%rsp),%rdx
lea    0x18(%rsp),%rcx
call   1140 <getaddrinfo@plt>
mov    0x18(%rsp),%rax
mov    0x10(%rax),%esi
mov    0xc(%rax),%edx
mov    0x8(%rax),%ecx
mov    (%rax),%r9d
mov    0x4(%rax),%r8d
mov    0x2c(%rsp),%eax
mov    0x28(%rsp),%edi
mov    %eax,0x10(%rsp)
mov    %edi,0x8(%rsp)
call   10e0 <server@plt>
mov    %eax,%r15d
mov    $0x1,%r12d
jmp    13aa <main+0x17a>
lea    0xbdf(%rip),%rsi
mov    0x20(%rsp),%rdi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     153a <main+0x30a>
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
jmp    1546 <main+0x316>
lea    0xbbc(%rip),%rdi
call   1040 <puts@plt>
mov    0x18(%rsp),%rdi
call   1150 <freeaddrinfo@plt>
mov    %r15d,%edi
call   1090 <close@plt>
cmp    $0x1,%r12d
jne    1563 <main+0x333>
call   1090 <close@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2a4a(%rip),%rax
mov    (%rax),%edi
lea    0xa79(%rip),%rsi
jmp    15ab <main+0x37b>
mov    0x2a38(%rip),%rax
mov    (%rax),%edi
lea    0xaae(%rip),%rsi
jmp    15ab <main+0x37b>
mov    0x2a26(%rip),%rax
mov    (%rax),%edi
lea    0xae9(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.addrinfo = type { i32, i32, i32, i32, i32, i8* }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [71 x i8] c"Too few arguments. Usage: ./main $PORT or ./main -c $IP_ADDRESS $PORT\0A\00"
@.str.1 = [77 x i8] c"Bad number of arguments. Usage: ./main $PORT or ./main -c $IP_ADDRESS $PORT\0A\00"
@.str.2 = [72 x i8] c"Too many arguments. Usage: ./main $PORT or ./main -c $IP_ADDRESS $PORT\0A\00"
@.str.3 = [3 x i8] c"-c\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i8* null
@.str.4 = [12 x i8] c"IP ADDRESS:\00"
@.str.5 = [6 x i8] c"PORT:\00"
@.str.6 = [5 x i8] c"%s: \00"
@stdin = global i32 0
@.str.7 = [7 x i8] c"/quit\0A\00"
@.str.8 = [119 x i8] c"Other side quit. Hopefully they had the common courtesy to say good bye first. The very last message was not relayed.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sockaddr_storage
%7 = alloca i32
%8 = alloca %struct.addrinfo
%9 = alloca %struct.addrinfo*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [17 x i8]
%17 = alloca [7 x i8]
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i8*
%21 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%22 = call i8* @malloc(i32 256)
store i8* %22, i8** %18
%23 = call i8* @malloc(i32 256)
store i8* %23, i8** %19
%24 = call i8* @malloc(i32 32)
store i8* %24, i8** %20
%25 = call i8* @malloc(i32 32)
store i8* %25, i8** %21
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 2
br i1 %27, label %28, label %32
28: ; preds = %2
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %2
%33 = load i32, i32* %4
%34 = icmp eq i32 %33, 3
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0))
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %32
%40 = load i32, i32* %4
%41 = icmp sgt i32 %40, 4
br i1 %41, label %42, label %46
42: ; preds = %39
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.2, i64 0, i64 0))
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %39
%47 = load i8*, i8** %20
%48 = load i8*, i8** %19
%49 = call i32 @input(i8* %47, i8* %48)
br label %50
50: ; preds = %46
br label %51
51: ; preds = %50
br label %52
52: ; preds = %51
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %52
store i32 1, i32* %15
br label %60
59: ; preds = %52
store i32 0, i32* %15
br label %60
60: ; preds = %59, %58
%61 = call i32 @memset(%struct.addrinfo* %8, i32 0, i32 32)
%62 = load i32, i32* @AF_UNSPEC
%63 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 4
store i32 %62, i32* %63
%64 = load i32, i32* @SOCK_STREAM
%65 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 3
store i32 %64, i32* %65
%66 = load i32, i32* %15
%67 = icmp eq i32 %66, 1
br i1 %67, label %68, label %76
68: ; preds = %60
%69 = load i8**, i8*** %5
%70 = getelementptr inbounds i8*, i8** %69, i64 2
%71 = load i8*, i8** %70
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 3
%74 = load i8*, i8** %73
%75 = call i32 @getaddrinfo(i8* %71, i8* %74, %struct.addrinfo* %8, %struct.addrinfo** %9)
br label %83
76: ; preds = %60
%77 = load i8*, i8** @AI_PASSIVE
%78 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 5
store i8* %77, i8** %78
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 1
%81 = load i8*, i8** %80
%82 = call i32 @getaddrinfo(i8* null, i8* %81, %struct.addrinfo* %8, %struct.addrinfo** %9)
br label %83
83: ; preds = %76, %68
%84 = load i32, i32* %15
%85 = icmp eq i32 %84, 1
br i1 %85, label %86, label %103
86: ; preds = %83
%87 = load %struct.addrinfo*, %struct.addrinfo** %9
%88 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %87, i32 0, i32 4
%89 = load i32, i32* %88
%90 = load %struct.addrinfo*, %struct.addrinfo** %9
%91 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %90, i32 0, i32 3
%92 = load i32, i32* %91
%93 = load %struct.addrinfo*, %struct.addrinfo** %9
%94 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %93, i32 0, i32 2
%95 = load i32, i32* %94
%96 = load %struct.addrinfo*, %struct.addrinfo** %9
%97 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %96, i32 0, i32 1
%98 = load i32, i32* %97
%99 = load %struct.addrinfo*, %struct.addrinfo** %9
%100 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %99, i32 0, i32 0
%101 = load i32, i32* %100
%102 = call i32 @client(i32 %89, i32 %92, i32 %95, i32 %98, i32 %101)
store i32 %102, i32* %11
store i32 0, i32* %12
br label %125
103: ; preds = %83
%104 = load i32, i32* %10
%105 = load %struct.addrinfo*, %struct.addrinfo** %9
%106 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %105, i32 0, i32 4
%107 = load i32, i32* %106
%108 = load %struct.addrinfo*, %struct.addrinfo** %9
%109 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %108, i32 0, i32 3
%110 = load i32, i32* %109
%111 = load %struct.addrinfo*, %struct.addrinfo** %9
%112 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %111, i32 0, i32 2
%113 = load i32, i32* %112
%114 = load %struct.addrinfo*, %struct.addrinfo** %9
%115 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %114, i32 0, i32 1
%116 = load i32, i32* %115
%117 = load %struct.addrinfo*, %struct.addrinfo** %9
%118 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %117, i32 0, i32 0
%119 = load i32, i32* %118
%120 = load i32, i32* %13
%121 = load i32, i32* %7
%122 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %6, i32 0, i32 0
%123 = load i32, i32* %122
%124 = call i32 @server(i32 %104, i32 %107, i32 %110, i32 %113, i32 %116, i32 %119, i32 %120, i32 %123, i32 %121)
store i32 %124, i32* %11
store i32 1, i32* %12
br label %125
125: ; preds = %103, %86
%126 = load i32, i32* %11
%127 = load i8*, i8** %20
%128 = load i8*, i8** %21
%129 = load i8*, i8** %19
%130 = load i8*, i8** %18
%131 = call i32 @chat(i32 %126, i8* %127, i8* %128, i8* %129, i8* %130)
store i32 %131, i32* %14
br label %132
132: ; preds = %219, %125
%133 = load i32, i32* %14
%134 = icmp ne i32 %133, 0
br i1 %134, label %135, label %231
135: ; preds = %132
%136 = load i32, i32* %11
%137 = call i32 @close(i32 %136)
%138 = load i32, i32* %14
%139 = icmp eq i32 %138, 1
br i1 %139, label %140, label %178
140: ; preds = %135
%141 = load i32, i32* %12
%142 = icmp eq i32 %141, 0
br i1 %142, label %143, label %173
143: ; preds = %140
%144 = load %struct.addrinfo*, %struct.addrinfo** %9
%145 = call i32 @freeaddrinfo(%struct.addrinfo* %144)
%146 = load i8*, i8** @AI_PASSIVE
%147 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 5
store i8* %146, i8** %147
%148 = load i8**, i8*** %5
%149 = getelementptr inbounds i8*, i8** %148, i64 1
%150 = load i8*, i8** %149
%151 = call i32 @getaddrinfo(i8* null, i8* %150, %struct.addrinfo* %8, %struct.addrinfo** %9)
%152 = load i32, i32* %10
%153 = load %struct.addrinfo*, %struct.addrinfo** %9
%154 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %153, i32 0, i32 4
%155 = load i32, i32* %154
%156 = load %struct.addrinfo*, %struct.addrinfo** %9
%157 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %156, i32 0, i32 3
%158 = load i32, i32* %157
%159 = load %struct.addrinfo*, %struct.addrinfo** %9
%160 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %159, i32 0, i32 2
%161 = load i32, i32* %160
%162 = load %struct.addrinfo*, %struct.addrinfo** %9
%163 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %162, i32 0, i32 1
%164 = load i32, i32* %163
%165 = load %struct.addrinfo*, %struct.addrinfo** %9
%166 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %165, i32 0, i32 0
%167 = load i32, i32* %166
%168 = load i32, i32* %13
%169 = load i32, i32* %7
%170 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %6, i32 0, i32 0
%171 = load i32, i32* %170
%172 = call i32 @server(i32 %152, i32 %155, i32 %158, i32 %161, i32 %164, i32 %167, i32 %168, i32 %171, i32 %169)
store i32 %172, i32* %11
store i32 1, i32* %12
br label %177
173: ; preds = %140
%174 = load i32, i32* %10
%175 = bitcast %struct.sockaddr_storage* %6 to %struct.sockaddr*
%176 = call i32 @accept(i32 %174, %struct.sockaddr* %175, i32* %7)
store i32 %176, i32* %11
br label %177
177: ; preds = %173, %143
br label %219
178: ; preds = %135
%179 = load %struct.addrinfo*, %struct.addrinfo** %9
%180 = call i32 @freeaddrinfo(%struct.addrinfo* %179)
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%182 = getelementptr inbounds [17 x i8], [17 x i8]* %16, i64 0, i64 0
%183 = call i32 @gets(i8* %182)
%184 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%185 = getelementptr inbounds [7 x i8], [7 x i8]* %17, i64 0, i64 0
%186 = call i32 @gets(i8* %185)
%187 = getelementptr inbounds [17 x i8], [17 x i8]* %16, i64 0, i64 0
%188 = getelementptr inbounds [7 x i8], [7 x i8]* %17, i64 0, i64 0
%189 = call i32 @getaddrinfo(i8* %187, i8* %188, %struct.addrinfo* %8, %struct.addrinfo** %9)
%190 = load i32, i32* %15
%191 = icmp eq i32 %190, 0
br i1 %191, label %192, label %209
192: ; preds = %178
%193 = load %struct.addrinfo*, %struct.addrinfo** %9
%194 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %193, i32 0, i32 4
%195 = load i32, i32* %194
%196 = load %struct.addrinfo*, %struct.addrinfo** %9
%197 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %196, i32 0, i32 3
%198 = load i32, i32* %197
%199 = load %struct.addrinfo*, %struct.addrinfo** %9
%200 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %199, i32 0, i32 2
%201 = load i32, i32* %200
%202 = load %struct.addrinfo*, %struct.addrinfo** %9
%203 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %202, i32 0, i32 1
%204 = load i32, i32* %203
%205 = load %struct.addrinfo*, %struct.addrinfo** %9
%206 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %205, i32 0, i32 0
%207 = load i32, i32* %206
%208 = call i32 @client(i32 %195, i32 %198, i32 %201, i32 %204, i32 %207)
store i32 %208, i32* %11
br label %218
209: ; preds = %178
%210 = load i32, i32* %11
%211 = load %struct.addrinfo*, %struct.addrinfo** %9
%212 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %211, i32 0, i32 1
%213 = load i32, i32* %212
%214 = load %struct.addrinfo*, %struct.addrinfo** %9
%215 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %214, i32 0, i32 0
%216 = load i32, i32* %215
%217 = call i32 @connect(i32 %210, i32 %213, i32 %216)
br label %218
218: ; preds = %209, %192
br label %219
219: ; preds = %218, %177
%220 = load i8*, i8** %20
%221 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %220)
%222 = load i8*, i8** %19
%223 = load i32, i32* @stdin
%224 = call i32 @fgets(i8* %222, i32 250, i32 %223)
%225 = load i32, i32* %11
%226 = load i8*, i8** %20
%227 = load i8*, i8** %21
%228 = load i8*, i8** %19
%229 = load i8*, i8** %18
%230 = call i32 @chat(i32 %225, i8* %226, i8* %227, i8* %228, i8* %229)
store i32 %230, i32* %14
br label %132
231: ; preds = %132
%232 = load i8*, i8** %18
%233 = call i64 @strcmp(i8* %232, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%234 = icmp eq i64 %233, 0
br i1 %234, label %235, label %237
235: ; preds = %231
%236 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([119 x i8], [119 x i8]* @.str.8, i64 0, i64 0))
br label %241
237: ; preds = %231
%238 = load i32, i32* %11
%239 = load i8*, i8** %19
%240 = call i32 @send(i32 %238, i8* %239, i32 256, i32 0)
br label %241
241: ; preds = %237, %235
%242 = load %struct.addrinfo*, %struct.addrinfo** %9
%243 = call i32 @freeaddrinfo(%struct.addrinfo* %242)
%244 = load i32, i32* %11
%245 = call i32 @close(i32 %244)
%246 = load i32, i32* %12
%247 = icmp eq i32 %246, 1
br i1 %247, label %248, label %251
248: ; preds = %241
%249 = load i32, i32* %10
%250 = call i32 @close(i32 %249)
br label %251
251: ; preds = %248, %241
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
%struct.addrinfo = type { i32, i32, i32, i32, i32, i8* }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [71 x i8] c"Too few arguments. Usage: ./main $PORT or ./main -c $IP_ADDRESS $PORT\0A\00"
@.str.1 = [77 x i8] c"Bad number of arguments. Usage: ./main $PORT or ./main -c $IP_ADDRESS $PORT\0A\00"
@.str.2 = [72 x i8] c"Too many arguments. Usage: ./main $PORT or ./main -c $IP_ADDRESS $PORT\0A\00"
@.str.3 = [3 x i8] c"-c\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i8* null
@.str.4 = [12 x i8] c"IP ADDRESS:\00"
@.str.5 = [6 x i8] c"PORT:\00"
@.str.6 = [5 x i8] c"%s: \00"
@stdin = global i32 0
@.str.7 = [7 x i8] c"/quit\0A\00"
@str = [118 x i8] c"Other side quit. Hopefully they had the common courtesy to say good bye first. The very last message was not relayed.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_storage
%4 = alloca i32
%5 = alloca %struct.addrinfo
%6 = alloca %struct.addrinfo*
%7 = alloca [17 x i8]
%8 = alloca [7 x i8]
%9 = bitcast %struct.sockaddr_storage* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast %struct.addrinfo* %5 to i8*
%12 = bitcast %struct.addrinfo** %6 to i8*
%13 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 0
%14 = getelementptr inbounds [7 x i8], [7 x i8]* %8, i64 0, i64 0
%15 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%16 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%17 = tail call dereferenceable_or_null(32) i8* @malloc(i32 32)
%18 = tail call dereferenceable_or_null(32) i8* @malloc(i32 32)
%19 = icmp slt i32 %0, 2
br i1 %19, label %20, label %24
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %2
%25 = icmp eq i32 %0, 3
br i1 %25, label %26, label %30
26: ; preds = %24
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0))
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %24
%31 = icmp ugt i32 %0, 4
br i1 %31, label %32, label %36
32: ; preds = %30
%33 = load i32, i32* @stderr
%34 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.2, i64 0, i64 0))
%35 = tail call i32 @exit(i32 1)
unreachable
36: ; preds = %30
%37 = tail call i32 @input(i8* %17, i8* %16)
%38 = getelementptr inbounds i8*, i8** %1, i64 1
%39 = load i8*, i8** %38
%40 = tail call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
%42 = call i32 @memset(%struct.addrinfo* %5, i32 0, i32 32)
%43 = load i32, i32* @AF_UNSPEC
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 4
store i32 %43, i32* %44
%45 = load i32, i32* @SOCK_STREAM
%46 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 3
store i32 %45, i32* %46
br i1 %41, label %47, label %65
47: ; preds = %36
%48 = getelementptr inbounds i8*, i8** %1, i64 2
%49 = load i8*, i8** %48
%50 = getelementptr inbounds i8*, i8** %1, i64 3
%51 = load i8*, i8** %50
%52 = call i32 @getaddrinfo(i8* %49, i8* %51, %struct.addrinfo* %5, %struct.addrinfo** %6)
%53 = load %struct.addrinfo*, %struct.addrinfo** %6
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i64 0, i32 4
%55 = load i32, i32* %54
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i64 0, i32 3
%57 = load i32, i32* %56
%58 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i64 0, i32 2
%59 = load i32, i32* %58
%60 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i64 0, i32 1
%61 = load i32, i32* %60
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i64 0, i32 0
%63 = load i32, i32* %62
%64 = call i32 @client(i32 %55, i32 %57, i32 %59, i32 %61, i32 %63)
br label %82
65: ; preds = %36
%66 = load i8*, i8** @AI_PASSIVE
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 5
store i8* %66, i8** %67
%68 = load i8*, i8** %38
%69 = call i32 @getaddrinfo(i8* null, i8* %68, %struct.addrinfo* %5, %struct.addrinfo** %6)
%70 = load %struct.addrinfo*, %struct.addrinfo** %6
%71 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %70, i64 0, i32 4
%72 = load i32, i32* %71
%73 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %70, i64 0, i32 3
%74 = load i32, i32* %73
%75 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %70, i64 0, i32 2
%76 = load i32, i32* %75
%77 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %70, i64 0, i32 1
%78 = load i32, i32* %77
%79 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %70, i64 0, i32 0
%80 = load i32, i32* %79
%81 = call i32 @server(i32 undef, i32 %72, i32 %74, i32 %76, i32 %78, i32 %80, i32 undef, i32 undef, i32 undef)
br label %82
82: ; preds = %65, %47
%83 = phi i32 [ 0, %47 ], [ 1, %65 ]
%84 = phi i32 [ %64, %47 ], [ %81, %65 ]
%85 = call i32 @chat(i32 %84, i8* %17, i8* %18, i8* %16, i8* %15)
%86 = icmp eq i32 %85, 0
br i1 %86, label %156, label %87
87: ; preds = %82
%88 = bitcast %struct.sockaddr_storage* %3 to %struct.sockaddr*
%89 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 5
%90 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %3, i64 0, i32 0
br label %91
91: ; preds = %87, %148
%92 = phi i32 [ %84, %87 ], [ %150, %148 ]
%93 = phi i32 [ %83, %87 ], [ %149, %148 ]
%94 = phi i32 [ %85, %87 ], [ %154, %148 ]
%95 = call i32 @close(i32 %92)
%96 = icmp eq i32 %94, 1
br i1 %96, label %97, label %121
97: ; preds = %91
%98 = icmp eq i32 %93, 0
br i1 %98, label %99, label %119
99: ; preds = %97
%100 = load %struct.addrinfo*, %struct.addrinfo** %6
%101 = call i32 @freeaddrinfo(%struct.addrinfo* %100)
%102 = load i8*, i8** @AI_PASSIVE
store i8* %102, i8** %89
%103 = load i8*, i8** %38
%104 = call i32 @getaddrinfo(i8* null, i8* %103, %struct.addrinfo* %5, %struct.addrinfo** %6)
%105 = load %struct.addrinfo*, %struct.addrinfo** %6
%106 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %105, i64 0, i32 4
%107 = load i32, i32* %106
%108 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %105, i64 0, i32 3
%109 = load i32, i32* %108
%110 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %105, i64 0, i32 2
%111 = load i32, i32* %110
%112 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %105, i64 0, i32 1
%113 = load i32, i32* %112
%114 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %105, i64 0, i32 0
%115 = load i32, i32* %114
%116 = load i32, i32* %4
%117 = load i32, i32* %90
%118 = call i32 @server(i32 undef, i32 %107, i32 %109, i32 %111, i32 %113, i32 %115, i32 undef, i32 %117, i32 %116)
br label %148
119: ; preds = %97
%120 = call i32 @accept(i32 undef, %struct.sockaddr* %88, i32* %4)
br label %148
121: ; preds = %91
%122 = load %struct.addrinfo*, %struct.addrinfo** %6
%123 = call i32 @freeaddrinfo(%struct.addrinfo* %122)
%124 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%125 = call i32 @gets(i8* %13)
%126 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%127 = call i32 @gets(i8* %14)
%128 = call i32 @getaddrinfo(i8* %13, i8* %14, %struct.addrinfo* %5, %struct.addrinfo** %6)
%129 = load %struct.addrinfo*, %struct.addrinfo** %6
br i1 %41, label %142, label %130
130: ; preds = %121
%131 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %129, i64 0, i32 4
%132 = load i32, i32* %131
%133 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %129, i64 0, i32 3
%134 = load i32, i32* %133
%135 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %129, i64 0, i32 2
%136 = load i32, i32* %135
%137 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %129, i64 0, i32 1
%138 = load i32, i32* %137
%139 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %129, i64 0, i32 0
%140 = load i32, i32* %139
%141 = call i32 @client(i32 %132, i32 %134, i32 %136, i32 %138, i32 %140)
br label %148
142: ; preds = %121
%143 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %129, i64 0, i32 1
%144 = load i32, i32* %143
%145 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %129, i64 0, i32 0
%146 = load i32, i32* %145
%147 = call i32 @connect(i32 %92, i32 %144, i32 %146)
br label %148
148: ; preds = %130, %142, %99, %119
%149 = phi i32 [ 1, %99 ], [ 1, %119 ], [ %93, %130 ], [ %93, %142 ]
%150 = phi i32 [ %118, %99 ], [ %120, %119 ], [ %141, %130 ], [ %92, %142 ]
%151 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %17)
%152 = load i32, i32* @stdin
%153 = call i32 @fgets(i8* %16, i32 250, i32 %152)
%154 = call i32 @chat(i32 %150, i8* %17, i8* %18, i8* %16, i8* %15)
%155 = icmp eq i32 %154, 0
br i1 %155, label %156, label %91
156: ; preds = %148, %82
%157 = phi i32 [ %83, %82 ], [ %149, %148 ]
%158 = phi i32 [ %84, %82 ], [ %150, %148 ]
%159 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%160 = icmp eq i64 %159, 0
br i1 %160, label %161, label %163
161: ; preds = %156
%162 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([118 x i8], [118 x i8]* @str, i64 0, i64 0))
br label %165
163: ; preds = %156
%164 = call i32 @send(i32 %158, i8* %16, i32 256, i32 0)
br label %165
165: ; preds = %163, %161
%166 = load %struct.addrinfo*, %struct.addrinfo** %6
%167 = call i32 @freeaddrinfo(%struct.addrinfo* %166)
%168 = call i32 @close(i32 %158)
%169 = icmp eq i32 %157, 1
br i1 %169, label %170, label %172
170: ; preds = %165
%171 = call i32 @close(i32 undef)
br label %172
172: ; preds = %170, %165
ret i32 0
}