#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(char);
int /*<<< orphan*/ not_found(int);
int /*<<< orphan*/ printf(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 process_request(int clifd) {
  char buf[2048];
  int numchars;
  char method[255];
  char url[255];
  char path[512];
  char *query_string = NULL;
  int i, j;
  struct stat st;
  int cgi = 0;
  numchars = get_line(clifd, buf, sizeof(buf));
  if (numchars == 0) {
    printf("error in get_line()\n");
    return;
  }
  i = j = 0;
  while (!isspace(buf[j]) && (i < sizeof(method) - 1)) {
    method[i++] = buf[j++];
  }
  method[i] = '\0';
  if (strcasecmp(method, "GET") && strcasecmp(method, "POST")) {
    unimplemented(clifd);
    return;
  }
  if (strcasecmp(method, "POST") == 0)
    cgi = 1;
  i = 0;
  while (isspace(buf[j]) && (j < sizeof(buf)))
    ++j;
  while (!isspace(buf[j]) && (i < sizeof(url) - 1) && (j < sizeof(buf)))
    url[i++] = buf[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, "/var/www/html%s", url);
  if (path[strlen(path) - 1] == '/')
    strcat(path, "index.html");
  printf("path = %s\n", path);
  if (stat(path, &st) == -1) {
    while ((numchars > 0) && strcmp("\n", buf))
      numchars = get_line(clifd, buf, sizeof(buf));
    not_found(clifd);
  } 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;
    }
    cgi = 0;
    if (cgi)
      execute_cgi(clifd, path, method, query_string);
    else
      serve_file(clifd, path);
  }
  close(clifd);
  return;
}


x86 assembly (clang, -O0):
<process_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc50,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0xc28(%rbp)
movl   $0x0,-0xc3c(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x810(%rbp),%rsi
mov    $0x800,%edx
call   1040 <get_line@plt>
mov    %eax,-0x814(%rbp)
cmpl   $0x0,-0x814(%rbp)
jne    123d <process_request+0x5d>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1719 <process_request+0x539>
movl   $0x0,-0xc30(%rbp)
movl   $0x0,-0xc2c(%rbp)
movslq -0xc30(%rbp),%rax
movsbl -0x810(%rbp,%rax,1),%edi
ff
call   1080 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xc3d(%rbp)
jne    1290 <process_request+0xb0>
movslq -0xc2c(%rbp),%rax
cmp    $0xfe,%rax
setb   %al
mov    %al,-0xc3d(%rbp)
mov    -0xc3d(%rbp),%al
test   $0x1,%al
jne    12a3 <process_request+0xc3>
jmp    12dc <process_request+0xfc>
mov    -0xc30(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc30(%rbp)
cltq
mov    -0x810(%rbp,%rax,1),%cl
mov    -0xc2c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xc2c(%rbp)
cltq
mov    %cl,-0x920(%rbp,%rax,1)
jmp    1251 <process_request+0x71>
movslq -0xc2c(%rbp),%rax
movb   $0x0,-0x920(%rbp,%rax,1)
lea    -0x920(%rbp),%rdi
lea    0xd1c(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     1332 <process_request+0x152>
lea    -0x920(%rbp),%rdi
lea    0xd03(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     1332 <process_request+0x152>
mov    -0x4(%rbp),%edi
call   10a0 <unimplemented@plt>
jmp    1719 <process_request+0x539>
lea    -0x920(%rbp),%rdi
lea    0xcd9(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1359 <process_request+0x179>
movl   $0x1,-0xc3c(%rbp)
movl   $0x0,-0xc2c(%rbp)
movslq -0xc30(%rbp),%rax
movsbl -0x810(%rbp,%rax,1),%edi
ff
call   1080 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xc3e(%rbp)
je     13a2 <process_request+0x1c2>
movslq -0xc30(%rbp),%rax
cmp    $0x800,%rax
setb   %al
mov    %al,-0xc3e(%rbp)
mov    -0xc3e(%rbp),%al
test   $0x1,%al
jne    13b5 <process_request+0x1d5>
jmp    13c9 <process_request+0x1e9>
mov    -0xc30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc30(%rbp)
jmp    1363 <process_request+0x183>
jmp    13ce <process_request+0x1ee>
movslq -0xc30(%rbp),%rax
movsbl -0x810(%rbp,%rax,1),%edi
ff
call   1080 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xc3f(%rbp)
jne    1429 <process_request+0x249>
movslq -0xc2c(%rbp),%rcx
xor    %eax,%eax
cmp    $0xfe,%rcx
mov    %al,-0xc3f(%rbp)
jae    1429 <process_request+0x249>
movslq -0xc30(%rbp),%rax
cmp    $0x800,%rax
setb   %al
mov    %al,-0xc3f(%rbp)
mov    -0xc3f(%rbp),%al
test   $0x1,%al
jne    143c <process_request+0x25c>
jmp    1475 <process_request+0x295>
mov    -0xc30(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc30(%rbp)
cltq
mov    -0x810(%rbp,%rax,1),%cl
mov    -0xc2c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xc2c(%rbp)
cltq
mov    %cl,-0xa20(%rbp,%rax,1)
jmp    13ce <process_request+0x1ee>
movslq -0xc2c(%rbp),%rax
movb   $0x0,-0xa20(%rbp,%rax,1)
lea    -0x920(%rbp),%rdi
lea    0xb83(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1548 <process_request+0x368>
lea    -0xa20(%rbp),%rax
mov    %rax,-0xc28(%rbp)
mov    -0xc28(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x3f,%ecx
mov    %al,-0xc40(%rbp)
je     14e0 <process_request+0x300>
mov    -0xc28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0xc40(%rbp)
mov    -0xc40(%rbp),%al
test   $0x1,%al
jne    14f3 <process_request+0x313>
jmp    150a <process_request+0x32a>
mov    -0xc28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xc28(%rbp)
jmp    14af <process_request+0x2cf>
mov    -0xc28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3f,%eax
jne    1543 <process_request+0x363>
movl   $0x1,-0xc3c(%rbp)
mov    -0xc28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0xc28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xc28(%rbp)
jmp    1548 <process_request+0x368>
lea    -0xc20(%rbp),%rdi
lea    -0xa20(%rbp),%rdx
lea    0xac1(%rip),%rsi
call   1100 <sprintf@plt>
lea    -0xc20(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0xc20(%rbp,%rax,1),%eax
ff
cmp    $0x2f,%eax
jne    1597 <process_request+0x3b7>
lea    -0xc20(%rbp),%rdi
lea    0xaa8(%rip),%rsi
call   10f0 <strcat@plt>
lea    -0xc20(%rbp),%rsi
lea    0xa89(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xc20(%rbp),%rdi
lea    -0xc38(%rbp),%rsi
call   10b0 <stat@plt>
cmp    $0xffffffff,%eax
jne    1641 <process_request+0x461>
jmp    15cd <process_request+0x3ed>
xor    %eax,%eax
cmpl   $0x0,-0x814(%rbp)
mov    %al,-0xc41(%rbp)
jle    1602 <process_request+0x422>
lea    -0x810(%rbp),%rsi
lea    0xa23(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xc41(%rbp)
mov    -0xc41(%rbp),%al
test   $0x1,%al
jne    1615 <process_request+0x435>
jmp    1634 <process_request+0x454>
mov    -0x4(%rbp),%edi
lea    -0x810(%rbp),%rsi
mov    $0x800,%edx
call   1040 <get_line@plt>
mov    %eax,-0x814(%rbp)
jmp    15cd <process_request+0x3ed>
mov    -0x4(%rbp),%edi
call   10c0 <not_found@plt>
jmp    1711 <process_request+0x531>
mov    -0xc38(%rbp),%eax
mov    0x297a(%rip),%rcx
and    (%rcx),%eax
mov    0x2961(%rip),%rcx
cmp    (%rcx),%eax
jne    1672 <process_request+0x492>
lea    -0xc20(%rbp),%rdi
lea    0x9cc(%rip),%rsi
call   10f0 <strcat@plt>
mov    -0xc38(%rbp),%eax
mov    0x2961(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    16ba <process_request+0x4da>
mov    -0xc38(%rbp),%eax
mov    0x2941(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    16ba <process_request+0x4da>
mov    -0xc38(%rbp),%eax
mov    0x2939(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     16c4 <process_request+0x4e4>
movl   $0x1,-0xc3c(%rbp)
movl   $0x0,-0xc3c(%rbp)
cmpl   $0x0,-0xc3c(%rbp)
je     16fd <process_request+0x51d>
mov    -0x4(%rbp),%edi
lea    -0xc20(%rbp),%rsi
lea    -0x920(%rbp),%rdx
mov    -0xc28(%rbp),%rcx
call   10e0 <execute_cgi@plt>
jmp    170c <process_request+0x52c>
mov    -0x4(%rbp),%edi
lea    -0xc20(%rbp),%rsi
call   10d0 <serve_file@plt>
jmp    1711 <process_request+0x531>
mov    -0x4(%rbp),%edi
call   1070 <close@plt>
add    $0xc50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_request>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc18,%rsp
mov    %edi,%r14d
lea    0x410(%rsp),%rsi
mov    $0x800,%edx
call   1050 <get_line@plt>
test   %eax,%eax
je     1224 <process_request+0x44>
mov    %eax,%r15d
movsbl 0x410(%rsp),%edi
call   1090 <isspace@plt>
test   %rax,%rax
je     1235 <process_request+0x55>
xor    %r13d,%r13d
jmp    126e <process_request+0x8e>
lea    0xe05(%rip),%rdi
call   1040 <puts@plt>
jmp    1484 <process_request+0x2a4>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
lea    0x1(%rbx),%r13
movzbl 0x410(%rsp,%rbx,1),%eax
mov    %al,0x10(%rsp,%rbx,1)
movsbl 0x411(%rsp,%rbx,1),%edi
call   1090 <isspace@plt>
test   %rax,%rax
jne    126e <process_request+0x8e>
cmp    $0xfd,%rbx
mov    %r13,%rbx
jb     1240 <process_request+0x60>
movb   $0x0,0x10(%rsp,%r13,1)
lea    0xd85(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     12ad <process_request+0xcd>
lea    0xd73(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     12ad <process_request+0xcd>
mov    %r14d,%edi
call   10b0 <unimplemented@plt>
jmp    1484 <process_request+0x2a4>
add    $0xffffffffffffffff,%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl 0x411(%rsp,%r13,1),%edi
add    $0x1,%r13
call   1090 <isspace@plt>
test   %rax,%rax
je     12e0 <process_request+0x100>
cmp    $0x800,%r13
jb     12c0 <process_request+0xe0>
movsbl 0x410(%rsp,%r13,1),%edi
call   1090 <isspace@plt>
mov    %r13d,%ecx
and    $0xfffff800,%ecx
or     %rax,%rcx
jne    1345 <process_request+0x165>
xor    %ebp,%ebp
xchg   %ax,%ax
lea    (%rsp,%rbp,1),%rax
add    $0x410,%rax
movzbl 0x0(%r13,%rax,1),%ecx
lea    0x1(%rbp),%r12
mov    %cl,0x110(%rsp,%rbp,1)
movsbl 0x1(%r13,%rax,1),%edi
call   1090 <isspace@plt>
test   %rax,%rax
jne    1348 <process_request+0x168>
cmp    $0xfc,%rbp
ja     1348 <process_request+0x168>
add    %r13,%rbp
cmp    $0x7ff,%rbp
mov    %r12,%rbp
jb     1300 <process_request+0x120>
jmp    1348 <process_request+0x168>
xor    %r12d,%r12d
movb   $0x0,0x110(%rsp,%r12,1)
lea    0xca8(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    1385 <process_request+0x1a5>
lea    0x110(%rsp),%rax
nop
movzbl (%rax),%ecx
test   %cl,%cl
je     1385 <process_request+0x1a5>
cmp    $0x3f,%cl
je     1382 <process_request+0x1a2>
add    $0x1,%rax
jmp    1370 <process_request+0x190>
movb   $0x0,(%rax)
lea    0xc7d(%rip),%rsi
lea    0x210(%rsp),%rbx
lea    0x110(%rsp),%rdx
mov    %rbx,%rdi
call   1100 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
jne    13c9 <process_request+0x1e9>
lea    0xc69(%rip),%rsi
lea    0x210(%rsp),%rdi
call   10f0 <strcat@plt>
lea    0xc49(%rip),%rdi
lea    0x210(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   10c0 <stat@plt>
cmp    $0xffffffff,%eax
je     1432 <process_request+0x252>
mov    0x2be5(%rip),%rax
mov    (%rax),%eax
and    0x8(%rsp),%eax
mov    0x2bc8(%rip),%rcx
cmp    (%rcx),%eax
jne    1420 <process_request+0x240>
lea    0xc11(%rip),%rsi
lea    0x210(%rsp),%rdi
call   10f0 <strcat@plt>
lea    0x210(%rsp),%rsi
mov    %r14d,%edi
call   10e0 <serve_file@plt>
jmp    147c <process_request+0x29c>
test   %r15d,%r15d
jle    1474 <process_request+0x294>
lea    0xbe4(%rip),%rbp
lea    0x410(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1474 <process_request+0x294>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x800,%edx
call   1050 <get_line@plt>
test   %eax,%eax
jg     1450 <process_request+0x270>
mov    %r14d,%edi
call   10d0 <not_found@plt>
mov    %r14d,%edi
call   1080 <close@plt>
add    $0xc18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str.1 = [4 x i8] c"GET\00"
@.str.2 = [5 x i8] c"POST\00"
@.str.3 = [16 x i8] c"/var/www/html%s\00"
@.str.4 = [11 x i8] c"index.html\00"
@.str.5 = [11 x i8] c"path = %s\0A\00"
@.str.6 = [2 x i8] c"\0A\00"
@S_IFMT = global i32 0
@S_IFDIR = global i32 0
@.str.7 = [12 x i8] c"/index.html\00"
@S_IXUSR = global i32 0
@S_IXGRP = global i32 0
@S_IXOTH = global i32 0
@str = [20 x i8] c"error in get_line()\00"
define void @process_request(i32 %0) {
%2 = alloca [2048 x i8]
%3 = alloca [255 x i8]
%4 = alloca [255 x i8]
%5 = alloca [512 x i8]
%6 = alloca %struct.stat
%7 = getelementptr inbounds [2048 x i8], [2048 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 2048)
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %1
%15 = load i8, i8* %7
%16 = call i64 @isspace(i8 signext %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %32
18: ; preds = %1
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %124
20: ; preds = %14, %20
%21 = phi i64 [ %23, %20 ], [ 0, %14 ]
%22 = phi i8* [ %26, %20 ], [ %7, %14 ]
%23 = add nuw nsw i64 %21, 1
%24 = load i8, i8* %22
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %21
store i8 %24, i8* %25
%26 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 %23
%27 = load i8, i8* %26
%28 = call i64 @isspace(i8 signext %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 %20, label %32
32: ; preds = %20, %14
%33 = phi i64 [ 0, %14 ], [ %23, %20 ]
%34 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %33
store i8 0, i8* %34
%35 = call i64 @strcasecmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %38, %32
br label %43
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 %37, label %41
41: ; preds = %38
%42 = call i32 @unimplemented(i32 %0)
br label %124
43: ; preds = %37, %43
%44 = phi i64 [ %51, %43 ], [ %33, %37 ]
%45 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = call i64 @isspace(i8 signext %46)
%48 = icmp ne i64 %47, 0
%49 = icmp ult i64 %44, 2048
%50 = select i1 %48, i1 %49, i1 false
%51 = add nuw nsw i64 %44, 1
br i1 %50, label %43, label %52
52: ; preds = %43
%53 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 %44
%54 = load i8, i8* %53
%55 = call i64 @isspace(i8 signext %54)
%56 = icmp eq i64 %55, 0
%57 = and i64 %44, 4294965248
%58 = icmp eq i64 %57, 0
%59 = select i1 %56, i1 %58, i1 false
br i1 %59, label %60, label %76
60: ; preds = %52, %60
%61 = phi i64 [ %66, %60 ], [ 0, %52 ]
%62 = phi i64 [ %64, %60 ], [ %44, %52 ]
%63 = phi i8* [ %68, %60 ], [ %53, %52 ]
%64 = add nuw nsw i64 %62, 1
%65 = load i8, i8* %63
%66 = add nuw nsw i64 %61, 1
%67 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 %61
store i8 %65, i8* %67
%68 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 %64
%69 = load i8, i8* %68
%70 = call i64 @isspace(i8 signext %69)
%71 = icmp eq i64 %70, 0
%72 = icmp ult i64 %61, 253
%73 = select i1 %71, i1 %72, i1 false
%74 = icmp ult i64 %62, 2047
%75 = select i1 %73, i1 %74, i1 false
br i1 %75, label %60, label %76
76: ; preds = %60, %52
%77 = phi i64 [ 0, %52 ], [ %66, %60 ]
%78 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 %77
store i8 0, i8* %78
%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 %87
81: ; preds = %76, %84
%82 = phi i8* [ %85, %84 ], [ %9, %76 ]
%83 = load i8, i8* %82
switch i8 %83, label %84 [
i8 63, label %86
i8 0, label %87
]
84: ; preds = %81
%85 = getelementptr inbounds i8, i8* %82, i64 1
br label %81
86: ; preds = %81
store i8 0, i8* %82
br label %87
87: ; preds = %81, %86, %76
%88 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%89 = call i32 @strlen(i8* %10)
%90 = add nsw i32 %89, -1
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %91
%93 = load i8, i8* %92
%94 = icmp eq i8 %93, 47
br i1 %94, label %95, label %97
95: ; preds = %87
%96 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %97
97: ; preds = %95, %87
%98 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %10)
%99 = call i32 @stat(i8* %10, %struct.stat* %6)
%100 = icmp eq i32 %99, -1
br i1 %100, label %101, label %111
101: ; preds = %97
%102 = icmp sgt i32 %12, 0
br i1 %102, label %103, label %109
103: ; preds = %101, %106
%104 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* %7)
%105 = icmp eq i64 %104, 0
br i1 %105, label %109, label %106
106: ; preds = %103
%107 = call i32 @get_line(i32 %0, i8* %7, i32 2048)
%108 = icmp sgt i32 %107, 0
br i1 %108, label %103, label %109
109: ; preds = %103, %106, %101
%110 = call i32 @not_found(i32 %0)
br label %122
111: ; preds = %97
%112 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
%113 = load i32, i32* %112
%114 = load i32, i32* @S_IFMT
%115 = and i32 %114, %113
%116 = load i32, i32* @S_IFDIR
%117 = icmp eq i32 %115, %116
br i1 %117, label %118, label %120
118: ; preds = %111
%119 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %120
120: ; preds = %118, %111
%121 = call i32 @serve_file(i32 %0, i8* %10)
br label %122
122: ; preds = %120, %109
%123 = call i32 @close(i32 %0)
br label %124
124: ; preds = %122, %41, %18
ret void
}