#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 {
  int st_size;
  int /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_mode;
};
struct dirent {
  int /*<<< orphan*/ d_name;
};
typedef int /*<<< orphan*/ location;
typedef int /*<<< orphan*/ line;
typedef int /*<<< orphan*/ idx;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int /*<<< orphan*/ alphasort;
scalar_t__ chdir(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
char *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ file_details(char *, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
char *get_mime_type(char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ putchar(int);
int scandir(char *, struct dirent ***, int /*<<< orphan*/ *,
            int /*<<< orphan*/);
int /*<<< orphan*/ send_error(int, char *, char *, char *);
int /*<<< orphan*/ send_headers(int, char *, char *, char *, int,
                                int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int sscanf(char *, char *, char *, char *, char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcasecmp(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strdecode(char *, char *);
size_t strlen(char *);
scalar_t__ strncmp(char *, char *, int);
char *strstr(char *, char *);
int main(int argc, char **argv) {
  char line[10000], method[10000], path[10000], protocol[10000], idx[20000],
      location[20000];
  char *file;
  size_t len;
  int ich;
  struct stat sb;
  FILE *fp;
  struct dirent **dl;
  int i, n;
  if (argc != 2)
    send_error(500, "Internal Error", (char *)0,
               "Config error - no dir specified.");
  if (chdir(argv[1]) < 0)
    send_error(500, "Internal Error", (char *)0,
               "Config error - couldn't chdir().");
  if (fgets(line, sizeof(line), stdin) == (char *)0)
    send_error(400, "Bad Request", (char *)0, "No request found.");
  if (sscanf(line, "%[^ ] %[^ ] %[^ ]", method, path, protocol) != 3)
    send_error(400, "Bad Request", (char *)0, "Can't parse request.");
  while (fgets(line, sizeof(line), stdin) != (char *)0) {
    if (strcmp(line, "\n") == 0 || strcmp(line, "\r\n") == 0)
      break;
  }
  if (strcasecmp(method, "get") != 0)
    send_error(501, "Not Implemented", (char *)0,
               "That method is not implemented.");
  if (path[0] != '/')
    send_error(400, "Bad Request", (char *)0, "Bad filename.");
  file = &(path[1]);
  strdecode(file, file);
  if (file[0] == '\0')
    file = "./";
  len = strlen(file);
  if (file[0] == '/' || strcmp(file, "..") == 0 ||
      strncmp(file, "../", 3) == 0 || strstr(file, "/../") != (char *)0 ||
      strcmp(&(file[len - 3]), "/..") == 0)
    send_error(400, "Bad Request", (char *)0, "Illegal filename.");
  if (stat(file, &sb) < 0)
    send_error(404, "Not Found", (char *)0, "File not found.");
  if (S_ISDIR(sb.st_mode)) {
    if (file[len - 1] != '/') {
      (void)snprintf(location, sizeof(location), "Location: %s/", path);
      send_error(302, "Found", location, "Directories must end with a slash.");
    }
    (void)snprintf(idx, sizeof(idx), "%sindex.html", file);
    if (stat(idx, &sb) >= 0) {
      file = idx;
      goto do_file;
    }
    send_headers(200, "Ok", (char *)0, "text/html", -1, sb.st_mtime);
    (void)printf(
        "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" "
        "\"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n  <head>\n    "
        "<meta http-equiv=\"Content-type\" "
        "content=\"text/html;charset=UTF-8\">\n    <title>Index of "
        "%s</title>\n  </head>\n  <body bgcolor=\"#99cc99\">\n    <h4>Index of "
        "%s</h4>\n    <pre>\n",
        file, file);
    n = scandir(file, &dl, NULL, alphasort);
    if (n < 0)
      perror("scandir");
    else
      for (i = 0; i < n; ++i)
        file_details(file, dl[i]->d_name);
    (void)printf("    </pre>\n    <hr>\n    <address><a "
                 "href=\"%s\">%s</a></address>\n  </body>\n</html>\n",
                 "http://www.acme.com/software/micro_httpd/", "micro_httpd");
  } else {
  do_file:
    fp = fopen(file, "r");
    if (fp == (FILE *)0)
      send_error(403, "Forbidden", (char *)0, "File is protected.");
    send_headers(200, "Ok", (char *)0, get_mime_type(file), sb.st_size,
                 sb.st_mtime);
    while ((ich = getc(fp)) != EOF)
      putchar(ich);
  }
  (void)fflush(stdout);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x138d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     12bf <main+0x3f>
mov    $0x1f4,%edi
lea    0xd51(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    0xd55(%rip),%rcx
call   1120 <send_error@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <chdir@plt>
cmp    $0x0,%rax
jge    12f2 <main+0x72>
mov    $0x1f4,%edi
lea    0xd1e(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    0xd43(%rip),%rcx
call   1120 <send_error@plt>
lea    -0x2720(%rbp),%rdi
mov    0x2ce8(%rip),%rax
mov    (%rax),%edx
mov    $0x2710,%esi
call   10c0 <fgets@plt>
cmp    $0x0,%rax
jne    1332 <main+0xb2>
mov    $0x190,%edi
lea    0xd2f(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    0xd30(%rip),%rcx
call   1120 <send_error@plt>
lea    -0x2720(%rbp),%rdi
lea    -0x4e30(%rbp),%rdx
lea    -0x7540(%rbp),%rcx
lea    -0x9c50(%rbp),%r8
lea    0xd1a(%rip),%rsi
call   1140 <sscanf@plt>
cmp    $0x3,%eax
je     137f <main+0xff>
mov    $0x190,%edi
lea    0xce2(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    0xd07(%rip),%rcx
call   1120 <send_error@plt>
jmp    1384 <main+0x104>
lea    -0x2720(%rbp),%rdi
mov    0x2c56(%rip),%rax
mov    (%rax),%edx
mov    $0x2710,%esi
call   10c0 <fgets@plt>
cmp    $0x0,%rax
je     13ec <main+0x16c>
lea    -0x2720(%rbp),%rdi
lea    0xce1(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
je     13e2 <main+0x162>
lea    -0x2720(%rbp),%rdi
lea    0xcc3(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    13e7 <main+0x167>
jmp    13ec <main+0x16c>
jmp    1384 <main+0x104>
lea    -0x4e30(%rbp),%rdi
lea    0xc9f(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
je     1425 <main+0x1a5>
mov    $0x1f5,%edi
lea    0xc88(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    0xc8d(%rip),%rcx
call   1120 <send_error@plt>
movsbl -0x7540(%rbp),%eax
cmp    $0x2f,%eax
je     1451 <main+0x1d1>
mov    $0x190,%edi
lea    0xc10(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    0xc81(%rip),%rcx
call   1120 <send_error@plt>
lea    -0x7540(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x13898(%rbp)
mov    -0x13898(%rbp),%rdi
mov    -0x13898(%rbp),%rsi
call   1180 <strdecode@plt>
mov    -0x13898(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1497 <main+0x217>
lea    0xc4d(%rip),%rax
mov    %rax,-0x13898(%rbp)
mov    -0x13898(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x138a0(%rbp)
mov    -0x13898(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1544 <main+0x2c4>
mov    -0x13898(%rbp),%rdi
lea    0xc16(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
je     1544 <main+0x2c4>
mov    -0x13898(%rbp),%rdi
lea    0xbf4(%rip),%rsi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     1544 <main+0x2c4>
mov    -0x13898(%rbp),%rdi
lea    0xbd1(%rip),%rsi
call   11a0 <strstr@plt>
cmp    $0x0,%rax
jne    1544 <main+0x2c4>
mov    -0x13898(%rbp),%rdi
mov    -0x138a0(%rbp),%rax
sub    $0x3,%rax
add    %rax,%rdi
lea    0xbab(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
jne    1560 <main+0x2e0>
mov    $0x190,%edi
lea    0xb01(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    0xb89(%rip),%rcx
call   1120 <send_error@plt>
mov    -0x13898(%rbp),%rdi
lea    -0x138b0(%rbp),%rsi
call   1100 <stat@plt>
cmp    $0x0,%rax
jge    1599 <main+0x319>
mov    $0x194,%edi
lea    0xb6d(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    0xb6c(%rip),%rcx
call   1120 <send_error@plt>
mov    -0x138a8(%rbp),%edi
call   1090 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1755 <main+0x4d5>
mov    -0x13898(%rbp),%rax
mov    -0x138a0(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     160b <main+0x38b>
lea    -0x13890(%rbp),%rdi
lea    -0x7540(%rbp),%rcx
mov    $0x4e20,%esi
lea    0xb29(%rip),%rdx
call   10a0 <snprintf@plt>
lea    -0x13890(%rbp),%rdx
mov    $0x12e,%edi
lea    0xafb(%rip),%rsi
lea    0xb18(%rip),%rcx
call   1120 <send_error@plt>
lea    -0xea70(%rbp),%rdi
mov    -0x13898(%rbp),%rcx
mov    $0x4e20,%esi
lea    0xb1c(%rip),%rdx
call   10a0 <snprintf@plt>
lea    -0xea70(%rbp),%rdi
lea    -0x138b0(%rbp),%rsi
call   1100 <stat@plt>
cmp    $0x0,%rax
jl     165a <main+0x3da>
lea    -0xea70(%rbp),%rax
mov    %rax,-0x13898(%rbp)
jmp    175a <main+0x4da>
mov    -0x138ac(%rbp),%r9d
mov    $0xc8,%edi
lea    0xae1(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    0xad9(%rip),%rcx
mov    $0xffffffff,%r8d
call   10d0 <send_headers@plt>
mov    -0x13898(%rbp),%rsi
mov    -0x13898(%rbp),%rdx
lea    0xac3(%rip),%rdi
call   1080 <printf@plt>
mov    -0x13898(%rbp),%rdi
mov    0x291d(%rip),%rax
mov    (%rax),%ecx
lea    -0x138c0(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   10b0 <scandir@plt>
mov    %eax,-0x138c8(%rbp)
cmpl   $0x0,-0x138c8(%rbp)
jge    16e1 <main+0x461>
lea    0xbaa(%rip),%rdi
call   1160 <perror@plt>
jmp    1736 <main+0x4b6>
movl   $0x0,-0x138c4(%rbp)
mov    -0x138c4(%rbp),%eax
cmp    -0x138c8(%rbp),%eax
jge    1731 <main+0x4b1>
mov    -0x13898(%rbp),%rdi
mov    -0x138c0(%rbp),%rax
movslq -0x138c4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%esi
call   1110 <file_details@plt>
mov    -0x138c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x138c4(%rbp)
jmp    16eb <main+0x46b>
jmp    1736 <main+0x4b6>
lea    0xb4c(%rip),%rdi
lea    0xb97(%rip),%rsi
lea    0xbba(%rip),%rdx
call   1080 <printf@plt>
jmp    1806 <main+0x586>
jmp    175a <main+0x4da>
mov    -0x13898(%rbp),%rdi
lea    0xb1f(%rip),%rsi
call   1150 <fopen@plt>
mov    %rax,-0x138b8(%rbp)
cmpq   $0x0,-0x138b8(%rbp)
jne    179e <main+0x51e>
mov    $0x193,%edi
lea    0xb83(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    0xb82(%rip),%rcx
call   1120 <send_error@plt>
mov    -0x13898(%rbp),%rdi
call   10e0 <get_mime_type@plt>
mov    %rax,%rcx
mov    -0x138b0(%rbp),%r8d
mov    -0x138ac(%rbp),%r9d
mov    $0xc8,%edi
lea    0x987(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   10d0 <send_headers@plt>
mov    -0x138b8(%rbp),%rdi
call   1190 <getc@plt>
mov    %eax,-0x138a4(%rbp)
mov    0x27f7(%rip),%rcx
cmp    (%rcx),%eax
je     1801 <main+0x581>
mov    -0x138a4(%rbp),%edi
call   1030 <putchar@plt>
jmp    17d0 <main+0x550>
jmp    1806 <main+0x586>
mov    0x27c3(%rip),%rax
mov    (%rax),%edi
call   1130 <fflush@plt>
xor    %edi,%edi
call   1170 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x138a8,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
je     12b0 <main+0x30>
lea    0xd63(%rip),%rsi
lea    0xd6b(%rip),%rcx
mov    $0x1f4,%edi
xor    %edx,%edx
call   1120 <send_error@plt>
mov    0x8(%rbx),%rdi
call   1070 <chdir@plt>
test   %rax,%rax
jns    12d8 <main+0x58>
lea    0xd3b(%rip),%rsi
lea    0xd64(%rip),%rcx
mov    $0x1f4,%edi
xor    %edx,%edx
call   1120 <send_error@plt>
mov    0x2d09(%rip),%r12
mov    (%r12),%edx
lea    0x2730(%rsp),%rdi
mov    $0x2710,%esi
call   10c0 <fgets@plt>
test   %rax,%rax
jne    1314 <main+0x94>
lea    0xd50(%rip),%rsi
lea    0xd55(%rip),%rcx
mov    $0x190,%edi
xor    %edx,%edx
call   1120 <send_error@plt>
lea    0xd54(%rip),%rsi
lea    0x2730(%rsp),%rdi
lea    0x4e40(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x7550(%rsp),%r8
call   1140 <sscanf@plt>
cmp    $0x3,%eax
je     135c <main+0xdc>
lea    0xd08(%rip),%rsi
lea    0xd31(%rip),%rcx
mov    $0x190,%edi
xor    %edx,%edx
call   1120 <send_error@plt>
lea    0x2730(%rsp),%rbx
lea    0xd2c(%rip),%r14
lea    0xd24(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x2710,%esi
call   10c0 <fgets@plt>
test   %rax,%rax
je     13b6 <main+0x136>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10f0 <strcmp@plt>
test   %rax,%rax
je     13b6 <main+0x136>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10f0 <strcmp@plt>
test   %rax,%rax
jne    1380 <main+0x100>
lea    0xcdc(%rip),%rsi
lea    0x4e40(%rsp),%rdi
call   1040 <strcasecmp@plt>
test   %rax,%rax
je     13e9 <main+0x169>
lea    0xcc7(%rip),%rsi
lea    0xcd0(%rip),%rcx
mov    $0x1f5,%edi
xor    %edx,%edx
call   1120 <send_error@plt>
cmpb   $0x2f,0x20(%rsp)
je     140a <main+0x18a>
lea    0xc5a(%rip),%rsi
lea    0xccf(%rip),%rcx
mov    $0x190,%edi
xor    %edx,%edx
call   1120 <send_error@plt>
lea    0x21(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1180 <strdecode@plt>
cmpb   $0x0,0x21(%rsp)
lea    0xcb7(%rip),%r15
cmovne %rbx,%r15
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %rax,%r14
cmpb   $0x2f,(%r15)
je     1495 <main+0x215>
lea    0xc9f(%rip),%rsi
mov    %r15,%rdi
call   10f0 <strcmp@plt>
test   %rax,%rax
je     1495 <main+0x215>
lea    0xc86(%rip),%rsi
mov    %r15,%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
je     1495 <main+0x215>
lea    0xc6c(%rip),%rsi
mov    %r15,%rdi
call   11a0 <strstr@plt>
test   %rax,%rax
jne    1495 <main+0x215>
lea    (%r14,%r15,1),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xc55(%rip),%rsi
call   10f0 <strcmp@plt>
test   %rax,%rax
jne    14af <main+0x22f>
lea    0xbb5(%rip),%rsi
lea    0xc41(%rip),%rcx
mov    $0x190,%edi
xor    %edx,%edx
call   1120 <send_error@plt>
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
call   1100 <stat@plt>
test   %rax,%rax
jns    14db <main+0x25b>
lea    0xc2e(%rip),%rsi
lea    0xc31(%rip),%rcx
mov    $0x194,%edi
xor    %edx,%edx
call   1120 <send_error@plt>
mov    0x10(%rsp),%edi
call   1090 <S_ISDIR@plt>
test   %rax,%rax
jne    14ee <main+0x26e>
mov    %r15,%r14
jmp    1567 <main+0x2e7>
cmpb   $0x2f,-0x1(%r14,%r15,1)
je     1532 <main+0x2b2>
lea    0xc13(%rip),%rdx
lea    0x9c60(%rsp),%rbx
lea    0x20(%rsp),%rcx
mov    %rbx,%rdi
mov    $0x4e20,%esi
call   10a0 <snprintf@plt>
lea    0xbdc(%rip),%rsi
lea    0xbf9(%rip),%rcx
mov    $0x12e,%edi
mov    %rbx,%rdx
call   1120 <send_error@plt>
lea    0xea80(%rsp),%r14
lea    0xc00(%rip),%rdx
mov    %r14,%rdi
mov    $0x4e20,%esi
mov    %r15,%rcx
call   10a0 <snprintf@plt>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1100 <stat@plt>
test   %rax,%rax
js     15ea <main+0x36a>
lea    0xd19(%rip),%rsi
mov    %r14,%rdi
call   1150 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1598 <main+0x318>
lea    0xd8c(%rip),%rsi
lea    0xd8f(%rip),%rcx
mov    $0x193,%edi
xor    %edx,%edx
call   1120 <send_error@plt>
mov    %r14,%rdi
call   10e0 <get_mime_type@plt>
mov    0x8(%rsp),%r8d
mov    0xc(%rsp),%r9d
lea    0xb9d(%rip),%rsi
mov    $0xc8,%edi
xor    %edx,%edx
mov    %rax,%rcx
call   10d0 <send_headers@plt>
mov    %rbx,%rdi
call   1190 <getc@plt>
mov    0x2a11(%rip),%r14
nop
cmp    (%r14),%eax
je     1663 <main+0x3e3>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1190 <getc@plt>
jmp    15d0 <main+0x350>
mov    0xc(%rsp),%r9d
lea    0xb58(%rip),%rsi
lea    0xb54(%rip),%rcx
mov    $0xc8,%edi
xor    %edx,%edx
mov    $0xffffffff,%r8d
call   10d0 <send_headers@plt>
lea    0xb45(%rip),%rdi
mov    %r15,%rsi
mov    %r15,%rdx
call   1080 <printf@plt>
mov    0x29a0(%rip),%rax
mov    (%rax),%ecx
lea    0x18(%rsp),%rsi
mov    %r15,%rdi
xor    %edx,%edx
call   10b0 <scandir@plt>
test   %eax,%eax
jns    1678 <main+0x3f8>
lea    0xc3d(%rip),%rdi
call   1160 <perror@plt>
lea    0xc39(%rip),%rdi
lea    0xc84(%rip),%rsi
lea    0xca7(%rip),%rdx
call   1080 <printf@plt>
mov    0x2966(%rip),%rax
mov    (%rax),%edi
call   1130 <fflush@plt>
xor    %edi,%edi
call   1170 <exit@plt>
je     1649 <main+0x3c9>
mov    %eax,%r14d
xor    %ebx,%ebx
nop
mov    0x18(%rsp),%rax
mov    (%rax,%rbx,8),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   1110 <file_details@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1680 <main+0x400>
jmp    1649 <main+0x3c9>

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32 }
%struct.dirent = type { i32 }
@.str = [15 x i8] c"Internal Error\00"
@.str.1 = [33 x i8] c"Config error - no dir specified.\00"
@.str.2 = [33 x i8] c"Config error - couldn't chdir().\00"
@stdin = global i32 0
@.str.3 = [12 x i8] c"Bad Request\00"
@.str.4 = [18 x i8] c"No request found.\00"
@.str.5 = [18 x i8] c"%[^ ] %[^ ] %[^ ]\00"
@.str.6 = [21 x i8] c"Can't parse request.\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [3 x i8] c"\0D\0A\00"
@.str.9 = [4 x i8] c"get\00"
@.str.10 = [16 x i8] c"Not Implemented\00"
@.str.11 = [32 x i8] c"That method is not implemented.\00"
@.str.12 = [14 x i8] c"Bad filename.\00"
@.str.13 = [3 x i8] c"./\00"
@.str.14 = [3 x i8] c"..\00"
@.str.15 = [4 x i8] c"../\00"
@.str.16 = [5 x i8] c"/../\00"
@.str.17 = [4 x i8] c"/..\00"
@.str.18 = [18 x i8] c"Illegal filename.\00"
@.str.19 = [10 x i8] c"Not Found\00"
@.str.20 = [16 x i8] c"File not found.\00"
@.str.21 = [14 x i8] c"Location: %s/\00"
@.str.22 = [6 x i8] c"Found\00"
@.str.23 = [35 x i8] c"Directories must end with a slash.\00"
@.str.24 = [13 x i8] c"%sindex.html\00"
@.str.25 = [3 x i8] c"Ok\00"
@.str.26 = [10 x i8] c"text/html\00"
@.str.27 = [294 x i8] c"<!DOCTYPE html PUBLIC \22-//W3C//DTD HTML 4.01 Transitional//EN\22 \22http://www.w3.org/TR/html4/loose.dtd\22>\0A<html>\0A <head>\0A <meta http-equiv=\22Content-type\22 content=\22text/html;charset=UTF-8\22>\0A <title>Index of %s</title>\0A </head>\0A <body bgcolor=\22cc99\22>\0A <h4>Index of %s</h4>\0A <pre>\0A\00"
@alphasort = global i32 0
@.str.28 = [8 x i8] c"scandir\00"
@.str.29 = [82 x i8] c" </pre>\0A <hr>\0A <address><a href=\22%s\22>%s</a></address>\0A </body>\0A</html>\0A\00"
@.str.30 = [42 x i8] c"http://www.acme.com/software/micro_httpd/\00"
@.str.31 = [12 x i8] c"micro_httpd\00"
@.str.32 = [2 x i8] c"r\00"
@.str.33 = [10 x i8] c"Forbidden\00"
@.str.34 = [19 x i8] c"File is protected.\00"
@EOF = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10000 x i8]
%7 = alloca [10000 x i8]
%8 = alloca [10000 x i8]
%9 = alloca [10000 x i8]
%10 = alloca [20000 x i8]
%11 = alloca [20000 x i8]
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i32
%15 = alloca %struct.stat
%16 = alloca i32*
%17 = alloca %struct.dirent**
%18 = alloca i32
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 2
br i1 %21, label %22, label %24
22: ; preds = %2
%23 = call i32 @send_error(i32 500, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i64 @chdir(i8* %27)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = call i32 @send_error(i32 500, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %24
%33 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%34 = load i32, i32* @stdin
%35 = call i8* @fgets(i8* %33, i32 10000, i32 %34)
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = call i32 @send_error(i32 400, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %39
39: ; preds = %37, %32
%40 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%41 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 0
%42 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%43 = getelementptr inbounds [10000 x i8], [10000 x i8]* %9, i64 0, i64 0
%44 = call i32 @sscanf(i8* %40, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %41, i8* %42, i8* %43)
%45 = icmp ne i32 %44, 3
br i1 %45, label %46, label %48
46: ; preds = %39
%47 = call i32 @send_error(i32 400, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %48
48: ; preds = %46, %39
br label %49
49: ; preds = %63, %48
%50 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%51 = load i32, i32* @stdin
%52 = call i8* @fgets(i8* %50, i32 10000, i32 %51)
%53 = icmp ne i8* %52, null
br i1 %53, label %54, label %64
54: ; preds = %49
%55 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %62, label %58
58: ; preds = %54
%59 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%60 = call i64 @strcmp(i8* %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %58, %54
br label %64
63: ; preds = %58
br label %49
64: ; preds = %62, %49
%65 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 0
%66 = call i64 @strcasecmp(i8* %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %64
%69 = call i32 @send_error(i32 501, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0))
br label %70
70: ; preds = %68, %64
%71 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp ne i32 %73, 47
br i1 %74, label %75, label %77
75: ; preds = %70
%76 = call i32 @send_error(i32 400, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0))
br label %77
77: ; preds = %75, %70
%78 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 1
store i8* %78, i8** %12
%79 = load i8*, i8** %12
%80 = load i8*, i8** %12
%81 = call i32 @strdecode(i8* %79, i8* %80)
%82 = load i8*, i8** %12
%83 = getelementptr inbounds i8, i8* %82, i64 0
%84 = load i8, i8* %83
%85 = sext i8 %84 to i32
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %88
87: ; preds = %77
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8** %12
br label %88
88: ; preds = %87, %77
%89 = load i8*, i8** %12
%90 = call i64 @strlen(i8* %89)
store i64 %90, i64* %13
%91 = load i8*, i8** %12
%92 = getelementptr inbounds i8, i8* %91, i64 0
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp eq i32 %94, 47
br i1 %95, label %115, label %96
96: ; preds = %88
%97 = load i8*, i8** %12
%98 = call i64 @strcmp(i8* %97, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
%99 = icmp eq i64 %98, 0
br i1 %99, label %115, label %100
100: ; preds = %96
%101 = load i8*, i8** %12
%102 = call i64 @strncmp(i8* %101, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0), i32 3)
%103 = icmp eq i64 %102, 0
br i1 %103, label %115, label %104
104: ; preds = %100
%105 = load i8*, i8** %12
%106 = call i8* @strstr(i8* %105, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%107 = icmp ne i8* %106, null
br i1 %107, label %115, label %108
108: ; preds = %104
%109 = load i8*, i8** %12
%110 = load i64, i64* %13
%111 = sub i64 %110, 3
%112 = getelementptr inbounds i8, i8* %109, i64 %111
%113 = call i64 @strcmp(i8* %112, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0))
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %117
115: ; preds = %108, %104, %100, %96, %88
%116 = call i32 @send_error(i32 400, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.18, i64 0, i64 0))
br label %117
117: ; preds = %115, %108
%118 = load i8*, i8** %12
%119 = call i64 @stat(i8* %118, %struct.stat* %15)
%120 = icmp slt i64 %119, 0
br i1 %120, label %121, label %123
121: ; preds = %117
%122 = call i32 @send_error(i32 404, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.19, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.20, i64 0, i64 0))
br label %123
123: ; preds = %121, %117
%124 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 2
%125 = load i32, i32* %124
%126 = call i64 @S_ISDIR(i32 %125)
%127 = icmp ne i64 %126, 0
br i1 %127, label %128, label %186
128: ; preds = %123
%129 = load i8*, i8** %12
%130 = load i64, i64* %13
%131 = sub i64 %130, 1
%132 = getelementptr inbounds i8, i8* %129, i64 %131
%133 = load i8, i8* %132
%134 = sext i8 %133 to i32
%135 = icmp ne i32 %134, 47
br i1 %135, label %136, label %142
136: ; preds = %128
%137 = getelementptr inbounds [20000 x i8], [20000 x i8]* %11, i64 0, i64 0
%138 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%139 = call i32 @snprintf(i8* %137, i32 20000, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0), i8* %138)
%140 = getelementptr inbounds [20000 x i8], [20000 x i8]* %11, i64 0, i64 0
%141 = call i32 @send_error(i32 302, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.22, i64 0, i64 0), i8* %140, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.23, i64 0, i64 0))
br label %142
142: ; preds = %136, %128
%143 = getelementptr inbounds [20000 x i8], [20000 x i8]* %10, i64 0, i64 0
%144 = load i8*, i8** %12
%145 = call i32 @snprintf(i8* %143, i32 20000, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.24, i64 0, i64 0), i8* %144)
%146 = getelementptr inbounds [20000 x i8], [20000 x i8]* %10, i64 0, i64 0
%147 = call i64 @stat(i8* %146, %struct.stat* %15)
%148 = icmp sge i64 %147, 0
br i1 %148, label %149, label %151
149: ; preds = %142
%150 = getelementptr inbounds [20000 x i8], [20000 x i8]* %10, i64 0, i64 0
store i8* %150, i8** %12
br label %187
151: ; preds = %142
%152 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 1
%153 = load i32, i32* %152
%154 = call i32 @send_headers(i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.26, i64 0, i64 0), i32 -1, i32 %153)
%155 = load i8*, i8** %12
%156 = load i8*, i8** %12
%157 = call i32 @printf(i8* getelementptr inbounds ([294 x i8], [294 x i8]* @.str.27, i64 0, i64 0), i8* %155, i8* %156)
%158 = load i8*, i8** %12
%159 = load i32, i32* @alphasort
%160 = call i32 @scandir(i8* %158, %struct.dirent*** %17, i32* null, i32 %159)
store i32 %160, i32* %19
%161 = load i32, i32* %19
%162 = icmp slt i32 %161, 0
br i1 %162, label %163, label %165
163: ; preds = %151
%164 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.28, i64 0, i64 0))
br label %184
165: ; preds = %151
store i32 0, i32* %18
br label %166
166: ; preds = %180, %165
%167 = load i32, i32* %18
%168 = load i32, i32* %19
%169 = icmp slt i32 %167, %168
br i1 %169, label %170, label %183
170: ; preds = %166
%171 = load i8*, i8** %12
%172 = load %struct.dirent**, %struct.dirent*** %17
%173 = load i32, i32* %18
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds %struct.dirent*, %struct.dirent** %172, i64 %174
%176 = load %struct.dirent*, %struct.dirent** %175
%177 = getelementptr inbounds %struct.dirent, %struct.dirent* %176, i32 0, i32 0
%178 = load i32, i32* %177
%179 = call i32 @file_details(i8* %171, i32 %178)
br label %180
180: ; preds = %170
%181 = load i32, i32* %18
%182 = add nsw i32 %181, 1
store i32 %182, i32* %18
br label %166
183: ; preds = %166
br label %184
184: ; preds = %183, %163
%185 = call i32 @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.29, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.30, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.31, i64 0, i64 0))
br label %211
186: ; preds = %123
br label %187
187: ; preds = %186, %149
%188 = load i8*, i8** %12
%189 = call i32* @fopen(i8* %188, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.32, i64 0, i64 0))
store i32* %189, i32** %16
%190 = load i32*, i32** %16
%191 = icmp eq i32* %190, null
br i1 %191, label %192, label %194
192: ; preds = %187
%193 = call i32 @send_error(i32 403, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.33, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.34, i64 0, i64 0))
br label %194
194: ; preds = %192, %187
%195 = load i8*, i8** %12
%196 = call i8* @get_mime_type(i8* %195)
%197 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%198 = load i32, i32* %197
%199 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 1
%200 = load i32, i32* %199
%201 = call i32 @send_headers(i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i64 0, i64 0), i8* null, i8* %196, i32 %198, i32 %200)
br label %202
202: ; preds = %207, %194
%203 = load i32*, i32** %16
%204 = call i32 @getc(i32* %203)
store i32 %204, i32* %14
%205 = load i32, i32* @EOF
%206 = icmp ne i32 %204, %205
br i1 %206, label %207, label %210
207: ; preds = %202
%208 = load i32, i32* %14
%209 = call i32 @putchar(i32 %208)
br label %202
210: ; preds = %202
br label %211
211: ; preds = %210, %184
%212 = load i32, i32* @stdout
%213 = call i32 @fflush(i32 %212)
%214 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32 }
%struct.dirent = type { i32 }
@.str = [15 x i8] c"Internal Error\00"
@.str.1 = [33 x i8] c"Config error - no dir specified.\00"
@.str.2 = [33 x i8] c"Config error - couldn't chdir().\00"
@stdin = global i32 0
@.str.3 = [12 x i8] c"Bad Request\00"
@.str.4 = [18 x i8] c"No request found.\00"
@.str.5 = [18 x i8] c"%[^ ] %[^ ] %[^ ]\00"
@.str.6 = [21 x i8] c"Can't parse request.\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [3 x i8] c"\0D\0A\00"
@.str.9 = [4 x i8] c"get\00"
@.str.10 = [16 x i8] c"Not Implemented\00"
@.str.11 = [32 x i8] c"That method is not implemented.\00"
@.str.12 = [14 x i8] c"Bad filename.\00"
@.str.13 = [3 x i8] c"./\00"
@.str.14 = [3 x i8] c"..\00"
@.str.15 = [4 x i8] c"../\00"
@.str.16 = [5 x i8] c"/../\00"
@.str.17 = [4 x i8] c"/..\00"
@.str.18 = [18 x i8] c"Illegal filename.\00"
@.str.19 = [10 x i8] c"Not Found\00"
@.str.20 = [16 x i8] c"File not found.\00"
@.str.21 = [14 x i8] c"Location: %s/\00"
@.str.22 = [6 x i8] c"Found\00"
@.str.23 = [35 x i8] c"Directories must end with a slash.\00"
@.str.24 = [13 x i8] c"%sindex.html\00"
@.str.25 = [3 x i8] c"Ok\00"
@.str.26 = [10 x i8] c"text/html\00"
@.str.27 = [294 x i8] c"<!DOCTYPE html PUBLIC \22-//W3C//DTD HTML 4.01 Transitional//EN\22 \22http://www.w3.org/TR/html4/loose.dtd\22>\0A<html>\0A <head>\0A <meta http-equiv=\22Content-type\22 content=\22text/html;charset=UTF-8\22>\0A <title>Index of %s</title>\0A </head>\0A <body bgcolor=\22cc99\22>\0A <h4>Index of %s</h4>\0A <pre>\0A\00"
@alphasort = global i32 0
@.str.28 = [8 x i8] c"scandir\00"
@.str.29 = [82 x i8] c" </pre>\0A <hr>\0A <address><a href=\22%s\22>%s</a></address>\0A </body>\0A</html>\0A\00"
@.str.30 = [42 x i8] c"http://www.acme.com/software/micro_httpd/\00"
@.str.31 = [12 x i8] c"micro_httpd\00"
@.str.32 = [2 x i8] c"r\00"
@.str.33 = [10 x i8] c"Forbidden\00"
@.str.34 = [19 x i8] c"File is protected.\00"
@EOF = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10000 x i8]
%4 = alloca [10000 x i8]
%5 = alloca [10000 x i8]
%6 = alloca [10000 x i8]
%7 = alloca [20000 x i8]
%8 = alloca [20000 x i8]
%9 = alloca %struct.stat
%10 = alloca %struct.dirent**
%11 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%15 = getelementptr inbounds [20000 x i8], [20000 x i8]* %7, i64 0, i64 0
%16 = getelementptr inbounds [20000 x i8], [20000 x i8]* %8, i64 0, i64 0
%17 = bitcast %struct.stat* %9 to i8*
%18 = bitcast %struct.dirent*** %10 to i8*
%19 = icmp eq i32 %0, 2
br i1 %19, label %22, label %20
20: ; preds = %2
%21 = tail call i32 @send_error(i32 500, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %2
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = tail call i64 @chdir(i8* %24)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = tail call i32 @send_error(i32 500, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %22
%30 = load i32, i32* @stdin
%31 = call i8* @fgets(i8* %11, i32 10000, i32 %30)
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 @send_error(i32 400, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %35
35: ; preds = %33, %29
%36 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %12, i8* %13, i8* %14)
%37 = icmp eq i32 %36, 3
br i1 %37, label %40, label %38
38: ; preds = %35
%39 = call i32 @send_error(i32 400, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %40
40: ; preds = %38, %35
br label %41
41: ; preds = %40, %48
%42 = load i32, i32* @stdin
%43 = call i8* @fgets(i8* %11, i32 10000, i32 %42)
%44 = icmp eq i8* %43, null
br i1 %44, label %51, label %45
45: ; preds = %41
%46 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %45
%49 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %41
51: ; preds = %45, %48, %41
%52 = call i64 @strcasecmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %56, label %54
54: ; preds = %51
%55 = call i32 @send_error(i32 501, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0))
br label %56
56: ; preds = %54, %51
%57 = load i8, i8* %13
%58 = icmp eq i8 %57, 47
br i1 %58, label %61, label %59
59: ; preds = %56
%60 = call i32 @send_error(i32 400, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0))
br label %61
61: ; preds = %59, %56
%62 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 1
%63 = call i32 @strdecode(i8* %62, i8* %62)
%64 = load i8, i8* %62
%65 = icmp eq i8 %64, 0
%66 = select i1 %65, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* %62
%67 = call i64 @strlen(i8* dereferenceable(1) %66)
%68 = load i8, i8* %66
%69 = icmp eq i8 %68, 47
br i1 %69, label %84, label %70
70: ; preds = %61
%71 = call i64 @strcmp(i8* %66, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
%72 = icmp eq i64 %71, 0
br i1 %72, label %84, label %73
73: ; preds = %70
%74 = call i64 @strncmp(i8* %66, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0), i32 3)
%75 = icmp eq i64 %74, 0
br i1 %75, label %84, label %76
76: ; preds = %73
%77 = call i8* @strstr(i8* %66, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%78 = icmp eq i8* %77, null
br i1 %78, label %79, label %84
79: ; preds = %76
%80 = add i64 %67, -3
%81 = getelementptr inbounds i8, i8* %66, i64 %80
%82 = call i64 @strcmp(i8* %81, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0))
%83 = icmp eq i64 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %79, %76, %73, %70, %61
%85 = call i32 @send_error(i32 400, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.18, i64 0, i64 0))
br label %86
86: ; preds = %84, %79
%87 = call i64 @stat(i8* %66, %struct.stat* %9)
%88 = icmp slt i64 %87, 0
br i1 %88, label %89, label %91
89: ; preds = %86
%90 = call i32 @send_error(i32 404, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.19, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.20, i64 0, i64 0))
br label %91
91: ; preds = %89, %86
%92 = getelementptr inbounds %struct.stat, %struct.stat* %9, i64 0, i32 2
%93 = load i32, i32* %92
%94 = call i64 @S_ISDIR(i32 %93)
%95 = icmp eq i64 %94, 0
br i1 %95, label %134, label %96
96: ; preds = %91
%97 = add i64 %67, -1
%98 = getelementptr inbounds i8, i8* %66, i64 %97
%99 = load i8, i8* %98
%100 = icmp eq i8 %99, 47
br i1 %100, label %104, label %101
101: ; preds = %96
%102 = call i32 @snprintf(i8* %16, i32 20000, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0), i8* %13)
%103 = call i32 @send_error(i32 302, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.22, i64 0, i64 0), i8* %16, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.23, i64 0, i64 0))
br label %104
104: ; preds = %101, %96
%105 = call i32 @snprintf(i8* %15, i32 20000, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.24, i64 0, i64 0), i8* %66)
%106 = call i64 @stat(i8* %15, %struct.stat* %9)
%107 = icmp sgt i64 %106, -1
br i1 %107, label %134, label %108
108: ; preds = %104
%109 = getelementptr inbounds %struct.stat, %struct.stat* %9, i64 0, i32 1
%110 = load i32, i32* %109
%111 = call i32 @send_headers(i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.26, i64 0, i64 0), i32 -1, i32 %110)
%112 = call i32 @printf(i8* getelementptr inbounds ([294 x i8], [294 x i8]* @.str.27, i64 0, i64 0), i8* %66, i8* %66)
%113 = load i32, i32* @alphasort
%114 = call i32 @scandir(i8* %66, %struct.dirent*** %10, i32* null, i32 %113)
%115 = icmp slt i32 %114, 0
br i1 %115, label %120, label %116
116: ; preds = %108
%117 = icmp eq i32 %114, 0
br i1 %117, label %132, label %118
118: ; preds = %116
%119 = zext i32 %114 to i64
br label %122
120: ; preds = %108
%121 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.28, i64 0, i64 0))
br label %132
122: ; preds = %118, %122
%123 = phi i64 [ 0, %118 ], [ %130, %122 ]
%124 = load %struct.dirent**, %struct.dirent*** %10
%125 = getelementptr inbounds %struct.dirent*, %struct.dirent** %124, i64 %123
%126 = load %struct.dirent*, %struct.dirent** %125
%127 = getelementptr inbounds %struct.dirent, %struct.dirent* %126, i64 0, i32 0
%128 = load i32, i32* %127
%129 = call i32 @file_details(i8* %66, i32 %128)
%130 = add nuw nsw i64 %123, 1
%131 = icmp eq i64 %130, %119
br i1 %131, label %132, label %122
132: ; preds = %122, %116, %120
%133 = call i32 @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.29, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.30, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.31, i64 0, i64 0))
br label %156
134: ; preds = %104, %91
%135 = phi i8* [ %66, %91 ], [ %15, %104 ]
%136 = call i32* @fopen(i8* %135, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.32, i64 0, i64 0))
%137 = icmp eq i32* %136, null
br i1 %137, label %138, label %140
138: ; preds = %134
%139 = call i32 @send_error(i32 403, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.33, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.34, i64 0, i64 0))
br label %140
140: ; preds = %138, %134
%141 = call i8* @get_mime_type(i8* %135)
%142 = getelementptr inbounds %struct.stat, %struct.stat* %9, i64 0, i32 0
%143 = load i32, i32* %142
%144 = getelementptr inbounds %struct.stat, %struct.stat* %9, i64 0, i32 1
%145 = load i32, i32* %144
%146 = call i32 @send_headers(i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i64 0, i64 0), i8* null, i8* %141, i32 %143, i32 %145)
%147 = call i32 @getc(i32* %136)
%148 = load i32, i32* @EOF
%149 = icmp eq i32 %147, %148
br i1 %149, label %156, label %150
150: ; preds = %140, %150
%151 = phi i32 [ %153, %150 ], [ %147, %140 ]
%152 = call i32 @putchar(i32 %151)
%153 = call i32 @getc(i32* %136)
%154 = load i32, i32* @EOF
%155 = icmp eq i32 %153, %154
br i1 %155, label %156, label %150
156: ; preds = %150, %140, %132
%157 = load i32, i32* @stdout
%158 = call i32 @fflush(i32 %157)
%159 = call i32 @exit(i32 0)
unreachable
}