#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*/ 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];
  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;
  int client = *((int *)clientPtr);
  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';
  printf("Accepted a %s\n", method);
  if (strcasecmp(method, "GET") && strcasecmp(method, "POST")) {
    unimplemented(client);
    return 0;
  }
  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 (!(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    1778 <accept_request+0x598>
lea    -0x520(%rbp),%rdi
lea    0xcb9(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1373 <accept_request+0x193>
movl   $0x1,-0x83c(%rbp)
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,-0x84e(%rbp)
je     13bb <accept_request+0x1db>
cmpq   $0x400,-0x830(%rbp)
setb   %al
mov    %al,-0x84e(%rbp)
mov    -0x84e(%rbp),%al
test   $0x1,%al
jne    13ce <accept_request+0x1ee>
jmp    13e5 <accept_request+0x205>
mov    -0x830(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x830(%rbp)
jmp    137e <accept_request+0x19e>
jmp    13ea <accept_request+0x20a>
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    1440 <accept_request+0x260>
xor    %eax,%eax
cmpq   $0xfe,-0x828(%rbp)
mov    %al,-0x84f(%rbp)
jae    1440 <accept_request+0x260>
cmpq   $0x400,-0x830(%rbp)
setb   %al
mov    %al,-0x84f(%rbp)
mov    -0x84f(%rbp),%al
test   $0x1,%al
jne    1453 <accept_request+0x273>
jmp    1498 <accept_request+0x2b8>
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    13ea <accept_request+0x20a>
mov    -0x828(%rbp),%rax
movb   $0x0,-0x620(%rbp,%rax,1)
lea    -0x520(%rbp),%rdi
lea    0xb5a(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    156b <accept_request+0x38b>
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     1503 <accept_request+0x323>
mov    -0x848(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x850(%rbp)
mov    -0x850(%rbp),%al
test   $0x1,%al
jne    1516 <accept_request+0x336>
jmp    152d <accept_request+0x34d>
mov    -0x848(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x848(%rbp)
jmp    14d2 <accept_request+0x2f2>
mov    -0x848(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3f,%eax
jne    1566 <accept_request+0x386>
movl   $0x1,-0x83c(%rbp)
mov    -0x848(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x848(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x848(%rbp)
jmp    156b <accept_request+0x38b>
lea    -0x820(%rbp),%rdi
lea    -0x620(%rbp),%rdx
lea    0xa98(%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    15ba <accept_request+0x3da>
lea    -0x820(%rbp),%rdi
lea    0xa6d(%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    15fe <accept_request+0x41e>
lea    -0x820(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x820(%rbp,%rax,1),%eax
ff
cmp    $0x63,%eax
je     1699 <accept_request+0x4b9>
lea    -0x820(%rbp),%rdi
lea    -0x838(%rbp),%rsi
call   10b0 <stat@plt>
cmp    $0xffffffff,%eax
jne    1699 <accept_request+0x4b9>
jmp    161f <accept_request+0x43f>
xor    %eax,%eax
cmpl   $0x0,-0x414(%rbp)
mov    %al,-0x851(%rbp)
jle    1654 <accept_request+0x474>
lea    -0x410(%rbp),%rsi
lea    0x9cb(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x851(%rbp)
mov    -0x851(%rbp),%al
test   $0x1,%al
jne    1667 <accept_request+0x487>
jmp    1689 <accept_request+0x4a9>
mov    -0x84c(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1040 <get_line@plt>
mov    %eax,-0x414(%rbp)
jmp    161f <accept_request+0x43f>
mov    -0x84c(%rbp),%edi
call   10c0 <not_found@plt>
jmp    1765 <accept_request+0x585>
mov    -0x838(%rbp),%eax
mov    0x2922(%rip),%rcx
and    (%rcx),%eax
mov    0x2909(%rip),%rcx
cmp    (%rcx),%eax
jne    16ca <accept_request+0x4ea>
lea    -0x820(%rbp),%rdi
lea    0x95c(%rip),%rsi
call   10f0 <strcat@plt>
mov    -0x838(%rbp),%eax
mov    0x2909(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    1712 <accept_request+0x532>
mov    -0x838(%rbp),%eax
mov    0x28e9(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    1712 <accept_request+0x532>
mov    -0x838(%rbp),%eax
mov    0x28e1(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     171c <accept_request+0x53c>
movl   $0x1,-0x83c(%rbp)
cmpl   $0x0,-0x83c(%rbp)
jne    1740 <accept_request+0x560>
mov    -0x84c(%rbp),%edi
lea    -0x820(%rbp),%rsi
call   10d0 <serve_file@plt>
jmp    1760 <accept_request+0x580>
mov    -0x84c(%rbp),%edi
lea    -0x820(%rbp),%rsi
lea    -0x520(%rbp),%rdx
mov    -0x848(%rbp),%rcx
call   10e0 <execute_cgi@plt>
jmp    1765 <accept_request+0x585>
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,%r12d
movsbl 0x410(%rsp),%edi
call   1080 <isspace@plt>
test   %rax,%rax
je     1223 <accept_request+0x43>
xor    %r14d,%r14d
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),%r14
movsbl 0x411(%rsp,%rbx,1),%edi
call   1080 <isspace@plt>
test   %rax,%rax
jne    125e <accept_request+0x7e>
cmp    $0xfd,%rbx
mov    %r14,%rbx
jb     1230 <accept_request+0x50>
movb   $0x0,0x10(%rsp,%r14,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     12af <accept_request+0xcf>
lea    0xd80(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     12af <accept_request+0xcf>
mov    %r15d,%edi
call   10a0 <unimplemented@plt>
jmp    14d4 <accept_request+0x2f4>
mov    %r12d,0xc(%rsp)
lea    0xd58(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
mov    %rax,%r12
nopl   0x0(%rax,%rax,1)
mov    %r14,%rbp
movsbl 0x410(%rsp,%r14,1),%edi
call   1080 <isspace@plt>
add    $0x1,%r14
test   %rax,%rax
je     12f3 <accept_request+0x113>
cmp    $0x400,%rbp
jb     12d0 <accept_request+0xf0>
test   %r12,%r12
sete   %r12b
movsbl 0x410(%rsp,%rbp,1),%edi
call   1080 <isspace@plt>
xor    %r13d,%r13d
test   %rax,%rax
jne    1363 <accept_request+0x183>
cmp    $0x3ff,%rbp
ja     1363 <accept_request+0x183>
add    $0xffffffffffffffff,%r14
xor    %ebp,%ebp
xchg   %ax,%ax
movzbl 0x410(%rsp,%r14,1),%eax
mov    %al,0x110(%rsp,%rbp,1)
lea    0x1(%rbp),%r13
movsbl 0x411(%rsp,%r14,1),%edi
call   1080 <isspace@plt>
test   %rax,%rax
jne    1363 <accept_request+0x183>
cmp    $0xfc,%rbp
ja     1363 <accept_request+0x183>
lea    0x1(%r14),%rax
mov    %r13,%rbp
cmp    $0x3ff,%r14
mov    %rax,%r14
jb     1320 <accept_request+0x140>
movb   $0x0,0x110(%rsp,%r13,1)
lea    0xc9c(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1386 <accept_request+0x1a6>
xor    %ebp,%ebp
jmp    13ad <accept_request+0x1cd>
lea    0x110(%rsp),%rbp
xchg   %ax,%ax
movzbl 0x0(%rbp),%eax
test   %al,%al
je     13ad <accept_request+0x1cd>
cmp    $0x3f,%al
je     13a2 <accept_request+0x1c2>
add    $0x1,%rbp
jmp    1390 <accept_request+0x1b0>
movb   $0x0,0x0(%rbp)
add    $0x1,%rbp
mov    $0x1,%r12b
lea    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     142e <accept_request+0x24e>
lea    0x210(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   10b0 <stat@plt>
cmp    $0xffffffff,%eax
je     1488 <accept_request+0x2a8>
mov    0x8(%rsp),%ebx
mov    0x2b93(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    0x2b78(%rip),%rcx
cmp    (%rcx),%eax
jne    1458 <accept_request+0x278>
lea    0xbd6(%rip),%rsi
lea    0x210(%rsp),%rdi
call   10f0 <strcat@plt>
mov    0x2b81(%rip),%rax
test   %ebx,(%rax)
jne    146e <accept_request+0x28e>
mov    0x2b6e(%rip),%rax
test   %ebx,(%rax)
je     14e8 <accept_request+0x308>
lea    0x210(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r15d,%edi
mov    %rbp,%rcx
call   10e0 <execute_cgi@plt>
jmp    14cc <accept_request+0x2ec>
cmpl   $0x0,0xc(%rsp)
jle    14c4 <accept_request+0x2e4>
lea    0xb77(%rip),%rbx
lea    0x410(%rsp),%rbp
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     14c4 <accept_request+0x2e4>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x400,%edx
call   1040 <get_line@plt>
test   %eax,%eax
jg     14a0 <accept_request+0x2c0>
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
mov    0x2af9(%rip),%rax
test   %ebx,(%rax)
jne    146e <accept_request+0x28e>
xor    $0x1,%r12b
je     146e <accept_request+0x28e>
lea    0x210(%rsp),%rsi
mov    %r15d,%edi
call   10d0 <serve_file@plt>
jmp    14cc <accept_request+0x2ec>

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

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