#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*/ url;
struct stat {
  int st_mode;
};
typedef int /*<<< orphan*/ method;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int S_IFDIR;
int S_IFMT;
int S_IXGRP;
int S_IXOTH;
int S_IXUSR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ execute_cgi(int, char *, char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int get_line(int, char *, int);
scalar_t__ isspace(int);
int /*<<< orphan*/ not_found(int);
int /*<<< orphan*/ serve_file(int, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int stat(char *, struct stat *);
int /*<<< orphan*/ stdout;
scalar_t__ strcasecmp(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ unimplemented(int);
void accept_request(void *arg) {
  char buf[1024];
  char method[255];
  char url[255];
  char path[512];
  int client = *(int *)arg;
  int numchars;
  size_t i, j;
  struct stat st;
  int cgi = 0;
  char *query_string = NULL;
  numchars = get_line(client, buf, sizeof(buf));
  fprintf(stdout, "%s\n", buf);
  i = 0;
  j = 0;
  while (!isspace((int)(buf[j])) && (i < sizeof(method) - 1)) {
    method[i] = buf[j];
    i++;
    j++;
  }
  method[i] = '\0';
  if (strcasecmp(method, "GET") && strcasecmp(method, "POST")) {
    unimplemented(client);
    return;
  }
  if (strcasecmp(method, "POST") == 0)
    cgi = 1;
  i = 0;
  while (isspace((int)(buf[j])) && (j < sizeof(buf)))
    j++;
  while (!isspace((int)(buf[j])) && (i < sizeof(url) - 1) &&
         (j < sizeof(buf))) {
    url[i] = buf[j];
    i++;
    j++;
  }
  url[i] = '\0';
  if (strcasecmp(method, "GET") == 0) {
    query_string = url;
    while ((*query_string != '?') && (*query_string != '\0'))
      query_string++;
    if (*query_string == '?') {
      cgi = 1;
      *query_string = '\0';
      query_string++;
    }
  }
  sprintf(path, "htdocs%s", url);
  if (path[strlen(path) - 1] == '/')
    strcat(path, "index.html");
  if (stat(path, &st) == -1) {
    while ((numchars > 0) && strcmp("\n", buf))
      numchars = get_line(client, buf, sizeof(buf));
    not_found(client);
  } else {
    if ((st.st_mode & S_IFMT) == S_IFDIR)
      strcat(path, "/index.html");
    if ((st.st_mode & S_IXUSR) || (st.st_mode & S_IXGRP) ||
        (st.st_mode & S_IXOTH))
      cgi = 1;
    if (!cgi)
      serve_file(client, path);
    else
      execute_cgi(client, path, method, query_string);
  }
  close(client);
}


x86 assembly (clang, -O0):
<accept_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x850,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x814(%rbp)
movl   $0x0,-0x834(%rbp)
movq   $0x0,-0x840(%rbp)
mov    -0x814(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1040 <get_line@plt>
mov    %eax,-0x818(%rbp)
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rdx
lea    0xdbc(%rip),%rsi
call   1090 <fprintf@plt>
movq   $0x0,-0x820(%rbp)
movq   $0x0,-0x828(%rbp)
mov    -0x828(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1070 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x841(%rbp)
jne    129c <accept_request+0xbc>
cmpq   $0xfe,-0x820(%rbp)
setb   %al
mov    %al,-0x841(%rbp)
mov    -0x841(%rbp),%al
test   $0x1,%al
jne    12af <accept_request+0xcf>
jmp    12f4 <accept_request+0x114>
mov    -0x828(%rbp),%rax
mov    -0x410(%rbp,%rax,1),%cl
mov    -0x820(%rbp),%rax
mov    %cl,-0x510(%rbp,%rax,1)
mov    -0x820(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x820(%rbp)
mov    -0x828(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x828(%rbp)
jmp    125f <accept_request+0x7f>
mov    -0x820(%rbp),%rax
movb   $0x0,-0x510(%rbp,%rax,1)
lea    -0x510(%rbp),%rdi
lea    0xcf3(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     134d <accept_request+0x16d>
lea    -0x510(%rbp),%rdi
lea    0xcda(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     134d <accept_request+0x16d>
mov    -0x814(%rbp),%edi
call   10a0 <unimplemented@plt>
jmp    172d <accept_request+0x54d>
lea    -0x510(%rbp),%rdi
lea    0xcad(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1374 <accept_request+0x194>
movl   $0x1,-0x834(%rbp)
movq   $0x0,-0x820(%rbp)
mov    -0x828(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1070 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x842(%rbp)
je     13bc <accept_request+0x1dc>
cmpq   $0x400,-0x828(%rbp)
setb   %al
mov    %al,-0x842(%rbp)
mov    -0x842(%rbp),%al
test   $0x1,%al
jne    13cf <accept_request+0x1ef>
jmp    13e6 <accept_request+0x206>
mov    -0x828(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x828(%rbp)
jmp    137f <accept_request+0x19f>
jmp    13eb <accept_request+0x20b>
mov    -0x828(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1070 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x843(%rbp)
jne    1441 <accept_request+0x261>
xor    %eax,%eax
cmpq   $0xfe,-0x820(%rbp)
mov    %al,-0x843(%rbp)
jae    1441 <accept_request+0x261>
cmpq   $0x400,-0x828(%rbp)
setb   %al
mov    %al,-0x843(%rbp)
mov    -0x843(%rbp),%al
test   $0x1,%al
jne    1454 <accept_request+0x274>
jmp    1499 <accept_request+0x2b9>
mov    -0x828(%rbp),%rax
mov    -0x410(%rbp,%rax,1),%cl
mov    -0x820(%rbp),%rax
mov    %cl,-0x610(%rbp,%rax,1)
mov    -0x820(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x820(%rbp)
mov    -0x828(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x828(%rbp)
jmp    13eb <accept_request+0x20b>
mov    -0x820(%rbp),%rax
movb   $0x0,-0x610(%rbp,%rax,1)
lea    -0x510(%rbp),%rdi
lea    0xb4e(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    156c <accept_request+0x38c>
lea    -0x610(%rbp),%rax
mov    %rax,-0x840(%rbp)
mov    -0x840(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x3f,%ecx
mov    %al,-0x844(%rbp)
je     1504 <accept_request+0x324>
mov    -0x840(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x844(%rbp)
mov    -0x844(%rbp),%al
test   $0x1,%al
jne    1517 <accept_request+0x337>
jmp    152e <accept_request+0x34e>
mov    -0x840(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x840(%rbp)
jmp    14d3 <accept_request+0x2f3>
mov    -0x840(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3f,%eax
jne    1567 <accept_request+0x387>
movl   $0x1,-0x834(%rbp)
mov    -0x840(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x840(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x840(%rbp)
jmp    156c <accept_request+0x38c>
lea    -0x810(%rbp),%rdi
lea    -0x610(%rbp),%rdx
lea    0xa8c(%rip),%rsi
call   1100 <sprintf@plt>
lea    -0x810(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x810(%rbp,%rax,1),%eax
ff
cmp    $0x2f,%eax
jne    15bb <accept_request+0x3db>
lea    -0x810(%rbp),%rdi
lea    0xa61(%rip),%rsi
call   10f0 <strcat@plt>
lea    -0x810(%rbp),%rdi
lea    -0x830(%rbp),%rsi
call   10b0 <stat@plt>
cmp    $0xffffffff,%eax
jne    1656 <accept_request+0x476>
jmp    15dc <accept_request+0x3fc>
xor    %eax,%eax
cmpl   $0x0,-0x818(%rbp)
mov    %al,-0x845(%rbp)
jle    1611 <accept_request+0x431>
lea    -0x410(%rbp),%rsi
lea    0xa03(%rip),%rdi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x845(%rbp)
mov    -0x845(%rbp),%al
test   $0x1,%al
jne    1624 <accept_request+0x444>
jmp    1646 <accept_request+0x466>
mov    -0x814(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1040 <get_line@plt>
mov    %eax,-0x818(%rbp)
jmp    15dc <accept_request+0x3fc>
mov    -0x814(%rbp),%edi
call   10c0 <not_found@plt>
jmp    1722 <accept_request+0x542>
mov    -0x830(%rbp),%eax
mov    0x2965(%rip),%rcx
and    (%rcx),%eax
mov    0x2944(%rip),%rcx
cmp    (%rcx),%eax
jne    1687 <accept_request+0x4a7>
lea    -0x810(%rbp),%rdi
lea    0x994(%rip),%rsi
call   10f0 <strcat@plt>
mov    -0x830(%rbp),%eax
mov    0x294c(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    16cf <accept_request+0x4ef>
mov    -0x830(%rbp),%eax
mov    0x292c(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    16cf <accept_request+0x4ef>
mov    -0x830(%rbp),%eax
mov    0x2924(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     16d9 <accept_request+0x4f9>
movl   $0x1,-0x834(%rbp)
cmpl   $0x0,-0x834(%rbp)
jne    16fd <accept_request+0x51d>
mov    -0x814(%rbp),%edi
lea    -0x810(%rbp),%rsi
call   10d0 <serve_file@plt>
jmp    171d <accept_request+0x53d>
mov    -0x814(%rbp),%edi
lea    -0x810(%rbp),%rsi
lea    -0x510(%rbp),%rdx
mov    -0x840(%rbp),%rcx
call   10e0 <execute_cgi@plt>
jmp    1722 <accept_request+0x542>
mov    -0x814(%rbp),%edi
call   1060 <close@plt>
add    $0x850,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<accept_request>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
mov    (%rdi),%r15d
lea    0x410(%rsp),%rbx
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1040 <get_line@plt>
mov    %eax,%ebp
mov    0x2dab(%rip),%rax
mov    (%rax),%edi
lea    0xde2(%rip),%rsi
mov    %rbx,%rdx
call   1090 <fprintf@plt>
movsbl 0x410(%rsp),%edi
call   1070 <isspace@plt>
test   %rax,%rax
je     123d <accept_request+0x5d>
xor    %r14d,%r14d
jmp    126e <accept_request+0x8e>
xor    %ebx,%ebx
nop
movzbl 0x410(%rsp,%rbx,1),%eax
mov    %al,0x10(%rsp,%rbx,1)
lea    0x1(%rbx),%r14
movsbl 0x411(%rsp,%rbx,1),%edi
call   1070 <isspace@plt>
test   %rax,%rax
jne    126e <accept_request+0x8e>
cmp    $0xfd,%rbx
mov    %r14,%rbx
jb     1240 <accept_request+0x60>
movb   $0x0,0x10(%rsp,%r14,1)
lea    0xd89(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     12ad <accept_request+0xcd>
lea    0xd77(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     12ad <accept_request+0xcd>
mov    %r15d,%edi
call   10a0 <unimplemented@plt>
jmp    14b4 <accept_request+0x2d4>
mov    %ebp,0xc(%rsp)
lea    0xd50(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
mov    %rax,%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rbp
movsbl 0x410(%rsp,%r14,1),%edi
call   1070 <isspace@plt>
add    $0x1,%r14
test   %rax,%rax
je     12f3 <accept_request+0x113>
cmp    $0x400,%rbp
jb     12d0 <accept_request+0xf0>
test   %r12,%r12
sete   %r12b
movsbl 0x410(%rsp,%rbp,1),%edi
call   1070 <isspace@plt>
xor    %r13d,%r13d
test   %rax,%rax
jne    1363 <accept_request+0x183>
cmp    $0x3ff,%rbp
ja     1363 <accept_request+0x183>
add    $0xffffffffffffffff,%r14
xor    %ebp,%ebp
xchg   %ax,%ax
movzbl 0x410(%rsp,%r14,1),%eax
mov    %al,0x110(%rsp,%rbp,1)
lea    0x1(%rbp),%r13
movsbl 0x411(%rsp,%r14,1),%edi
call   1070 <isspace@plt>
test   %rax,%rax
jne    1363 <accept_request+0x183>
cmp    $0xfc,%rbp
ja     1363 <accept_request+0x183>
lea    0x1(%r14),%rax
mov    %r13,%rbp
cmp    $0x3ff,%r14
mov    %rax,%r14
jb     1320 <accept_request+0x140>
movb   $0x0,0x110(%rsp,%r13,1)
lea    0xc91(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1386 <accept_request+0x1a6>
xor    %ebp,%ebp
jmp    13ad <accept_request+0x1cd>
lea    0x110(%rsp),%rbp
xchg   %ax,%ax
movzbl 0x0(%rbp),%eax
test   %al,%al
je     13ad <accept_request+0x1cd>
cmp    $0x3f,%al
je     13a2 <accept_request+0x1c2>
add    $0x1,%rbp
jmp    1390 <accept_request+0x1b0>
movb   $0x0,0x0(%rbp)
add    $0x1,%rbp
mov    $0x1,%r12b
lea    0xc59(%rip),%rsi
lea    0x210(%rsp),%rbx
lea    0x110(%rsp),%rdx
mov    %rbx,%rdi
call   1100 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
jne    13f1 <accept_request+0x211>
lea    0xc33(%rip),%rsi
lea    0x210(%rsp),%rdi
call   10f0 <strcat@plt>
lea    0x210(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   10b0 <stat@plt>
cmp    $0xffffffff,%eax
je     1466 <accept_request+0x286>
mov    0x8(%rsp),%ebx
mov    0x2bb5(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    0x2b92(%rip),%rcx
cmp    (%rcx),%eax
jne    1436 <accept_request+0x256>
lea    0xbed(%rip),%rsi
lea    0x210(%rsp),%rdi
call   10f0 <strcat@plt>
mov    0x2ba3(%rip),%rax
test   %ebx,(%rax)
jne    144c <accept_request+0x26c>
mov    0x2b90(%rip),%rax
test   %ebx,(%rax)
je     14c6 <accept_request+0x2e6>
lea    0x210(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r15d,%edi
mov    %rbp,%rcx
call   10e0 <execute_cgi@plt>
jmp    14ac <accept_request+0x2cc>
cmpl   $0x0,0xc(%rsp)
jle    14a4 <accept_request+0x2c4>
lea    0xb8e(%rip),%rbp
lea    0x410(%rsp),%rbx
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     14a4 <accept_request+0x2c4>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1040 <get_line@plt>
test   %eax,%eax
jg     1480 <accept_request+0x2a0>
mov    %r15d,%edi
call   10c0 <not_found@plt>
mov    %r15d,%edi
call   1060 <close@plt>
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b1b(%rip),%rax
test   %ebx,(%rax)
jne    144c <accept_request+0x26c>
xor    $0x1,%r12b
je     144c <accept_request+0x26c>
lea    0x210(%rsp),%rsi
mov    %r15d,%edi
call   10d0 <serve_file@plt>
jmp    14ac <accept_request+0x2cc>

LLVM IR (-O0):
%struct.stat = type { i32 }
@stdout = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [4 x i8] c"GET\00"
@.str.2 = [5 x i8] c"POST\00"
@.str.3 = [9 x i8] c"htdocs%s\00"
@.str.4 = [11 x i8] c"index.html\00"
@.str.5 = [2 x i8] c"\0A\00"
@S_IFMT = global i32 0
@S_IFDIR = global i32 0
@.str.6 = [12 x i8] c"/index.html\00"
@S_IXUSR = global i32 0
@S_IXGRP = global i32 0
@S_IXOTH = global i32 0
define void @accept_request(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca [255 x i8]
%5 = alloca [255 x i8]
%6 = alloca [512 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64
%11 = alloca %struct.stat
%12 = alloca i32
%13 = alloca i8*
store i8* %0, i8** %2
%14 = load i8*, i8** %2
%15 = bitcast i8* %14 to i32*
%16 = load i32, i32* %15
store i32 %16, i32* %7
store i32 0, i32* %12
store i8* null, i8** %13
%17 = load i32, i32* %7
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%19 = call i32 @get_line(i32 %17, i8* %18, i32 1024)
store i32 %19, i32* %8
%20 = load i32, i32* @stdout
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %21)
store i64 0, i64* %9
store i64 0, i64* %10
br label %23
23: ; preds = %35, %1
%24 = load i64, i64* %10
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i64 @isspace(i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %23
%31 = load i64, i64* %9
%32 = icmp ult i64 %31, 254
br label %33
33: ; preds = %30, %23
%34 = phi i1 [ false, %23 ], [ %32, %30 ]
br i1 %34, label %35, label %45
35: ; preds = %33
%36 = load i64, i64* %10
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = load i64, i64* %9
%40 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 %39
store i8 %38, i8* %40
%41 = load i64, i64* %9
%42 = add i64 %41, 1
store i64 %42, i64* %9
%43 = load i64, i64* %10
%44 = add i64 %43, 1
store i64 %44, i64* %10
br label %23
45: ; preds = %33
%46 = load i64, i64* %9
%47 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 %46
store i8 0, i8* %47
%48 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%49 = call i64 @strcasecmp(i8* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %58
51: ; preds = %45
%52 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%53 = call i64 @strcasecmp(i8* %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = load i32, i32* %7
%57 = call i32 @unimplemented(i32 %56)
br label %220
58: ; preds = %51, %45
%59 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%60 = call i64 @strcasecmp(i8* %59, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %58
store i32 1, i32* %12
br label %63
63: ; preds = %62, %58
store i64 0, i64* %9
br label %64
64: ; preds = %76, %63
%65 = load i64, i64* %10
%66 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = call i64 @isspace(i32 %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %64
%72 = load i64, i64* %10
%73 = icmp ult i64 %72, 1024
br label %74
74: ; preds = %71, %64
%75 = phi i1 [ false, %64 ], [ %73, %71 ]
br i1 %75, label %76, label %79
76: ; preds = %74
%77 = load i64, i64* %10
%78 = add i64 %77, 1
store i64 %78, i64* %10
br label %64
79: ; preds = %74
br label %80
80: ; preds = %95, %79
%81 = load i64, i64* %10
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %81
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = call i64 @isspace(i32 %84)
%86 = icmp ne i64 %85, 0
br i1 %86, label %93, label %87
87: ; preds = %80
%88 = load i64, i64* %9
%89 = icmp ult i64 %88, 254
br i1 %89, label %90, label %93
90: ; preds = %87
%91 = load i64, i64* %10
%92 = icmp ult i64 %91, 1024
br label %93
93: ; preds = %90, %87, %80
%94 = phi i1 [ false, %87 ], [ false, %80 ], [ %92, %90 ]
br i1 %94, label %95, label %105
95: ; preds = %93
%96 = load i64, i64* %10
%97 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %96
%98 = load i8, i8* %97
%99 = load i64, i64* %9
%100 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 %99
store i8 %98, i8* %100
%101 = load i64, i64* %9
%102 = add i64 %101, 1
store i64 %102, i64* %9
%103 = load i64, i64* %10
%104 = add i64 %103, 1
store i64 %104, i64* %10
br label %80
105: ; preds = %93
%106 = load i64, i64* %9
%107 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 %106
store i8 0, i8* %107
%108 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%109 = call i64 @strcasecmp(i8* %108, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%110 = icmp eq i64 %109, 0
br i1 %110, label %111, label %138
111: ; preds = %105
%112 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
store i8* %112, i8** %13
br label %113
113: ; preds = %125, %111
%114 = load i8*, i8** %13
%115 = load i8, i8* %114
%116 = sext i8 %115 to i32
%117 = icmp ne i32 %116, 63
br i1 %117, label %118, label %123
118: ; preds = %113
%119 = load i8*, i8** %13
%120 = load i8, i8* %119
%121 = sext i8 %120 to i32
%122 = icmp ne i32 %121, 0
br label %123
123: ; preds = %118, %113
%124 = phi i1 [ false, %113 ], [ %122, %118 ]
br i1 %124, label %125, label %128
125: ; preds = %123
%126 = load i8*, i8** %13
%127 = getelementptr inbounds i8, i8* %126, i32 1
store i8* %127, i8** %13
br label %113
128: ; preds = %123
%129 = load i8*, i8** %13
%130 = load i8, i8* %129
%131 = sext i8 %130 to i32
%132 = icmp eq i32 %131, 63
br i1 %132, label %133, label %137
133: ; preds = %128
store i32 1, i32* %12
%134 = load i8*, i8** %13
store i8 0, i8* %134
%135 = load i8*, i8** %13
%136 = getelementptr inbounds i8, i8* %135, i32 1
store i8* %136, i8** %13
br label %137
137: ; preds = %133, %128
br label %138
138: ; preds = %137, %105
%139 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%140 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%141 = call i32 @sprintf(i8* %139, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %140)
%142 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%143 = call i32 @strlen(i8* %142)
%144 = sub nsw i32 %143, 1
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 %145
%147 = load i8, i8* %146
%148 = sext i8 %147 to i32
%149 = icmp eq i32 %148, 47
br i1 %149, label %150, label %153
150: ; preds = %138
%151 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%152 = call i32 @strcat(i8* %151, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %153
153: ; preds = %150, %138
%154 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%155 = call i32 @stat(i8* %154, %struct.stat* %11)
%156 = icmp eq i32 %155, -1
br i1 %156, label %157, label %174
157: ; preds = %153
br label %158
158: ; preds = %167, %157
%159 = load i32, i32* %8
%160 = icmp sgt i32 %159, 0
br i1 %160, label %161, label %165
161: ; preds = %158
%162 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%163 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %162)
%164 = icmp ne i64 %163, 0
br label %165
165: ; preds = %161, %158
%166 = phi i1 [ false, %158 ], [ %164, %161 ]
br i1 %166, label %167, label %171
167: ; preds = %165
%168 = load i32, i32* %7
%169 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%170 = call i32 @get_line(i32 %168, i8* %169, i32 1024)
store i32 %170, i32* %8
br label %158
171: ; preds = %165
%172 = load i32, i32* %7
%173 = call i32 @not_found(i32 %172)
br label %217
174: ; preds = %153
%175 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%176 = load i32, i32* %175
%177 = load i32, i32* @S_IFMT
%178 = and i32 %176, %177
%179 = load i32, i32* @S_IFDIR
%180 = icmp eq i32 %178, %179
br i1 %180, label %181, label %184
181: ; preds = %174
%182 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%183 = call i32 @strcat(i8* %182, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %184
184: ; preds = %181, %174
%185 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%186 = load i32, i32* %185
%187 = load i32, i32* @S_IXUSR
%188 = and i32 %186, %187
%189 = icmp ne i32 %188, 0
br i1 %189, label %202, label %190
190: ; preds = %184
%191 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%192 = load i32, i32* %191
%193 = load i32, i32* @S_IXGRP
%194 = and i32 %192, %193
%195 = icmp ne i32 %194, 0
br i1 %195, label %202, label %196
196: ; preds = %190
%197 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%198 = load i32, i32* %197
%199 = load i32, i32* @S_IXOTH
%200 = and i32 %198, %199
%201 = icmp ne i32 %200, 0
br i1 %201, label %202, label %203
202: ; preds = %196, %190, %184
store i32 1, i32* %12
br label %203
203: ; preds = %202, %196
%204 = load i32, i32* %12
%205 = icmp ne i32 %204, 0
br i1 %205, label %210, label %206
206: ; preds = %203
%207 = load i32, i32* %7
%208 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%209 = call i32 @serve_file(i32 %207, i8* %208)
br label %216
210: ; preds = %203
%211 = load i32, i32* %7
%212 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%213 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%214 = load i8*, i8** %13
%215 = call i32 @execute_cgi(i32 %211, i8* %212, i8* %213, i8* %214)
br label %216
216: ; preds = %210, %206
br label %217
217: ; preds = %216, %171
%218 = load i32, i32* %7
%219 = call i32 @close(i32 %218)
br label %220
220: ; preds = %217, %55
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stdout = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [4 x i8] c"GET\00"
@.str.2 = [5 x i8] c"POST\00"
@.str.3 = [9 x i8] c"htdocs%s\00"
@.str.4 = [11 x i8] c"index.html\00"
@.str.5 = [2 x i8] c"\0A\00"
@S_IFMT = global i32 0
@S_IFDIR = global i32 0
@.str.6 = [12 x i8] c"/index.html\00"
@S_IXUSR = global i32 0
@S_IXGRP = global i32 0
@S_IXOTH = global i32 0
define void @accept_request(i8* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = alloca [255 x i8]
%4 = alloca [255 x i8]
%5 = alloca [512 x i8]
%6 = alloca %struct.stat
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%11 = bitcast i8* %0 to i32*
%12 = load i32, i32* %11
%13 = bitcast %struct.stat* %6 to i8*
%14 = call i32 @get_line(i32 %12, i8* %7, i32 1024)
%15 = load i32, i32* @stdout
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %7)
%17 = load i8, i8* %7
%18 = sext i8 %17 to i32
%19 = call i64 @isspace(i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %34
21: ; preds = %1, %21
%22 = phi i8* [ %27, %21 ], [ %7, %1 ]
%23 = phi i64 [ %26, %21 ], [ 0, %1 ]
%24 = load i8, i8* %22
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %23
store i8 %24, i8* %25
%26 = add nuw nsw i64 %23, 1
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = call i64 @isspace(i32 %29)
%31 = icmp eq i64 %30, 0
%32 = icmp ult i64 %23, 253
%33 = select i1 %31, i1 %32, i1 false
br i1 %33, label %21, label %34
34: ; preds = %21, %1
%35 = phi i64 [ 0, %1 ], [ %26, %21 ]
%36 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %35
store i8 0, i8* %36
%37 = call i64 @strcasecmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %44, label %39
39: ; preds = %34
%40 = call i64 @strcasecmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = call i32 @unimplemented(i32 %12)
br label %147
44: ; preds = %39, %34
%45 = call i64 @strcasecmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %46
46: ; preds = %46, %44
%47 = phi i64 [ %35, %44 ], [ %55, %46 ]
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = call i64 @isspace(i32 %50)
%52 = icmp ne i64 %51, 0
%53 = icmp ult i64 %47, 1024
%54 = select i1 %52, i1 %53, i1 false
%55 = add nuw nsw i64 %47, 1
br i1 %54, label %46, label %56
56: ; preds = %46
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %47
%58 = icmp eq i64 %45, 0
%59 = load i8, i8* %57
%60 = sext i8 %59 to i32
%61 = call i64 @isspace(i32 %60)
%62 = icmp eq i64 %61, 0
%63 = select i1 %62, i1 %53, i1 false
br i1 %63, label %64, label %81
64: ; preds = %56, %64
%65 = phi i8* [ %72, %64 ], [ %57, %56 ]
%66 = phi i64 [ %71, %64 ], [ %47, %56 ]
%67 = phi i64 [ %70, %64 ], [ 0, %56 ]
%68 = load i8, i8* %65
%69 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 %67
store i8 %68, i8* %69
%70 = add nuw nsw i64 %67, 1
%71 = add nuw nsw i64 %66, 1
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %71
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = call i64 @isspace(i32 %74)
%76 = icmp eq i64 %75, 0
%77 = icmp ult i64 %67, 253
%78 = select i1 %76, i1 %77, i1 false
%79 = icmp ult i64 %66, 1023
%80 = select i1 %78, i1 %79, i1 false
br i1 %80, label %64, label %81
81: ; preds = %64, %56
%82 = phi i64 [ 0, %56 ], [ %70, %64 ]
%83 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 %82
store i8 0, i8* %83
%84 = call i64 @strcasecmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %93
86: ; preds = %81, %89
%87 = phi i8* [ %90, %89 ], [ %9, %81 ]
%88 = load i8, i8* %87
switch i8 %88, label %89 [
i8 63, label %91
i8 0, label %93
]
89: ; preds = %86
%90 = getelementptr inbounds i8, i8* %87, i64 1
br label %86
91: ; preds = %86
store i8 0, i8* %87
%92 = getelementptr inbounds i8, i8* %87, i64 1
br label %93
93: ; preds = %86, %91, %81
%94 = phi i1 [ true, %91 ], [ %58, %81 ], [ %58, %86 ]
%95 = phi i8* [ %92, %91 ], [ null, %81 ], [ %87, %86 ]
%96 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%97 = call i32 @strlen(i8* %10)
%98 = add nsw i32 %97, -1
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %99
%101 = load i8, i8* %100
%102 = icmp eq i8 %101, 47
br i1 %102, label %103, label %105
103: ; preds = %93
%104 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %105
105: ; preds = %103, %93
%106 = call i32 @stat(i8* %10, %struct.stat* %6)
%107 = icmp eq i32 %106, -1
br i1 %107, label %108, label %118
108: ; preds = %105
%109 = icmp sgt i32 %14, 0
br i1 %109, label %110, label %116
110: ; preds = %108, %113
%111 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %7)
%112 = icmp eq i64 %111, 0
br i1 %112, label %116, label %113
113: ; preds = %110
%114 = call i32 @get_line(i32 %12, i8* %7, i32 1024)
%115 = icmp sgt i32 %114, 0
br i1 %115, label %110, label %116
116: ; preds = %110, %113, %108
%117 = call i32 @not_found(i32 %12)
br label %145
118: ; preds = %105
%119 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
%120 = load i32, i32* %119
%121 = load i32, i32* @S_IFMT
%122 = and i32 %121, %120
%123 = load i32, i32* @S_IFDIR
%124 = icmp eq i32 %122, %123
br i1 %124, label %125, label %127
125: ; preds = %118
%126 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %127
127: ; preds = %125, %118
%128 = load i32, i32* @S_IXUSR
%129 = and i32 %128, %120
%130 = icmp eq i32 %129, 0
br i1 %130, label %131, label %143
131: ; preds = %127
%132 = load i32, i32* @S_IXGRP
%133 = and i32 %132, %120
%134 = icmp eq i32 %133, 0
br i1 %134, label %135, label %143
135: ; preds = %131
%136 = load i32, i32* @S_IXOTH
%137 = and i32 %136, %120
%138 = icmp eq i32 %137, 0
%139 = xor i1 %94, true
%140 = select i1 %138, i1 %139, i1 false
br i1 %140, label %141, label %143
141: ; preds = %135
%142 = call i32 @serve_file(i32 %12, i8* %10)
br label %145
143: ; preds = %135, %131, %127
%144 = call i32 @execute_cgi(i32 %12, i8* %10, i8* %8, i8* %95)
br label %145
145: ; preds = %141, %143, %116
%146 = call i32 @close(i32 %12)
br label %147
147: ; preds = %145, %42
ret void
}