#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 */
typedef int /*<<< orphan*/ time_t;
struct tm {
  int tm_mday;
  int tm_mon;
  int tm_year;
  int tm_hour;
  int tm_min;
  int tm_sec;
};
struct sockaddr_storage {
  int dummy;
};
struct sockaddr_in6 {
  int /*<<< orphan*/ sin6_addr;
  int /*<<< orphan*/ sin6_port;
};
struct sockaddr_in {
  int dummy;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ ipstr;
typedef int /*<<< orphan*/ hostName;
typedef int /*<<< orphan*/ addrInfo;

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int INET6_ADDRSTRLEN;
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ close(int);
int createSocket(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ gethostname(char *, int);
int /*<<< orphan*/ getsockname(int, struct sockaddr *, int *);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/ *, char *,
                             int);
struct tm *localtime(int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ receiveFile(char *, int, int);
int recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sendFile(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void server(char **argv) {
  int s_tcp, s_client;
  struct sockaddr_in6 sa_client;
  int sa_len = sizeof(struct sockaddr_in), n;
  char *serverAddress = argv[2];
  char *buffer;
  int bufferSize = 1024;
  buffer = malloc(bufferSize * sizeof(char));
  char fileName[256], hostName[64];
  char ipstr[INET6_ADDRSTRLEN];
  struct sockaddr_storage addrInfo;
  socklen_t addrInfoLen = sizeof(addrInfo);
  s_tcp = createSocket(serverAddress, "SERVER");
  while (1) {
    printf("> Waiting for TCP connections ... \n");
    if ((s_client = accept(s_tcp, (struct sockaddr *)&sa_client, &sa_len)) <
        0) {
      perror("accept");
      close(s_tcp);
      exit(1);
    }
    printf("accepted\n");
    n = 1;
    getsockname(s_client, (struct sockaddr *)&addrInfo, &addrInfoLen);
    while (n > 0) {
      memset(buffer, 0, bufferSize);
      n = recv(s_client, buffer, bufferSize, 0);
      if (n > 0) {
        if (strncmp(buffer, "@RECEIVE", 8) == 0) {
          strcpy(fileName, buffer + 9);
          send(s_client, "OK", 3, 0);
          receiveFile(fileName, s_client, 1);
          struct sockaddr_in6 *s = (struct sockaddr_in6 *)&addrInfo;
          inet_ntop(AF_INET6, &s->sin6_addr, ipstr, sizeof(ipstr));
          memset(buffer, 0, bufferSize);
          sprintf(buffer, "OK <%s>:<%d>", ipstr, ntohs(sa_client.sin6_port));
          send(s_client, buffer, bufferSize, 0);
        } else if (strncmp(buffer, "@SEND", 5) == 0) {
          strcpy(fileName, buffer + 6);
          gethostname(hostName, sizeof(hostName));
          struct sockaddr_in6 *s = (struct sockaddr_in6 *)&addrInfo;
          inet_ntop(AF_INET6, &s->sin6_addr, ipstr, sizeof(ipstr));
          time_t tmpTime;
          time(&tmpTime);
          struct tm *curLocalTime = localtime(&tmpTime);
          memset(buffer, 0, bufferSize);
          sprintf(buffer, "<%02d.%02d.%d %02d:%02d:%02d>\n<%s>\n<%s>\n",
                  curLocalTime->tm_mday, curLocalTime->tm_mon + 1,
                  curLocalTime->tm_year + 1900, curLocalTime->tm_hour,
                  curLocalTime->tm_min, curLocalTime->tm_sec, hostName, ipstr);
          send(s_client, buffer, bufferSize, 0);
          recv(s_client, buffer, bufferSize, 0);
          sendFile(fileName, s_client);
        }
      }
    }
  }
  free(buffer);
  close(s_tcp);
}


x86 assembly (clang, -O0):
<server>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x1d8,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x4,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x30(%rbp)
movl   $0x400,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
call   10f0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    0x2d5b(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x1d0(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x188(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x1c8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x190(%rbp)
movl   $0x4,-0x19c(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xd29(%rip),%rsi
call   1050 <createSocket@plt>
mov    %eax,-0x14(%rbp)
jmp    12e4 <server+0x94>
lea    0xd1c(%rip),%rdi
call   10a0 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1130 <accept@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    132a <server+0xda>
lea    0xd18(%rip),%rdi
call   1120 <perror@plt>
mov    -0x14(%rbp),%edi
call   10c0 <close@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
lea    0xd01(%rip),%rdi
call   10a0 <printf@plt>
movl   $0x1,-0x28(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x198(%rbp),%rsi
lea    -0x19c(%rbp),%rdx
call   1140 <getsockname@plt>
cmpl   $0x0,-0x28(%rbp)
jle    15d4 <server+0x384>
mov    -0x38(%rbp),%rdi
mov    -0x3c(%rbp),%edx
xor    %esi,%esi
call   10b0 <memset@plt>
mov    -0x18(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jle    15cf <server+0x37f>
mov    -0x38(%rbp),%rdi
lea    0xca8(%rip),%rsi
mov    $0x8,%edx
call   1070 <strncmp@plt>
cmp    $0x0,%rax
jne    146e <server+0x21e>
lea    -0x140(%rbp),%rdi
mov    -0x38(%rbp),%rsi
add    $0x9,%rsi
call   1080 <strcpy@plt>
mov    -0x18(%rbp),%edi
lea    0xc7f(%rip),%rsi
mov    $0x3,%edx
xor    %ecx,%ecx
call   1090 <send@plt>
lea    -0x140(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    $0x1,%edx
call   10d0 <receiveFile@plt>
mov    -0x1c8(%rbp),%rdx
mov    -0x1d0(%rbp),%rax
lea    -0x198(%rbp),%rcx
mov    %rcx,-0x1a8(%rbp)
mov    0x2bd7(%rip),%rcx
mov    (%rcx),%edi
mov    -0x1a8(%rbp),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0x38(%rbp),%rdi
mov    -0x3c(%rbp),%edx
xor    %esi,%esi
call   10b0 <memset@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x1d8(%rbp)
mov    -0x1c(%rbp),%edi
call   1100 <ntohs@plt>
mov    -0x1d8(%rbp),%rdi
mov    -0x1c8(%rbp),%rdx
mov    %eax,%ecx
lea    0xbf7(%rip),%rsi
mov    $0x0,%al
call   1160 <sprintf@plt>
mov    -0x18(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
xor    %ecx,%ecx
call   1090 <send@plt>
jmp    15ca <server+0x37a>
mov    -0x38(%rbp),%rdi
lea    0xbdc(%rip),%rsi
mov    $0x5,%edx
call   1070 <strncmp@plt>
cmp    $0x0,%rax
jne    15c5 <server+0x375>
lea    -0x140(%rbp),%rdi
mov    -0x38(%rbp),%rsi
add    $0x6,%rsi
call   1080 <strcpy@plt>
lea    -0x180(%rbp),%rdi
mov    $0x40,%esi
call   1150 <gethostname@plt>
mov    -0x1c8(%rbp),%rdx
mov    -0x1d0(%rbp),%rax
lea    -0x198(%rbp),%rcx
mov    %rcx,-0x1b0(%rbp)
mov    0x2b0b(%rip),%rcx
mov    (%rcx),%edi
mov    -0x1b0(%rbp),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
lea    -0x1b4(%rbp),%rdi
call   10e0 <time@plt>
lea    -0x1b4(%rbp),%rdi
call   1060 <localtime@plt>
mov    %rax,-0x1c0(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x3c(%rbp),%edx
xor    %esi,%esi
call   10b0 <memset@plt>
mov    -0x1c8(%rbp),%rax
mov    -0x38(%rbp),%rdi
mov    -0x1c0(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x1c0(%rbp),%rcx
mov    0x4(%rcx),%ecx
add    $0x1,%ecx
mov    -0x1c0(%rbp),%rsi
mov    0x8(%rsi),%r8d
add    $0x76c,%r8d
mov    -0x1c0(%rbp),%rsi
mov    0xc(%rsi),%r9d
mov    -0x1c0(%rbp),%rsi
mov    0x10(%rsi),%ebx
mov    -0x1c0(%rbp),%rsi
mov    0x14(%rsi),%r11d
lea    -0x180(%rbp),%r10
lea    0xae8(%rip),%rsi
sub    $0x20,%rsp
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
mov    $0x0,%al
call   1160 <sprintf@plt>
add    $0x20,%rsp
mov    -0x18(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
xor    %ecx,%ecx
call   1090 <send@plt>
mov    -0x18(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
lea    -0x140(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1110 <sendFile@plt>
jmp    15ca <server+0x37a>
jmp    15cf <server+0x37f>
jmp    1353 <server+0x103>
jmp    12df <server+0x8f>

x86 assembly (clang, -O2):
<server>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x188,%rsp
movl   $0x4,-0x38(%rbp)
mov    0x10(%rdi),%r12
mov    $0x400,%edi
call   10f0 <malloc@plt>
mov    %rax,%rbx
mov    0x2d65(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
mov    %rax,-0x48(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
movl   $0x4,-0x3c(%rbp)
lea    0xd58(%rip),%rsi
mov    %r12,%rdi
call   1050 <createSocket@plt>
mov    %eax,%r12d
lea    0xd9c(%rip),%rdi
call   1090 <puts@plt>
lea    -0x50(%rbp),%rsi
lea    -0x38(%rbp),%rdx
mov    %r12d,-0x34(%rbp)
mov    %r12d,%edi
call   1130 <accept@plt>
test   %eax,%eax
jns    12f5 <server+0xa5>
lea    0xd29(%rip),%rdi
call   1120 <perror@plt>
mov    -0x34(%rbp),%edi
call   10c0 <close@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    %eax,%r13d
lea    0x6(%rbx),%rax
mov    %rax,-0x60(%rbp)
mov    %rbx,%rax
add    $0x9,%rax
mov    %rax,-0x68(%rbp)
mov    %r15,-0x58(%rbp)
jmp    1343 <server+0xf3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xd2f(%rip),%rdi
call   1090 <puts@plt>
mov    -0x34(%rbp),%edi
lea    -0x50(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1130 <accept@plt>
mov    %eax,%r13d
test   %eax,%eax
js     12d7 <server+0x87>
lea    0xd2f(%rip),%rdi
call   1090 <puts@plt>
mov    %r13d,%edi
lea    -0x30(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
call   1140 <getsockname@plt>
jmp    1401 <server+0x1b1>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    -0x1b0(%rbp),%r14
mov    %r14,%rdi
mov    -0x68(%rbp),%rsi
call   1080 <strcpy@plt>
mov    %r13d,%edi
lea    0xc8a(%rip),%rsi
mov    $0x3,%edx
xor    %ecx,%ecx
call   10a0 <send@plt>
mov    %r14,%rdi
mov    %r13d,%esi
mov    $0x1,%edx
call   10d0 <receiveFile@plt>
mov    0x2c30(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
mov    %r15,%rdx
mov    -0x48(%rbp),%rcx
call   1030 <inet_ntop@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   10b0 <memset@plt>
mov    -0x4c(%rbp),%edi
call   1100 <ntohs@plt>
mov    %rbx,%rdi
lea    0xc37(%rip),%rsi
mov    %r15,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1160 <sprintf@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   10a0 <send@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   10b0 <memset@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
test   %eax,%eax
jle    1320 <server+0xd0>
mov    %rbx,%rdi
lea    0xbda(%rip),%rsi
mov    $0x8,%edx
call   1070 <strncmp@plt>
test   %rax,%rax
je     1370 <server+0x120>
mov    %rbx,%rdi
lea    0xbd6(%rip),%rsi
mov    $0x5,%edx
call   1070 <strncmp@plt>
test   %rax,%rax
jne    1401 <server+0x1b1>
lea    -0x1b0(%rbp),%rdi
mov    -0x60(%rbp),%rsi
call   1080 <strcpy@plt>
lea    -0xb0(%rbp),%r12
mov    %r12,%rdi
mov    $0x40,%esi
call   1150 <gethostname@plt>
mov    0x2b55(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
mov    %r15,%rdx
mov    -0x48(%rbp),%rcx
call   1030 <inet_ntop@plt>
lea    -0x6c(%rbp),%r14
mov    %r14,%rdi
call   10e0 <time@plt>
mov    %r14,%rdi
call   1060 <localtime@plt>
mov    %rax,%r14
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   10b0 <memset@plt>
mov    (%r14),%edx
mov    0x4(%r14),%ecx
add    $0x1,%ecx
mov    0x8(%r14),%r8d
mov    $0x76c,%eax
add    %eax,%r8d
mov    0xc(%r14),%r9d
mov    0x10(%r14),%r10d
mov    0x14(%r14),%r11d
mov    -0x58(%rbp),%r15
mov    %rbx,%rdi
lea    0xb3a(%rip),%rsi
xor    %eax,%eax
push   %r15
push   %r12
push   %r11
push   %r10
call   1160 <sprintf@plt>
add    $0x20,%rsp
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   10a0 <send@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
lea    -0x1b0(%rbp),%rdi
mov    %r13d,%esi
call   1110 <sendFile@plt>
jmp    1401 <server+0x1b1>

LLVM IR (-O0):
%struct.sockaddr_in6 = type { i32, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
%struct.sockaddr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@.str = [7 x i8] c"SERVER\00"
@.str.1 = [36 x i8] c"> Waiting for TCP connections ... \0A\00"
@.str.2 = [7 x i8] c"accept\00"
@.str.3 = [10 x i8] c"accepted\0A\00"
@.str.4 = [9 x i8] c"@RECEIVE\00"
@.str.5 = [3 x i8] c"OK\00"
@AF_INET6 = global i32 0
@.str.6 = [13 x i8] c"OK <%s>:<%d>\00"
@.str.7 = [6 x i8] c"@SEND\00"
@.str.8 = [41 x i8] c"<%02d.%02d.%d %02d:%02d:%02d>\0A<%s>\0A<%s>\0A\00"
define void @server(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.sockaddr_in6
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca [256 x i8]
%12 = alloca [64 x i8]
%13 = alloca i8*
%14 = alloca i64
%15 = alloca %struct.sockaddr_storage
%16 = alloca i32
%17 = alloca %struct.sockaddr_in6*
%18 = alloca %struct.sockaddr_in6*
%19 = alloca i32
%20 = alloca %struct.tm*
store i8** %0, i8*** %2
store i32 4, i32* %6
%21 = load i8**, i8*** %2
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
store i8* %23, i8** %8
store i32 1024, i32* %10
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = mul i64 %25, 1
%27 = trunc i64 %26 to i32
%28 = call i8* @malloc(i32 %27)
store i8* %28, i8** %9
%29 = load i32, i32* @INET6_ADDRSTRLEN
%30 = zext i32 %29 to i64
%31 = call i8* @llvm.stacksave()
store i8* %31, i8** %13
%32 = alloca i8, i64 %30
store i64 %30, i64* %14
store i32 4, i32* %16
%33 = load i8*, i8** %8
%34 = call i32 @createSocket(i8* %33, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %34, i32* %3
br label %35
35: ; preds = %156, %1
br label %36
36: ; preds = %35
%37 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%38 = load i32, i32* %3
%39 = bitcast %struct.sockaddr_in6* %5 to %struct.sockaddr*
%40 = call i32 @accept(i32 %38, %struct.sockaddr* %39, i32* %6)
store i32 %40, i32* %4
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %36
%43 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%44 = load i32, i32* %3
%45 = call i32 @close(i32 %44)
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %36
%48 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %7
%49 = load i32, i32* %4
%50 = bitcast %struct.sockaddr_storage* %15 to %struct.sockaddr*
%51 = call i32 @getsockname(i32 %49, %struct.sockaddr* %50, i32* %16)
br label %52
52: ; preds = %155, %47
%53 = load i32, i32* %7
%54 = icmp sgt i32 %53, 0
br i1 %54, label %55, label %156
55: ; preds = %52
%56 = load i8*, i8** %9
%57 = load i32, i32* %10
%58 = call i32 @memset(i8* %56, i32 0, i32 %57)
%59 = load i32, i32* %4
%60 = load i8*, i8** %9
%61 = load i32, i32* %10
%62 = call i32 @recv(i32 %59, i8* %60, i32 %61, i32 0)
store i32 %62, i32* %7
%63 = load i32, i32* %7
%64 = icmp sgt i32 %63, 0
br i1 %64, label %65, label %155
65: ; preds = %55
%66 = load i8*, i8** %9
%67 = call i64 @strncmp(i8* %66, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %97
69: ; preds = %65
%70 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%71 = load i8*, i8** %9
%72 = getelementptr inbounds i8, i8* %71, i64 9
%73 = call i32 @strcpy(i8* %70, i8* %72)
%74 = load i32, i32* %4
%75 = call i32 @send(i32 %74, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 3, i32 0)
%76 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%77 = load i32, i32* %4
%78 = call i32 @receiveFile(i8* %76, i32 %77, i32 1)
%79 = bitcast %struct.sockaddr_storage* %15 to %struct.sockaddr_in6*
store %struct.sockaddr_in6* %79, %struct.sockaddr_in6** %17
%80 = load i32, i32* @AF_INET6
%81 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %17
%82 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %81, i32 0, i32 0
%83 = trunc i64 %30 to i32
%84 = call i32 @inet_ntop(i32 %80, i32* %82, i8* %32, i32 %83)
%85 = load i8*, i8** %9
%86 = load i32, i32* %10
%87 = call i32 @memset(i8* %85, i32 0, i32 %86)
%88 = load i8*, i8** %9
%89 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %5, i32 0, i32 1
%90 = load i32, i32* %89
%91 = call i32 @ntohs(i32 %90)
%92 = call i32 (i8*, i8*, ...) @sprintf(i8* %88, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %32, i32 %91)
%93 = load i32, i32* %4
%94 = load i8*, i8** %9
%95 = load i32, i32* %10
%96 = call i32 @send(i32 %93, i8* %94, i32 %95, i32 0)
br label %154
97: ; preds = %65
%98 = load i8*, i8** %9
%99 = call i64 @strncmp(i8* %98, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 5)
%100 = icmp eq i64 %99, 0
br i1 %100, label %101, label %153
101: ; preds = %97
%102 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%103 = load i8*, i8** %9
%104 = getelementptr inbounds i8, i8* %103, i64 6
%105 = call i32 @strcpy(i8* %102, i8* %104)
%106 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 0
%107 = call i32 @gethostname(i8* %106, i32 64)
%108 = bitcast %struct.sockaddr_storage* %15 to %struct.sockaddr_in6*
store %struct.sockaddr_in6* %108, %struct.sockaddr_in6** %18
%109 = load i32, i32* @AF_INET6
%110 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %18
%111 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %110, i32 0, i32 0
%112 = trunc i64 %30 to i32
%113 = call i32 @inet_ntop(i32 %109, i32* %111, i8* %32, i32 %112)
%114 = call i32 @time(i32* %19)
%115 = call %struct.tm* @localtime(i32* %19)
store %struct.tm* %115, %struct.tm** %20
%116 = load i8*, i8** %9
%117 = load i32, i32* %10
%118 = call i32 @memset(i8* %116, i32 0, i32 %117)
%119 = load i8*, i8** %9
%120 = load %struct.tm*, %struct.tm** %20
%121 = getelementptr inbounds %struct.tm, %struct.tm* %120, i32 0, i32 0
%122 = load i32, i32* %121
%123 = load %struct.tm*, %struct.tm** %20
%124 = getelementptr inbounds %struct.tm, %struct.tm* %123, i32 0, i32 1
%125 = load i32, i32* %124
%126 = add nsw i32 %125, 1
%127 = load %struct.tm*, %struct.tm** %20
%128 = getelementptr inbounds %struct.tm, %struct.tm* %127, i32 0, i32 2
%129 = load i32, i32* %128
%130 = add nsw i32 %129, 1900
%131 = load %struct.tm*, %struct.tm** %20
%132 = getelementptr inbounds %struct.tm, %struct.tm* %131, i32 0, i32 3
%133 = load i32, i32* %132
%134 = load %struct.tm*, %struct.tm** %20
%135 = getelementptr inbounds %struct.tm, %struct.tm* %134, i32 0, i32 4
%136 = load i32, i32* %135
%137 = load %struct.tm*, %struct.tm** %20
%138 = getelementptr inbounds %struct.tm, %struct.tm* %137, i32 0, i32 5
%139 = load i32, i32* %138
%140 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 0
%141 = call i32 (i8*, i8*, ...) @sprintf(i8* %119, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0), i32 %122, i32 %126, i32 %130, i32 %133, i32 %136, i32 %139, i8* %140, i8* %32)
%142 = load i32, i32* %4
%143 = load i8*, i8** %9
%144 = load i32, i32* %10
%145 = call i32 @send(i32 %142, i8* %143, i32 %144, i32 0)
%146 = load i32, i32* %4
%147 = load i8*, i8** %9
%148 = load i32, i32* %10
%149 = call i32 @recv(i32 %146, i8* %147, i32 %148, i32 0)
%150 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%151 = load i32, i32* %4
%152 = call i32 @sendFile(i8* %150, i32 %151)
br label %153
153: ; preds = %101, %97
br label %154
154: ; preds = %153, %69
br label %155
155: ; preds = %154, %55
br label %52
156: ; preds = %52
br label %35
}

LLVM IR (-O2):
%struct.sockaddr_in6 = type { i32, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@INET6_ADDRSTRLEN = global i32 0
@.str = [7 x i8] c"SERVER\00"
@.str.2 = [7 x i8] c"accept\00"
@.str.4 = [9 x i8] c"@RECEIVE\00"
@.str.5 = [3 x i8] c"OK\00"
@AF_INET6 = global i32 0
@.str.6 = [13 x i8] c"OK <%s>:<%d>\00"
@.str.7 = [6 x i8] c"@SEND\00"
@.str.8 = [41 x i8] c"<%02d.%02d.%d %02d:%02d:%02d>\0A<%s>\0A<%s>\0A\00"
@str = [35 x i8] c"> Waiting for TCP connections ... \00"
@str.9 = [9 x i8] c"accepted\00"
define void @server(i8** nocapture %0) {
%2 = alloca %struct.sockaddr_in6
%3 = alloca i32
%4 = alloca [256 x i8]
%5 = alloca [64 x i8]
%6 = alloca %struct.sockaddr_storage
%7 = alloca i32
%8 = alloca i32
%9 = bitcast %struct.sockaddr_in6* %2 to i8*
%10 = bitcast i32* %3 to i8*
store i32 4, i32* %3
%11 = getelementptr inbounds i8*, i8** %0, i64 2
%12 = load i8*, i8** %11
%13 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%16 = load i32, i32* @INET6_ADDRSTRLEN
%17 = zext i32 %16 to i64
%18 = alloca i8, i64 %17
%19 = bitcast %struct.sockaddr_storage* %6 to i8*
%20 = bitcast i32* %7 to i8*
store i32 4, i32* %7
%21 = tail call i32 @createSocket(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%23 = bitcast %struct.sockaddr_in6* %2 to %struct.sockaddr*
%24 = call i32 @accept(i32 %21, %struct.sockaddr* %23, i32* %3)
%25 = icmp slt i32 %24, 0
br i1 %25, label %37, label %26
26: ; preds = %1
%27 = bitcast %struct.sockaddr_storage* %6 to %struct.sockaddr*
%28 = getelementptr inbounds i8, i8* %13, i64 6
%29 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %6, i64 0, i32 0
%30 = bitcast i32* %8 to i8*
%31 = getelementptr inbounds i8, i8* %13, i64 9
%32 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %2, i64 0, i32 1
br label %41
33: ; preds = %91, %41
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%35 = call i32 @accept(i32 %21, %struct.sockaddr* %23, i32* %3)
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %33, %1
%38 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%39 = call i32 @close(i32 %21)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %26, %33
%42 = phi i32 [ %24, %26 ], [ %35, %33 ]
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0))
%44 = call i32 @getsockname(i32 %42, %struct.sockaddr* %27, i32* %7)
%45 = call i32 @memset(i8* %13, i32 0, i32 1024)
%46 = call i32 @recv(i32 %42, i8* %13, i32 1024, i32 0)
%47 = icmp sgt i32 %46, 0
br i1 %47, label %48, label %33
48: ; preds = %41, %91
%49 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %62
51: ; preds = %48
%52 = call i32 @strcpy(i8* %14, i8* %31)
%53 = call i32 @send(i32 %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 3, i32 0)
%54 = call i32 @receiveFile(i8* %14, i32 %42, i32 1)
%55 = load i32, i32* @AF_INET6
%56 = call i32 @inet_ntop(i32 %55, i32* %29, i8* %18, i32 %16)
%57 = call i32 @memset(i8* %13, i32 0, i32 1024)
%58 = load i32, i32* %32
%59 = call i32 @ntohs(i32 %58)
%60 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %13, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %18, i32 %59)
%61 = call i32 @send(i32 %42, i8* %13, i32 1024, i32 0)
br label %91
62: ; preds = %48
%63 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 5)
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %91
65: ; preds = %62
%66 = call i32 @strcpy(i8* %14, i8* %28)
%67 = call i32 @gethostname(i8* %15, i32 64)
%68 = load i32, i32* @AF_INET6
%69 = call i32 @inet_ntop(i32 %68, i32* %29, i8* %18, i32 %16)
%70 = call i32 @time(i32* %8)
%71 = call %struct.tm* @localtime(i32* %8)
%72 = call i32 @memset(i8* %13, i32 0, i32 1024)
%73 = getelementptr inbounds %struct.tm, %struct.tm* %71, i64 0, i32 0
%74 = load i32, i32* %73
%75 = getelementptr inbounds %struct.tm, %struct.tm* %71, i64 0, i32 1
%76 = load i32, i32* %75
%77 = add nsw i32 %76, 1
%78 = getelementptr inbounds %struct.tm, %struct.tm* %71, i64 0, i32 2
%79 = load i32, i32* %78
%80 = add nsw i32 %79, 1900
%81 = getelementptr inbounds %struct.tm, %struct.tm* %71, i64 0, i32 3
%82 = load i32, i32* %81
%83 = getelementptr inbounds %struct.tm, %struct.tm* %71, i64 0, i32 4
%84 = load i32, i32* %83
%85 = getelementptr inbounds %struct.tm, %struct.tm* %71, i64 0, i32 5
%86 = load i32, i32* %85
%87 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %13, i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0), i32 %74, i32 %77, i32 %80, i32 %82, i32 %84, i32 %86, i8* %15, i8* %18)
%88 = call i32 @send(i32 %42, i8* %13, i32 1024, i32 0)
%89 = call i32 @recv(i32 %42, i8* %13, i32 1024, i32 0)
%90 = call i32 @sendFile(i8* %14, i32 %42)
br label %91
91: ; preds = %51, %65, %62
%92 = call i32 @memset(i8* %13, i32 0, i32 1024)
%93 = call i32 @recv(i32 %42, i8* %13, i32 1024, i32 0)
%94 = icmp sgt i32 %93, 0
br i1 %94, label %48, label %33
}