#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(int client) {
  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;
  }
  if (strcasecmp(method, "POST") == 0)
    cgi = 1;
  i = 0;
  while (isspace((int)(buf[j])) && (j < sizeof(buf)))
    j++;
  while (!isspace((int)(buf[j])) && (i < sizeof(url) - 1) &&
         (j < sizeof(buf))) {
    url[i] = buf[j];
    i++;
    j++;
  }
  url[i] = '\0';
  if (strcasecmp(method, "GET") == 0) {
    query_string = url;
    while ((*query_string != '?') && (*query_string != '\0'))
      query_string++;
    if (*query_string == '?') {
      cgi = 1;
      *query_string = '\0';
      query_string++;
    }
  }
  sprintf(path, "htdocs%s", url);
  if (path[strlen(path) - 1] == '/')
    strcat(path, "index.html");
  if (stat(path, &st) == -1) {
    while ((numchars > 0) && strcmp("\n", buf))
      numchars = get_line(client, buf, sizeof(buf));
    not_found(client);
  } else {
    if ((st.st_mode & S_IFMT) == S_IFDIR)
      strcat(path, "/index.html");
    if ((st.st_mode & S_IXUSR) || (st.st_mode & S_IXGRP) ||
        (st.st_mode & S_IXOTH))
      cgi = 1;
    if (!cgi) {
      serve_file(client, path);
    } else {
      execute_cgi(client, path, method, query_string);
    }
  }
  close(client);
}


x86 assembly (clang, -O0):
<accept_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x850,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x83c(%rbp)
movq   $0x0,-0x848(%rbp)
mov    -0x4(%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   1070 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x849(%rbp)
jne    1260 <accept_request+0x90>
cmpq   $0xfe,-0x828(%rbp)
setb   %al
mov    %al,-0x849(%rbp)
mov    -0x849(%rbp),%al
test   $0x1,%al
jne    1273 <accept_request+0xa3>
jmp    12b8 <accept_request+0xe8>
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    1223 <accept_request+0x53>
mov    -0x828(%rbp),%rax
movb   $0x0,-0x520(%rbp,%rax,1)
lea    -0x520(%rbp),%rdi
lea    0xd2b(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     130e <accept_request+0x13e>
lea    -0x520(%rbp),%rdi
lea    0xd12(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     130e <accept_request+0x13e>
mov    -0x4(%rbp),%edi
call   1090 <unimplemented@plt>
jmp    16df <accept_request+0x50f>
lea    -0x520(%rbp),%rdi
lea    0xce8(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1335 <accept_request+0x165>
movl   $0x1,-0x83c(%rbp)
movq   $0x0,-0x828(%rbp)
mov    -0x830(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1070 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x84a(%rbp)
je     137d <accept_request+0x1ad>
cmpq   $0x400,-0x830(%rbp)
setb   %al
mov    %al,-0x84a(%rbp)
mov    -0x84a(%rbp),%al
test   $0x1,%al
jne    1390 <accept_request+0x1c0>
jmp    13a7 <accept_request+0x1d7>
mov    -0x830(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x830(%rbp)
jmp    1340 <accept_request+0x170>
jmp    13ac <accept_request+0x1dc>
mov    -0x830(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1070 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x84b(%rbp)
jne    1402 <accept_request+0x232>
xor    %eax,%eax
cmpq   $0xfe,-0x828(%rbp)
mov    %al,-0x84b(%rbp)
jae    1402 <accept_request+0x232>
cmpq   $0x400,-0x830(%rbp)
setb   %al
mov    %al,-0x84b(%rbp)
mov    -0x84b(%rbp),%al
test   $0x1,%al
jne    1415 <accept_request+0x245>
jmp    145a <accept_request+0x28a>
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    13ac <accept_request+0x1dc>
mov    -0x828(%rbp),%rax
movb   $0x0,-0x620(%rbp,%rax,1)
lea    -0x520(%rbp),%rdi
lea    0xb89(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    152d <accept_request+0x35d>
lea    -0x620(%rbp),%rax
mov    %rax,-0x848(%rbp)
mov    -0x848(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x3f,%ecx
mov    %al,-0x84c(%rbp)
je     14c5 <accept_request+0x2f5>
mov    -0x848(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x84c(%rbp)
mov    -0x84c(%rbp),%al
test   $0x1,%al
jne    14d8 <accept_request+0x308>
jmp    14ef <accept_request+0x31f>
mov    -0x848(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x848(%rbp)
jmp    1494 <accept_request+0x2c4>
mov    -0x848(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3f,%eax
jne    1528 <accept_request+0x358>
movl   $0x1,-0x83c(%rbp)
mov    -0x848(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x848(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x848(%rbp)
jmp    152d <accept_request+0x35d>
lea    -0x820(%rbp),%rdi
lea    -0x620(%rbp),%rdx
lea    0xac7(%rip),%rsi
call   10f0 <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    157c <accept_request+0x3ac>
lea    -0x820(%rbp),%rdi
lea    0xa9e(%rip),%rsi
call   10e0 <strcat@plt>
lea    -0x820(%rbp),%rdi
lea    -0x838(%rbp),%rsi
call   10a0 <stat@plt>
cmp    $0xffffffff,%eax
jne    1611 <accept_request+0x441>
jmp    159d <accept_request+0x3cd>
xor    %eax,%eax
cmpl   $0x0,-0x414(%rbp)
mov    %al,-0x84d(%rbp)
jle    15d2 <accept_request+0x402>
lea    -0x410(%rbp),%rsi
lea    0xa52(%rip),%rdi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x84d(%rbp)
mov    -0x84d(%rbp),%al
test   $0x1,%al
jne    15e5 <accept_request+0x415>
jmp    1604 <accept_request+0x434>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1040 <get_line@plt>
mov    %eax,-0x414(%rbp)
jmp    159d <accept_request+0x3cd>
mov    -0x4(%rbp),%edi
call   10b0 <not_found@plt>
jmp    16d7 <accept_request+0x507>
mov    -0x838(%rbp),%eax
mov    0x29aa(%rip),%rcx
and    (%rcx),%eax
mov    0x2991(%rip),%rcx
cmp    (%rcx),%eax
jne    1642 <accept_request+0x472>
lea    -0x820(%rbp),%rdi
lea    0x9d7(%rip),%rsi
call   10e0 <strcat@plt>
mov    -0x838(%rbp),%eax
mov    0x2991(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    168a <accept_request+0x4ba>
mov    -0x838(%rbp),%eax
mov    0x2971(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    168a <accept_request+0x4ba>
mov    -0x838(%rbp),%eax
mov    0x2969(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1694 <accept_request+0x4c4>
movl   $0x1,-0x83c(%rbp)
cmpl   $0x0,-0x83c(%rbp)
jne    16b5 <accept_request+0x4e5>
mov    -0x4(%rbp),%edi
lea    -0x820(%rbp),%rsi
call   10c0 <serve_file@plt>
jmp    16d2 <accept_request+0x502>
mov    -0x4(%rbp),%edi
lea    -0x820(%rbp),%rsi
lea    -0x520(%rbp),%rdx
mov    -0x848(%rbp),%rcx
call   10d0 <execute_cgi@plt>
jmp    16d7 <accept_request+0x507>
mov    -0x4(%rbp),%edi
call   1060 <close@plt>
add    $0x850,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<accept_request>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
mov    %edi,%r15d
lea    0x410(%rsp),%rsi
mov    $0x400,%edx
call   1040 <get_line@plt>
mov    %eax,%ebp
movsbl 0x410(%rsp),%edi
call   1070 <isspace@plt>
test   %rax,%rax
je     120f <accept_request+0x3f>
xor    %r14d,%r14d
jmp    124e <accept_request+0x7e>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl 0x410(%rsp,%rbx,1),%eax
mov    %al,0x10(%rsp,%rbx,1)
lea    0x1(%rbx),%r14
movsbl 0x411(%rsp,%rbx,1),%edi
call   1070 <isspace@plt>
test   %rax,%rax
jne    124e <accept_request+0x7e>
cmp    $0xfd,%rbx
mov    %r14,%rbx
jb     1220 <accept_request+0x50>
movb   $0x0,0x10(%rsp,%r14,1)
lea    0xda5(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     128d <accept_request+0xbd>
lea    0xd93(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     128d <accept_request+0xbd>
mov    %r15d,%edi
call   1090 <unimplemented@plt>
jmp    1494 <accept_request+0x2c4>
mov    %ebp,0xc(%rsp)
lea    0xd6c(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
mov    %rax,%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rbp
movsbl 0x410(%rsp,%r14,1),%edi
call   1070 <isspace@plt>
add    $0x1,%r14
test   %rax,%rax
je     12d3 <accept_request+0x103>
cmp    $0x400,%rbp
jb     12b0 <accept_request+0xe0>
test   %r12,%r12
sete   %r12b
movsbl 0x410(%rsp,%rbp,1),%edi
call   1070 <isspace@plt>
xor    %r13d,%r13d
test   %rax,%rax
jne    1343 <accept_request+0x173>
cmp    $0x3ff,%rbp
ja     1343 <accept_request+0x173>
add    $0xffffffffffffffff,%r14
xor    %ebp,%ebp
xchg   %ax,%ax
movzbl 0x410(%rsp,%r14,1),%eax
mov    %al,0x110(%rsp,%rbp,1)
lea    0x1(%rbp),%r13
movsbl 0x411(%rsp,%r14,1),%edi
call   1070 <isspace@plt>
test   %rax,%rax
jne    1343 <accept_request+0x173>
cmp    $0xfc,%rbp
ja     1343 <accept_request+0x173>
lea    0x1(%r14),%rax
mov    %r13,%rbp
cmp    $0x3ff,%r14
mov    %rax,%r14
jb     1300 <accept_request+0x130>
movb   $0x0,0x110(%rsp,%r13,1)
lea    0xcad(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1366 <accept_request+0x196>
xor    %ebp,%ebp
jmp    138d <accept_request+0x1bd>
lea    0x110(%rsp),%rbp
xchg   %ax,%ax
movzbl 0x0(%rbp),%eax
test   %al,%al
je     138d <accept_request+0x1bd>
cmp    $0x3f,%al
je     1382 <accept_request+0x1b2>
add    $0x1,%rbp
jmp    1370 <accept_request+0x1a0>
movb   $0x0,0x0(%rbp)
add    $0x1,%rbp
mov    $0x1,%r12b
lea    0xc75(%rip),%rsi
lea    0x210(%rsp),%rbx
lea    0x110(%rsp),%rdx
mov    %rbx,%rdi
call   10f0 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
jne    13d1 <accept_request+0x201>
lea    0xc51(%rip),%rsi
lea    0x210(%rsp),%rdi
call   10e0 <strcat@plt>
lea    0x210(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   10a0 <stat@plt>
cmp    $0xffffffff,%eax
je     1446 <accept_request+0x276>
mov    0x8(%rsp),%ebx
mov    0x2bd5(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    0x2bba(%rip),%rcx
cmp    (%rcx),%eax
jne    1416 <accept_request+0x246>
lea    0xc0b(%rip),%rsi
lea    0x210(%rsp),%rdi
call   10e0 <strcat@plt>
mov    0x2bc3(%rip),%rax
test   %ebx,(%rax)
jne    142c <accept_request+0x25c>
mov    0x2bb0(%rip),%rax
test   %ebx,(%rax)
je     14a6 <accept_request+0x2d6>
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>
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b3b(%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 void @accept_request(i32 %0) {
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = alloca i32
%5 = alloca [255 x i8]
%6 = alloca [255 x i8]
%7 = alloca [512 x i8]
%8 = alloca i64
%9 = alloca i64
%10 = alloca %struct.stat
%11 = alloca i32
%12 = alloca i8*
store i32 %0, i32* %2
store i32 0, i32* %11
store i8* null, i8** %12
%13 = load i32, i32* %2
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%15 = call i32 @get_line(i32 %13, i8* %14, i32 1024)
store i32 %15, i32* %4
store i64 0, i64* %8
store i64 0, i64* %9
br label %16
16: ; preds = %28, %1
%17 = load i64, i64* %9
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = call i64 @isspace(i32 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %16
%24 = load i64, i64* %8
%25 = icmp ult i64 %24, 254
br label %26
26: ; preds = %23, %16
%27 = phi i1 [ false, %16 ], [ %25, %23 ]
br i1 %27, label %28, label %38
28: ; preds = %26
%29 = load i64, i64* %9
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = load i64, i64* %8
%33 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 %32
store i8 %31, i8* %33
%34 = load i64, i64* %8
%35 = add i64 %34, 1
store i64 %35, i64* %8
%36 = load i64, i64* %9
%37 = add i64 %36, 1
store i64 %37, i64* %9
br label %16
38: ; preds = %26
%39 = load i64, i64* %8
%40 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 %39
store i8 0, i8* %40
%41 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%42 = call i64 @strcasecmp(i8* %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %51
44: ; preds = %38
%45 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%46 = call i64 @strcasecmp(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %44
%49 = load i32, i32* %2
%50 = call i32 @unimplemented(i32 %49)
br label %213
51: ; preds = %44, %38
%52 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%53 = call i64 @strcasecmp(i8* %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %51
store i32 1, i32* %11
br label %56
56: ; preds = %55, %51
store i64 0, i64* %8
br label %57
57: ; preds = %69, %56
%58 = load i64, i64* %9
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = call i64 @isspace(i32 %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %57
%65 = load i64, i64* %9
%66 = icmp ult i64 %65, 1024
br label %67
67: ; preds = %64, %57
%68 = phi i1 [ false, %57 ], [ %66, %64 ]
br i1 %68, label %69, label %72
69: ; preds = %67
%70 = load i64, i64* %9
%71 = add i64 %70, 1
store i64 %71, i64* %9
br label %57
72: ; preds = %67
br label %73
73: ; preds = %88, %72
%74 = load i64, i64* %9
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %74
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = call i64 @isspace(i32 %77)
%79 = icmp ne i64 %78, 0
br i1 %79, label %86, label %80
80: ; preds = %73
%81 = load i64, i64* %8
%82 = icmp ult i64 %81, 254
br i1 %82, label %83, label %86
83: ; preds = %80
%84 = load i64, i64* %9
%85 = icmp ult i64 %84, 1024
br label %86
86: ; preds = %83, %80, %73
%87 = phi i1 [ false, %80 ], [ false, %73 ], [ %85, %83 ]
br i1 %87, label %88, label %98
88: ; preds = %86
%89 = load i64, i64* %9
%90 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %89
%91 = load i8, i8* %90
%92 = load i64, i64* %8
%93 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 %92
store i8 %91, i8* %93
%94 = load i64, i64* %8
%95 = add i64 %94, 1
store i64 %95, i64* %8
%96 = load i64, i64* %9
%97 = add i64 %96, 1
store i64 %97, i64* %9
br label %73
98: ; preds = %86
%99 = load i64, i64* %8
%100 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 %99
store i8 0, i8* %100
%101 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%102 = call i64 @strcasecmp(i8* %101, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%103 = icmp eq i64 %102, 0
br i1 %103, label %104, label %131
104: ; preds = %98
%105 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
store i8* %105, i8** %12
br label %106
106: ; preds = %118, %104
%107 = load i8*, i8** %12
%108 = load i8, i8* %107
%109 = sext i8 %108 to i32
%110 = icmp ne i32 %109, 63
br i1 %110, label %111, label %116
111: ; preds = %106
%112 = load i8*, i8** %12
%113 = load i8, i8* %112
%114 = sext i8 %113 to i32
%115 = icmp ne i32 %114, 0
br label %116
116: ; preds = %111, %106
%117 = phi i1 [ false, %106 ], [ %115, %111 ]
br i1 %117, label %118, label %121
118: ; preds = %116
%119 = load i8*, i8** %12
%120 = getelementptr inbounds i8, i8* %119, i32 1
store i8* %120, i8** %12
br label %106
121: ; preds = %116
%122 = load i8*, i8** %12
%123 = load i8, i8* %122
%124 = sext i8 %123 to i32
%125 = icmp eq i32 %124, 63
br i1 %125, label %126, label %130
126: ; preds = %121
store i32 1, i32* %11
%127 = load i8*, i8** %12
store i8 0, i8* %127
%128 = load i8*, i8** %12
%129 = getelementptr inbounds i8, i8* %128, i32 1
store i8* %129, i8** %12
br label %130
130: ; preds = %126, %121
br label %131
131: ; preds = %130, %98
%132 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%133 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%134 = call i32 @sprintf(i8* %132, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %133)
%135 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%136 = call i32 @strlen(i8* %135)
%137 = sub nsw i32 %136, 1
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 %138
%140 = load i8, i8* %139
%141 = sext i8 %140 to i32
%142 = icmp eq i32 %141, 47
br i1 %142, label %143, label %146
143: ; preds = %131
%144 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%145 = call i32 @strcat(i8* %144, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %146
146: ; preds = %143, %131
%147 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%148 = call i32 @stat(i8* %147, %struct.stat* %10)
%149 = icmp eq i32 %148, -1
br i1 %149, label %150, label %167
150: ; preds = %146
br label %151
151: ; preds = %160, %150
%152 = load i32, i32* %4
%153 = icmp sgt i32 %152, 0
br i1 %153, label %154, label %158
154: ; preds = %151
%155 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%156 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %155)
%157 = icmp ne i64 %156, 0
br label %158
158: ; preds = %154, %151
%159 = phi i1 [ false, %151 ], [ %157, %154 ]
br i1 %159, label %160, label %164
160: ; preds = %158
%161 = load i32, i32* %2
%162 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%163 = call i32 @get_line(i32 %161, i8* %162, i32 1024)
store i32 %163, i32* %4
br label %151
164: ; preds = %158
%165 = load i32, i32* %2
%166 = call i32 @not_found(i32 %165)
br label %210
167: ; preds = %146
%168 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%169 = load i32, i32* %168
%170 = load i32, i32* @S_IFMT
%171 = and i32 %169, %170
%172 = load i32, i32* @S_IFDIR
%173 = icmp eq i32 %171, %172
br i1 %173, label %174, label %177
174: ; preds = %167
%175 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%176 = call i32 @strcat(i8* %175, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %177
177: ; preds = %174, %167
%178 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%179 = load i32, i32* %178
%180 = load i32, i32* @S_IXUSR
%181 = and i32 %179, %180
%182 = icmp ne i32 %181, 0
br i1 %182, label %195, label %183
183: ; preds = %177
%184 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%185 = load i32, i32* %184
%186 = load i32, i32* @S_IXGRP
%187 = and i32 %185, %186
%188 = icmp ne i32 %187, 0
br i1 %188, label %195, label %189
189: ; preds = %183
%190 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%191 = load i32, i32* %190
%192 = load i32, i32* @S_IXOTH
%193 = and i32 %191, %192
%194 = icmp ne i32 %193, 0
br i1 %194, label %195, label %196
195: ; preds = %189, %183, %177
store i32 1, i32* %11
br label %196
196: ; preds = %195, %189
%197 = load i32, i32* %11
%198 = icmp ne i32 %197, 0
br i1 %198, label %203, label %199
199: ; preds = %196
%200 = load i32, i32* %2
%201 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%202 = call i32 @serve_file(i32 %200, i8* %201)
br label %209
203: ; preds = %196
%204 = load i32, i32* %2
%205 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%206 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%207 = load i8*, i8** %12
%208 = call i32 @execute_cgi(i32 %204, i8* %205, i8* %206, i8* %207)
br label %209
209: ; preds = %203, %199
br label %210
210: ; preds = %209, %164
%211 = load i32, i32* %2
%212 = call i32 @close(i32 %211)
br label %213
213: ; preds = %210, %48
ret void
}

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