#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, "woff2") == 0) {
        contentType = "font/woff2";
      } 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    1581 <writeFileResponse+0x3e1>
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     155a <writeFileResponse+0x3ba>
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    1555 <writeFileResponse+0x3b5>
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    1550 <writeFileResponse+0x3b0>
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    154b <writeFileResponse+0x3ab>
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    1546 <writeFileResponse+0x3a6>
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    1541 <writeFileResponse+0x3a1>
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    153c <writeFileResponse+0x39c>
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    1537 <writeFileResponse+0x397>
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    1532 <writeFileResponse+0x392>
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    152d <writeFileResponse+0x38d>
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    1528 <writeFileResponse+0x388>
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    1523 <writeFileResponse+0x383>
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    151e <writeFileResponse+0x37e>
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    1519 <writeFileResponse+0x379>
mov    -0x38(%rbp),%rdi
lea    0xc48(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    14ab <writeFileResponse+0x30b>
lea    0xc2d(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1514 <writeFileResponse+0x374>
mov    -0x38(%rbp),%rdi
lea    0xc37(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    14d5 <writeFileResponse+0x335>
lea    0xc0e(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    150f <writeFileResponse+0x36f>
mov    -0x38(%rbp),%rdi
lea    0xc11(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    14ff <writeFileResponse+0x35f>
lea    0xbff(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    150a <writeFileResponse+0x36a>
lea    0xc0d(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    150f <writeFileResponse+0x36f>
jmp    1514 <writeFileResponse+0x374>
jmp    1519 <writeFileResponse+0x379>
jmp    151e <writeFileResponse+0x37e>
jmp    1523 <writeFileResponse+0x383>
jmp    1528 <writeFileResponse+0x388>
jmp    152d <writeFileResponse+0x38d>
jmp    1532 <writeFileResponse+0x392>
jmp    1537 <writeFileResponse+0x397>
jmp    153c <writeFileResponse+0x39c>
jmp    1541 <writeFileResponse+0x3a1>
jmp    1546 <writeFileResponse+0x3a6>
jmp    154b <writeFileResponse+0x3ab>
jmp    1550 <writeFileResponse+0x3b0>
jmp    1555 <writeFileResponse+0x3b5>
jmp    1565 <writeFileResponse+0x3c5>
lea    0xbb2(%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     13de <writeFileResponse+0x23e>
mov    %r13,%rdi
call   10c0 <getExtension@plt>
test   %rax,%rax
je     13ba <writeFileResponse+0x21a>
mov    %rax,%rbx
lea    0xe08(%rip),%rsi
mov    %rax,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13c3 <writeFileResponse+0x223>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13cc <writeFileResponse+0x22c>
lea    0xdeb(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13d5 <writeFileResponse+0x235>
lea    0xdd7(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13f9 <writeFileResponse+0x259>
lea    0xde5(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1402 <writeFileResponse+0x262>
lea    0xdd2(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
lea    0xdc7(%rip),%rbp
test   %rax,%rax
je     1409 <writeFileResponse+0x269>
lea    0xdbd(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1409 <writeFileResponse+0x269>
lea    0xdb0(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1435 <writeFileResponse+0x295>
lea    0xda2(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     143e <writeFileResponse+0x29e>
lea    0xd94(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1447 <writeFileResponse+0x2a7>
lea    0xd86(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1450 <writeFileResponse+0x2b0>
lea    0xd73(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1459 <writeFileResponse+0x2b9>
lea    0xd6c(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1462 <writeFileResponse+0x2c2>
lea    0xd77(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     146b <writeFileResponse+0x2cb>
lea    0xd69(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1474 <writeFileResponse+0x2d4>
lea    0xd6a(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     147d <writeFileResponse+0x2dd>
lea    0xd56(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
lea    0xd48(%rip),%rax
lea    0xd5f(%rip),%rbp
cmove  %rax,%rbp
jmp    1409 <writeFileResponse+0x269>
lea    0xd52(%rip),%rbp
jmp    1409 <writeFileResponse+0x269>
lea    0xc4d(%rip),%rbp
jmp    1409 <writeFileResponse+0x269>
lea    0xc4e(%rip),%rbp
jmp    1409 <writeFileResponse+0x269>
lea    0xc4e(%rip),%rbp
jmp    1409 <writeFileResponse+0x269>
lea    0xc1d(%rip),%rdi
call   10b0 <perror@plt>
mov    %r14d,%edi
mov    $0x1f4,%esi
call   1070 <writeError@plt>
jmp    141f <writeFileResponse+0x27f>
lea    0xc36(%rip),%rbp
jmp    1409 <writeFileResponse+0x269>
lea    0xc44(%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    0xc31(%rip),%rbp
jmp    1409 <writeFileResponse+0x269>
lea    0xc32(%rip),%rbp
jmp    1409 <writeFileResponse+0x269>
lea    0xc33(%rip),%rbp
jmp    1409 <writeFileResponse+0x269>
lea    0xc34(%rip),%rbp
jmp    1409 <writeFileResponse+0x269>
lea    0xc3a(%rip),%rbp
jmp    1409 <writeFileResponse+0x269>
lea    0xc42(%rip),%rbp
jmp    1409 <writeFileResponse+0x269>
lea    0xc47(%rip),%rbp
jmp    1409 <writeFileResponse+0x269>
lea    0xc54(%rip),%rbp
jmp    1409 <writeFileResponse+0x269>
lea    0xc56(%rip),%rbp
jmp    1409 <writeFileResponse+0x269>

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 = [6 x i8] c"woff2\00"
@.str.30 = [11 x i8] c"font/woff2\00"
@.str.31 = [4 x i8] c"ttf\00"
@.str.32 = [23 x i8] c"application/x-font-ttf\00"
@.str.33 = [4 x i8] c"eot\00"
@.str.34 = [30 x i8] c"application/vnd.ms-fontobject\00"
@.str.35 = [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 %149
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 %140
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 %139
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 %138
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 %137
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 %136
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 %135
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 %134
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 %133
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 %132
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 %131
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 %130
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 %129
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 %128
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 %127
108: ; preds = %103
%109 = load i8*, i8** %10
%110 = call i64 @strcmp(i8* %109, i8* getelementptr inbounds ([6 x i8], [6 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 ([11 x i8], [11 x i8]* @.str.30, i64 0, i64 0), i8** %9
br label %126
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 ([23 x i8], [23 x i8]* @.str.32, i64 0, i64 0), i8** %9
br label %125
118: ; preds = %113
%119 = load i8*, i8** %10
%120 = call i64 @strcmp(i8* %119, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.33, i64 0, i64 0))
%121 = icmp eq i64 %120, 0
br i1 %121, label %122, label %123
122: ; preds = %118
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.34, i64 0, i64 0), i8** %9
br label %124
123: ; preds = %118
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.35, i64 0, i64 0), i8** %9
br label %124
124: ; preds = %123, %122
br label %125
125: ; preds = %124, %117
br label %126
126: ; preds = %125, %112
br label %127
127: ; preds = %126, %107
br label %128
128: ; preds = %127, %102
br label %129
129: ; preds = %128, %97
br label %130
130: ; preds = %129, %92
br label %131
131: ; preds = %130, %87
br label %132
132: ; preds = %131, %82
br label %133
133: ; preds = %132, %77
br label %134
134: ; preds = %133, %72
br label %135
135: ; preds = %134, %63
br label %136
136: ; preds = %135, %58
br label %137
137: ; preds = %136, %53
br label %138
138: ; preds = %137, %48
br label %139
139: ; preds = %138, %43
br label %141
140: ; preds = %32
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.35, i64 0, i64 0), i8** %9
br label %141
141: ; preds = %140, %139
%142 = load i32, i32* %5
%143 = load i8*, i8** %8
%144 = load i8*, i8** %9
%145 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%146 = load i64, i64* %145
%147 = trunc i64 %146 to i32
%148 = call i32 @writeBasicResponse(i32 %142, i32 200, i8* %143, i8* %144, i32 %147)
br label %149
149: ; preds = %141, %26
%150 = load i8*, i8** %8
%151 = call i32 @free(i8* %150)
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 = [6 x i8] c"woff2\00"
@.str.30 = [11 x i8] c"font/woff2\00"
@.str.31 = [4 x i8] c"ttf\00"
@.str.32 = [23 x i8] c"application/x-font-ttf\00"
@.str.33 = [4 x i8] c"eot\00"
@.str.34 = [30 x i8] c"application/vnd.ms-fontobject\00"
@.str.35 = [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 %72
14: ; preds = %3
%15 = tail call i8* @getExtension(i8* %1)
%16 = icmp eq i8* %15, null
br i1 %16, label %69, 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 %69, 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 %69, 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 %69, 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 %69, 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 %69, 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 %69, 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 %69, 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 %69, 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 %69, 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 %69, 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 %69, 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 %69, 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 %69, 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 %69, label %59
59: ; preds = %56
%60 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.29, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %69, 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
br i1 %64, label %69, label %65
65: ; preds = %62
%66 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.33, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
%68 = select i1 %67, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.34, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.35, i64 0, i64 0)
br label %69
69: ; preds = %14, %65, %62, %59, %56, %53, %50, %47, %44, %41, %38, %32, %35, %29, %26, %23, %20, %17
%70 = 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 ([11 x i8], [11 x i8]* @.str.30, i64 0, i64 0), %59 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.32, i64 0, i64 0), %62 ], [ %68, %65 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.35, i64 0, i64 0), %14 ]
%71 = tail call i32 @writeBasicResponse(i32 %0, i32 200, i8* %7, i8* %70, i32 %5)
br label %72
72: ; preds = %69, %11
%73 = tail call i32 @free(i8* %7)
ret void
}