#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 int32_t;
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(char);
int /*<<< orphan*/ not_found(int);
int /*<<< orphan*/ printf(char *, char *);
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 *clientPtr) {
  char buf[1024];
  int32_t numchars;
  char method[255];
  char url[255];
  char path[512];
  size_t i, j;
  struct stat st;
  int32_t cgi = 0;
  char *query_string = NULL;
  int32_t client = *((int32_t *)clientPtr);
  numchars = get_line(client, buf, sizeof(buf));
  i = 0;
  j = 0;
  while (!isspace(buf[j]) && (i < sizeof(method) - 1)) {
    method[i] = buf[j];
    i++;
    j++;
  }
  method[i] = '\0';
  printf("Accepted a %s\n", method);
  if (strcasecmp(method, "GET") && strcasecmp(method, "POST")) {
    unimplemented(client);
    return 0;
  }
  while (isspace(buf[j]) && (j < sizeof(buf))) {
    j++;
  }
  i = 0;
  while (!isspace(buf[j]) && (i < sizeof(url) - 1) && (j < sizeof(buf))) {
    url[i] = buf[j];
    i++;
    j++;
  }
  url[i] = '\0';
  if (strcasecmp(method, "POST") == 0) {
    cgi = 1;
  } else 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 (!(path[strlen(path) - 2] == '.' && path[strlen(path) - 1] == 'c') &&
      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 0;
}


x86 assembly (clang, -O0):
<accept_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x860,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x83c(%rbp)
movq   $0x0,-0x848(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x84c(%rbp)
mov    -0x84c(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1040 <get_line@plt>
mov    %eax,-0x414(%rbp)
movq   $0x0,-0x828(%rbp)
movq   $0x0,-0x830(%rbp)
mov    -0x830(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1080 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x84d(%rbp)
jne    1280 <accept_request+0xa0>
cmpq   $0xfe,-0x828(%rbp)
setb   %al
mov    %al,-0x84d(%rbp)
mov    -0x84d(%rbp),%al
test   $0x1,%al
jne    1293 <accept_request+0xb3>
jmp    12d8 <accept_request+0xf8>
mov    -0x830(%rbp),%rax
mov    -0x410(%rbp,%rax,1),%cl
mov    -0x828(%rbp),%rax
mov    %cl,-0x520(%rbp,%rax,1)
mov    -0x828(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x828(%rbp)
mov    -0x830(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x830(%rbp)
jmp    1243 <accept_request+0x63>
mov    -0x828(%rbp),%rax
movb   $0x0,-0x520(%rbp,%rax,1)
lea    -0x520(%rbp),%rsi
lea    0xd0b(%rip),%rdi
call   1060 <printf@plt>
lea    -0x520(%rbp),%rdi
lea    0xd07(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     134c <accept_request+0x16c>
lea    -0x520(%rbp),%rdi
lea    0xcee(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     134c <accept_request+0x16c>
mov    -0x84c(%rbp),%edi
call   10a0 <unimplemented@plt>
movq   $0x0,-0x8(%rbp)
jmp    1782 <accept_request+0x5a2>
jmp    1351 <accept_request+0x171>
mov    -0x830(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1080 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x84e(%rbp)
je     138e <accept_request+0x1ae>
cmpq   $0x400,-0x830(%rbp)
setb   %al
mov    %al,-0x84e(%rbp)
mov    -0x84e(%rbp),%al
test   $0x1,%al
jne    13a1 <accept_request+0x1c1>
jmp    13b8 <accept_request+0x1d8>
mov    -0x830(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x830(%rbp)
jmp    1351 <accept_request+0x171>
movq   $0x0,-0x828(%rbp)
mov    -0x830(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1080 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x84f(%rbp)
jne    1419 <accept_request+0x239>
xor    %eax,%eax
cmpq   $0xfe,-0x828(%rbp)
mov    %al,-0x84f(%rbp)
jae    1419 <accept_request+0x239>
cmpq   $0x400,-0x830(%rbp)
setb   %al
mov    %al,-0x84f(%rbp)
mov    -0x84f(%rbp),%al
test   $0x1,%al
jne    142c <accept_request+0x24c>
jmp    1471 <accept_request+0x291>
mov    -0x830(%rbp),%rax
mov    -0x410(%rbp,%rax,1),%cl
mov    -0x828(%rbp),%rax
mov    %cl,-0x620(%rbp,%rax,1)
mov    -0x828(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x828(%rbp)
mov    -0x830(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x830(%rbp)
jmp    13c3 <accept_request+0x1e3>
mov    -0x828(%rbp),%rax
movb   $0x0,-0x620(%rbp,%rax,1)
lea    -0x520(%rbp),%rdi
lea    0xb85(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    14ac <accept_request+0x2cc>
movl   $0x1,-0x83c(%rbp)
jmp    1575 <accept_request+0x395>
lea    -0x520(%rbp),%rdi
lea    0xb55(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1570 <accept_request+0x390>
lea    -0x620(%rbp),%rax
mov    %rax,-0x848(%rbp)
mov    -0x848(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x3f,%ecx
mov    %al,-0x850(%rbp)
je     1508 <accept_request+0x328>
mov    -0x848(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x850(%rbp)
mov    -0x850(%rbp),%al
test   $0x1,%al
jne    151b <accept_request+0x33b>
jmp    1532 <accept_request+0x352>
mov    -0x848(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x848(%rbp)
jmp    14d7 <accept_request+0x2f7>
mov    -0x848(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3f,%eax
jne    156b <accept_request+0x38b>
movl   $0x1,-0x83c(%rbp)
mov    -0x848(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x848(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x848(%rbp)
jmp    1570 <accept_request+0x390>
jmp    1575 <accept_request+0x395>
lea    -0x820(%rbp),%rdi
lea    -0x620(%rbp),%rdx
lea    0xa8e(%rip),%rsi
call   1100 <sprintf@plt>
lea    -0x820(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x820(%rbp,%rax,1),%eax
ff
cmp    $0x2f,%eax
jne    15c4 <accept_request+0x3e4>
lea    -0x820(%rbp),%rdi
lea    0xa63(%rip),%rsi
call   10f0 <strcat@plt>
lea    -0x820(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x2,%eax
cltq
movsbl -0x820(%rbp,%rax,1),%eax
ff
cmp    $0x2e,%eax
jne    1608 <accept_request+0x428>
lea    -0x820(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x820(%rbp,%rax,1),%eax
ff
cmp    $0x63,%eax
je     16a3 <accept_request+0x4c3>
lea    -0x820(%rbp),%rdi
lea    -0x838(%rbp),%rsi
call   10b0 <stat@plt>
cmp    $0xffffffff,%eax
jne    16a3 <accept_request+0x4c3>
jmp    1629 <accept_request+0x449>
xor    %eax,%eax
cmpl   $0x0,-0x414(%rbp)
mov    %al,-0x851(%rbp)
jle    165e <accept_request+0x47e>
lea    -0x410(%rbp),%rsi
lea    0x9c1(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x851(%rbp)
mov    -0x851(%rbp),%al
test   $0x1,%al
jne    1671 <accept_request+0x491>
jmp    1693 <accept_request+0x4b3>
mov    -0x84c(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1040 <get_line@plt>
mov    %eax,-0x414(%rbp)
jmp    1629 <accept_request+0x449>
mov    -0x84c(%rbp),%edi
call   10c0 <not_found@plt>
jmp    176f <accept_request+0x58f>
mov    -0x838(%rbp),%eax
mov    0x2918(%rip),%rcx
and    (%rcx),%eax
mov    0x28ff(%rip),%rcx
cmp    (%rcx),%eax
jne    16d4 <accept_request+0x4f4>
lea    -0x820(%rbp),%rdi
lea    0x952(%rip),%rsi
call   10f0 <strcat@plt>
mov    -0x838(%rbp),%eax
mov    0x28ff(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    171c <accept_request+0x53c>
mov    -0x838(%rbp),%eax
mov    0x28df(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    171c <accept_request+0x53c>
mov    -0x838(%rbp),%eax
mov    0x28d7(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1726 <accept_request+0x546>
movl   $0x1,-0x83c(%rbp)
cmpl   $0x0,-0x83c(%rbp)
jne    174a <accept_request+0x56a>
mov    -0x84c(%rbp),%edi
lea    -0x820(%rbp),%rsi
call   10d0 <serve_file@plt>
jmp    176a <accept_request+0x58a>
mov    -0x84c(%rbp),%edi
lea    -0x820(%rbp),%rsi
lea    -0x520(%rbp),%rdx
mov    -0x848(%rbp),%rcx
call   10e0 <execute_cgi@plt>
jmp    176f <accept_request+0x58f>
mov    -0x84c(%rbp),%edi
call   1070 <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,%r14d
movsbl 0x410(%rsp),%edi
call   1080 <isspace@plt>
test   %rax,%rax
je     1223 <accept_request+0x43>
xor    %r13d,%r13d
jmp    125e <accept_request+0x7e>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x410(%rsp,%rbx,1),%eax
mov    %al,0x10(%rsp,%rbx,1)
lea    0x1(%rbx),%r13
movsbl 0x411(%rsp,%rbx,1),%edi
call   1080 <isspace@plt>
test   %rax,%rax
jne    125e <accept_request+0x7e>
cmp    $0xfd,%rbx
mov    %r13,%rbx
jb     1230 <accept_request+0x50>
movb   $0x0,0x10(%rsp,%r13,1)
lea    0xd95(%rip),%rdi
lea    0x10(%rsp),%rbp
mov    %rbp,%rsi
call   1060 <printf@plt>
lea    0xd90(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     12b0 <accept_request+0xd0>
lea    0xd80(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     12b0 <accept_request+0xd0>
mov    %r15d,%edi
call   10a0 <unimplemented@plt>
jmp    1504 <accept_request+0x324>
nop
mov    %r13,%rbp
movsbl 0x410(%rsp,%r13,1),%edi
call   1080 <isspace@plt>
add    $0x1,%r13
test   %rax,%rax
je     12d3 <accept_request+0xf3>
cmp    $0x400,%rbp
jb     12b0 <accept_request+0xd0>
movsbl 0x410(%rsp,%rbp,1),%edi
call   1080 <isspace@plt>
xor    %r12d,%r12d
test   %rax,%rax
jne    1343 <accept_request+0x163>
cmp    $0x3ff,%rbp
ja     1343 <accept_request+0x163>
add    $0xffffffffffffffff,%r13
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movzbl 0x410(%rsp,%r13,1),%eax
mov    %al,0x110(%rsp,%rbp,1)
lea    0x1(%rbp),%r12
movsbl 0x411(%rsp,%r13,1),%edi
call   1080 <isspace@plt>
test   %rax,%rax
jne    1343 <accept_request+0x163>
cmp    $0xfc,%rbp
ja     1343 <accept_request+0x163>
lea    0x1(%r13),%rax
mov    %r12,%rbp
cmp    $0x3ff,%r13
mov    %rax,%r13
jb     1300 <accept_request+0x120>
movb   $0x0,0x110(%rsp,%r12,1)
lea    0xcc0(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     137f <accept_request+0x19f>
lea    0xca6(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
mov    $0x1,%r12b
test   %rax,%rax
je     1386 <accept_request+0x1a6>
xor    %ebp,%ebp
jmp    13ad <accept_request+0x1cd>
xor    %r12d,%r12d
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
xor    %r12d,%r12d
lea    0xc64(%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    0xc3e(%rip),%rsi
lea    0x210(%rsp),%rdi
call   10f0 <strcat@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0x2e,-0x2(%rax,%rbx,1)
jne    1413 <accept_request+0x233>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0x63,-0x1(%rax,%rbx,1)
je     1432 <accept_request+0x252>
lea    0x210(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   10b0 <stat@plt>
cmp    $0xffffffff,%eax
je     14b3 <accept_request+0x2d3>
mov    0x8(%rsp),%ebx
mov    0x2b8f(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    0x2b74(%rip),%rcx
cmp    (%rcx),%eax
jne    145c <accept_request+0x27c>
lea    0xbd2(%rip),%rsi
lea    0x210(%rsp),%rdi
call   10f0 <strcat@plt>
mov    0x2b7d(%rip),%rax
test   %ebx,(%rax)
jne    1499 <accept_request+0x2b9>
mov    0x2b6a(%rip),%rax
test   %ebx,(%rax)
jne    1499 <accept_request+0x2b9>
mov    0x2b6f(%rip),%rax
test   %ebx,(%rax)
setne  %al
xor    $0x1,%r12b
or     %al,%r12b
jne    1499 <accept_request+0x2b9>
lea    0x210(%rsp),%rsi
mov    %r15d,%edi
call   10d0 <serve_file@plt>
jmp    14fc <accept_request+0x31c>
lea    0x210(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r15d,%edi
mov    %rbp,%rcx
call   10e0 <execute_cgi@plt>
jmp    14fc <accept_request+0x31c>
test   %r14d,%r14d
jle    14f4 <accept_request+0x314>
lea    0xb4e(%rip),%rbx
lea    0x410(%rsp),%rbp
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     14f4 <accept_request+0x314>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x400,%edx
call   1040 <get_line@plt>
test   %eax,%eax
jg     14d0 <accept_request+0x2f0>
mov    %r15d,%edi
call   10c0 <not_found@plt>
mov    %r15d,%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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