#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 sockaddr_un {
  int /*<<< orphan*/ sun_path;
  int /*<<< orphan*/ sun_family;
};
struct sockaddr {
  int dummy;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ localname;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_LOCAL;
char EOF;
int atoi(char *);
int /*<<< orphan*/ bzero(char *, int);
char *ctime(int /*<<< orphan*/ *);
int errno;
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int fread(char *, int, int, int /*<<< orphan*/);
int fwrite(char *, int, scalar_t__, int /*<<< orphan*/ *);
char getc(int /*<<< orphan*/);
int make_named_socket(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ remove_newline_ch(char *);
int sendto(int, char *, scalar_t__, int /*<<< orphan*/, struct sockaddr *, int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
char *strerror(int);
scalar_t__ strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  if (argc < 3) {
    perror("Not enough command line arguments");
  }
  char *packet_src = argv[1];
  char *log_file_name = argv[2];
  FILE *logfile = fopen(log_file_name, "a");
  if (!logfile) {
    printf("LOGFILE: %s\n", log_file_name);
    error("Server error opening log file");
  }
  char header[5];
  bzero(header, 5);
  int read_cnt = fread(header, sizeof(char), 5, stdin);
  if (read_cnt < 5) {
    fprintf(logfile, "ERROR: Bad header\n");
    exit(1);
  }
  int bytes_to_read = atoi(header);
  if (bytes_to_read > 4096 - 1) {
    fprintf(logfile, "ERROR: Packet exceeds max supported size\n");
    exit(1);
  }
  char buffer[4096];
  bzero(buffer, 4096);
  int bytes = 0;
  char c;
  do {
    c = getc(stdin);
    buffer[bytes] = c;
    bytes++;
  } while ((bytes < bytes_to_read) && (c != EOF));
  if (bytes < bytes_to_read) {
    fprintf(logfile, "Missing %d bytes\n", bytes_to_read - bytes);
  }
  if (ferror(stdin)) {
    fprintf(logfile, "Read Error (%d):%s\n", errno, strerror(errno));
  }
  time_t tm;
  time(&tm);
  char *time_str = ctime(&tm);
  remove_newline_ch(time_str);
  fprintf(logfile, "%s\t%s\t%s\n", time_str, packet_src, buffer);
  fflush(logfile);
  int localsock;
  struct sockaddr_un localname;
  ssize_t localname_size;
  localsock = make_named_socket("/tmp/clientsocket_connected");
  localname.sun_family = AF_LOCAL;
  strcpy(localname.sun_path, "/tmp/serversocket_connected");
  localname_size = sizeof(localname);
  int recv_bytes, send_bytes;
  send_bytes = sendto(localsock, buffer, strlen(buffer) + 1, 0,
                      (struct sockaddr *)&localname, localname_size);
  if (send_bytes < 0) {
    perror("localsocket send error");
  }
  char response[5 + 1];
  sprintf(response, "%05u", (unsigned int)bytes);
  int response_written =
      fwrite(response, sizeof(char), strlen(response), stdout);
  fflush(stdout);
  getc(stdin);
  fclose(logfile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    129f <main+0x2f>
lea    0xd66(%rip),%rdi
call   1110 <perror@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xd60(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12f2 <main+0x82>
mov    -0x20(%rbp),%rsi
lea    0xd43(%rip),%rdi
call   1090 <printf@plt>
lea    0xd44(%rip),%rdi
call   10f0 <error@plt>
lea    -0x2d(%rbp),%rdi
mov    $0x5,%esi
call   1120 <bzero@plt>
lea    -0x2d(%rbp),%rdi
mov    0x2cdd(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x5,%edx
call   1050 <fread@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x5,-0x34(%rbp)
jge    1345 <main+0xd5>
mov    -0x28(%rbp),%rdi
lea    0xd1b(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
lea    -0x2d(%rbp),%rdi
call   1130 <atoi@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0xfff,-0x38(%rbp)
jle    137a <main+0x10a>
mov    -0x28(%rbp),%rdi
lea    0xcf9(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
lea    -0x1040(%rbp),%rdi
mov    $0x1000,%esi
call   1120 <bzero@plt>
movl   $0x0,-0x1044(%rbp)
mov    0x2c4c(%rip),%rax
mov    (%rax),%edi
call   1180 <getc@plt>
mov    %al,-0x1045(%rbp)
mov    -0x1045(%rbp),%cl
movslq -0x1044(%rbp),%rax
mov    %cl,-0x1040(%rbp,%rax,1)
mov    -0x1044(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1044(%rbp)
mov    -0x1044(%rbp),%ecx
xor    %eax,%eax
cmp    -0x38(%rbp),%ecx
mov    %al,-0x1081(%rbp)
jge    13ff <main+0x18f>
movsbl -0x1045(%rbp),%eax
mov    0x2be7(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x1081(%rbp)
mov    -0x1081(%rbp),%al
test   $0x1,%al
jne    1395 <main+0x125>
mov    -0x1044(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    1437 <main+0x1c7>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%edx
sub    -0x1044(%rbp),%edx
lea    0xc5c(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2baa(%rip),%rax
mov    (%rax),%edi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     1495 <main+0x225>
mov    -0x28(%rbp),%rax
mov    %rax,-0x1090(%rbp)
mov    0x2b67(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1088(%rbp)
mov    0x2b58(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0x1090(%rbp),%rdi
mov    -0x1088(%rbp),%edx
mov    %rax,%rcx
lea    0xc10(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
lea    -0x104c(%rbp),%rdi
call   10d0 <time@plt>
lea    -0x104c(%rbp),%rdi
call   1070 <ctime@plt>
mov    %rax,-0x1058(%rbp)
mov    -0x1058(%rbp),%rdi
call   10b0 <remove_newline_ch@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1058(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    -0x1040(%rbp),%r8
lea    0xbd5(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   10e0 <fflush@plt>
lea    0xbc8(%rip),%rdi
call   1190 <make_named_socket@plt>
mov    %eax,-0x105c(%rbp)
mov    0x2ada(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1064(%rbp)
mov    -0x1068(%rbp),%edi
lea    0xbbd(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x8,-0x106c(%rbp)
mov    -0x105c(%rbp),%eax
mov    %eax,-0x109c(%rbp)
lea    -0x1040(%rbp),%rax
mov    %rax,-0x1098(%rbp)
lea    -0x1040(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x109c(%rbp),%edi
mov    -0x1098(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
lea    -0x1068(%rbp),%r8
mov    -0x106c(%rbp),%r9d
xor    %ecx,%ecx
call   10a0 <sendto@plt>
mov    %eax,-0x1074(%rbp)
cmpl   $0x0,-0x1074(%rbp)
jge    1598 <main+0x328>
lea    0xb61(%rip),%rdi
call   1110 <perror@plt>
lea    -0x107a(%rbp),%rdi
mov    -0x1044(%rbp),%edx
lea    0xb5f(%rip),%rsi
call   1140 <sprintf@plt>
lea    -0x107a(%rbp),%rax
mov    %rax,-0x10a8(%rbp)
lea    -0x107a(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x10a8(%rbp),%rdi
mov    %rax,%rdx
mov    0x29e4(%rip),%rax
mov    (%rax),%rcx
mov    $0x1,%esi
call   1160 <fwrite@plt>
mov    %eax,-0x1080(%rbp)
mov    0x29ca(%rip),%rax
mov    (%rax),%rdi
call   10e0 <fflush@plt>
mov    0x29e3(%rip),%rax
mov    (%rax),%edi
call   1180 <getc@plt>
mov    -0x28(%rbp),%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x10b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1038,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jle    14aa <main+0x23a>
mov    0x8(%rbx),%rbp
mov    0x10(%rbx),%rbx
lea    0xd86(%rip),%rsi
mov    %rbx,%rdi
call   1100 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    12c7 <main+0x57>
lea    0xd71(%rip),%rdi
mov    %rbx,%rsi
call   1090 <printf@plt>
lea    0xd6f(%rip),%rdi
call   10f0 <error@plt>
lea    0xb(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1120 <bzero@plt>
mov    0x2d08(%rip),%r13
mov    0x0(%r13),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x5,%edx
call   1050 <fread@plt>
cmp    $0x4,%eax
jle    14cc <main+0x25c>
mov    %rbp,0x10(%rsp)
lea    0xb(%rsp),%rdi
call   1130 <atoi@plt>
cmp    $0x1000,%eax
jge    14da <main+0x26a>
mov    %eax,%r12d
lea    0x30(%rsp),%rdi
mov    $0x1000,%esi
call   1120 <bzero@plt>
movslq %r12d,%rbp
xor    %ebx,%ebx
mov    0x2ca1(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%edi
call   1180 <getc@plt>
mov    %al,0x30(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    %rbp,%rbx
jge    135b <main+0xeb>
cmp    (%r14),%al
jne    1340 <main+0xd0>
cmp    %rbp,%rbx
jge    1377 <main+0x107>
sub    %ebx,%r12d
lea    0xd22(%rip),%rsi
mov    %r15,%rdi
mov    %r12d,%edx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    0x0(%r13),%edi
call   1040 <ferror@plt>
test   %rax,%rax
mov    0x10(%rsp),%r14
je     13b0 <main+0x140>
mov    0x2c37(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1170 <strerror@plt>
lea    0xcfd(%rip),%rsi
mov    %r15,%rdi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   10c0 <fprintf@plt>
lea    0x24(%rsp),%rbp
mov    %rbp,%rdi
call   10d0 <time@plt>
mov    %rbp,%rdi
call   1070 <ctime@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   10b0 <remove_newline_ch@plt>
lea    0xcdb(%rip),%rsi
lea    0x30(%rsp),%r12
mov    %r15,%rdi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %r12,%r8
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %r15,%rdi
call   10e0 <fflush@plt>
lea    0xcbe(%rip),%rdi
call   1190 <make_named_socket@plt>
mov    %eax,%ebp
mov    0x2bd4(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
lea    0xcbf(%rip),%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
call   1080 <strlen@plt>
lea    0x1(%rax),%rdx
lea    0x18(%rsp),%r8
mov    %ebp,%edi
mov    %r12,%rsi
xor    %ecx,%ecx
mov    $0x8,%r9d
call   10a0 <sendto@plt>
test   %eax,%eax
js     14bb <main+0x24b>
lea    0xcbf(%rip),%rsi
lea    0x2a(%rsp),%rbp
mov    %rbp,%rdi
mov    %ebx,%edx
call   1140 <sprintf@plt>
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    0x2b56(%rip),%rbx
mov    (%rbx),%rcx
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
call   1160 <fwrite@plt>
mov    (%rbx),%rdi
call   10e0 <fflush@plt>
mov    0x0(%r13),%edi
call   1180 <getc@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x1038,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb4f(%rip),%rdi
call   1110 <perror@plt>
jmp    128d <main+0x1d>
lea    0xc32(%rip),%rdi
call   1110 <perror@plt>
jmp    1445 <main+0x1d5>
lea    0xb7c(%rip),%rdi
mov    $0x12,%esi
jmp    14e6 <main+0x276>
lea    0xb81(%rip),%rdi
mov    $0x29,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1160 <fwrite@plt>
mov    $0x1,%edi
call   1150 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [34 x i8] c"Not enough command line arguments\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [13 x i8] c"LOGFILE: %s\0A\00"
@.str.3 = [30 x i8] c"Server error opening log file\00"
@stdin = global i32 0
@.str.4 = [19 x i8] c"ERROR: Bad header\0A\00"
@.str.5 = [42 x i8] c"ERROR: Packet exceeds max supported size\0A\00"
@EOF = global i8 0
@.str.6 = [18 x i8] c"Missing %d bytes\0A\00"
@.str.7 = [20 x i8] c"Read Error (%d):%s\0A\00"
@errno = global i32 0
@.str.8 = [10 x i8] c"%s\09%s\09%s\0A\00"
@.str.9 = [28 x i8] c"/tmp/clientsocket_connected\00"
@AF_LOCAL = global i32 0
@.str.10 = [28 x i8] c"/tmp/serversocket_connected\00"
@.str.11 = [23 x i8] c"localsocket send error\00"
@.str.12 = [5 x i8] c"%05u\00"
@stdout = global i32* null
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca [5 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca [4096 x i8]
%13 = alloca i32
%14 = alloca i8
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i32
%18 = alloca %struct.sockaddr_un
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca [6 x i8]
%23 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 3
br i1 %25, label %26, label %28
26: ; preds = %2
%27 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %26, %2
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
store i8* %31, i8** %6
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
store i8* %34, i8** %7
%35 = load i8*, i8** %7
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %36, i32** %8
%37 = load i32*, i32** %8
%38 = icmp ne i32* %37, null
br i1 %38, label %43, label %39
39: ; preds = %28
%40 = load i8*, i8** %7
%41 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %40)
%42 = call i32 @error(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %39, %28
%44 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
%45 = call i32 @bzero(i8* %44, i32 5)
%46 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
%47 = load i32, i32* @stdin
%48 = call i32 @fread(i8* %46, i32 1, i32 5, i32 %47)
store i32 %48, i32* %10
%49 = load i32, i32* %10
%50 = icmp slt i32 %49, 5
br i1 %50, label %51, label %55
51: ; preds = %43
%52 = load i32*, i32** %8
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %43
%56 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
%57 = call i32 @atoi(i8* %56)
store i32 %57, i32* %11
%58 = load i32, i32* %11
%59 = icmp sgt i32 %58, 4095
br i1 %59, label %60, label %64
60: ; preds = %55
%61 = load i32*, i32** %8
%62 = call i32 (i32*, i8*, ...) @fprintf(i32* %61, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %55
%65 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%66 = call i32 @bzero(i8* %65, i32 4096)
store i32 0, i32* %13
br label %67
67: ; preds = %86, %64
%68 = load i32, i32* @stdin
%69 = call signext i8 @getc(i32 %68)
store i8 %69, i8* %14
%70 = load i8, i8* %14
%71 = load i32, i32* %13
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 %72
store i8 %70, i8* %73
%74 = load i32, i32* %13
%75 = add nsw i32 %74, 1
store i32 %75, i32* %13
br label %76
76: ; preds = %67
%77 = load i32, i32* %13
%78 = load i32, i32* %11
%79 = icmp slt i32 %77, %78
br i1 %79, label %80, label %86
80: ; preds = %76
%81 = load i8, i8* %14
%82 = sext i8 %81 to i32
%83 = load i8, i8* @EOF
%84 = sext i8 %83 to i32
%85 = icmp ne i32 %82, %84
br label %86
86: ; preds = %80, %76
%87 = phi i1 [ false, %76 ], [ %85, %80 ]
br i1 %87, label %67, label %88
88: ; preds = %86
%89 = load i32, i32* %13
%90 = load i32, i32* %11
%91 = icmp slt i32 %89, %90
br i1 %91, label %92, label %98
92: ; preds = %88
%93 = load i32*, i32** %8
%94 = load i32, i32* %11
%95 = load i32, i32* %13
%96 = sub nsw i32 %94, %95
%97 = call i32 (i32*, i8*, ...) @fprintf(i32* %93, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %96)
br label %98
98: ; preds = %92, %88
%99 = load i32, i32* @stdin
%100 = call i64 @ferror(i32 %99)
%101 = icmp ne i64 %100, 0
br i1 %101, label %102, label %108
102: ; preds = %98
%103 = load i32*, i32** %8
%104 = load i32, i32* @errno
%105 = load i32, i32* @errno
%106 = call i8* @strerror(i32 %105)
%107 = call i32 (i32*, i8*, ...) @fprintf(i32* %103, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %104, i8* %106)
br label %108
108: ; preds = %102, %98
%109 = call i32 @time(i32* %15)
%110 = call i8* @ctime(i32* %15)
store i8* %110, i8** %16
%111 = load i8*, i8** %16
%112 = call i32 @remove_newline_ch(i8* %111)
%113 = load i32*, i32** %8
%114 = load i8*, i8** %16
%115 = load i8*, i8** %6
%116 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%117 = call i32 (i32*, i8*, ...) @fprintf(i32* %113, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %114, i8* %115, i8* %116)
%118 = load i32*, i32** %8
%119 = call i32 @fflush(i32* %118)
%120 = call i32 @make_named_socket(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
store i32 %120, i32* %17
%121 = load i32, i32* @AF_LOCAL
%122 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %18, i32 0, i32 1
store i32 %121, i32* %122
%123 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %18, i32 0, i32 0
%124 = load i32, i32* %123
%125 = call i32 @strcpy(i32 %124, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0))
store i32 8, i32* %19
%126 = load i32, i32* %17
%127 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%128 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%129 = call i64 @strlen(i8* %128)
%130 = add nsw i64 %129, 1
%131 = bitcast %struct.sockaddr_un* %18 to %struct.sockaddr*
%132 = load i32, i32* %19
%133 = call i32 @sendto(i32 %126, i8* %127, i64 %130, i32 0, %struct.sockaddr* %131, i32 %132)
store i32 %133, i32* %21
%134 = load i32, i32* %21
%135 = icmp slt i32 %134, 0
br i1 %135, label %136, label %138
136: ; preds = %108
%137 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0))
br label %138
138: ; preds = %136, %108
%139 = getelementptr inbounds [6 x i8], [6 x i8]* %22, i64 0, i64 0
%140 = load i32, i32* %13
%141 = call i32 @sprintf(i8* %139, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %140)
%142 = getelementptr inbounds [6 x i8], [6 x i8]* %22, i64 0, i64 0
%143 = getelementptr inbounds [6 x i8], [6 x i8]* %22, i64 0, i64 0
%144 = call i64 @strlen(i8* %143)
%145 = load i32*, i32** @stdout
%146 = call i32 @fwrite(i8* %142, i32 1, i64 %144, i32* %145)
store i32 %146, i32* %23
%147 = load i32*, i32** @stdout
%148 = call i32 @fflush(i32* %147)
%149 = load i32, i32* @stdin
%150 = call signext i8 @getc(i32 %149)
%151 = load i32*, i32** %8
%152 = call i32 @fclose(i32* %151)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [34 x i8] c"Not enough command line arguments\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [13 x i8] c"LOGFILE: %s\0A\00"
@.str.3 = [30 x i8] c"Server error opening log file\00"
@stdin = global i32 0
@.str.4 = [19 x i8] c"ERROR: Bad header\0A\00"
@.str.5 = [42 x i8] c"ERROR: Packet exceeds max supported size\0A\00"
@EOF = global i8 0
@.str.6 = [18 x i8] c"Missing %d bytes\0A\00"
@.str.7 = [20 x i8] c"Read Error (%d):%s\0A\00"
@errno = global i32 0
@.str.8 = [10 x i8] c"%s\09%s\09%s\0A\00"
@.str.9 = [28 x i8] c"/tmp/clientsocket_connected\00"
@AF_LOCAL = global i32 0
@.str.10 = [28 x i8] c"/tmp/serversocket_connected\00"
@.str.11 = [23 x i8] c"localsocket send error\00"
@.str.12 = [5 x i8] c"%05u\00"
@stdout = global i32* null
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [5 x i8]
%4 = alloca [4096 x i8]
%5 = alloca i32
%6 = alloca %struct.sockaddr_un
%7 = alloca [6 x i8]
%8 = icmp slt i32 %0, 3
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %11
%19 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%20 = tail call i32 @error(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %18, %11
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%23 = call i32 @bzero(i8* %22, i32 5)
%24 = load i32, i32* @stdin
%25 = call i32 @fread(i8* %22, i32 1, i32 5, i32 %24)
%26 = icmp slt i32 %25, 5
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = call i64 bitcast (i32 (i8*, i32, i64, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i64 18, i64 1, i32* %16)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %21
%31 = call i32 @atoi(i8* %22)
%32 = icmp sgt i32 %31, 4095
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = call i64 bitcast (i32 (i8*, i32, i64, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i64 41, i64 1, i32* %16)
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %30
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%38 = call i32 @bzero(i8* %37, i32 4096)
%39 = sext i32 %31 to i64
br label %40
40: ; preds = %40, %36
%41 = phi i64 [ %45, %40 ], [ 0, %36 ]
%42 = load i32, i32* @stdin
%43 = call signext i8 @getc(i32 %42)
%44 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %41
store i8 %43, i8* %44
%45 = add nuw nsw i64 %41, 1
%46 = icmp slt i64 %45, %39
%47 = load i8, i8* @EOF
%48 = icmp ne i8 %43, %47
%49 = select i1 %46, i1 %48, i1 false
br i1 %49, label %40, label %50
50: ; preds = %40
%51 = trunc i64 %45 to i32
br i1 %46, label %52, label %55
52: ; preds = %50
%53 = sub nsw i32 %31, %51
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %52, %50
%56 = load i32, i32* @stdin
%57 = call i64 @ferror(i32 %56)
%58 = icmp eq i64 %57, 0
br i1 %58, label %63, label %59
59: ; preds = %55
%60 = load i32, i32* @errno
%61 = call i8* @strerror(i32 %60)
%62 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %60, i8* %61)
br label %63
63: ; preds = %59, %55
%64 = bitcast i32* %5 to i8*
%65 = call i32 @time(i32* %5)
%66 = call i8* @ctime(i32* %5)
%67 = call i32 @remove_newline_ch(i8* %66)
%68 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %66, i8* %13, i8* %37)
%69 = call i32 @fflush(i32* %16)
%70 = bitcast %struct.sockaddr_un* %6 to i8*
%71 = call i32 @make_named_socket(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
%72 = load i32, i32* @AF_LOCAL
%73 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %6, i64 0, i32 1
store i32 %72, i32* %73
%74 = call i32 @strcpy(i32 undef, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0))
%75 = call i64 @strlen(i8* %37)
%76 = add nsw i64 %75, 1
%77 = bitcast %struct.sockaddr_un* %6 to %struct.sockaddr*
%78 = call i32 @sendto(i32 %71, i8* %37, i64 %76, i32 0, %struct.sockaddr* %77, i32 8)
%79 = icmp slt i32 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %63
%81 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0))
br label %82
82: ; preds = %80, %63
%83 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%84 = call i32 @sprintf(i8* %83, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %51)
%85 = call i64 @strlen(i8* %83)
%86 = load i32*, i32** @stdout
%87 = call i32 @fwrite(i8* %83, i32 1, i64 %85, i32* %86)
%88 = load i32*, i32** @stdout
%89 = call i32 @fflush(i32* %88)
%90 = load i32, i32* @stdin
%91 = call signext i8 @getc(i32 %90)
%92 = call i32 @fclose(i32* %16)
ret i32 0
}