#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;
};
typedef int /*<<< orphan*/ socklen_t;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, 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*/ free(char *);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int /*<<< orphan*/ getaddrinfo(char *, char *, struct addrinfo *,
                               struct addrinfo **);
int /*<<< orphan*/ gets(char *);
char *malloc(int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
scalar_t__ strncmp(char *, char *, size_t);
char *strtok(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;
  size_t mematch, partmatch;
  mematch = (3 * sizeof(char));
  partmatch = (5 * sizeof(char));
  if (argc != 3) {
    fprintf(
        stderr,
        "Error: Wrong number of arguments. Usage: ./client $IP_ADDRESS $PORT");
    exit(1);
  }
  char *buffer;
  buffer = malloc(256 * sizeof(char));
  char *recv_buffer;
  recv_buffer = malloc(256 * sizeof(char));
  char *name;
  name = malloc(32 * sizeof(char));
  char *recv_name;
  recv_name = malloc(32 * sizeof(char));
  char *mebuffer;
  mebuffer = malloc(256 * sizeof(char));
  printf("Send /quit to terminate the program but give a name first.\nName: ");
  gets(name);
  printf("%s: ", name);
  fgets(buffer, 250, stdin);
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  getaddrinfo(argv[1], argv[2], &hints, &res);
  client_sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
  connect(client_sock, res->ai_addr, res->ai_addrlen);
  send(client_sock, name, 32, 0);
  recv(client_sock, recv_name, 32, 0);
  printf("Now talking to %s\n", recv_name);
  while ((strcmp(buffer, "/quit\n")) != 0) {
    send(client_sock, buffer, 256, 0);
    recv(client_sock, recv_buffer, 256, 0);
    if ((strcmp(recv_buffer, "/quit\n")) == 0)
      break;
    if ((strncmp(recv_buffer, "/me", mematch)) == 0) {
      mebuffer = strtok(recv_buffer, " ");
      mebuffer = strtok(NULL, "");
      printf("*%s %s%s: ", recv_name, mebuffer, name);
    } else if ((strncmp(recv_buffer, "/part", partmatch)) == 0) {
      close(client_sock);
      client_sock = accept(sock, (struct sockaddr *)&client_addr, &addr_size);
    } else if ((strncmp(recv_buffer, "/join", partmatch)) == 0) {
      close(client_sock);
    } else {
      printf("%s: %s%s: ", recv_name, recv_buffer, name);
    }
    fgets(buffer, 250, stdin);
  }
  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(sock);
  free(buffer);
  free(recv_buffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x3,-0x50(%rbp)
movq   $0x5,-0x58(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1282 <main+0x52>
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
lea    0xd8d(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    $0x100,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    $0x100,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x68(%rbp)
mov    $0x20,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x70(%rbp)
mov    $0x20,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x78(%rbp)
mov    $0x100,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x80(%rbp)
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x70(%rbp),%rdi
call   10d0 <gets@plt>
mov    -0x70(%rbp),%rsi
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x60(%rbp),%rdi
mov    0x2ce4(%rip),%rax
mov    (%rax),%edx
mov    $0xfa,%esi
call   10a0 <fgets@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1080 <memset@plt>
mov    0x2cc9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2c9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   1130 <getaddrinfo@plt>
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%edx
call   1150 <socket@plt>
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%edi
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x38(%rbp),%rax
mov    (%rax),%edx
call   1120 <connect@plt>
mov    -0x40(%rbp),%edi
mov    -0x70(%rbp),%rsi
mov    $0x20,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    -0x40(%rbp),%edi
mov    -0x78(%rbp),%rsi
mov    $0x20,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
mov    -0x78(%rbp),%rsi
lea    0xcd6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x60(%rbp),%rdi
lea    0xcd7(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     1524 <main+0x2f4>
mov    -0x40(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    -0x40(%rbp),%edi
mov    -0x68(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
mov    -0x68(%rbp),%rdi
lea    0xc97(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    1416 <main+0x1e6>
jmp    1524 <main+0x2f4>
mov    -0x68(%rbp),%rdi
mov    -0x50(%rbp),%rdx
lea    0xc7b(%rip),%rsi
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    147b <main+0x24b>
mov    -0x68(%rbp),%rdi
lea    0xc45(%rip),%rsi
call   10f0 <strtok@plt>
mov    %rax,-0x80(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xce9(%rip),%rsi
call   10f0 <strtok@plt>
mov    %rax,-0x80(%rbp)
mov    -0x78(%rbp),%rsi
mov    -0x80(%rbp),%rdx
mov    -0x70(%rbp),%rcx
lea    0xc35(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1508 <main+0x2d8>
mov    -0x68(%rbp),%rdi
mov    -0x58(%rbp),%rdx
lea    0xc25(%rip),%rsi
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    14b9 <main+0x289>
mov    -0x40(%rbp),%edi
call   1090 <close@plt>
mov    -0x3c(%rbp),%edi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x40(%rbp)
jmp    1503 <main+0x2d3>
mov    -0x68(%rbp),%rdi
mov    -0x58(%rbp),%rdx
lea    0xbed(%rip),%rsi
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    14e4 <main+0x2b4>
mov    -0x40(%rbp),%edi
call   1090 <close@plt>
jmp    14fe <main+0x2ce>
mov    -0x78(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x70(%rbp),%rcx
lea    0xbc4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1503 <main+0x2d3>
jmp    1508 <main+0x2d8>
mov    -0x60(%rbp),%rdi
mov    0x2acd(%rip),%rax
mov    (%rax),%edx
mov    $0xfa,%esi
call   10a0 <fgets@plt>
jmp    13b7 <main+0x187>
mov    -0x68(%rbp),%rdi
lea    0xb6a(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    1551 <main+0x321>
lea    0xb81(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1564 <main+0x334>
mov    -0x40(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    -0x38(%rbp),%rdi
call   1140 <freeaddrinfo@plt>
mov    -0x3c(%rbp),%edi
call   1090 <close@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x3,%edi
jne    151b <main+0x2db>
mov    %rsi,%r13
mov    $0x100,%edi
call   10f0 <malloc@plt>
mov    %rax,%r14
mov    $0x100,%edi
call   10f0 <malloc@plt>
mov    %rax,%rbx
mov    $0x20,%edi
call   10f0 <malloc@plt>
mov    %rax,%r15
mov    $0x20,%edi
call   10f0 <malloc@plt>
mov    %rax,%r12
lea    0xdaf(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r15,%rdi
call   10e0 <gets@plt>
lea    0xe16(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2d24(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0xfa,%esi
call   10b0 <fgets@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1090 <memset@plt>
mov    0x2d02(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
mov    0x2cd5(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
mov    0x8(%r13),%rdi
mov    0x10(%r13),%rsi
mov    %rsp,%rcx
mov    %rbp,%rdx
call   1140 <getaddrinfo@plt>
mov    (%rsp),%rax
mov    0x10(%rax),%edi
mov    0x8(%rax),%edx
mov    0xc(%rax),%esi
call   1160 <socket@plt>
mov    %eax,%ebp
mov    (%rsp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %ebp,%edi
call   1130 <connect@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x20,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    $0x20,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
lea    0xd2d(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd2f(%rip),%rsi
mov    %r14,%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     14b9 <main+0x279>
lea    0xd17(%rip),%r13
jmp    13ee <main+0x1ae>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
lea    0xcea(%rip),%rsi
call   1100 <strtok@plt>
xor    %edi,%edi
lea    0xcf0(%rip),%rsi
call   1100 <strtok@plt>
lea    0xcf0(%rip),%rdi
mov    %r12,%rsi
mov    %rax,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2c15(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0xfa,%esi
call   10b0 <fgets@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     14b9 <main+0x279>
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     14b9 <main+0x279>
mov    $0x3,%edx
mov    %rbx,%rdi
lea    0xc6d(%rip),%rsi
call   1050 <strncmp@plt>
test   %rax,%rax
je     1390 <main+0x150>
mov    $0x5,%edx
mov    %rbx,%rdi
lea    0xc5f(%rip),%rsi
call   1050 <strncmp@plt>
test   %rax,%rax
je     1490 <main+0x250>
mov    $0x5,%edx
mov    %rbx,%rdi
lea    0xc4c(%rip),%rsi
call   1050 <strncmp@plt>
test   %rax,%rax
je     14ad <main+0x26d>
lea    0xc41(%rip),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
jmp    13ba <main+0x17a>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
call   10a0 <close@plt>
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1110 <accept@plt>
mov    %eax,%ebp
jmp    13c4 <main+0x184>
mov    %ebp,%edi
call   10a0 <close@plt>
jmp    13c4 <main+0x184>
lea    0xbd9(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     14e0 <main+0x2a0>
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
jmp    14ec <main+0x2ac>
lea    0xbdf(%rip),%rdi
call   1060 <puts@plt>
mov    (%rsp),%rdi
call   1150 <freeaddrinfo@plt>
call   10a0 <close@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2aae(%rip),%rax
mov    (%rax),%edi
lea    0xad5(%rip),%rsi
call   10d0 <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 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [68 x i8] c"Error: Wrong number of arguments. Usage: ./client $IP_ADDRESS $PORT\00"
@.str.1 = [66 x i8] c"Send /quit to terminate the program but give a name first.\0AName: \00"
@.str.2 = [5 x i8] c"%s: \00"
@stdin = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str.3 = [19 x i8] c"Now talking to %s\0A\00"
@.str.4 = [7 x i8] c"/quit\0A\00"
@.str.5 = [4 x i8] c"/me\00"
@.str.6 = [2 x i8] c" \00"
@.str.7 = [1 x i8] zeroinitializer
@.str.8 = [11 x i8] c"*%s %s%s: \00"
@.str.9 = [6 x i8] c"/part\00"
@.str.10 = [6 x i8] c"/join\00"
@.str.11 = [11 x i8] c"%s: %s%s: \00"
@.str.12 = [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 i64
%14 = alloca i64
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 3, i64* %13
store i64 5, i64* %14
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 3
br i1 %21, label %22, label %26
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = call i8* @malloc(i32 256)
store i8* %27, i8** %15
%28 = call i8* @malloc(i32 256)
store i8* %28, i8** %16
%29 = call i8* @malloc(i32 32)
store i8* %29, i8** %17
%30 = call i8* @malloc(i32 32)
store i8* %30, i8** %18
%31 = call i8* @malloc(i32 256)
store i8* %31, i8** %19
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0))
%33 = load i8*, i8** %17
%34 = call i32 @gets(i8* %33)
%35 = load i8*, i8** %17
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %35)
%37 = load i8*, i8** %15
%38 = load i32, i32* @stdin
%39 = call i32 @fgets(i8* %37, i32 250, i32 %38)
%40 = call i32 @memset(%struct.addrinfo* %8, i32 0, i32 20)
%41 = load i32, i32* @AF_UNSPEC
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 4
store i32 %41, i32* %42
%43 = load i32, i32* @SOCK_STREAM
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 3
store i32 %43, i32* %44
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = call i32 @getaddrinfo(i8* %47, i8* %50, %struct.addrinfo* %8, %struct.addrinfo** %9)
%52 = load %struct.addrinfo*, %struct.addrinfo** %9
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %52, i32 0, i32 4
%54 = load i32, i32* %53
%55 = load %struct.addrinfo*, %struct.addrinfo** %9
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %55, i32 0, i32 3
%57 = load i32, i32* %56
%58 = load %struct.addrinfo*, %struct.addrinfo** %9
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %58, i32 0, i32 2
%60 = load i32, i32* %59
%61 = call i32 @socket(i32 %54, i32 %57, i32 %60)
store i32 %61, i32* %11
%62 = load i32, i32* %11
%63 = load %struct.addrinfo*, %struct.addrinfo** %9
%64 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %63, i32 0, i32 1
%65 = load i32, i32* %64
%66 = load %struct.addrinfo*, %struct.addrinfo** %9
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %66, i32 0, i32 0
%68 = load i32, i32* %67
%69 = call i32 @connect(i32 %62, i32 %65, i32 %68)
%70 = load i32, i32* %11
%71 = load i8*, i8** %17
%72 = call i32 @send(i32 %70, i8* %71, i32 32, i32 0)
%73 = load i32, i32* %11
%74 = load i8*, i8** %18
%75 = call i32 @recv(i32 %73, i8* %74, i32 32, i32 0)
%76 = load i8*, i8** %18
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %76)
br label %78
78: ; preds = %132, %26
%79 = load i8*, i8** %15
%80 = call i64 @strcmp(i8* %79, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %136
82: ; preds = %78
%83 = load i32, i32* %11
%84 = load i8*, i8** %15
%85 = call i32 @send(i32 %83, i8* %84, i32 256, i32 0)
%86 = load i32, i32* %11
%87 = load i8*, i8** %16
%88 = call i32 @recv(i32 %86, i8* %87, i32 256, i32 0)
%89 = load i8*, i8** %16
%90 = call i64 @strcmp(i8* %89, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%91 = icmp eq i64 %90, 0
br i1 %91, label %92, label %93
92: ; preds = %82
br label %136
93: ; preds = %82
%94 = load i8*, i8** %16
%95 = load i64, i64* %13
%96 = call i64 @strncmp(i8* %94, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 %95)
%97 = icmp eq i64 %96, 0
br i1 %97, label %98, label %106
98: ; preds = %93
%99 = load i8*, i8** %16
%100 = call i8* @strtok(i8* %99, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i8* %100, i8** %19
%101 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
store i8* %101, i8** %19
%102 = load i8*, i8** %18
%103 = load i8*, i8** %19
%104 = load i8*, i8** %17
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* %102, i8* %103, i8* %104)
br label %132
106: ; preds = %93
%107 = load i8*, i8** %16
%108 = load i64, i64* %14
%109 = call i64 @strncmp(i8* %107, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i64 %108)
%110 = icmp eq i64 %109, 0
br i1 %110, label %111, label %117
111: ; preds = %106
%112 = load i32, i32* %11
%113 = call i32 @close(i32 %112)
%114 = load i32, i32* %10
%115 = bitcast %struct.sockaddr_storage* %6 to %struct.sockaddr*
%116 = call i32 @accept(i32 %114, %struct.sockaddr* %115, i32* %7)
store i32 %116, i32* %11
br label %131
117: ; preds = %106
%118 = load i8*, i8** %16
%119 = load i64, i64* %14
%120 = call i64 @strncmp(i8* %118, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i64 %119)
%121 = icmp eq i64 %120, 0
br i1 %121, label %122, label %125
122: ; preds = %117
%123 = load i32, i32* %11
%124 = call i32 @close(i32 %123)
br label %130
125: ; preds = %117
%126 = load i8*, i8** %18
%127 = load i8*, i8** %16
%128 = load i8*, i8** %17
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i8* %126, i8* %127, i8* %128)
br label %130
130: ; preds = %125, %122
br label %131
131: ; preds = %130, %111
br label %132
132: ; preds = %131, %98
%133 = load i8*, i8** %15
%134 = load i32, i32* @stdin
%135 = call i32 @fgets(i8* %133, i32 250, i32 %134)
br label %78
136: ; preds = %92, %78
%137 = load i8*, i8** %16
%138 = call i64 @strcmp(i8* %137, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%139 = icmp eq i64 %138, 0
br i1 %139, label %140, label %142
140: ; preds = %136
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([119 x i8], [119 x i8]* @.str.12, i64 0, i64 0))
br label %146
142: ; preds = %136
%143 = load i32, i32* %11
%144 = load i8*, i8** %15
%145 = call i32 @send(i32 %143, i8* %144, i32 256, i32 0)
br label %146
146: ; preds = %142, %140
%147 = load %struct.addrinfo*, %struct.addrinfo** %9
%148 = call i32 @freeaddrinfo(%struct.addrinfo* %147)
%149 = load i32, i32* %10
%150 = call i32 @close(i32 %149)
%151 = load i8*, i8** %15
%152 = call i32 @free(i8* %151)
%153 = load i8*, i8** %16
%154 = call i32 @free(i8* %153)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
%struct.addrinfo = type { i32, i32, i32, i32, i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [68 x i8] c"Error: Wrong number of arguments. Usage: ./client $IP_ADDRESS $PORT\00"
@.str.1 = [66 x i8] c"Send /quit to terminate the program but give a name first.\0AName: \00"
@.str.2 = [5 x i8] c"%s: \00"
@stdin = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str.3 = [19 x i8] c"Now talking to %s\0A\00"
@.str.4 = [7 x i8] c"/quit\0A\00"
@.str.5 = [4 x i8] c"/me\00"
@.str.6 = [2 x i8] c" \00"
@.str.7 = [1 x i8] zeroinitializer
@.str.8 = [11 x i8] c"*%s %s%s: \00"
@.str.9 = [6 x i8] c"/part\00"
@.str.10 = [6 x i8] c"/join\00"
@.str.11 = [11 x i8] c"%s: %s%s: \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 = bitcast %struct.sockaddr_storage* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast %struct.addrinfo* %5 to i8*
%10 = bitcast %struct.addrinfo** %6 to i8*
%11 = icmp eq i32 %0, 3
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%18 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%19 = tail call dereferenceable_or_null(32) i8* @malloc(i32 32)
%20 = tail call dereferenceable_or_null(32) i8* @malloc(i32 32)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0))
%22 = tail call i32 @gets(i8* %19)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%24 = load i32, i32* @stdin
%25 = tail call i32 @fgets(i8* %17, i32 250, i32 %24)
%26 = call i32 @memset(%struct.addrinfo* %5, i32 0, i32 20)
%27 = load i32, i32* @AF_UNSPEC
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 4
store i32 %27, i32* %28
%29 = load i32, i32* @SOCK_STREAM
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 3
store i32 %29, i32* %30
%31 = getelementptr inbounds i8*, i8** %1, i64 1
%32 = load i8*, i8** %31
%33 = getelementptr inbounds i8*, i8** %1, i64 2
%34 = load i8*, i8** %33
%35 = call i32 @getaddrinfo(i8* %32, i8* %34, %struct.addrinfo* %5, %struct.addrinfo** %6)
%36 = load %struct.addrinfo*, %struct.addrinfo** %6
%37 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 4
%38 = load i32, i32* %37
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 3
%40 = load i32, i32* %39
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i64 0, i32 2
%42 = load i32, i32* %41
%43 = call i32 @socket(i32 %38, i32 %40, i32 %42)
%44 = load %struct.addrinfo*, %struct.addrinfo** %6
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i64 0, i32 1
%46 = load i32, i32* %45
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i64 0, i32 0
%48 = load i32, i32* %47
%49 = call i32 @connect(i32 %43, i32 %46, i32 %48)
%50 = call i32 @send(i32 %43, i8* %19, i32 32, i32 0)
%51 = call i32 @recv(i32 %43, i8* %20, i32 32, i32 0)
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%53 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %89, label %55
55: ; preds = %16
%56 = bitcast %struct.sockaddr_storage* %3 to %struct.sockaddr*
br label %57
57: ; preds = %55, %83
%58 = phi i32 [ %43, %55 ], [ %84, %83 ]
%59 = call i32 @send(i32 %58, i8* %17, i32 256, i32 0)
%60 = call i32 @recv(i32 %58, i8* %18, i32 256, i32 0)
%61 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %89, label %63
63: ; preds = %57
%64 = call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 3)
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %70
66: ; preds = %63
%67 = call i8* @strtok(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%68 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* %20, i8* %68, i8* %19)
br label %83
70: ; preds = %63
%71 = call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i64 5)
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %76
73: ; preds = %70
%74 = call i32 @close(i32 %58)
%75 = call i32 @accept(i32 undef, %struct.sockaddr* %56, i32* %4)
br label %83
76: ; preds = %70
%77 = call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i64 5)
%78 = icmp eq i64 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %76
%80 = call i32 @close(i32 %58)
br label %83
81: ; preds = %76
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i8* %20, i8* %18, i8* %19)
br label %83
83: ; preds = %73, %81, %79, %66
%84 = phi i32 [ %58, %66 ], [ %75, %73 ], [ %58, %79 ], [ %58, %81 ]
%85 = load i32, i32* @stdin
%86 = call i32 @fgets(i8* %17, i32 250, i32 %85)
%87 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%88 = icmp eq i64 %87, 0
br i1 %88, label %89, label %57
89: ; preds = %83, %57, %16
%90 = phi i32 [ %43, %16 ], [ %58, %57 ], [ %84, %83 ]
%91 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%92 = icmp eq i64 %91, 0
br i1 %92, label %93, label %95
93: ; preds = %89
%94 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([118 x i8], [118 x i8]* @str, i64 0, i64 0))
br label %97
95: ; preds = %89
%96 = call i32 @send(i32 %90, i8* %17, i32 256, i32 0)
br label %97
97: ; preds = %95, %93
%98 = load %struct.addrinfo*, %struct.addrinfo** %6
%99 = call i32 @freeaddrinfo(%struct.addrinfo* %98)
%100 = call i32 @close(i32 undef)
%101 = call i32 @free(i8* %17)
%102 = call i32 @free(i8* %18)
ret i32 0
}