#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], command[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("<html><head><title>Index of %s</title></head>\n<body "
                 "bgcolor=\"#99cc99\"><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></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    $0x186f0,%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,-0x186b8(%rbp)
mov    -0x186b8(%rbp),%rdi
mov    -0x186b8(%rbp),%rsi
call   1180 <strdecode@plt>
mov    -0x186b8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1497 <main+0x217>
lea    0xc4d(%rip),%rax
mov    %rax,-0x186b8(%rbp)
mov    -0x186b8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x186c0(%rbp)
mov    -0x186b8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1544 <main+0x2c4>
mov    -0x186b8(%rbp),%rdi
lea    0xc16(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
je     1544 <main+0x2c4>
mov    -0x186b8(%rbp),%rdi
lea    0xbf4(%rip),%rsi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     1544 <main+0x2c4>
mov    -0x186b8(%rbp),%rdi
lea    0xbd1(%rip),%rsi
call   11a0 <strstr@plt>
cmp    $0x0,%rax
jne    1544 <main+0x2c4>
mov    -0x186b8(%rbp),%rdi
mov    -0x186c0(%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    -0x186b8(%rbp),%rdi
lea    -0x186d0(%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    -0x186c8(%rbp),%edi
call   1090 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1755 <main+0x4d5>
mov    -0x186b8(%rbp),%rax
mov    -0x186c0(%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    -0x186b8(%rbp),%rcx
mov    $0x4e20,%esi
lea    0xb1c(%rip),%rdx
call   10a0 <snprintf@plt>
lea    -0xea70(%rbp),%rdi
lea    -0x186d0(%rbp),%rsi
call   1100 <stat@plt>
cmp    $0x0,%rax
jl     165a <main+0x3da>
lea    -0xea70(%rbp),%rax
mov    %rax,-0x186b8(%rbp)
jmp    175a <main+0x4da>
mov    -0x186cc(%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    -0x186b8(%rbp),%rsi
mov    -0x186b8(%rbp),%rdx
lea    0xac3(%rip),%rdi
call   1080 <printf@plt>
mov    -0x186b8(%rbp),%rdi
mov    0x291d(%rip),%rax
mov    (%rax),%ecx
lea    -0x186e0(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   10b0 <scandir@plt>
mov    %eax,-0x186e8(%rbp)
cmpl   $0x0,-0x186e8(%rbp)
jge    16e1 <main+0x461>
lea    0xae6(%rip),%rdi
call   1160 <perror@plt>
jmp    1736 <main+0x4b6>
movl   $0x0,-0x186e4(%rbp)
mov    -0x186e4(%rbp),%eax
cmp    -0x186e8(%rbp),%eax
jge    1731 <main+0x4b1>
mov    -0x186b8(%rbp),%rdi
mov    -0x186e0(%rbp),%rax
movslq -0x186e4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%esi
call   1110 <file_details@plt>
mov    -0x186e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x186e4(%rbp)
jmp    16eb <main+0x46b>
jmp    1736 <main+0x4b6>
lea    0xa88(%rip),%rdi
lea    0xac4(%rip),%rsi
lea    0xae7(%rip),%rdx
call   1080 <printf@plt>
jmp    1806 <main+0x586>
jmp    175a <main+0x4da>
mov    -0x186b8(%rbp),%rdi
lea    0xa5b(%rip),%rsi
call   1150 <fopen@plt>
mov    %rax,-0x186d8(%rbp)
cmpq   $0x0,-0x186d8(%rbp)
jne    179e <main+0x51e>
mov    $0x193,%edi
lea    0xab0(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    0xaaf(%rip),%rcx
call   1120 <send_error@plt>
mov    -0x186b8(%rbp),%rdi
call   10e0 <get_mime_type@plt>
mov    %rax,%rcx
mov    -0x186d0(%rbp),%r8d
mov    -0x186cc(%rbp),%r9d
mov    $0xc8,%edi
lea    0x987(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   10d0 <send_headers@plt>
mov    -0x186d8(%rbp),%rdi
call   1190 <getc@plt>
mov    %eax,-0x186c4(%rbp)
mov    0x27f7(%rip),%rcx
cmp    (%rcx),%eax
je     1801 <main+0x581>
mov    -0x186c4(%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    0xc55(%rip),%rsi
mov    %r14,%rdi
call   1150 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1598 <main+0x318>
lea    0xcb9(%rip),%rsi
lea    0xcbc(%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    0xb79(%rip),%rdi
call   1160 <perror@plt>
lea    0xb75(%rip),%rdi
lea    0xbb1(%rip),%rsi
lea    0xbd4(%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 = [98 x i8] c"<html><head><title>Index of %s</title></head>\0A<body bgcolor=\22cc99\22><h4>Index of %s</h4>\0A<pre>\0A\00"
@alphasort = global i32 0
@.str.28 = [8 x i8] c"scandir\00"
@.str.29 = [67 x i8] c"</pre>\0A<hr>\0A<address><a href=\22%s\22>%s</a></address>\0A</body></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 [20000 x i8]
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32
%16 = alloca %struct.stat
%17 = alloca i32*
%18 = alloca %struct.dirent**
%19 = alloca i32
%20 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 2
br i1 %22, label %23, label %25
23: ; preds = %2
%24 = 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 %25
25: ; preds = %23, %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i64 @chdir(i8* %28)
%30 = icmp slt i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = 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 %33
33: ; preds = %31, %25
%34 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%35 = load i32, i32* @stdin
%36 = call i8* @fgets(i8* %34, i32 10000, i32 %35)
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %40
38: ; preds = %33
%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 ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %40
40: ; preds = %38, %33
%41 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%42 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 0
%43 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%44 = getelementptr inbounds [10000 x i8], [10000 x i8]* %9, i64 0, i64 0
%45 = call i32 @sscanf(i8* %41, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %42, i8* %43, i8* %44)
%46 = icmp ne i32 %45, 3
br i1 %46, label %47, label %49
47: ; preds = %40
%48 = 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 %49
49: ; preds = %47, %40
br label %50
50: ; preds = %64, %49
%51 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%52 = load i32, i32* @stdin
%53 = call i8* @fgets(i8* %51, i32 10000, i32 %52)
%54 = icmp ne i8* %53, null
br i1 %54, label %55, label %65
55: ; preds = %50
%56 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%57 = call i64 @strcmp(i8* %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
br i1 %58, label %63, label %59
59: ; preds = %55
%60 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %59, %55
br label %65
64: ; preds = %59
br label %50
65: ; preds = %63, %50
%66 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 0
%67 = call i64 @strcasecmp(i8* %66, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %65
%70 = 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 %71
71: ; preds = %69, %65
%72 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp ne i32 %74, 47
br i1 %75, label %76, label %78
76: ; preds = %71
%77 = 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 %78
78: ; preds = %76, %71
%79 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 1
store i8* %79, i8** %13
%80 = load i8*, i8** %13
%81 = load i8*, i8** %13
%82 = call i32 @strdecode(i8* %80, i8* %81)
%83 = load i8*, i8** %13
%84 = getelementptr inbounds i8, i8* %83, i64 0
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
%87 = icmp eq i32 %86, 0
br i1 %87, label %88, label %89
88: ; preds = %78
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8** %13
br label %89
89: ; preds = %88, %78
%90 = load i8*, i8** %13
%91 = call i64 @strlen(i8* %90)
store i64 %91, i64* %14
%92 = load i8*, i8** %13
%93 = getelementptr inbounds i8, i8* %92, i64 0
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 47
br i1 %96, label %116, label %97
97: ; preds = %89
%98 = load i8*, i8** %13
%99 = call i64 @strcmp(i8* %98, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
%100 = icmp eq i64 %99, 0
br i1 %100, label %116, label %101
101: ; preds = %97
%102 = load i8*, i8** %13
%103 = call i64 @strncmp(i8* %102, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0), i32 3)
%104 = icmp eq i64 %103, 0
br i1 %104, label %116, label %105
105: ; preds = %101
%106 = load i8*, i8** %13
%107 = call i8* @strstr(i8* %106, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%108 = icmp ne i8* %107, null
br i1 %108, label %116, label %109
109: ; preds = %105
%110 = load i8*, i8** %13
%111 = load i64, i64* %14
%112 = sub i64 %111, 3
%113 = getelementptr inbounds i8, i8* %110, i64 %112
%114 = call i64 @strcmp(i8* %113, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0))
%115 = icmp eq i64 %114, 0
br i1 %115, label %116, label %118
116: ; preds = %109, %105, %101, %97, %89
%117 = 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 %118
118: ; preds = %116, %109
%119 = load i8*, i8** %13
%120 = call i64 @stat(i8* %119, %struct.stat* %16)
%121 = icmp slt i64 %120, 0
br i1 %121, label %122, label %124
122: ; preds = %118
%123 = 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 %124
124: ; preds = %122, %118
%125 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 2
%126 = load i32, i32* %125
%127 = call i64 @S_ISDIR(i32 %126)
%128 = icmp ne i64 %127, 0
br i1 %128, label %129, label %187
129: ; preds = %124
%130 = load i8*, i8** %13
%131 = load i64, i64* %14
%132 = sub i64 %131, 1
%133 = getelementptr inbounds i8, i8* %130, i64 %132
%134 = load i8, i8* %133
%135 = sext i8 %134 to i32
%136 = icmp ne i32 %135, 47
br i1 %136, label %137, label %143
137: ; preds = %129
%138 = getelementptr inbounds [20000 x i8], [20000 x i8]* %11, i64 0, i64 0
%139 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%140 = call i32 @snprintf(i8* %138, i32 20000, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0), i8* %139)
%141 = getelementptr inbounds [20000 x i8], [20000 x i8]* %11, i64 0, i64 0
%142 = call i32 @send_error(i32 302, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.22, i64 0, i64 0), i8* %141, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.23, i64 0, i64 0))
br label %143
143: ; preds = %137, %129
%144 = getelementptr inbounds [20000 x i8], [20000 x i8]* %10, i64 0, i64 0
%145 = load i8*, i8** %13
%146 = call i32 @snprintf(i8* %144, i32 20000, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.24, i64 0, i64 0), i8* %145)
%147 = getelementptr inbounds [20000 x i8], [20000 x i8]* %10, i64 0, i64 0
%148 = call i64 @stat(i8* %147, %struct.stat* %16)
%149 = icmp sge i64 %148, 0
br i1 %149, label %150, label %152
150: ; preds = %143
%151 = getelementptr inbounds [20000 x i8], [20000 x i8]* %10, i64 0, i64 0
store i8* %151, i8** %13
br label %188
152: ; preds = %143
%153 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 1
%154 = load i32, i32* %153
%155 = 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 %154)
%156 = load i8*, i8** %13
%157 = load i8*, i8** %13
%158 = call i32 @printf(i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.27, i64 0, i64 0), i8* %156, i8* %157)
%159 = load i8*, i8** %13
%160 = load i32, i32* @alphasort
%161 = call i32 @scandir(i8* %159, %struct.dirent*** %18, i32* null, i32 %160)
store i32 %161, i32* %20
%162 = load i32, i32* %20
%163 = icmp slt i32 %162, 0
br i1 %163, label %164, label %166
164: ; preds = %152
%165 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.28, i64 0, i64 0))
br label %185
166: ; preds = %152
store i32 0, i32* %19
br label %167
167: ; preds = %181, %166
%168 = load i32, i32* %19
%169 = load i32, i32* %20
%170 = icmp slt i32 %168, %169
br i1 %170, label %171, label %184
171: ; preds = %167
%172 = load i8*, i8** %13
%173 = load %struct.dirent**, %struct.dirent*** %18
%174 = load i32, i32* %19
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds %struct.dirent*, %struct.dirent** %173, i64 %175
%177 = load %struct.dirent*, %struct.dirent** %176
%178 = getelementptr inbounds %struct.dirent, %struct.dirent* %177, i32 0, i32 0
%179 = load i32, i32* %178
%180 = call i32 @file_details(i8* %172, i32 %179)
br label %181
181: ; preds = %171
%182 = load i32, i32* %19
%183 = add nsw i32 %182, 1
store i32 %183, i32* %19
br label %167
184: ; preds = %167
br label %185
185: ; preds = %184, %164
%186 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 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 %212
187: ; preds = %124
br label %188
188: ; preds = %187, %150
%189 = load i8*, i8** %13
%190 = call i32* @fopen(i8* %189, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.32, i64 0, i64 0))
store i32* %190, i32** %17
%191 = load i32*, i32** %17
%192 = icmp eq i32* %191, null
br i1 %192, label %193, label %195
193: ; preds = %188
%194 = 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 %195
195: ; preds = %193, %188
%196 = load i8*, i8** %13
%197 = call i8* @get_mime_type(i8* %196)
%198 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 0
%199 = load i32, i32* %198
%200 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 1
%201 = load i32, i32* %200
%202 = call i32 @send_headers(i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i64 0, i64 0), i8* null, i8* %197, i32 %199, i32 %201)
br label %203
203: ; preds = %208, %195
%204 = load i32*, i32** %17
%205 = call i32 @getc(i32* %204)
store i32 %205, i32* %15
%206 = load i32, i32* @EOF
%207 = icmp ne i32 %205, %206
br i1 %207, label %208, label %211
208: ; preds = %203
%209 = load i32, i32* %15
%210 = call i32 @putchar(i32 %209)
br label %203
211: ; preds = %203
br label %212
212: ; preds = %211, %185
%213 = load i32, i32* @stdout
%214 = call i32 @fflush(i32 %213)
%215 = 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 = [98 x i8] c"<html><head><title>Index of %s</title></head>\0A<body bgcolor=\22cc99\22><h4>Index of %s</h4>\0A<pre>\0A\00"
@alphasort = global i32 0
@.str.28 = [8 x i8] c"scandir\00"
@.str.29 = [67 x i8] c"</pre>\0A<hr>\0A<address><a href=\22%s\22>%s</a></address>\0A</body></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 ([98 x i8], [98 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 ([67 x i8], [67 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
}