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

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ AI_PASSIVE;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ bind(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
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(int /*<<< orphan*/ *, char *, struct addrinfo *,
                               struct addrinfo **);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ listen(int, int);
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 != 2) {
    fprintf(stderr, "Error: Wrong number of arguments. Usage: ./server $PORT");
    exit(1);
  }
  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));
  char *mebuffer;
  mebuffer = malloc(256 * sizeof(char));
  printf("Send /quit in order 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;
  hints.ai_flags = AI_PASSIVE;
  getaddrinfo(NULL, argv[1], &hints, &res);
  sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
  bind(sock, res->ai_addr, res->ai_addrlen);
  listen(sock, 10);
  addr_size = sizeof client_addr;
  client_sock = accept(sock, (struct sockaddr *)&client_addr, &addr_size);
  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(recv_buffer);
  free(buffer);
  return 0;
}


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)
movq   $0x3,-0x58(%rbp)
movq   $0x5,-0x60(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1292 <main+0x52>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
lea    0xd7d(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    $0x100,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x68(%rbp)
mov    $0x100,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x70(%rbp)
mov    $0x20,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x78(%rbp)
mov    $0x20,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x80(%rbp)
mov    $0x100,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x88(%rbp)
lea    0xd56(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x78(%rbp),%rdi
call   10d0 <gets@plt>
mov    -0x78(%rbp),%rsi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x70(%rbp),%rdi
mov    0x2cc9(%rip),%rax
mov    (%rax),%edx
mov    $0xfa,%esi
call   10a0 <fgets@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    0x2cae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2c82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2c9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x38(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   1140 <getaddrinfo@plt>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x40(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%edx
call   1160 <socket@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x40(%rbp),%rax
mov    (%rax),%edx
call   1100 <bind@plt>
mov    -0x44(%rbp),%edi
mov    $0xa,%esi
call   10f0 <listen@plt>
movl   $0x4,-0x1c(%rbp)
mov    -0x44(%rbp),%edi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1120 <accept@plt>
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%edi
mov    -0x78(%rbp),%rsi
mov    $0x20,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    -0x48(%rbp),%edi
mov    -0x80(%rbp),%rsi
mov    $0x20,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
mov    -0x80(%rbp),%rsi
lea    0xc91(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x70(%rbp),%rdi
lea    0xc92(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     156f <main+0x32f>
mov    -0x48(%rbp),%edi
mov    -0x70(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    -0x48(%rbp),%edi
mov    -0x68(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
mov    -0x68(%rbp),%rdi
lea    0xc52(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    1458 <main+0x218>
jmp    156f <main+0x32f>
mov    -0x68(%rbp),%rdi
mov    -0x58(%rbp),%rdx
lea    0xc36(%rip),%rsi
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    14c6 <main+0x286>
mov    -0x68(%rbp),%rdi
lea    0xc00(%rip),%rsi
call   1110 <strtok@plt>
mov    %rax,-0x88(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xca1(%rip),%rsi
call   1110 <strtok@plt>
mov    %rax,-0x88(%rbp)
mov    -0x80(%rbp),%rsi
mov    -0x88(%rbp),%rdx
mov    -0x78(%rbp),%rcx
lea    0xbe7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1553 <main+0x313>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rdx
lea    0xbd7(%rip),%rsi
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    1504 <main+0x2c4>
mov    -0x48(%rbp),%edi
call   1090 <close@plt>
mov    -0x44(%rbp),%edi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1120 <accept@plt>
mov    %eax,-0x48(%rbp)
jmp    154e <main+0x30e>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rdx
lea    0xb9f(%rip),%rsi
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    152f <main+0x2ef>
mov    -0x48(%rbp),%edi
call   1090 <close@plt>
jmp    1549 <main+0x309>
mov    -0x80(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x78(%rbp),%rcx
lea    0xb76(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    154e <main+0x30e>
jmp    1553 <main+0x313>
mov    -0x70(%rbp),%rdi
mov    0x2a7a(%rip),%rax
mov    (%rax),%edx
mov    $0xfa,%esi
call   10a0 <fgets@plt>
jmp    13f9 <main+0x1b9>
mov    -0x68(%rbp),%rdi
lea    0xb1c(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    159c <main+0x35c>
lea    0xb33(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    15af <main+0x36f>
mov    -0x48(%rbp),%edi
mov    -0x70(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    -0x40(%rbp),%rdi
call   1150 <freeaddrinfo@plt>
mov    -0x44(%rbp),%edi
call   1090 <close@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%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
cmp    $0x2,%edi
jne    1574 <main+0x324>
mov    %rsi,%r12
mov    $0x100,%edi
call   10f0 <malloc@plt>
mov    %rax,%rbx
mov    $0x100,%edi
call   10f0 <malloc@plt>
mov    %rax,%r14
mov    $0x20,%edi
call   10f0 <malloc@plt>
mov    %rax,%r15
mov    $0x20,%edi
call   10f0 <malloc@plt>
mov    %rax,%r13
lea    0xd93(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r15,%rdi
call   10e0 <gets@plt>
lea    0xe03(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2d0c(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0xfa,%esi
call   10b0 <fgets@plt>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
mov    0x2cea(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x30(%rsp)
mov    0x2cbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x2c(%rsp)
mov    0x2cd8(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x34(%rsp)
mov    0x8(%r12),%rsi
lea    0x10(%rsp),%rcx
xor    %edi,%edi
mov    %rbp,%rdx
call   1150 <getaddrinfo@plt>
mov    0x10(%rsp),%rax
mov    0x10(%rax),%edi
mov    0x8(%rax),%edx
mov    0xc(%rax),%esi
call   1170 <socket@plt>
mov    %eax,%ebp
mov    0x10(%rsp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %ebp,%edi
call   1110 <bind@plt>
mov    %ebp,%edi
mov    $0xa,%esi
call   1100 <listen@plt>
movl   $0x4,0xc(%rsp)
lea    0x18(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %ebp,0x8(%rsp)
mov    %ebp,%edi
call   1130 <accept@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %r15,%rsi
mov    $0x20,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x20,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
lea    0xcdf(%rip),%rdi
mov    %r13,%r12
mov    %r13,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xcde(%rip),%rsi
mov    %r14,%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     150d <main+0x2bd>
lea    0xcc6(%rip),%r13
jmp    143e <main+0x1ee>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
lea    0xc97(%rip),%rsi
call   1120 <strtok@plt>
xor    %edi,%edi
lea    0xc9d(%rip),%rsi
call   1120 <strtok@plt>
lea    0xc9d(%rip),%rdi
mov    %r12,%rsi
mov    %rax,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2bbd(%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     150d <main+0x2bd>
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     150d <main+0x2bd>
mov    $0x3,%edx
mov    %rbx,%rdi
lea    0xc1a(%rip),%rsi
call   1050 <strncmp@plt>
test   %rax,%rax
je     13e0 <main+0x190>
mov    $0x5,%edx
mov    %rbx,%rdi
lea    0xc0c(%rip),%rsi
call   1050 <strncmp@plt>
test   %rax,%rax
je     14e0 <main+0x290>
mov    $0x5,%edx
mov    %rbx,%rdi
lea    0xbf9(%rip),%rsi
call   1050 <strncmp@plt>
test   %rax,%rax
je     1501 <main+0x2b1>
lea    0xbee(%rip),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
jmp    140a <main+0x1ba>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
call   10a0 <close@plt>
mov    0x8(%rsp),%edi
lea    0x18(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1130 <accept@plt>
mov    %eax,%ebp
jmp    1414 <main+0x1c4>
mov    %ebp,%edi
call   10a0 <close@plt>
jmp    1414 <main+0x1c4>
lea    0xb82(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1534 <main+0x2e4>
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
jmp    1540 <main+0x2f0>
lea    0xb88(%rip),%rdi
call   1060 <puts@plt>
mov    0x10(%rsp),%rdi
call   1160 <freeaddrinfo@plt>
mov    0x8(%rsp),%edi
call   10a0 <close@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2a4d(%rip),%rax
mov    (%rax),%edi
lea    0xa7c(%rip),%rsi
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   1140 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.addrinfo = type { i32, i32, i32, i32, i32, i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [56 x i8] c"Error: Wrong number of arguments. Usage: ./server $PORT\00"
@.str.1 = [75 x i8] c"Send /quit in order 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
@AI_PASSIVE = 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, 2
br i1 %21, label %22, label %26
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([56 x i8], [56 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 ([75 x i8], [75 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** %16
%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 24)
%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 i32, i32* @AI_PASSIVE
%46 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 5
store i32 %45, i32* %46
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i32 @getaddrinfo(i32* null, i8* %49, %struct.addrinfo* %8, %struct.addrinfo** %9)
%51 = load %struct.addrinfo*, %struct.addrinfo** %9
%52 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %51, i32 0, i32 4
%53 = load i32, i32* %52
%54 = load %struct.addrinfo*, %struct.addrinfo** %9
%55 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %54, i32 0, i32 3
%56 = load i32, i32* %55
%57 = load %struct.addrinfo*, %struct.addrinfo** %9
%58 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %57, i32 0, i32 2
%59 = load i32, i32* %58
%60 = call i32 @socket(i32 %53, i32 %56, i32 %59)
store i32 %60, i32* %10
%61 = load i32, i32* %10
%62 = load %struct.addrinfo*, %struct.addrinfo** %9
%63 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %62, i32 0, i32 1
%64 = load i32, i32* %63
%65 = load %struct.addrinfo*, %struct.addrinfo** %9
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %65, i32 0, i32 0
%67 = load i32, i32* %66
%68 = call i32 @bind(i32 %61, i32 %64, i32 %67)
%69 = load i32, i32* %10
%70 = call i32 @listen(i32 %69, i32 10)
store i32 4, i32* %7
%71 = load i32, i32* %10
%72 = bitcast %struct.sockaddr_storage* %6 to %struct.sockaddr*
%73 = call i32 @accept(i32 %71, %struct.sockaddr* %72, i32* %7)
store i32 %73, i32* %11
%74 = load i32, i32* %11
%75 = load i8*, i8** %17
%76 = call i32 @send(i32 %74, i8* %75, i32 32, i32 0)
%77 = load i32, i32* %11
%78 = load i8*, i8** %18
%79 = call i32 @recv(i32 %77, i8* %78, i32 32, i32 0)
%80 = load i8*, i8** %18
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %80)
br label %82
82: ; preds = %136, %26
%83 = load i8*, i8** %16
%84 = call i64 @strcmp(i8* %83, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%85 = icmp ne i64 %84, 0
br i1 %85, label %86, label %140
86: ; preds = %82
%87 = load i32, i32* %11
%88 = load i8*, i8** %16
%89 = call i32 @send(i32 %87, i8* %88, i32 256, i32 0)
%90 = load i32, i32* %11
%91 = load i8*, i8** %15
%92 = call i32 @recv(i32 %90, i8* %91, i32 256, i32 0)
%93 = load i8*, i8** %15
%94 = call i64 @strcmp(i8* %93, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %97
96: ; preds = %86
br label %140
97: ; preds = %86
%98 = load i8*, i8** %15
%99 = load i64, i64* %13
%100 = call i64 @strncmp(i8* %98, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 %99)
%101 = icmp eq i64 %100, 0
br i1 %101, label %102, label %110
102: ; preds = %97
%103 = load i8*, i8** %15
%104 = call i8* @strtok(i8* %103, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i8* %104, i8** %19
%105 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
store i8* %105, i8** %19
%106 = load i8*, i8** %18
%107 = load i8*, i8** %19
%108 = load i8*, i8** %17
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* %106, i8* %107, i8* %108)
br label %136
110: ; preds = %97
%111 = load i8*, i8** %15
%112 = load i64, i64* %14
%113 = call i64 @strncmp(i8* %111, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i64 %112)
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %121
115: ; preds = %110
%116 = load i32, i32* %11
%117 = call i32 @close(i32 %116)
%118 = load i32, i32* %10
%119 = bitcast %struct.sockaddr_storage* %6 to %struct.sockaddr*
%120 = call i32 @accept(i32 %118, %struct.sockaddr* %119, i32* %7)
store i32 %120, i32* %11
br label %135
121: ; preds = %110
%122 = load i8*, i8** %15
%123 = load i64, i64* %14
%124 = call i64 @strncmp(i8* %122, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i64 %123)
%125 = icmp eq i64 %124, 0
br i1 %125, label %126, label %129
126: ; preds = %121
%127 = load i32, i32* %11
%128 = call i32 @close(i32 %127)
br label %134
129: ; preds = %121
%130 = load i8*, i8** %18
%131 = load i8*, i8** %15
%132 = load i8*, i8** %17
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i8* %130, i8* %131, i8* %132)
br label %134
134: ; preds = %129, %126
br label %135
135: ; preds = %134, %115
br label %136
136: ; preds = %135, %102
%137 = load i8*, i8** %16
%138 = load i32, i32* @stdin
%139 = call i32 @fgets(i8* %137, i32 250, i32 %138)
br label %82
140: ; preds = %96, %82
%141 = load i8*, i8** %15
%142 = call i64 @strcmp(i8* %141, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%143 = icmp eq i64 %142, 0
br i1 %143, label %144, label %146
144: ; preds = %140
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([119 x i8], [119 x i8]* @.str.12, i64 0, i64 0))
br label %150
146: ; preds = %140
%147 = load i32, i32* %11
%148 = load i8*, i8** %16
%149 = call i32 @send(i32 %147, i8* %148, i32 256, i32 0)
br label %150
150: ; preds = %146, %144
%151 = load %struct.addrinfo*, %struct.addrinfo** %9
%152 = call i32 @freeaddrinfo(%struct.addrinfo* %151)
%153 = load i32, i32* %10
%154 = call i32 @close(i32 %153)
%155 = load i8*, i8** %15
%156 = call i32 @free(i8* %155)
%157 = load i8*, i8** %16
%158 = call i32 @free(i8* %157)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
%struct.addrinfo = type { i32, i32, i32, i32, i32, i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [56 x i8] c"Error: Wrong number of arguments. Usage: ./server $PORT\00"
@.str.1 = [75 x i8] c"Send /quit in order 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
@AI_PASSIVE = 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, 2
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 ([56 x i8], [56 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 ([75 x i8], [75 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* %18, i32 250, i32 %24)
%26 = call i32 @memset(%struct.addrinfo* %5, i32 0, i32 24)
%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 = load i32, i32* @AI_PASSIVE
%32 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 5
store i32 %31, i32* %32
%33 = getelementptr inbounds i8*, i8** %1, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @getaddrinfo(i32* null, 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 @bind(i32 %43, i32 %46, i32 %48)
%50 = call i32 @listen(i32 %43, i32 10)
store i32 4, i32* %4
%51 = bitcast %struct.sockaddr_storage* %3 to %struct.sockaddr*
%52 = call i32 @accept(i32 %43, %struct.sockaddr* %51, i32* %4)
%53 = call i32 @send(i32 %52, i8* %19, i32 32, i32 0)
%54 = call i32 @recv(i32 %52, i8* %20, i32 32, i32 0)
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%56 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %90, label %58
58: ; preds = %16, %84
%59 = phi i32 [ %85, %84 ], [ %52, %16 ]
%60 = call i32 @send(i32 %59, i8* %18, i32 256, i32 0)
%61 = call i32 @recv(i32 %59, i8* %17, i32 256, i32 0)
%62 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%63 = icmp eq i64 %62, 0
br i1 %63, label %90, label %64
64: ; preds = %58
%65 = call i64 @strncmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 3)
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %71
67: ; preds = %64
%68 = call i8* @strtok(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%69 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* %20, i8* %69, i8* %19)
br label %84
71: ; preds = %64
%72 = call i64 @strncmp(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i64 5)
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %71
%75 = call i32 @close(i32 %59)
%76 = call i32 @accept(i32 %43, %struct.sockaddr* %51, i32* %4)
br label %84
77: ; preds = %71
%78 = call i64 @strncmp(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i64 5)
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %77
%81 = call i32 @close(i32 %59)
br label %84
82: ; preds = %77
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i8* %20, i8* %17, i8* %19)
br label %84
84: ; preds = %74, %82, %80, %67
%85 = phi i32 [ %59, %67 ], [ %76, %74 ], [ %59, %80 ], [ %59, %82 ]
%86 = load i32, i32* @stdin
%87 = call i32 @fgets(i8* %18, i32 250, i32 %86)
%88 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %58
90: ; preds = %84, %58, %16
%91 = phi i32 [ %52, %16 ], [ %59, %58 ], [ %85, %84 ]
%92 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%93 = icmp eq i64 %92, 0
br i1 %93, label %94, label %96
94: ; preds = %90
%95 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([118 x i8], [118 x i8]* @str, i64 0, i64 0))
br label %98
96: ; preds = %90
%97 = call i32 @send(i32 %91, i8* %18, i32 256, i32 0)
br label %98
98: ; preds = %96, %94
%99 = load %struct.addrinfo*, %struct.addrinfo** %6
%100 = call i32 @freeaddrinfo(%struct.addrinfo* %99)
%101 = call i32 @close(i32 %43)
%102 = call i32 @free(i8* %17)
%103 = call i32 @free(i8* %18)
ret i32 0
}