#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 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 *);
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) {
  int client = (int)arg;
  char buf[1024];
  int numchars;
  char method[255];
  char url[255];
  char path[512];
  size_t i, j;
  struct stat st;
  int cgi = 0;
  char *query_string = NULL;
  numchars = get_line(client, buf, sizeof(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 NULL;
  }
  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);
  return NULL;
}


x86 assembly (clang, -O0):
<accept_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x860,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x84c(%rbp)
movq   $0x0,-0x858(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1040 <get_line@plt>
mov    %eax,-0x424(%rbp)
movq   $0x0,-0x838(%rbp)
movq   $0x0,-0x840(%rbp)
mov    -0x840(%rbp),%rax
movsbl -0x420(%rbp,%rax,1),%edi
ff
call   1070 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x859(%rbp)
jne    1268 <accept_request+0x98>
cmpq   $0xfe,-0x838(%rbp)
setb   %al
mov    %al,-0x859(%rbp)
mov    -0x859(%rbp),%al
test   $0x1,%al
jne    127b <accept_request+0xab>
jmp    12c0 <accept_request+0xf0>
mov    -0x840(%rbp),%rax
mov    -0x420(%rbp,%rax,1),%cl
mov    -0x838(%rbp),%rax
mov    %cl,-0x530(%rbp,%rax,1)
mov    -0x838(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x838(%rbp)
mov    -0x840(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x840(%rbp)
jmp    122b <accept_request+0x5b>
mov    -0x838(%rbp),%rax
movb   $0x0,-0x530(%rbp,%rax,1)
lea    -0x530(%rbp),%rdi
lea    0xd23(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     131e <accept_request+0x14e>
lea    -0x530(%rbp),%rdi
lea    0xd0a(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     131e <accept_request+0x14e>
mov    -0x14(%rbp),%edi
call   1090 <unimplemented@plt>
movq   $0x0,-0x8(%rbp)
jmp    16f7 <accept_request+0x527>
lea    -0x530(%rbp),%rdi
lea    0xcd8(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1345 <accept_request+0x175>
movl   $0x1,-0x84c(%rbp)
movq   $0x0,-0x838(%rbp)
mov    -0x840(%rbp),%rax
movsbl -0x420(%rbp,%rax,1),%edi
ff
call   1070 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x85a(%rbp)
je     138d <accept_request+0x1bd>
cmpq   $0x400,-0x840(%rbp)
setb   %al
mov    %al,-0x85a(%rbp)
mov    -0x85a(%rbp),%al
test   $0x1,%al
jne    13a0 <accept_request+0x1d0>
jmp    13b7 <accept_request+0x1e7>
mov    -0x840(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x840(%rbp)
jmp    1350 <accept_request+0x180>
jmp    13bc <accept_request+0x1ec>
mov    -0x840(%rbp),%rax
movsbl -0x420(%rbp,%rax,1),%edi
ff
call   1070 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x85b(%rbp)
jne    1412 <accept_request+0x242>
xor    %eax,%eax
cmpq   $0xfe,-0x838(%rbp)
mov    %al,-0x85b(%rbp)
jae    1412 <accept_request+0x242>
cmpq   $0x400,-0x840(%rbp)
setb   %al
mov    %al,-0x85b(%rbp)
mov    -0x85b(%rbp),%al
test   $0x1,%al
jne    1425 <accept_request+0x255>
jmp    146a <accept_request+0x29a>
mov    -0x840(%rbp),%rax
mov    -0x420(%rbp,%rax,1),%cl
mov    -0x838(%rbp),%rax
mov    %cl,-0x630(%rbp,%rax,1)
mov    -0x838(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x838(%rbp)
mov    -0x840(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x840(%rbp)
jmp    13bc <accept_request+0x1ec>
mov    -0x838(%rbp),%rax
movb   $0x0,-0x630(%rbp,%rax,1)
lea    -0x530(%rbp),%rdi
lea    0xb79(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    153d <accept_request+0x36d>
lea    -0x630(%rbp),%rax
mov    %rax,-0x858(%rbp)
mov    -0x858(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x3f,%ecx
mov    %al,-0x85c(%rbp)
je     14d5 <accept_request+0x305>
mov    -0x858(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x85c(%rbp)
mov    -0x85c(%rbp),%al
test   $0x1,%al
jne    14e8 <accept_request+0x318>
jmp    14ff <accept_request+0x32f>
mov    -0x858(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x858(%rbp)
jmp    14a4 <accept_request+0x2d4>
mov    -0x858(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3f,%eax
jne    1538 <accept_request+0x368>
movl   $0x1,-0x84c(%rbp)
mov    -0x858(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x858(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x858(%rbp)
jmp    153d <accept_request+0x36d>
lea    -0x830(%rbp),%rdi
lea    -0x630(%rbp),%rdx
lea    0xab7(%rip),%rsi
call   10f0 <sprintf@plt>
lea    -0x830(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x830(%rbp,%rax,1),%eax
ff
cmp    $0x2f,%eax
jne    158c <accept_request+0x3bc>
lea    -0x830(%rbp),%rdi
lea    0xa8e(%rip),%rsi
call   10e0 <strcat@plt>
lea    -0x830(%rbp),%rdi
lea    -0x848(%rbp),%rsi
call   10a0 <stat@plt>
cmp    $0xffffffff,%eax
jne    1621 <accept_request+0x451>
jmp    15ad <accept_request+0x3dd>
xor    %eax,%eax
cmpl   $0x0,-0x424(%rbp)
mov    %al,-0x85d(%rbp)
jle    15e2 <accept_request+0x412>
lea    -0x420(%rbp),%rsi
lea    0xa42(%rip),%rdi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x85d(%rbp)
mov    -0x85d(%rbp),%al
test   $0x1,%al
jne    15f5 <accept_request+0x425>
jmp    1614 <accept_request+0x444>
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1040 <get_line@plt>
mov    %eax,-0x424(%rbp)
jmp    15ad <accept_request+0x3dd>
mov    -0x14(%rbp),%edi
call   10b0 <not_found@plt>
jmp    16e7 <accept_request+0x517>
mov    -0x848(%rbp),%eax
mov    0x299a(%rip),%rcx
and    (%rcx),%eax
mov    0x2981(%rip),%rcx
cmp    (%rcx),%eax
jne    1652 <accept_request+0x482>
lea    -0x830(%rbp),%rdi
lea    0x9c7(%rip),%rsi
call   10e0 <strcat@plt>
mov    -0x848(%rbp),%eax
mov    0x2981(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    169a <accept_request+0x4ca>
mov    -0x848(%rbp),%eax
mov    0x2961(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    169a <accept_request+0x4ca>
mov    -0x848(%rbp),%eax
mov    0x2959(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     16a4 <accept_request+0x4d4>
movl   $0x1,-0x84c(%rbp)
cmpl   $0x0,-0x84c(%rbp)
jne    16c5 <accept_request+0x4f5>
mov    -0x14(%rbp),%edi
lea    -0x830(%rbp),%rsi
call   10c0 <serve_file@plt>
jmp    16e2 <accept_request+0x512>
mov    -0x14(%rbp),%edi
lea    -0x830(%rbp),%rsi
lea    -0x530(%rbp),%rdx
mov    -0x858(%rbp),%rcx
call   10d0 <execute_cgi@plt>
jmp    16e7 <accept_request+0x517>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x860,%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,%r15
lea    0x410(%rsp),%rsi
mov    $0x400,%edx
call   1040 <get_line@plt>
mov    %eax,%ebp
movsbl 0x410(%rsp),%edi
call   1070 <isspace@plt>
test   %rax,%rax
je     120f <accept_request+0x3f>
xor    %r14d,%r14d
jmp    124e <accept_request+0x7e>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
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    124e <accept_request+0x7e>
cmp    $0xfd,%rbx
mov    %r14,%rbx
jb     1220 <accept_request+0x50>
movb   $0x0,0x10(%rsp,%r14,1)
lea    0xda5(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     128d <accept_request+0xbd>
lea    0xd93(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     128d <accept_request+0xbd>
mov    %r15d,%edi
call   1090 <unimplemented@plt>
jmp    1494 <accept_request+0x2c4>
mov    %ebp,0xc(%rsp)
lea    0xd6c(%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     12d3 <accept_request+0x103>
cmp    $0x400,%rbp
jb     12b0 <accept_request+0xe0>
test   %r12,%r12
sete   %r12b
movsbl 0x410(%rsp,%rbp,1),%edi
call   1070 <isspace@plt>
xor    %r13d,%r13d
test   %rax,%rax
jne    1343 <accept_request+0x173>
cmp    $0x3ff,%rbp
ja     1343 <accept_request+0x173>
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    1343 <accept_request+0x173>
cmp    $0xfc,%rbp
ja     1343 <accept_request+0x173>
lea    0x1(%r14),%rax
mov    %r13,%rbp
cmp    $0x3ff,%r14
mov    %rax,%r14
jb     1300 <accept_request+0x130>
movb   $0x0,0x110(%rsp,%r13,1)
lea    0xcad(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1366 <accept_request+0x196>
xor    %ebp,%ebp
jmp    138d <accept_request+0x1bd>
lea    0x110(%rsp),%rbp
xchg   %ax,%ax
movzbl 0x0(%rbp),%eax
test   %al,%al
je     138d <accept_request+0x1bd>
cmp    $0x3f,%al
je     1382 <accept_request+0x1b2>
add    $0x1,%rbp
jmp    1370 <accept_request+0x1a0>
movb   $0x0,0x0(%rbp)
add    $0x1,%rbp
mov    $0x1,%r12b
lea    0xc75(%rip),%rsi
lea    0x210(%rsp),%rbx
lea    0x110(%rsp),%rdx
mov    %rbx,%rdi
call   10f0 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
jne    13d1 <accept_request+0x201>
lea    0xc51(%rip),%rsi
lea    0x210(%rsp),%rdi
call   10e0 <strcat@plt>
lea    0x210(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   10a0 <stat@plt>
cmp    $0xffffffff,%eax
je     1446 <accept_request+0x276>
mov    0x8(%rsp),%ebx
mov    0x2bd5(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    0x2bba(%rip),%rcx
cmp    (%rcx),%eax
jne    1416 <accept_request+0x246>
lea    0xc0b(%rip),%rsi
lea    0x210(%rsp),%rdi
call   10e0 <strcat@plt>
mov    0x2bc3(%rip),%rax
test   %ebx,(%rax)
jne    142c <accept_request+0x25c>
mov    0x2bb0(%rip),%rax
test   %ebx,(%rax)
je     14a8 <accept_request+0x2d8>
lea    0x210(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r15d,%edi
mov    %rbp,%rcx
call   10d0 <execute_cgi@plt>
jmp    148c <accept_request+0x2bc>
cmpl   $0x0,0xc(%rsp)
jle    1484 <accept_request+0x2b4>
lea    0xbbe(%rip),%rbp
lea    0x410(%rsp),%rbx
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1484 <accept_request+0x2b4>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1040 <get_line@plt>
test   %eax,%eax
jg     1460 <accept_request+0x290>
mov    %r15d,%edi
call   10b0 <not_found@plt>
mov    %r15d,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b39(%rip),%rax
test   %ebx,(%rax)
jne    142c <accept_request+0x25c>
xor    $0x1,%r12b
je     142c <accept_request+0x25c>
lea    0x210(%rsp),%rsi
mov    %r15d,%edi
call   10c0 <serve_file@plt>
jmp    148c <accept_request+0x2bc>

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

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