#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*/ timebuf;
struct tm {
  int dummy;
};
struct stat {
  scalar_t__ st_size;
  int /*<<< orphan*/ st_mode;
  int /*<<< orphan*/ st_mtime;
};
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
scalar_t__ S_ISDIR(int /*<<< orphan*/);
char *calloc(int, int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(char *);
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
int /*<<< orphan*/ *opendir(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ send_header(int /*<<< orphan*/ *, int, char *,
                               int /*<<< orphan*/ *, char *, int,
                               int /*<<< orphan*/);
int /*<<< orphan*/ set_simple_head(int /*<<< orphan*/ *, char *, char *,
                                   int /*<<< orphan*/ *);
int /*<<< orphan*/ stat(char *, struct stat *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
size_t strlen(char *);
void send_directory_listing(FILE *f, struct stat statbuf, char *relative_path,
                            char *path) {
  DIR *dir;
  struct dirent *de;
  send_header(f, 200, "OK", NULL, "text/html", -1, statbuf.st_mtime);
  fprintf(f, "<html>");
  set_simple_head(f, relative_path, relative_path, NULL);
  fprintf(f, "<body>");
  fprintf(f, "<h1>Index of %s</h1>\r\n", relative_path);
  fprintf(f, "<pre><table border=\"0\" width=\"100%%\">");
  fprintf(f, "<tr><th align=\"left\">Name</th><th align=\"left\">Last "
             "modified</th><th align=\"left\">Size</th></tr>");
  fprintf(f, "<hr />\r\n");
  dir = opendir(path);
  while ((de = readdir(dir)) != NULL) {
    char timebuf[32];
    struct tm *tm;
    char *pathbuf = calloc(strlen(path) + 128, sizeof(char));
    memcpy(pathbuf, path, strlen(path));
    pathbuf[strlen(pathbuf)] = '\0';
    strcat(pathbuf, de->d_name);
    stat(pathbuf, &statbuf);
    tm = gmtime(&statbuf.st_mtime);
    strftime(timebuf, sizeof(timebuf), "%Y-%b-%d %H:%M:%S", tm);
    fprintf(f, "<tr>");
    if (strcmp(de->d_name, ".") == 0)
      continue;
    if (strcmp(relative_path, "/") == 0 && strcmp(de->d_name, "..") == 0)
      continue;
    fprintf(f, "<td><a href=\"%s%s\">", de->d_name,
            S_ISDIR(statbuf.st_mode) ? "/" : "");
    fprintf(f, "%s%s</a></td>", de->d_name,
            S_ISDIR(statbuf.st_mode) ? "/" : "");
    if (S_ISDIR(statbuf.st_mode))
      fprintf(f, "<td>%s</td>", timebuf);
    else
      fprintf(f, "<td>%s</td> <td>%10llu</td>", timebuf,
              (unsigned long long)statbuf.st_size);
    fprintf(f, "</tr>");
    free(pathbuf);
  }
  closedir(dir);
  fprintf(f, "</table></pre>\r\n<hr /><address>%s</address>\r\n",
          "http_server 0.1");
  fprintf(f, "</body></html>");
}


x86 assembly (clang, -O0):
<send_directory_listing>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x8(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%eax
mov    $0xc8,%esi
lea    0xdce(%rip),%rdx
xor    %ecx,%ecx
lea    0xdc8(%rip),%r8
mov    $0xffffffff,%r9d
mov    %eax,(%rsp)
call   10b0 <send_header@plt>
mov    -0x18(%rbp),%rdi
lea    0xdb9(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x20(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1110 <set_simple_head@plt>
mov    -0x18(%rbp),%rdi
lea    0xd99(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xd8a(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xd8f(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xda3(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xdf2(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   10e0 <readdir@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     1526 <send_directory_listing+0x326>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x80,%rax
mov    %eax,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x88(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    %rax,%rdx
call   10d0 <memcpy@plt>
mov    -0x70(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x78(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x70(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    (%rax),%rsi
call   1120 <strcat@plt>
mov    -0x70(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   10c0 <stat@plt>
lea    -0x10(%rbp),%rdi
add    $0xc,%rdi
call   1100 <gmtime@plt>
mov    %rax,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x68(%rbp),%rcx
mov    $0x20,%esi
lea    0xd24(%rip),%rdx
call   10f0 <strftime@plt>
mov    -0x18(%rbp),%rdi
lea    0xd26(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    0xd19(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    13d7 <send_directory_listing+0x1d7>
jmp    12db <send_directory_listing+0xdb>
mov    -0x20(%rbp),%rdi
lea    0xcf7(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1413 <send_directory_listing+0x213>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    0xcdc(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1413 <send_directory_listing+0x213>
jmp    12db <send_directory_listing+0xdb>
mov    -0x18(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <S_ISDIR@plt>
mov    -0xa8(%rbp),%rdi
mov    -0xa0(%rbp),%rdx
mov    %rax,%rsi
lea    0xc75(%rip),%rcx
lea    0xc86(%rip),%rax
cmp    $0x0,%rsi
cmovne %rax,%rcx
lea    0xc7c(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x90(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <S_ISDIR@plt>
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rdx
mov    %rax,%rsi
lea    0xc1f(%rip),%rcx
lea    0xc30(%rip),%rax
cmp    $0x0,%rsi
cmovne %rax,%rcx
lea    0xc3a(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x8(%rbp),%edi
call   1060 <S_ISDIR@plt>
cmp    $0x0,%rax
je     14ec <send_directory_listing+0x2ec>
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xc20(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    1506 <send_directory_listing+0x306>
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xc0d(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xba2(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
jmp    12db <send_directory_listing+0xdb>
mov    -0x30(%rbp),%rdi
call   1070 <closedir@plt>
mov    -0x18(%rbp),%rdi
lea    0xbee(%rip),%rsi
lea    0xc15(%rip),%rdx
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xc13(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_directory_listing>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r8,%rbp
mov    %rcx,%rbx
mov    %rdi,%r12
mov    %rsi,0x8(%rsp)
mov    %rdx,0x10(%rsp)
shr    $0x20,%rdx
mov    %edx,(%rsp)
lea    0xdc1(%rip),%rdx
lea    0xdbd(%rip),%r8
mov    $0xc8,%esi
xor    %ecx,%ecx
mov    $0xffffffff,%r9d
call   10b0 <send_header@plt>
lea    0xdae(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1130 <fwrite@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1110 <set_simple_head@plt>
lea    0xd8c(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1130 <fwrite@plt>
lea    0xd7a(%rip),%rsi
mov    %r12,%rdi
mov    %rbx,0x20(%rsp)
mov    %rbx,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xd78(%rip),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xd8d(%rip),%rdi
mov    $0x60,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1130 <fwrite@plt>
lea    0xdd5(%rip),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1130 <fwrite@plt>
mov    %rbp,0x28(%rsp)
mov    %rbp,%rdi
call   1040 <opendir@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   10e0 <readdir@plt>
test   %rax,%rax
je     14f1 <send_directory_listing+0x2e1>
mov    %rax,%rbp
mov    %r14,0x18(%rsp)
jmp    1385 <send_directory_listing+0x175>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rcx
mov    %r12,%rdi
lea    0xdcd(%rip),%rsi
lea    0x30(%rsp),%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x18(%rsp),%r14
mov    $0x5,%esi
mov    $0x1,%edx
lea    0xd52(%rip),%rdi
mov    %r12,%rcx
call   1130 <fwrite@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   10e0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
je     14f1 <send_directory_listing+0x2e1>
mov    0x28(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rax,%r13
lea    0x80(%rax),%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   10d0 <memcpy@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
movb   $0x0,(%r15,%rax,1)
mov    0x0(%rbp),%rsi
mov    %r15,%rdi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0x8(%rsp),%rsi
call   10c0 <stat@plt>
lea    0x14(%rsp),%rdi
call   1100 <gmtime@plt>
lea    0x30(%rsp),%rdi
mov    $0x20,%esi
lea    0xccb(%rip),%rdx
mov    %rax,%rcx
call   10f0 <strftime@plt>
mov    $0x4,%esi
mov    $0x1,%edx
lea    0xcc4(%rip),%rdi
mov    %r12,%rcx
call   1130 <fwrite@plt>
mov    0x0(%rbp),%rdi
lea    0xcb9(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1371 <send_directory_listing+0x161>
mov    0x20(%rsp),%rdi
lea    0xc9c(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
jne    1460 <send_directory_listing+0x250>
mov    0x0(%rbp),%rdi
lea    0xc89(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1371 <send_directory_listing+0x161>
mov    0x0(%rbp),%rbx
mov    0x10(%rsp),%edi
call   1060 <S_ISDIR@plt>
test   %rax,%rax
lea    0xc62(%rip),%r14
mov    %r14,%rcx
lea    0xc40(%rip),%r13
cmove  %r13,%rcx
mov    %r12,%rdi
lea    0xc4f(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x0(%rbp),%rbx
mov    0x10(%rsp),%edi
call   1060 <S_ISDIR@plt>
test   %rax,%rax
cmove  %r13,%r14
mov    %r12,%rdi
lea    0xc3b(%rip),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x10(%rsp),%edi
call   1060 <S_ISDIR@plt>
test   %rax,%rax
je     1330 <send_directory_listing+0x120>
mov    %r12,%rdi
lea    0xc20(%rip),%rsi
lea    0x30(%rsp),%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    134b <send_directory_listing+0x13b>
mov    %r14,%rdi
call   1070 <closedir@plt>
lea    0xc28(%rip),%rsi
lea    0xc4f(%rip),%rdx
mov    %r12,%rdi
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xc4e(%rip),%rdi
mov    $0xe,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1130 <fwrite@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i64, i32, i32 }
%struct.dirent = type { i8* }
%struct.tm = type { i32 }
@.str = [3 x i8] c"OK\00"
@.str.1 = [10 x i8] c"text/html\00"
@.str.2 = [7 x i8] c"<html>\00"
@.str.3 = [7 x i8] c"<body>\00"
@.str.4 = [23 x i8] c"<h1>Index of %s</h1>\0D\0A\00"
@.str.5 = [38 x i8] c"<pre><table border=\220\22 width=\22100%%\22>\00"
@.str.6 = [97 x i8] c"<tr><th align=\22left\22>Name</th><th align=\22left\22>Last modified</th><th align=\22left\22>Size</th></tr>\00"
@.str.7 = [9 x i8] c"<hr />\0D\0A\00"
@.str.8 = [18 x i8] c"%Y-%b-%d %H:%M:%S\00"
@.str.9 = [5 x i8] c"<tr>\00"
@.str.10 = [2 x i8] c".\00"
@.str.11 = [2 x i8] c"/\00"
@.str.12 = [3 x i8] c"..\00"
@.str.13 = [20 x i8] c"<td><a href=\22%s%s\22>\00"
@.str.14 = [1 x i8] zeroinitializer
@.str.15 = [14 x i8] c"%s%s</a></td>\00"
@.str.16 = [12 x i8] c"<td>%s</td>\00"
@.str.17 = [28 x i8] c"<td>%s</td> <td>%10llu</td>\00"
@.str.18 = [6 x i8] c"</tr>\00"
@.str.19 = [46 x i8] c"</table></pre>\0D\0A<hr /><address>%s</address>\0D\0A\00"
@.str.20 = [16 x i8] c"http_server 0.1\00"
@.str.21 = [15 x i8] c"</body></html>\00"
define void @send_directory_listing(i32* %0, i64 %1, i64 %2, i8* %3, i8* %4) {
%6 = alloca %struct.stat
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca %struct.dirent*
%12 = alloca [32 x i8]
%13 = alloca %struct.tm*
%14 = alloca i8*
%15 = bitcast %struct.stat* %6 to { i64, i64 }*
%16 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %15, i32 0, i32 0
store i64 %1, i64* %16
%17 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %15, i32 0, i32 1
store i64 %2, i64* %17
store i32* %0, i32** %7
store i8* %3, i8** %8
store i8* %4, i8** %9
%18 = load i32*, i32** %7
%19 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 2
%20 = load i32, i32* %19
%21 = call i32 @send_header(i32* %18, i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* null, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 -1, i32 %20)
%22 = load i32*, i32** %7
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32*, i32** %7
%25 = load i8*, i8** %8
%26 = load i8*, i8** %8
%27 = call i32 @set_simple_head(i32* %24, i8* %25, i8* %26, i32* null)
%28 = load i32*, i32** %7
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32*, i32** %7
%31 = load i8*, i8** %8
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %31)
%33 = load i32*, i32** %7
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%35 = load i32*, i32** %7
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str.6, i64 0, i64 0))
%37 = load i32*, i32** %7
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%39 = load i8*, i8** %9
%40 = call i32* @opendir(i8* %39)
store i32* %40, i32** %10
br label %41
41: ; preds = %128, %90, %79, %5
%42 = load i32*, i32** %10
%43 = call %struct.dirent* @readdir(i32* %42)
store %struct.dirent* %43, %struct.dirent** %11
%44 = icmp ne %struct.dirent* %43, null
br i1 %44, label %45, label %133
45: ; preds = %41
%46 = load i8*, i8** %9
%47 = call i64 @strlen(i8* %46)
%48 = add i64 %47, 128
%49 = trunc i64 %48 to i32
%50 = call i8* @calloc(i32 %49, i32 1)
store i8* %50, i8** %14
%51 = load i8*, i8** %14
%52 = load i8*, i8** %9
%53 = load i8*, i8** %9
%54 = call i64 @strlen(i8* %53)
%55 = call i32 @memcpy(i8* %51, i8* %52, i64 %54)
%56 = load i8*, i8** %14
%57 = load i8*, i8** %14
%58 = call i64 @strlen(i8* %57)
%59 = getelementptr inbounds i8, i8* %56, i64 %58
store i8 0, i8* %59
%60 = load i8*, i8** %14
%61 = load %struct.dirent*, %struct.dirent** %11
%62 = getelementptr inbounds %struct.dirent, %struct.dirent* %61, i32 0, i32 0
%63 = load i8*, i8** %62
%64 = call i32 @strcat(i8* %60, i8* %63)
%65 = load i8*, i8** %14
%66 = call i32 @stat(i8* %65, %struct.stat* %6)
%67 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 2
%68 = call %struct.tm* @gmtime(i32* %67)
store %struct.tm* %68, %struct.tm** %13
%69 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%70 = load %struct.tm*, %struct.tm** %13
%71 = call i32 @strftime(i8* %69, i32 32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), %struct.tm* %70)
%72 = load i32*, i32** %7
%73 = call i32 (i32*, i8*, ...) @fprintf(i32* %72, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%74 = load %struct.dirent*, %struct.dirent** %11
%75 = getelementptr inbounds %struct.dirent, %struct.dirent* %74, i32 0, i32 0
%76 = load i8*, i8** %75
%77 = call i64 @strcmp(i8* %76, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%78 = icmp eq i64 %77, 0
br i1 %78, label %79, label %80
79: ; preds = %45
br label %41
80: ; preds = %45
%81 = load i8*, i8** %8
%82 = call i64 @strcmp(i8* %81, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%83 = icmp eq i64 %82, 0
br i1 %83, label %84, label %91
84: ; preds = %80
%85 = load %struct.dirent*, %struct.dirent** %11
%86 = getelementptr inbounds %struct.dirent, %struct.dirent* %85, i32 0, i32 0
%87 = load i8*, i8** %86
%88 = call i64 @strcmp(i8* %87, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %91
90: ; preds = %84
br label %41
91: ; preds = %84, %80
%92 = load i32*, i32** %7
%93 = load %struct.dirent*, %struct.dirent** %11
%94 = getelementptr inbounds %struct.dirent, %struct.dirent* %93, i32 0, i32 0
%95 = load i8*, i8** %94
%96 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%97 = load i32, i32* %96
%98 = call i64 @S_ISDIR(i32 %97)
%99 = icmp ne i64 %98, 0
%100 = zext i1 %99 to i64
%101 = select i1 %99, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.14, i64 0, i64 0)
%102 = call i32 (i32*, i8*, ...) @fprintf(i32* %92, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i8* %95, i8* %101)
%103 = load i32*, i32** %7
%104 = load %struct.dirent*, %struct.dirent** %11
%105 = getelementptr inbounds %struct.dirent, %struct.dirent* %104, i32 0, i32 0
%106 = load i8*, i8** %105
%107 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%108 = load i32, i32* %107
%109 = call i64 @S_ISDIR(i32 %108)
%110 = icmp ne i64 %109, 0
%111 = zext i1 %110 to i64
%112 = select i1 %110, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.14, i64 0, i64 0)
%113 = call i32 (i32*, i8*, ...) @fprintf(i32* %103, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0), i8* %106, i8* %112)
%114 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%115 = load i32, i32* %114
%116 = call i64 @S_ISDIR(i32 %115)
%117 = icmp ne i64 %116, 0
br i1 %117, label %118, label %122
118: ; preds = %91
%119 = load i32*, i32** %7
%120 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%121 = call i32 (i32*, i8*, ...) @fprintf(i32* %119, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0), i8* %120)
br label %128
122: ; preds = %91
%123 = load i32*, i32** %7
%124 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%125 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%126 = load i64, i64* %125
%127 = call i32 (i32*, i8*, ...) @fprintf(i32* %123, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.17, i64 0, i64 0), i8* %124, i64 %126)
br label %128
128: ; preds = %122, %118
%129 = load i32*, i32** %7
%130 = call i32 (i32*, i8*, ...) @fprintf(i32* %129, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0))
%131 = load i8*, i8** %14
%132 = call i32 @free(i8* %131)
br label %41
133: ; preds = %41
%134 = load i32*, i32** %10
%135 = call i32 @closedir(i32* %134)
%136 = load i32*, i32** %7
%137 = call i32 (i32*, i8*, ...) @fprintf(i32* %136, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.20, i64 0, i64 0))
%138 = load i32*, i32** %7
%139 = call i32 (i32*, i8*, ...) @fprintf(i32* %138, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.21, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.stat = type { i64, i32, i32 }
%struct.dirent = type { i8* }
%struct.tm = type { i32 }
@.str = [3 x i8] c"OK\00"
@.str.1 = [10 x i8] c"text/html\00"
@.str.2 = [7 x i8] c"<html>\00"
@.str.3 = [7 x i8] c"<body>\00"
@.str.4 = [23 x i8] c"<h1>Index of %s</h1>\0D\0A\00"
@.str.5 = [38 x i8] c"<pre><table border=\220\22 width=\22100%%\22>\00"
@.str.6 = [97 x i8] c"<tr><th align=\22left\22>Name</th><th align=\22left\22>Last modified</th><th align=\22left\22>Size</th></tr>\00"
@.str.7 = [9 x i8] c"<hr />\0D\0A\00"
@.str.8 = [18 x i8] c"%Y-%b-%d %H:%M:%S\00"
@.str.9 = [5 x i8] c"<tr>\00"
@.str.10 = [2 x i8] c".\00"
@.str.11 = [2 x i8] c"/\00"
@.str.12 = [3 x i8] c"..\00"
@.str.13 = [20 x i8] c"<td><a href=\22%s%s\22>\00"
@.str.14 = [1 x i8] zeroinitializer
@.str.15 = [14 x i8] c"%s%s</a></td>\00"
@.str.16 = [12 x i8] c"<td>%s</td>\00"
@.str.17 = [28 x i8] c"<td>%s</td> <td>%10llu</td>\00"
@.str.18 = [6 x i8] c"</tr>\00"
@.str.19 = [46 x i8] c"</table></pre>\0D\0A<hr /><address>%s</address>\0D\0A\00"
@.str.20 = [16 x i8] c"http_server 0.1\00"
@.str.21 = [15 x i8] c"</body></html>\00"
define void @send_directory_listing(i32* %0, i64 %1, i64 %2, i8* %3, i8* %4) {
%6 = alloca %struct.stat
%7 = alloca [32 x i8]
%8 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
store i64 %1, i64* %8
%9 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 1
%10 = bitcast i32* %9 to i64*
store i64 %2, i64* %10
%11 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 2
%12 = lshr i64 %2, 32
%13 = trunc i64 %12 to i32
%14 = tail call i32 @send_header(i32* %0, i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* null, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 -1, i32 %13)
%15 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 6, i64 1, i32* %0)
%16 = tail call i32 @set_simple_head(i32* %0, i8* %3, i8* %3, i32* null)
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 6, i64 1, i32* %0)
%18 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%19 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%20 = tail call i64 @fwrite(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str.6, i64 0, i64 0), i64 96, i64 1, i32* %0)
%21 = tail call i64 @fwrite(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i64 8, i64 1, i32* %0)
%22 = tail call i32* @opendir(i8* %4)
%23 = call %struct.dirent* @readdir(i32* %22)
%24 = icmp eq %struct.dirent* %23, null
br i1 %24, label %80, label %25
25: ; preds = %5
%26 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
br label %27
27: ; preds = %25, %77
%28 = phi %struct.dirent* [ %23, %25 ], [ %78, %77 ]
%29 = call i64 @strlen(i8* dereferenceable(1) %4)
%30 = trunc i64 %29 to i32
%31 = add i32 %30, 128
%32 = call i8* @calloc(i32 %31, i32 1)
%33 = call i32 @memcpy(i8* %32, i8* %4, i64 %29)
%34 = call i64 @strlen(i8* dereferenceable(1) %32)
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 0, i8* %35
%36 = getelementptr inbounds %struct.dirent, %struct.dirent* %28, i64 0, i32 0
%37 = load i8*, i8** %36
%38 = call i32 @strcat(i8* %32, i8* %37)
%39 = call i32 @stat(i8* %32, %struct.stat* %6)
%40 = call %struct.tm* @gmtime(i32* %11)
%41 = call i32 @strftime(i8* %26, i32 32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), %struct.tm* %40)
%42 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i64 4, i64 1, i32* %0)
%43 = load i8*, i8** %36
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %77, label %46
46: ; preds = %27
%47 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %46
%50 = load i8*, i8** %36
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %77, label %53
53: ; preds = %49, %46
%54 = load i8*, i8** %36
%55 = load i32, i32* %9
%56 = call i64 @S_ISDIR(i32 %55)
%57 = icmp eq i64 %56, 0
%58 = select i1 %57, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0)
%59 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i8* %54, i8* %58)
%60 = load i8*, i8** %36
%61 = load i32, i32* %9
%62 = call i64 @S_ISDIR(i32 %61)
%63 = icmp eq i64 %62, 0
%64 = select i1 %63, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0)
%65 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0), i8* %60, i8* %64)
%66 = load i32, i32* %9
%67 = call i64 @S_ISDIR(i32 %66)
%68 = icmp eq i64 %67, 0
br i1 %68, label %71, label %69
69: ; preds = %53
%70 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0), i8* %26)
br label %74
71: ; preds = %53
%72 = load i64, i64* %8
%73 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.17, i64 0, i64 0), i8* %26, i64 %72)
br label %74
74: ; preds = %71, %69
%75 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0), i64 5, i64 1, i32* %0)
%76 = call i32 @free(i8* %32)
br label %77
77: ; preds = %49, %27, %74
%78 = call %struct.dirent* @readdir(i32* %22)
%79 = icmp eq %struct.dirent* %78, null
br i1 %79, label %80, label %27
80: ; preds = %77, %5
%81 = call i32 @closedir(i32* %22)
%82 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.20, i64 0, i64 0))
%83 = call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.21, i64 0, i64 0), i64 14, i64 1, i32* %0)
ret void
}