#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 stat {
  scalar_t__ st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int fread(char *, scalar_t__, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
char *getExtension(char const *);
char *malloc(int);
int /*<<< orphan*/ perror(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ writeBasicResponse(int, int, char *, char *, int);
int /*<<< orphan*/ writeError(int, int);
void writeFileResponse(int socket, const char *file, struct stat fileStat) {
  FILE *fp = fopen(file, "r");
  char *buffer = malloc((fileStat.st_size + 1) * sizeof(char));
  if (fread(buffer, fileStat.st_size, 1, fp) == -1) {
    fclose(fp);
    perror("Problem reading file");
    writeError(socket, 500);
  } else {
    fclose(fp);
    char *contentType;
    char *extension = getExtension(file);
    if (extension) {
      if (strcmp(extension, "html") == 0) {
        contentType = "text/html";
      } else if (strcmp(extension, "xml") == 0) {
        contentType = "text/xml";
      } else if (strcmp(extension, "css") == 0) {
        contentType = "text/css";
      } else if (strcmp(extension, "js") == 0) {
        contentType = "application/javascript";
      } else if (strcmp(extension, "json") == 0) {
        contentType = "application/json";
      } else if (strcmp(extension, "jpg") == 0 ||
                 strcmp(extension, "jpeg") == 0) {
        contentType = "image/jpeg";
      } else if (strcmp(extension, "gif") == 0) {
        contentType = "image/gif";
      } else if (strcmp(extension, "png") == 0) {
        contentType = "image/png";
      } else if (strcmp(extension, "bmp") == 0) {
        contentType = "image/bmp";
      } else if (strcmp(extension, "tiff") == 0) {
        contentType = "image/tiff";
      } else if (strcmp(extension, "ico") == 0) {
        contentType = "image/x-icon";
      } else if (strcmp(extension, "svg") == 0) {
        contentType = "image/svg+xml";
      } else if (strcmp(extension, "woff") == 0) {
        contentType = "application/font-woff";
      } else if (strcmp(extension, "ttf") == 0) {
        contentType = "application/x-font-ttf";
      } else if (strcmp(extension, "eot") == 0) {
        contentType = "application/vnd.ms-fontobject";
      } else {
        contentType = "text/plain";
      }
    } else {
      contentType = "text/plain";
    }
    writeBasicResponse(socket, 200, buffer, contentType, (int)fileStat.st_size);
  }
  free(buffer);
}


x86 assembly (clang, -O0):
<writeFileResponse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdx,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fread@plt>
cmp    $0xffffffff,%eax
jne    1224 <writeFileResponse+0x84>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xdf5(%rip),%rdi
call   10b0 <perror@plt>
mov    -0xc(%rbp),%edi
mov    $0x1f4,%esi
call   1070 <writeError@plt>
jmp    1552 <writeFileResponse+0x3b2>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   10c0 <getExtension@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     152b <writeFileResponse+0x38b>
mov    -0x38(%rbp),%rdi
lea    0xdcc(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    126f <writeFileResponse+0xcf>
lea    0xdb1(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1526 <writeFileResponse+0x386>
mov    -0x38(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1299 <writeFileResponse+0xf9>
lea    0xd91(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1521 <writeFileResponse+0x381>
mov    -0x38(%rbp),%rdi
lea    0xd8b(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12c3 <writeFileResponse+0x123>
lea    0xd70(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    151c <writeFileResponse+0x37c>
mov    -0x38(%rbp),%rdi
lea    0xd65(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12ed <writeFileResponse+0x14d>
lea    0xd52(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1517 <writeFileResponse+0x377>
mov    -0x38(%rbp),%rdi
lea    0xd61(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1317 <writeFileResponse+0x177>
lea    0xd3f(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1512 <writeFileResponse+0x372>
mov    -0x38(%rbp),%rdi
lea    0xd3c(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     134b <writeFileResponse+0x1ab>
mov    -0x38(%rbp),%rdi
lea    0xd2c(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    135b <writeFileResponse+0x1bb>
lea    0xd10(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    150d <writeFileResponse+0x36d>
mov    -0x38(%rbp),%rdi
lea    0xd0d(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1385 <writeFileResponse+0x1e5>
lea    0xcf1(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1508 <writeFileResponse+0x368>
mov    -0x38(%rbp),%rdi
lea    0xced(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    13af <writeFileResponse+0x20f>
lea    0xcd1(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1503 <writeFileResponse+0x363>
mov    -0x38(%rbp),%rdi
lea    0xccd(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    13d9 <writeFileResponse+0x239>
lea    0xcb1(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    14fe <writeFileResponse+0x35e>
mov    -0x38(%rbp),%rdi
lea    0xcad(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1403 <writeFileResponse+0x263>
lea    0xc91(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    14f9 <writeFileResponse+0x359>
mov    -0x38(%rbp),%rdi
lea    0xc88(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    142d <writeFileResponse+0x28d>
lea    0xc76(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    14f4 <writeFileResponse+0x354>
mov    -0x38(%rbp),%rdi
lea    0xc6f(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1457 <writeFileResponse+0x2b7>
lea    0xc5d(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    14ef <writeFileResponse+0x34f>
mov    -0x38(%rbp),%rdi
lea    0xc68(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1481 <writeFileResponse+0x2e1>
lea    0xc41(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    14ea <writeFileResponse+0x34a>
mov    -0x38(%rbp),%rdi
lea    0xc56(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    14ab <writeFileResponse+0x30b>
lea    0xc2d(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    14e5 <writeFileResponse+0x345>
mov    -0x38(%rbp),%rdi
lea    0xc30(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    14d5 <writeFileResponse+0x335>
lea    0xc1e(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    14e0 <writeFileResponse+0x340>
lea    0xc2c(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    14e5 <writeFileResponse+0x345>
jmp    14ea <writeFileResponse+0x34a>
jmp    14ef <writeFileResponse+0x34f>
jmp    14f4 <writeFileResponse+0x354>
jmp    14f9 <writeFileResponse+0x359>
jmp    14fe <writeFileResponse+0x35e>
jmp    1503 <writeFileResponse+0x363>
jmp    1508 <writeFileResponse+0x368>
jmp    150d <writeFileResponse+0x36d>
jmp    1512 <writeFileResponse+0x372>
jmp    1517 <writeFileResponse+0x377>
jmp    151c <writeFileResponse+0x37c>
jmp    1521 <writeFileResponse+0x381>
jmp    1526 <writeFileResponse+0x386>
jmp    1536 <writeFileResponse+0x396>
lea    0xbd6(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %eax,%r8d
mov    $0xc8,%esi
call   1060 <writeBasicResponse@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeFileResponse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r13
mov    %edi,%r14d
lea    0xe45(%rip),%rsi
mov    %r13,%rdi
call   10a0 <fopen@plt>
mov    %rax,%rbp
lea    0x1(%r12),%edi
call   1090 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r12,%rsi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1050 <fclose@plt>
cmp    $0xffffffff,%ebx
je     13c6 <writeFileResponse+0x226>
mov    %r13,%rdi
call   10c0 <getExtension@plt>
test   %rax,%rax
je     13a2 <writeFileResponse+0x202>
mov    %rax,%rbx
lea    0xe08(%rip),%rsi
mov    %rax,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13ab <writeFileResponse+0x20b>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13b4 <writeFileResponse+0x214>
lea    0xdeb(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13bd <writeFileResponse+0x21d>
lea    0xdd7(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13e1 <writeFileResponse+0x241>
lea    0xde5(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13ea <writeFileResponse+0x24a>
lea    0xdd2(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
lea    0xdc7(%rip),%rbp
test   %rax,%rax
je     13f1 <writeFileResponse+0x251>
lea    0xdbd(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13f1 <writeFileResponse+0x251>
lea    0xdb0(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     141d <writeFileResponse+0x27d>
lea    0xda2(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1426 <writeFileResponse+0x286>
lea    0xd94(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     142f <writeFileResponse+0x28f>
lea    0xd86(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1438 <writeFileResponse+0x298>
lea    0xd73(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1441 <writeFileResponse+0x2a1>
lea    0xd6c(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     144a <writeFileResponse+0x2aa>
lea    0xd77(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1453 <writeFileResponse+0x2b3>
lea    0xd77(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     145c <writeFileResponse+0x2bc>
lea    0xd63(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
lea    0xd55(%rip),%rax
lea    0xd6c(%rip),%rbp
cmove  %rax,%rbp
jmp    13f1 <writeFileResponse+0x251>
lea    0xd5f(%rip),%rbp
jmp    13f1 <writeFileResponse+0x251>
lea    0xc65(%rip),%rbp
jmp    13f1 <writeFileResponse+0x251>
lea    0xc66(%rip),%rbp
jmp    13f1 <writeFileResponse+0x251>
lea    0xc66(%rip),%rbp
jmp    13f1 <writeFileResponse+0x251>
lea    0xc35(%rip),%rdi
call   10b0 <perror@plt>
mov    %r14d,%edi
mov    $0x1f4,%esi
call   1070 <writeError@plt>
jmp    1407 <writeFileResponse+0x267>
lea    0xc4e(%rip),%rbp
jmp    13f1 <writeFileResponse+0x251>
lea    0xc5c(%rip),%rbp
mov    %r14d,%edi
mov    $0xc8,%esi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %r12d,%r8d
call   1060 <writeBasicResponse@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
lea    0xc49(%rip),%rbp
jmp    13f1 <writeFileResponse+0x251>
lea    0xc4a(%rip),%rbp
jmp    13f1 <writeFileResponse+0x251>
lea    0xc4b(%rip),%rbp
jmp    13f1 <writeFileResponse+0x251>
lea    0xc4c(%rip),%rbp
jmp    13f1 <writeFileResponse+0x251>
lea    0xc52(%rip),%rbp
jmp    13f1 <writeFileResponse+0x251>
lea    0xc5a(%rip),%rbp
jmp    13f1 <writeFileResponse+0x251>
lea    0xc5f(%rip),%rbp
jmp    13f1 <writeFileResponse+0x251>
lea    0xc6c(%rip),%rbp
jmp    13f1 <writeFileResponse+0x251>

LLVM IR (-O0):
%struct.stat = type { i64 }
@.str = [2 x i8] c"r\00"
@.str.1 = [21 x i8] c"Problem reading file\00"
@.str.2 = [5 x i8] c"html\00"
@.str.3 = [10 x i8] c"text/html\00"
@.str.4 = [4 x i8] c"xml\00"
@.str.5 = [9 x i8] c"text/xml\00"
@.str.6 = [4 x i8] c"css\00"
@.str.7 = [9 x i8] c"text/css\00"
@.str.8 = [3 x i8] c"js\00"
@.str.9 = [23 x i8] c"application/javascript\00"
@.str.10 = [5 x i8] c"json\00"
@.str.11 = [17 x i8] c"application/json\00"
@.str.12 = [4 x i8] c"jpg\00"
@.str.13 = [5 x i8] c"jpeg\00"
@.str.14 = [11 x i8] c"image/jpeg\00"
@.str.15 = [4 x i8] c"gif\00"
@.str.16 = [10 x i8] c"image/gif\00"
@.str.17 = [4 x i8] c"png\00"
@.str.18 = [10 x i8] c"image/png\00"
@.str.19 = [4 x i8] c"bmp\00"
@.str.20 = [10 x i8] c"image/bmp\00"
@.str.21 = [5 x i8] c"tiff\00"
@.str.22 = [11 x i8] c"image/tiff\00"
@.str.23 = [4 x i8] c"ico\00"
@.str.24 = [13 x i8] c"image/x-icon\00"
@.str.25 = [4 x i8] c"svg\00"
@.str.26 = [14 x i8] c"image/svg+xml\00"
@.str.27 = [5 x i8] c"woff\00"
@.str.28 = [22 x i8] c"application/font-woff\00"
@.str.29 = [4 x i8] c"ttf\00"
@.str.30 = [23 x i8] c"application/x-font-ttf\00"
@.str.31 = [4 x i8] c"eot\00"
@.str.32 = [30 x i8] c"application/vnd.ms-fontobject\00"
@.str.33 = [11 x i8] c"text/plain\00"
define void @writeFileResponse(i32 %0, i8* %1, i64 %2) {
%4 = alloca %struct.stat
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
store i64 %2, i64* %11
store i32 %0, i32* %5
store i8* %1, i8** %6
%12 = load i8*, i8** %6
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %7
%14 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%15 = load i64, i64* %14
%16 = add nsw i64 %15, 1
%17 = mul i64 %16, 1
%18 = trunc i64 %17 to i32
%19 = call i8* @malloc(i32 %18)
store i8* %19, i8** %8
%20 = load i8*, i8** %8
%21 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%22 = load i64, i64* %21
%23 = load i32*, i32** %7
%24 = call i32 @fread(i8* %20, i64 %22, i32 1, i32* %23)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %32
26: ; preds = %3
%27 = load i32*, i32** %7
%28 = call i32 @fclose(i32* %27)
%29 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* %5
%31 = call i32 @writeError(i32 %30, i32 500)
br label %143
32: ; preds = %3
%33 = load i32*, i32** %7
%34 = call i32 @fclose(i32* %33)
%35 = load i8*, i8** %6
%36 = call i8* @getExtension(i8* %35)
store i8* %36, i8** %10
%37 = load i8*, i8** %10
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %134
39: ; preds = %32
%40 = load i8*, i8** %10
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %39
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %9
br label %133
44: ; preds = %39
%45 = load i8*, i8** %10
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %44
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %9
br label %132
49: ; preds = %44
%50 = load i8*, i8** %10
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %49
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8** %9
br label %131
54: ; preds = %49
%55 = load i8*, i8** %10
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %54
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8** %9
br label %130
59: ; preds = %54
%60 = load i8*, i8** %10
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %59
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i8** %9
br label %129
64: ; preds = %59
%65 = load i8*, i8** %10
%66 = call i64 @strcmp(i8* %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %72, label %68
68: ; preds = %64
%69 = load i8*, i8** %10
%70 = call i64 @strcmp(i8* %69, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %73
72: ; preds = %68, %64
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0), i8** %9
br label %128
73: ; preds = %68
%74 = load i8*, i8** %10
%75 = call i64 @strcmp(i8* %74, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0))
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %78
77: ; preds = %73
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0), i8** %9
br label %127
78: ; preds = %73
%79 = load i8*, i8** %10
%80 = call i64 @strcmp(i8* %79, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0))
%81 = icmp eq i64 %80, 0
br i1 %81, label %82, label %83
82: ; preds = %78
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0), i8** %9
br label %126
83: ; preds = %78
%84 = load i8*, i8** %10
%85 = call i64 @strcmp(i8* %84, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0))
%86 = icmp eq i64 %85, 0
br i1 %86, label %87, label %88
87: ; preds = %83
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.20, i64 0, i64 0), i8** %9
br label %125
88: ; preds = %83
%89 = load i8*, i8** %10
%90 = call i64 @strcmp(i8* %89, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.21, i64 0, i64 0))
%91 = icmp eq i64 %90, 0
br i1 %91, label %92, label %93
92: ; preds = %88
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.22, i64 0, i64 0), i8** %9
br label %124
93: ; preds = %88
%94 = load i8*, i8** %10
%95 = call i64 @strcmp(i8* %94, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.23, i64 0, i64 0))
%96 = icmp eq i64 %95, 0
br i1 %96, label %97, label %98
97: ; preds = %93
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.24, i64 0, i64 0), i8** %9
br label %123
98: ; preds = %93
%99 = load i8*, i8** %10
%100 = call i64 @strcmp(i8* %99, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.25, i64 0, i64 0))
%101 = icmp eq i64 %100, 0
br i1 %101, label %102, label %103
102: ; preds = %98
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.26, i64 0, i64 0), i8** %9
br label %122
103: ; preds = %98
%104 = load i8*, i8** %10
%105 = call i64 @strcmp(i8* %104, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.27, i64 0, i64 0))
%106 = icmp eq i64 %105, 0
br i1 %106, label %107, label %108
107: ; preds = %103
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.28, i64 0, i64 0), i8** %9
br label %121
108: ; preds = %103
%109 = load i8*, i8** %10
%110 = call i64 @strcmp(i8* %109, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.29, i64 0, i64 0))
%111 = icmp eq i64 %110, 0
br i1 %111, label %112, label %113
112: ; preds = %108
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.30, i64 0, i64 0), i8** %9
br label %120
113: ; preds = %108
%114 = load i8*, i8** %10
%115 = call i64 @strcmp(i8* %114, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.31, i64 0, i64 0))
%116 = icmp eq i64 %115, 0
br i1 %116, label %117, label %118
117: ; preds = %113
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.32, i64 0, i64 0), i8** %9
br label %119
118: ; preds = %113
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.33, i64 0, i64 0), i8** %9
br label %119
119: ; preds = %118, %117
br label %120
120: ; preds = %119, %112
br label %121
121: ; preds = %120, %107
br label %122
122: ; preds = %121, %102
br label %123
123: ; preds = %122, %97
br label %124
124: ; preds = %123, %92
br label %125
125: ; preds = %124, %87
br label %126
126: ; preds = %125, %82
br label %127
127: ; preds = %126, %77
br label %128
128: ; preds = %127, %72
br label %129
129: ; preds = %128, %63
br label %130
130: ; preds = %129, %58
br label %131
131: ; preds = %130, %53
br label %132
132: ; preds = %131, %48
br label %133
133: ; preds = %132, %43
br label %135
134: ; preds = %32
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.33, i64 0, i64 0), i8** %9
br label %135
135: ; preds = %134, %133
%136 = load i32, i32* %5
%137 = load i8*, i8** %8
%138 = load i8*, i8** %9
%139 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%140 = load i64, i64* %139
%141 = trunc i64 %140 to i32
%142 = call i32 @writeBasicResponse(i32 %136, i32 200, i8* %137, i8* %138, i32 %141)
br label %143
143: ; preds = %135, %26
%144 = load i8*, i8** %8
%145 = call i32 @free(i8* %144)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [21 x i8] c"Problem reading file\00"
@.str.2 = [5 x i8] c"html\00"
@.str.3 = [10 x i8] c"text/html\00"
@.str.4 = [4 x i8] c"xml\00"
@.str.5 = [9 x i8] c"text/xml\00"
@.str.6 = [4 x i8] c"css\00"
@.str.7 = [9 x i8] c"text/css\00"
@.str.8 = [3 x i8] c"js\00"
@.str.9 = [23 x i8] c"application/javascript\00"
@.str.10 = [5 x i8] c"json\00"
@.str.11 = [17 x i8] c"application/json\00"
@.str.12 = [4 x i8] c"jpg\00"
@.str.13 = [5 x i8] c"jpeg\00"
@.str.14 = [11 x i8] c"image/jpeg\00"
@.str.15 = [4 x i8] c"gif\00"
@.str.16 = [10 x i8] c"image/gif\00"
@.str.17 = [4 x i8] c"png\00"
@.str.18 = [10 x i8] c"image/png\00"
@.str.19 = [4 x i8] c"bmp\00"
@.str.20 = [10 x i8] c"image/bmp\00"
@.str.21 = [5 x i8] c"tiff\00"
@.str.22 = [11 x i8] c"image/tiff\00"
@.str.23 = [4 x i8] c"ico\00"
@.str.24 = [13 x i8] c"image/x-icon\00"
@.str.25 = [4 x i8] c"svg\00"
@.str.26 = [14 x i8] c"image/svg+xml\00"
@.str.27 = [5 x i8] c"woff\00"
@.str.28 = [22 x i8] c"application/font-woff\00"
@.str.29 = [4 x i8] c"ttf\00"
@.str.30 = [23 x i8] c"application/x-font-ttf\00"
@.str.31 = [4 x i8] c"eot\00"
@.str.32 = [30 x i8] c"application/vnd.ms-fontobject\00"
@.str.33 = [11 x i8] c"text/plain\00"
define void @writeFileResponse(i32 %0, i8* %1, i64 %2) {
%4 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = trunc i64 %2 to i32
%6 = add i32 %5, 1
%7 = tail call i8* @malloc(i32 %6)
%8 = tail call i32 @fread(i8* %7, i64 %2, i32 1, i32* %4)
%9 = icmp eq i32 %8, -1
%10 = tail call i32 @fclose(i32* %4)
br i1 %9, label %11, label %14
11: ; preds = %3
%12 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @writeError(i32 %0, i32 500)
br label %69
14: ; preds = %3
%15 = tail call i8* @getExtension(i8* %1)
%16 = icmp eq i8* %15, null
br i1 %16, label %66, label %17
17: ; preds = %14
%18 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %66, label %20
20: ; preds = %17
%21 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %66, label %23
23: ; preds = %20
%24 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %66, label %26
26: ; preds = %23
%27 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %66, label %29
29: ; preds = %26
%30 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %66, label %32
32: ; preds = %29
%33 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %66, label %35
35: ; preds = %32
%36 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %66, label %38
38: ; preds = %35
%39 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %66, label %41
41: ; preds = %38
%42 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %66, label %44
44: ; preds = %41
%45 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %66, label %47
47: ; preds = %44
%48 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.21, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %66, label %50
50: ; preds = %47
%51 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.23, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %66, label %53
53: ; preds = %50
%54 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.25, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %66, label %56
56: ; preds = %53
%57 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.27, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
br i1 %58, label %66, label %59
59: ; preds = %56
%60 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.29, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %66, label %62
62: ; preds = %59
%63 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.31, i64 0, i64 0))
%64 = icmp eq i64 %63, 0
%65 = select i1 %64, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.32, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.33, i64 0, i64 0)
br label %66
66: ; preds = %14, %62, %59, %56, %53, %50, %47, %44, %41, %38, %32, %35, %29, %26, %23, %20, %17
%67 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %17 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), %20 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), %23 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), %26 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), %29 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0), %35 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0), %32 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0), %38 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0), %41 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.20, i64 0, i64 0), %44 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.22, i64 0, i64 0), %47 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.24, i64 0, i64 0), %50 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.26, i64 0, i64 0), %53 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.28, i64 0, i64 0), %56 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.30, i64 0, i64 0), %59 ], [ %65, %62 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.33, i64 0, i64 0), %14 ]
%68 = tail call i32 @writeBasicResponse(i32 %0, i32 200, i8* %7, i8* %67, i32 %5)
br label %69
69: ; preds = %66, %11
%70 = tail call i32 @free(i8* %7)
ret void
}