#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 *client1) {
  int client = *(int *)client1;
  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    (%rax),%eax
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    126a <accept_request+0x9a>
cmpq   $0xfe,-0x838(%rbp)
setb   %al
mov    %al,-0x859(%rbp)
mov    -0x859(%rbp),%al
test   $0x1,%al
jne    127d <accept_request+0xad>
jmp    12c2 <accept_request+0xf2>
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    122d <accept_request+0x5d>
mov    -0x838(%rbp),%rax
movb   $0x0,-0x530(%rbp,%rax,1)
lea    -0x530(%rbp),%rdi
lea    0xd21(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     1320 <accept_request+0x150>
lea    -0x530(%rbp),%rdi
lea    0xd08(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     1320 <accept_request+0x150>
mov    -0x14(%rbp),%edi
call   1090 <unimplemented@plt>
movq   $0x0,-0x8(%rbp)
jmp    16f9 <accept_request+0x529>
lea    -0x530(%rbp),%rdi
lea    0xcd6(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1347 <accept_request+0x177>
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     138f <accept_request+0x1bf>
cmpq   $0x400,-0x840(%rbp)
setb   %al
mov    %al,-0x85a(%rbp)
mov    -0x85a(%rbp),%al
test   $0x1,%al
jne    13a2 <accept_request+0x1d2>
jmp    13b9 <accept_request+0x1e9>
mov    -0x840(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x840(%rbp)
jmp    1352 <accept_request+0x182>
jmp    13be <accept_request+0x1ee>
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    1414 <accept_request+0x244>
xor    %eax,%eax
cmpq   $0xfe,-0x838(%rbp)
mov    %al,-0x85b(%rbp)
jae    1414 <accept_request+0x244>
cmpq   $0x400,-0x840(%rbp)
setb   %al
mov    %al,-0x85b(%rbp)
mov    -0x85b(%rbp),%al
test   $0x1,%al
jne    1427 <accept_request+0x257>
jmp    146c <accept_request+0x29c>
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    13be <accept_request+0x1ee>
mov    -0x838(%rbp),%rax
movb   $0x0,-0x630(%rbp,%rax,1)
lea    -0x530(%rbp),%rdi
lea    0xb77(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    153f <accept_request+0x36f>
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     14d7 <accept_request+0x307>
mov    -0x858(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x85c(%rbp)
mov    -0x85c(%rbp),%al
test   $0x1,%al
jne    14ea <accept_request+0x31a>
jmp    1501 <accept_request+0x331>
mov    -0x858(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x858(%rbp)
jmp    14a6 <accept_request+0x2d6>
mov    -0x858(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3f,%eax
jne    153a <accept_request+0x36a>
movl   $0x1,-0x84c(%rbp)
mov    -0x858(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x858(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x858(%rbp)
jmp    153f <accept_request+0x36f>
lea    -0x830(%rbp),%rdi
lea    -0x630(%rbp),%rdx
lea    0xab5(%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    158e <accept_request+0x3be>
lea    -0x830(%rbp),%rdi
lea    0xa8c(%rip),%rsi
call   10e0 <strcat@plt>
lea    -0x830(%rbp),%rdi
lea    -0x848(%rbp),%rsi
call   10a0 <stat@plt>
cmp    $0xffffffff,%eax
jne    1623 <accept_request+0x453>
jmp    15af <accept_request+0x3df>
xor    %eax,%eax
cmpl   $0x0,-0x424(%rbp)
mov    %al,-0x85d(%rbp)
jle    15e4 <accept_request+0x414>
lea    -0x420(%rbp),%rsi
lea    0xa40(%rip),%rdi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x85d(%rbp)
mov    -0x85d(%rbp),%al
test   $0x1,%al
jne    15f7 <accept_request+0x427>
jmp    1616 <accept_request+0x446>
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1040 <get_line@plt>
mov    %eax,-0x424(%rbp)
jmp    15af <accept_request+0x3df>
mov    -0x14(%rbp),%edi
call   10b0 <not_found@plt>
jmp    16e9 <accept_request+0x519>
mov    -0x848(%rbp),%eax
mov    0x2998(%rip),%rcx
and    (%rcx),%eax
mov    0x297f(%rip),%rcx
cmp    (%rcx),%eax
jne    1654 <accept_request+0x484>
lea    -0x830(%rbp),%rdi
lea    0x9c5(%rip),%rsi
call   10e0 <strcat@plt>
mov    -0x848(%rbp),%eax
mov    0x297f(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    169c <accept_request+0x4cc>
mov    -0x848(%rbp),%eax
mov    0x295f(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    169c <accept_request+0x4cc>
mov    -0x848(%rbp),%eax
mov    0x2957(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     16a6 <accept_request+0x4d6>
movl   $0x1,-0x84c(%rbp)
cmpl   $0x0,-0x84c(%rbp)
jne    16c7 <accept_request+0x4f7>
mov    -0x14(%rbp),%edi
lea    -0x830(%rbp),%rsi
call   10c0 <serve_file@plt>
jmp    16e4 <accept_request+0x514>
mov    -0x14(%rbp),%edi
lea    -0x830(%rbp),%rsi
lea    -0x530(%rbp),%rdx
mov    -0x858(%rbp),%rcx
call   10d0 <execute_cgi@plt>
jmp    16e9 <accept_request+0x519>
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),%r15d
lea    0x410(%rsp),%rsi
mov    %r15d,%edi
mov    $0x400,%edx
call   1040 <get_line@plt>
mov    %eax,%ebp
movsbl 0x410(%rsp),%edi
call   1070 <isspace@plt>
test   %rax,%rax
je     1212 <accept_request+0x42>
xor    %r14d,%r14d
jmp    124e <accept_request+0x7e>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
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 = bitcast i8* %15 to i32*
%17 = load i32, i32* %16
store i32 %17, i32* %4
store i32 0, i32* %13
store i8* null, i8** %14
%18 = load i32, i32* %4
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%20 = call i32 @get_line(i32 %18, i8* %19, i32 1024)
store i32 %20, i32* %6
store i64 0, i64* %10
store i64 0, i64* %11
br label %21
21: ; preds = %33, %1
%22 = load i64, i64* %11
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = call i64 @isspace(i32 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %21
%29 = load i64, i64* %10
%30 = icmp ult i64 %29, 254
br label %31
31: ; preds = %28, %21
%32 = phi i1 [ false, %21 ], [ %30, %28 ]
br i1 %32, label %33, label %43
33: ; preds = %31
%34 = load i64, i64* %11
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = load i64, i64* %10
%38 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 %37
store i8 %36, i8* %38
%39 = load i64, i64* %10
%40 = add i64 %39, 1
store i64 %40, i64* %10
%41 = load i64, i64* %11
%42 = add i64 %41, 1
store i64 %42, i64* %11
br label %21
43: ; preds = %31
%44 = load i64, i64* %10
%45 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 %44
store i8 0, i8* %45
%46 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%47 = call i64 @strcasecmp(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %43
%50 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%51 = call i64 @strcasecmp(i8* %50, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = load i32, i32* %4
%55 = call i32 @unimplemented(i32 %54)
store i8* null, i8** %2
br label %218
56: ; preds = %49, %43
%57 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%58 = call i64 @strcasecmp(i8* %57, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %56
store i32 1, i32* %13
br label %61
61: ; preds = %60, %56
store i64 0, i64* %10
br label %62
62: ; preds = %74, %61
%63 = load i64, i64* %11
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = call i64 @isspace(i32 %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %62
%70 = load i64, i64* %11
%71 = icmp ult i64 %70, 1024
br label %72
72: ; preds = %69, %62
%73 = phi i1 [ false, %62 ], [ %71, %69 ]
br i1 %73, label %74, label %77
74: ; preds = %72
%75 = load i64, i64* %11
%76 = add i64 %75, 1
store i64 %76, i64* %11
br label %62
77: ; preds = %72
br label %78
78: ; preds = %93, %77
%79 = load i64, i64* %11
%80 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %79
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = call i64 @isspace(i32 %82)
%84 = icmp ne i64 %83, 0
br i1 %84, label %91, label %85
85: ; preds = %78
%86 = load i64, i64* %10
%87 = icmp ult i64 %86, 254
br i1 %87, label %88, label %91
88: ; preds = %85
%89 = load i64, i64* %11
%90 = icmp ult i64 %89, 1024
br label %91
91: ; preds = %88, %85, %78
%92 = phi i1 [ false, %85 ], [ false, %78 ], [ %90, %88 ]
br i1 %92, label %93, label %103
93: ; preds = %91
%94 = load i64, i64* %11
%95 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %94
%96 = load i8, i8* %95
%97 = load i64, i64* %10
%98 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 %97
store i8 %96, i8* %98
%99 = load i64, i64* %10
%100 = add i64 %99, 1
store i64 %100, i64* %10
%101 = load i64, i64* %11
%102 = add i64 %101, 1
store i64 %102, i64* %11
br label %78
103: ; preds = %91
%104 = load i64, i64* %10
%105 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 %104
store i8 0, i8* %105
%106 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%107 = call i64 @strcasecmp(i8* %106, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%108 = icmp eq i64 %107, 0
br i1 %108, label %109, label %136
109: ; preds = %103
%110 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
store i8* %110, i8** %14
br label %111
111: ; preds = %123, %109
%112 = load i8*, i8** %14
%113 = load i8, i8* %112
%114 = sext i8 %113 to i32
%115 = icmp ne i32 %114, 63
br i1 %115, label %116, label %121
116: ; preds = %111
%117 = load i8*, i8** %14
%118 = load i8, i8* %117
%119 = sext i8 %118 to i32
%120 = icmp ne i32 %119, 0
br label %121
121: ; preds = %116, %111
%122 = phi i1 [ false, %111 ], [ %120, %116 ]
br i1 %122, label %123, label %126
123: ; preds = %121
%124 = load i8*, i8** %14
%125 = getelementptr inbounds i8, i8* %124, i32 1
store i8* %125, i8** %14
br label %111
126: ; preds = %121
%127 = load i8*, i8** %14
%128 = load i8, i8* %127
%129 = sext i8 %128 to i32
%130 = icmp eq i32 %129, 63
br i1 %130, label %131, label %135
131: ; preds = %126
store i32 1, i32* %13
%132 = load i8*, i8** %14
store i8 0, i8* %132
%133 = load i8*, i8** %14
%134 = getelementptr inbounds i8, i8* %133, i32 1
store i8* %134, i8** %14
br label %135
135: ; preds = %131, %126
br label %136
136: ; preds = %135, %103
%137 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%138 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%139 = call i32 @sprintf(i8* %137, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %138)
%140 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%141 = call i32 @strlen(i8* %140)
%142 = sub nsw i32 %141, 1
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 %143
%145 = load i8, i8* %144
%146 = sext i8 %145 to i32
%147 = icmp eq i32 %146, 47
br i1 %147, label %148, label %151
148: ; preds = %136
%149 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%150 = call i32 @strcat(i8* %149, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %151
151: ; preds = %148, %136
%152 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%153 = call i32 @stat(i8* %152, %struct.stat* %12)
%154 = icmp eq i32 %153, -1
br i1 %154, label %155, label %172
155: ; preds = %151
br label %156
156: ; preds = %165, %155
%157 = load i32, i32* %6
%158 = icmp sgt i32 %157, 0
br i1 %158, label %159, label %163
159: ; preds = %156
%160 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%161 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %160)
%162 = icmp ne i64 %161, 0
br label %163
163: ; preds = %159, %156
%164 = phi i1 [ false, %156 ], [ %162, %159 ]
br i1 %164, label %165, label %169
165: ; preds = %163
%166 = load i32, i32* %4
%167 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%168 = call i32 @get_line(i32 %166, i8* %167, i32 1024)
store i32 %168, i32* %6
br label %156
169: ; preds = %163
%170 = load i32, i32* %4
%171 = call i32 @not_found(i32 %170)
br label %215
172: ; preds = %151
%173 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 0
%174 = load i32, i32* %173
%175 = load i32, i32* @S_IFMT
%176 = and i32 %174, %175
%177 = load i32, i32* @S_IFDIR
%178 = icmp eq i32 %176, %177
br i1 %178, label %179, label %182
179: ; preds = %172
%180 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%181 = call i32 @strcat(i8* %180, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %182
182: ; preds = %179, %172
%183 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 0
%184 = load i32, i32* %183
%185 = load i32, i32* @S_IXUSR
%186 = and i32 %184, %185
%187 = icmp ne i32 %186, 0
br i1 %187, label %200, label %188
188: ; preds = %182
%189 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 0
%190 = load i32, i32* %189
%191 = load i32, i32* @S_IXGRP
%192 = and i32 %190, %191
%193 = icmp ne i32 %192, 0
br i1 %193, label %200, label %194
194: ; preds = %188
%195 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 0
%196 = load i32, i32* %195
%197 = load i32, i32* @S_IXOTH
%198 = and i32 %196, %197
%199 = icmp ne i32 %198, 0
br i1 %199, label %200, label %201
200: ; preds = %194, %188, %182
store i32 1, i32* %13
br label %201
201: ; preds = %200, %194
%202 = load i32, i32* %13
%203 = icmp ne i32 %202, 0
br i1 %203, label %208, label %204
204: ; preds = %201
%205 = load i32, i32* %4
%206 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%207 = call i32 @serve_file(i32 %205, i8* %206)
br label %214
208: ; preds = %201
%209 = load i32, i32* %4
%210 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%211 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%212 = load i8*, i8** %14
%213 = call i32 @execute_cgi(i32 %209, i8* %210, i8* %211, i8* %212)
br label %214
214: ; preds = %208, %204
br label %215
215: ; preds = %214, %169
%216 = load i32, i32* %4
%217 = call i32 @close(i32 %216)
store i8* null, i8** %2
br label %218
218: ; preds = %215, %53
%219 = load i8*, i8** %2
ret i8* %219
}

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* 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 = bitcast i8* %0 to i32*
%8 = load i32, i32* %7
%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
}