#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*/ FILE;

/* Variables and functions */
char EOF;
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, scalar_t__);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strlen(char *);
scalar_t__ write(int, char *, scalar_t__);
void _sendFile(int clientSocket) {
  char buffer[256] = {'\0'};
  bzero(buffer, 256);
  int readStatus = read(clientSocket, buffer, 256);
  if (readStatus < 0) {
    fprintf(stderr, "Error: Reading from socket.\n");
    return;
  }
  char fileName[256] = {'\0'};
  sscanf(buffer, "GET /%s ", fileName);
  FILE *fp = fopen(fileName, "rb");
  if (!fp) {
    fprintf(stderr, "Error: File opening.\n");
    return;
  }
  fprintf(stdout, "Sending: %s\n", fileName);
  char fileChar = 0;
  int i = -1;
  bzero(buffer, 256);
  while ((fileChar = fgetc(fp)) != EOF) {
    buffer[++i] = fileChar;
  }
  fclose(fp);
  char header[256] = "HTTP/1.1 200 OK\r\n";
  char contentType[256] = "Content-Type: text/html; charset=UTF-8\r\n";
  char contentLength[256] = {'\0'};
  sprintf(contentLength, "Content-Length: %zu\r\n", strlen(buffer) + 1);
  char response[256] = {'\0'};
  strcat(response, header);
  strcat(response, contentType);
  strcat(response, contentLength);
  strcat(response, "\r\n\r\n");
  if (write(clientSocket, response, strlen(response)) < 0) {
    fprintf(stderr, "Error: Sending header.\n");
    return;
  };
  if (write(clientSocket, buffer, strlen(buffer) + 1) < 0) {
    fprintf(stderr, "Error: Sending file.\n");
    return;
  }
  fprintf(stdout, "Sent: %s\n\n", fileName);
  fprintf(stdout, "Waiting..\n\n");
}


x86 assembly (clang, -O0):
<_sendFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x660,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    -0x110(%rbp),%rdi
mov    $0x100,%esi
call   10d0 <bzero@plt>
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0x100,%edx
call   1080 <read@plt>
mov    %eax,-0x114(%rbp)
cmpl   $0x0,-0x114(%rbp)
jge    1245 <_sendFile+0x75>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0xdc7(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1517 <_sendFile+0x347>
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    -0x110(%rbp),%rdi
lea    -0x220(%rbp),%rdx
lea    0xdb0(%rip),%rsi
call   10b0 <sscanf@plt>
lea    -0x220(%rbp),%rdi
lea    0xda6(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x228(%rbp)
cmpq   $0x0,-0x228(%rbp)
jne    12b6 <_sendFile+0xe6>
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
lea    0xd7f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1517 <_sendFile+0x347>
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
lea    -0x220(%rbp),%rdx
lea    0xd72(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movb   $0x0,-0x229(%rbp)
movl   $0xffffffff,-0x230(%rbp)
ff ff ff
lea    -0x110(%rbp),%rdi
mov    $0x100,%esi
call   10d0 <bzero@plt>
mov    -0x228(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x229(%rbp)
movsbl %al,%eax
mov    0x2cd6(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1340 <_sendFile+0x170>
mov    -0x229(%rbp),%cl
mov    -0x230(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x230(%rbp)
cltq
mov    %cl,-0x110(%rbp,%rax,1)
jmp    12f6 <_sendFile+0x126>
mov    -0x228(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x330(%rbp),%rdi
lea    0xd56(%rip),%rsi
mov    $0x100,%edx
call   10a0 <memcpy@plt>
lea    -0x430(%rbp),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x100,%edx
call   10a0 <memcpy@plt>
lea    -0x530(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    -0x530(%rbp),%rax
mov    %rax,-0x648(%rbp)
lea    -0x110(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x648(%rbp),%rdi
mov    %rax,%rdx
add    $0x1,%rdx
lea    0xc8e(%rip),%rsi
call   10f0 <sprintf@plt>
lea    -0x630(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    -0x630(%rbp),%rdi
lea    -0x330(%rbp),%rsi
call   10e0 <strcat@plt>
lea    -0x630(%rbp),%rdi
lea    -0x430(%rbp),%rsi
call   10e0 <strcat@plt>
lea    -0x630(%rbp),%rdi
lea    -0x530(%rbp),%rsi
call   10e0 <strcat@plt>
lea    -0x630(%rbp),%rdi
lea    0xc45(%rip),%rsi
call   10e0 <strcat@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x63c(%rbp)
lea    -0x630(%rbp),%rax
mov    %rax,-0x638(%rbp)
lea    -0x630(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x63c(%rbp),%edi
mov    -0x638(%rbp),%rsi
mov    %rax,%rdx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    1480 <_sendFile+0x2b0>
mov    0x2b6d(%rip),%rax
mov    (%rax),%edi
lea    0xbf3(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1517 <_sendFile+0x347>
mov    -0x4(%rbp),%eax
mov    %eax,-0x654(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x650(%rbp)
lea    -0x110(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x654(%rbp),%edi
mov    -0x650(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    14e2 <_sendFile+0x312>
mov    0x2b0b(%rip),%rax
mov    (%rax),%edi
lea    0xba9(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1517 <_sendFile+0x347>
mov    0x2ae7(%rip),%rax
mov    (%rax),%edi
lea    -0x220(%rbp),%rdx
lea    0xb9c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2ac9(%rip),%rax
mov    (%rax),%edi
lea    0xb90(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
add    $0x660,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_sendFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x608,%rsp
mov    %edi,%r12d
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   10c0 <bzero@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1070 <read@plt>
test   %eax,%eax
js     1589 <_sendFile+0x3c9>
xorps  %xmm0,%xmm0
movaps %xmm0,0x1f0(%rsp)
movaps %xmm0,0x1e0(%rsp)
movaps %xmm0,0x1d0(%rsp)
movaps %xmm0,0x1c0(%rsp)
movaps %xmm0,0x1b0(%rsp)
movaps %xmm0,0x1a0(%rsp)
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
lea    0xd2d(%rip),%rsi
mov    %rsp,%rdi
lea    0x100(%rsp),%rbx
mov    %rbx,%rdx
call   10a0 <sscanf@plt>
lea    0xd1c(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     15b1 <_sendFile+0x3f1>
mov    %rax,%rbx
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
lea    0xd11(%rip),%rsi
lea    0x100(%rsp),%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x100,%esi
call   10c0 <bzero@plt>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    0x2c8c(%rip),%r14
cmp    (%r14),%al
je     1384 <_sendFile+0x1c4>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %al,0x0(%rbp)
mov    %rbx,%rdi
call   1060 <fgetc@plt>
add    $0x1,%rbp
cmp    (%r14),%al
jne    1370 <_sendFile+0x1b0>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xd1d(%rip),%rsi
lea    0x500(%rsp),%r14
mov    $0x100,%edx
mov    %r14,%rdi
call   1090 <memcpy@plt>
lea    0xe01(%rip),%rsi
lea    0x400(%rsp),%r15
mov    $0x100,%edx
mov    %r15,%rdi
call   1090 <memcpy@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x3f0(%rsp)
movaps %xmm0,0x3e0(%rsp)
movaps %xmm0,0x3d0(%rsp)
movaps %xmm0,0x3c0(%rsp)
movaps %xmm0,0x3b0(%rsp)
movaps %xmm0,0x3a0(%rsp)
movaps %xmm0,0x390(%rsp)
movaps %xmm0,0x380(%rsp)
movaps %xmm0,0x370(%rsp)
movaps %xmm0,0x360(%rsp)
movaps %xmm0,0x350(%rsp)
movaps %xmm0,0x340(%rsp)
movaps %xmm0,0x330(%rsp)
movaps %xmm0,0x320(%rsp)
movaps %xmm0,0x310(%rsp)
movaps %xmm0,0x300(%rsp)
mov    %rsp,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbx
add    $0x1,%rbx
lea    0xbef(%rip),%rsi
lea    0x300(%rsp),%r13
mov    %r13,%rdi
mov    %rbx,%rdx
call   10e0 <sprintf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x2f0(%rsp)
movaps %xmm0,0x2e0(%rsp)
movaps %xmm0,0x2d0(%rsp)
movaps %xmm0,0x2c0(%rsp)
movaps %xmm0,0x2b0(%rsp)
movaps %xmm0,0x2a0(%rsp)
movaps %xmm0,0x290(%rsp)
movaps %xmm0,0x280(%rsp)
movaps %xmm0,0x270(%rsp)
movaps %xmm0,0x260(%rsp)
movaps %xmm0,0x250(%rsp)
movaps %xmm0,0x240(%rsp)
movaps %xmm0,0x230(%rsp)
movaps %xmm0,0x220(%rsp)
movaps %xmm0,0x210(%rsp)
movaps %xmm0,0x200(%rsp)
lea    0x200(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
call   10d0 <strcat@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   10d0 <strcat@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   10d0 <strcat@plt>
lea    0xb3f(%rip),%rsi
mov    %rbp,%rdi
call   10d0 <strcat@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1030 <write@plt>
mov    0x2a90(%rip),%rbp
test   %rax,%rax
js     15c3 <_sendFile+0x403>
mov    %rsp,%rsi
mov    %r12d,%edi
mov    %rbx,%rdx
call   1030 <write@plt>
test   %rax,%rax
js     15cc <_sendFile+0x40c>
mov    0x2a69(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xb24(%rip),%rsi
lea    0x100(%rsp),%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xb19(%rip),%rsi
jmp    15d3 <_sendFile+0x413>
mov    0x2a48(%rip),%rax
mov    (%rax),%edi
lea    0xa67(%rip),%rsi
xor    %eax,%eax
add    $0x608,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <fprintf@plt>
mov    0x2a20(%rip),%rax
mov    (%rax),%edi
lea    0xa68(%rip),%rsi
jmp    15d6 <_sendFile+0x416>
lea    0xa9d(%rip),%rsi
jmp    15d3 <_sendFile+0x413>
lea    0xaac(%rip),%rsi
mov    0x0(%rbp),%edi
xor    %eax,%eax
call   1080 <fprintf@plt>
add    $0x608,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"Error: Reading from socket.\0A\00"
@.str.1 = [9 x i8] c"GET /%s \00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [22 x i8] c"Error: File opening.\0A\00"
@stdout = global i32 0
@.str.4 = [13 x i8] c"Sending: %s\0A\00"
@EOF = global i8 0
@__const._sendFile.header = [256 x i8] c"HTTP/1.1 200 OK\0D\0A\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const._sendFile.contentType = [256 x i8] c"Content-Type: text/html; charset=UTF-8\0D\0A\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.5 = [22 x i8] c"Content-Length: %zu\0D\0A\00"
@.str.6 = [5 x i8] c"\0D\0A\0D\0A\00"
@.str.7 = [24 x i8] c"Error: Sending header.\0A\00"
@.str.8 = [22 x i8] c"Error: Sending file.\0A\00"
@.str.9 = [11 x i8] c"Sent: %s\0A\0A\00"
@.str.10 = [12 x i8] c"Waiting..\0A\0A\00"
define void @_sendFile(i32 %0) {
%2 = alloca i32
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = alloca [256 x i8]
%6 = alloca i32*
%7 = alloca i8
%8 = alloca i32
%9 = alloca [256 x i8]
%10 = alloca [256 x i8]
%11 = alloca [256 x i8]
%12 = alloca [256 x i8]
store i32 %0, i32* %2
%13 = bitcast [256 x i8]* %3 to i8*
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%15 = call i32 @bzero(i8* %14, i32 256)
%16 = load i32, i32* %2
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%18 = call i32 @read(i32 %16, i8* %17, i32 256)
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %1
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %104
24: ; preds = %1
%25 = bitcast [256 x i8]* %5 to i8*
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%28 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %30, i32** %6
%31 = load i32*, i32** %6
%32 = icmp ne i32* %31, null
br i1 %32, label %36, label %33
33: ; preds = %24
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %104
36: ; preds = %24
%37 = load i32, i32* @stdout
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %38)
store i8 0, i8* %7
store i32 -1, i32* %8
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%41 = call i32 @bzero(i8* %40, i32 256)
br label %42
42: ; preds = %49, %36
%43 = load i32*, i32** %6
%44 = call signext i8 @fgetc(i32* %43)
store i8 %44, i8* %7
%45 = sext i8 %44 to i32
%46 = load i8, i8* @EOF
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %45, %47
br i1 %48, label %49, label %55
49: ; preds = %42
%50 = load i8, i8* %7
%51 = load i32, i32* %8
%52 = add nsw i32 %51, 1
store i32 %52, i32* %8
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %53
store i8 %50, i8* %54
br label %42
55: ; preds = %42
%56 = load i32*, i32** %6
%57 = call i32 @fclose(i32* %56)
%58 = bitcast [256 x i8]* %9 to i8*
%59 = bitcast [256 x i8]* %10 to i8*
%60 = bitcast [256 x i8]* %11 to i8*
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%62 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%63 = call i64 @strlen(i8* %62)
%64 = add nsw i64 %63, 1
%65 = call i32 @sprintf(i8* %61, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i64 %64)
%66 = bitcast [256 x i8]* %12 to i8*
%67 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%69 = call i32 @strcat(i8* %67, i8* %68)
%70 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%71 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%72 = call i32 @strcat(i8* %70, i8* %71)
%73 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%74 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%75 = call i32 @strcat(i8* %73, i8* %74)
%76 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%77 = call i32 @strcat(i8* %76, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%78 = load i32, i32* %2
%79 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%80 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%81 = call i64 @strlen(i8* %80)
%82 = call i64 @write(i32 %78, i8* %79, i64 %81)
%83 = icmp slt i64 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %55
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %104
87: ; preds = %55
%88 = load i32, i32* %2
%89 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%90 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%91 = call i64 @strlen(i8* %90)
%92 = add nsw i64 %91, 1
%93 = call i64 @write(i32 %88, i8* %89, i64 %92)
%94 = icmp slt i64 %93, 0
br i1 %94, label %95, label %98
95: ; preds = %87
%96 = load i32, i32* @stderr
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
br label %104
98: ; preds = %87
%99 = load i32, i32* @stdout
%100 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %100)
%102 = load i32, i32* @stdout
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %102, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %104
104: ; preds = %98, %95, %84, %33, %21
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"Error: Reading from socket.\0A\00"
@.str.1 = [9 x i8] c"GET /%s \00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [22 x i8] c"Error: File opening.\0A\00"
@stdout = global i32 0
@.str.4 = [13 x i8] c"Sending: %s\0A\00"
@EOF = global i8 0
@__const._sendFile.header = [256 x i8] c"HTTP/1.1 200 OK\0D\0A\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const._sendFile.contentType = [256 x i8] c"Content-Type: text/html; charset=UTF-8\0D\0A\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.5 = [22 x i8] c"Content-Length: %zu\0D\0A\00"
@.str.6 = [5 x i8] c"\0D\0A\0D\0A\00"
@.str.7 = [24 x i8] c"Error: Sending header.\0A\00"
@.str.8 = [22 x i8] c"Error: Sending file.\0A\00"
@.str.9 = [11 x i8] c"Sent: %s\0A\0A\00"
@.str.10 = [12 x i8] c"Waiting..\0A\0A\00"
define void @_sendFile(i32 %0) {
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%9 = call i32 @bzero(i8* %8, i32 256)
%10 = call i32 @read(i32 %0, i8* %8, i32 256)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %66
15: ; preds = %1
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%17 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %65
23: ; preds = %15
%24 = load i32, i32* @stdout
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %16)
%26 = call i32 @bzero(i8* %8, i32 256)
%27 = call signext i8 @fgetc(i32* %18)
%28 = load i8, i8* @EOF
%29 = icmp eq i8 %27, %28
br i1 %29, label %38, label %30
30: ; preds = %23, %30
%31 = phi i64 [ %33, %30 ], [ -1, %23 ]
%32 = phi i8 [ %35, %30 ], [ %27, %23 ]
%33 = add nsw i64 %31, 1
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %33
store i8 %32, i8* %34
%35 = call signext i8 @fgetc(i32* %18)
%36 = load i8, i8* @EOF
%37 = icmp eq i8 %35, %36
br i1 %37, label %38, label %30
38: ; preds = %30, %23
%39 = call i32 @fclose(i32* %18)
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%43 = call i64 @strlen(i8* %8)
%44 = add nsw i64 %43, 1
%45 = call i32 @sprintf(i8* %42, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i64 %44)
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%47 = call i32 @strcat(i8* %46, i8* %40)
%48 = call i32 @strcat(i8* %46, i8* %41)
%49 = call i32 @strcat(i8* %46, i8* %42)
%50 = call i32 @strcat(i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%51 = call i64 @strlen(i8* %46)
%52 = call i64 @write(i32 %0, i8* %46, i64 %51)
%53 = icmp slt i64 %52, 0
br i1 %53, label %60, label %54
54: ; preds = %38
%55 = call i64 @write(i32 %0, i8* %8, i64 %44)
%56 = icmp slt i64 %55, 0
br i1 %56, label %60, label %57
57: ; preds = %54
%58 = load i32, i32* @stdout
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %16)
br label %60
60: ; preds = %54, %38, %57
%61 = phi i32* [ @stdout, %57 ], [ @stderr, %38 ], [ @stderr, %54 ]
%62 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), %57 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), %38 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), %54 ]
%63 = load i32, i32* %61
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* %62)
br label %65
65: ; preds = %60, %20
br label %66
66: ; preds = %65, %12
ret void
}