#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*/ postContent;
typedef scalar_t__ int32_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ atoi(char *);
int /*<<< orphan*/ bad_request(scalar_t__);
int /*<<< orphan*/ execl(char const *, char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ get_line(scalar_t__, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ processMotorControl(char *);
int /*<<< orphan*/ putenv(char *);
int /*<<< orphan*/ recv(scalar_t__, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(scalar_t__, char *, int /*<<< orphan*/,
                        int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, ...);
scalar_t__ strcasecmp(char const *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char const *);
void execute_cgi(int32_t client, const char *path, const char *method,
                 const char *query_string) {
  char buf[1024];
  int32_t i;
  int32_t numchars = 1;
  int32_t content_length = -1;
  char postContent[1024];
  buf[0] = 'A';
  buf[1] = '\0';
  if (strcasecmp(method, "GET") == 0) {
    while ((numchars > 0) && strcmp("\n", buf)) {
      numchars = get_line(client, buf, sizeof(buf));
    }
  } else if (strcasecmp(method, "POST") == 0) {
    numchars = get_line(client, buf, sizeof(buf));
    while ((numchars > 0) && strcmp("\n", buf)) {
      buf[15] = '\0';
      if (strcasecmp(buf, "Content-Length:") == 0) {
        content_length = atoi(&(buf[16]));
      }
      numchars = get_line(client, buf, sizeof(buf));
    }
    if (content_length == -1) {
      bad_request(client);
      return;
    }
  }
  sprintf(buf, "HTTP/1.0 200 OK\r\n");
  send(client, buf, strlen(buf), 0);
  if (path[strlen(path) - 2] == '.' && path[strlen(path) - 1] == 'c') {
    if (strcasecmp(method, "GET") == 0) {
      printf("C GET: %s\n", query_string);
    } else if (strcasecmp(method, "POST") == 0) {
      memset(postContent, 0, sizeof(postContent));
      for (i = 0; i < content_length; i++) {
        recv(client, &postContent[i], 1, 0);
      }
    }
    if (0 == strcasecmp(path, "htdocs/motor_control.c")) {
      processMotorControl(postContent);
    }
  } else {
    char meth_env[255];
    char query_env[255];
    char length_env[255];
    sprintf(meth_env, "REQUEST_METHOD=%s", method);
    putenv(meth_env);
    if (strcasecmp(method, "GET") == 0) {
      sprintf(query_env, "QUERY_STRING=%s", query_string);
      putenv(query_env);
    } else if (strcasecmp(method, "POST") == 0) {
      sprintf(length_env, "CONTENT_LENGTH=%d", content_length);
      putenv(length_env);
    }
    execl(path, path, NULL);
    exit(0);
  }
}


x86 assembly (clang, -O0):
<execute_cgi>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x1,-0x430(%rbp)
movq   $0xffffffffffffffff,-0x438(%rbp)
ff ff ff ff
movb   $0x41,-0x420(%rbp)
movb   $0x0,-0x41f(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdc6(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    12bd <execute_cgi+0xcd>
jmp    124e <execute_cgi+0x5e>
xor    %eax,%eax
cmpq   $0x0,-0x430(%rbp)
mov    %al,-0xb41(%rbp)
jle    1284 <execute_cgi+0x94>
lea    -0x420(%rbp),%rsi
lea    0xdb7(%rip),%rdi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xb41(%rbp)
mov    -0xb41(%rbp),%al
test   $0x1,%al
jne    1297 <execute_cgi+0xa7>
jmp    12b8 <execute_cgi+0xc8>
mov    -0x8(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1050 <get_line@plt>
mov    %rax,-0x430(%rbp)
jmp    124e <execute_cgi+0x5e>
jmp    13be <execute_cgi+0x1ce>
mov    -0x18(%rbp),%rdi
lea    0xd3c(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    13b9 <execute_cgi+0x1c9>
mov    -0x8(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1050 <get_line@plt>
mov    %rax,-0x430(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x430(%rbp)
mov    %al,-0xb42(%rbp)
jle    1329 <execute_cgi+0x139>
lea    -0x420(%rbp),%rsi
lea    0xd12(%rip),%rdi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xb42(%rbp)
mov    -0xb42(%rbp),%al
test   $0x1,%al
jne    133c <execute_cgi+0x14c>
jmp    1398 <execute_cgi+0x1a8>
movb   $0x0,-0x411(%rbp)
lea    -0x420(%rbp),%rdi
lea    0xcb8(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1377 <execute_cgi+0x187>
lea    -0x420(%rbp),%rdi
add    $0x10,%rdi
call   10e0 <atoi@plt>
mov    %rax,-0x438(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1050 <get_line@plt>
mov    %rax,-0x430(%rbp)
jmp    12f3 <execute_cgi+0x103>
cmpq   $0xffffffffffffffff,-0x438(%rbp)
ff
jne    13b4 <execute_cgi+0x1c4>
mov    -0x8(%rbp),%rdi
call   10c0 <bad_request@plt>
jmp    1620 <execute_cgi+0x430>
jmp    13b9 <execute_cgi+0x1c9>
jmp    13be <execute_cgi+0x1ce>
lea    -0x420(%rbp),%rdi
lea    0xc4d(%rip),%rsi
mov    $0x0,%al
call   10f0 <sprintf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0xb60(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0xb58(%rbp)
lea    -0x420(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xb60(%rbp),%rdi
mov    -0xb58(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0xb50(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xb50(%rbp),%rax
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    1558 <execute_cgi+0x368>
mov    -0x10(%rbp),%rax
mov    %rax,-0xb68(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xb68(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x63,%eax
jne    1558 <execute_cgi+0x368>
mov    -0x18(%rbp),%rdi
lea    0xb86(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    149e <execute_cgi+0x2ae>
mov    -0x20(%rbp),%rsi
lea    0xb97(%rip),%rdi
call   1080 <printf@plt>
jmp    1529 <execute_cgi+0x339>
mov    -0x18(%rbp),%rdi
lea    0xb5b(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1524 <execute_cgi+0x334>
lea    -0x840(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
movq   $0x0,-0x428(%rbp)
mov    -0x428(%rbp),%rax
cmp    -0x438(%rbp),%rax
jge    151f <execute_cgi+0x32f>
mov    -0x8(%rbp),%rdi
lea    -0x840(%rbp),%rsi
add    -0x428(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x428(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x428(%rbp)
jmp    14d6 <execute_cgi+0x2e6>
jmp    1524 <execute_cgi+0x334>
jmp    1529 <execute_cgi+0x339>
mov    -0x10(%rbp),%rdi
lea    0xb02(%rip),%rsi
call   1040 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1553 <execute_cgi+0x363>
lea    -0x840(%rbp),%rdi
call   10d0 <processMotorControl@plt>
jmp    1620 <execute_cgi+0x430>
lea    -0x940(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xae3(%rip),%rsi
mov    $0x0,%al
call   10f0 <sprintf@plt>
lea    -0x940(%rbp),%rdi
call   10a0 <putenv@plt>
mov    -0x18(%rbp),%rdi
lea    0xa78(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    15c1 <execute_cgi+0x3d1>
lea    -0xa40(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xab6(%rip),%rsi
mov    $0x0,%al
call   10f0 <sprintf@plt>
lea    -0xa40(%rbp),%rdi
call   10a0 <putenv@plt>
jmp    1608 <execute_cgi+0x418>
mov    -0x18(%rbp),%rdi
lea    0xa38(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1603 <execute_cgi+0x413>
lea    -0xb40(%rbp),%rdi
mov    -0x438(%rbp),%rdx
lea    0xa7f(%rip),%rsi
mov    $0x0,%al
call   10f0 <sprintf@plt>
lea    -0xb40(%rbp),%rdi
call   10a0 <putenv@plt>
jmp    1608 <execute_cgi+0x418>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1110 <execl@plt>
xor    %edi,%edi
call   1100 <exit@plt>
add    $0xb70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_cgi>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x918,%rsp
mov    %rcx,(%rsp)
mov    %rdx,%r13
mov    %rsi,%r12
mov    %rdi,%r15
movw   $0x41,0x10(%rsp)
lea    0xde4(%rip),%rsi
mov    %rdx,%rdi
call   1040 <strcasecmp@plt>
test   %rax,%rax
je     12d9 <execute_cgi+0xe9>
lea    0xdd0(%rip),%rsi
mov    %r13,%rdi
call   1040 <strcasecmp@plt>
mov    $0xffffffffffffffff,%rbx
test   %rax,%rax
jne    1326 <execute_cgi+0x136>
lea    0x10(%rsp),%rsi
mov    %r15,%rdi
mov    $0x400,%edx
call   1050 <get_line@plt>
test   %rax,%rax
jle    1421 <execute_cgi+0x231>
mov    %r12,0x8(%rsp)
mov    $0xffffffffffffffff,%rbx
lea    0xdaf(%rip),%r12
lea    0x10(%rsp),%rbp
lea    0xd83(%rip),%r14
jmp    12a5 <execute_cgi+0xb5>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbp,%rsi
mov    $0x400,%edx
call   1050 <get_line@plt>
test   %rax,%rax
jle    1317 <execute_cgi+0x127>
mov    %r12,%rdi
mov    %rbp,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1317 <execute_cgi+0x127>
movb   $0x0,0x1f(%rsp)
mov    %rbp,%rdi
mov    %r14,%rsi
call   1040 <strcasecmp@plt>
test   %rax,%rax
jne    1290 <execute_cgi+0xa0>
lea    0x20(%rsp),%rdi
call   10e0 <atoi@plt>
mov    %rax,%rbx
jmp    1290 <execute_cgi+0xa0>
lea    0xd49(%rip),%r14
lea    0x10(%rsp),%rbp
mov    $0xffffffffffffffff,%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbp,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1326 <execute_cgi+0x136>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    $0x400,%edx
call   1050 <get_line@plt>
test   %rax,%rax
jg     12f0 <execute_cgi+0x100>
jmp    1326 <execute_cgi+0x136>
cmp    $0xffffffffffffffff,%rbx
mov    0x8(%rsp),%r12
je     1421 <execute_cgi+0x231>
movups 0xcec(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movw   $0xa,0x20(%rsp)
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
cltq
cmpb   $0x2e,-0x2(%rax,%r12,1)
jne    143b <execute_cgi+0x24b>
mov    %r12,%rdi
call   1060 <strlen@plt>
cltq
cmpb   $0x63,-0x1(%rax,%r12,1)
jne    143b <execute_cgi+0x24b>
lea    0xc78(%rip),%rsi
mov    %r13,%rdi
call   1040 <strcasecmp@plt>
test   %rax,%rax
je     13ee <execute_cgi+0x1fe>
lea    0xc68(%rip),%rsi
mov    %r13,%rdi
call   1040 <strcasecmp@plt>
test   %rax,%rax
jne    13fe <execute_cgi+0x20e>
lea    0x510(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
test   %rbx,%rbx
jle    13fe <execute_cgi+0x20e>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
add    $0x1,%rbp
add    $0xffffffffffffffff,%rbx
jne    13d0 <execute_cgi+0x1e0>
jmp    13fe <execute_cgi+0x20e>
lea    0xc36(%rip),%rdi
mov    (%rsp),%rsi
call   1080 <printf@plt>
lea    0xc31(%rip),%rsi
mov    %r12,%rdi
call   1040 <strcasecmp@plt>
test   %rax,%rax
jne    1429 <execute_cgi+0x239>
lea    0x510(%rsp),%rdi
call   10d0 <processMotorControl@plt>
jmp    1429 <execute_cgi+0x239>
mov    %r15,%rdi
call   10c0 <bad_request@plt>
add    $0x918,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc0b(%rip),%rsi
lea    0x510(%rsp),%rbp
mov    %rbp,%rdi
mov    %r13,%rdx
xor    %eax,%eax
call   10f0 <sprintf@plt>
mov    %rbp,%rdi
call   10a0 <putenv@plt>
lea    0xb9a(%rip),%rsi
mov    %r13,%rdi
call   1040 <strcasecmp@plt>
test   %rax,%rax
jne    148b <execute_cgi+0x29b>
lea    0x410(%rsp),%rbp
lea    0xbdd(%rip),%rsi
mov    %rbp,%rdi
mov    (%rsp),%rdx
jmp    14b4 <execute_cgi+0x2c4>
lea    0xb72(%rip),%rsi
mov    %r13,%rdi
call   1040 <strcasecmp@plt>
test   %rax,%rax
jne    14c3 <execute_cgi+0x2d3>
lea    0x410(%rsp),%rbp
lea    0xbc1(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   10f0 <sprintf@plt>
mov    %rbp,%rdi
call   10a0 <putenv@plt>
mov    %r12,%rdi
mov    %r12,%rsi
xor    %edx,%edx
call   1110 <execl@plt>
xor    %edi,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"GET\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [5 x i8] c"POST\00"
@.str.3 = [16 x i8] c"Content-Length:\00"
@.str.4 = [18 x i8] c"HTTP/1.0 200 OK\0D\0A\00"
@.str.5 = [11 x i8] c"C GET: %s\0A\00"
@.str.6 = [23 x i8] c"htdocs/motor_control.c\00"
@.str.7 = [18 x i8] c"REQUEST_METHOD=%s\00"
@.str.8 = [16 x i8] c"QUERY_STRING=%s\00"
@.str.9 = [18 x i8] c"CONTENT_LENGTH=%d\00"
define void @execute_cgi(i64 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [1024 x i8]
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca [1024 x i8]
%14 = alloca [255 x i8]
%15 = alloca [255 x i8]
%16 = alloca [255 x i8]
store i64 %0, i64* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i64 1, i64* %11
store i64 -1, i64* %12
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
store i8 65, i8* %17
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 1
store i8 0, i8* %18
%19 = load i8*, i8** %7
%20 = call i64 @strcasecmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %37
22: ; preds = %4
br label %23
23: ; preds = %32, %22
%24 = load i64, i64* %11
%25 = icmp sgt i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%28 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = icmp ne i64 %28, 0
br label %30
30: ; preds = %26, %23
%31 = phi i1 [ false, %23 ], [ %29, %26 ]
br i1 %31, label %32, label %36
32: ; preds = %30
%33 = load i64, i64* %5
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%35 = call i64 @get_line(i64 %33, i8* %34, i32 1024)
store i64 %35, i64* %11
br label %23
36: ; preds = %30
br label %74
37: ; preds = %4
%38 = load i8*, i8** %7
%39 = call i64 @strcasecmp(i8* %38, 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 %41, label %73
41: ; preds = %37
%42 = load i64, i64* %5
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%44 = call i64 @get_line(i64 %42, i8* %43, i32 1024)
store i64 %44, i64* %11
br label %45
45: ; preds = %62, %41
%46 = load i64, i64* %11
%47 = icmp sgt i64 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %45
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%50 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %49)
%51 = icmp ne i64 %50, 0
br label %52
52: ; preds = %48, %45
%53 = phi i1 [ false, %45 ], [ %51, %48 ]
br i1 %53, label %54, label %66
54: ; preds = %52
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 15
store i8 0, i8* %55
%56 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%57 = call i64 @strcasecmp(i8* %56, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %54
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 16
%61 = call i64 @atoi(i8* %60)
store i64 %61, i64* %12
br label %62
62: ; preds = %59, %54
%63 = load i64, i64* %5
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%65 = call i64 @get_line(i64 %63, i8* %64, i32 1024)
store i64 %65, i64* %11
br label %45
66: ; preds = %52
%67 = load i64, i64* %12
%68 = icmp eq i64 %67, -1
br i1 %68, label %69, label %72
69: ; preds = %66
%70 = load i64, i64* %5
%71 = call i32 @bad_request(i64 %70)
br label %168
72: ; preds = %66
br label %73
73: ; preds = %72, %37
br label %74
74: ; preds = %73, %36
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%76 = call i32 (i8*, i8*, ...) @sprintf(i8* %75, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%77 = load i64, i64* %5
%78 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%79 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%80 = call i32 @strlen(i8* %79)
%81 = call i32 @send(i64 %77, i8* %78, i32 %80, i32 0)
%82 = load i8*, i8** %6
%83 = load i8*, i8** %6
%84 = call i32 @strlen(i8* %83)
%85 = sub nsw i32 %84, 2
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8, i8* %82, i64 %86
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp eq i32 %89, 46
br i1 %90, label %91, label %137
91: ; preds = %74
%92 = load i8*, i8** %6
%93 = load i8*, i8** %6
%94 = call i32 @strlen(i8* %93)
%95 = sub nsw i32 %94, 1
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %92, i64 %96
%98 = load i8, i8* %97
%99 = sext i8 %98 to i32
%100 = icmp eq i32 %99, 99
br i1 %100, label %101, label %137
101: ; preds = %91
%102 = load i8*, i8** %7
%103 = call i64 @strcasecmp(i8* %102, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%104 = icmp eq i64 %103, 0
br i1 %104, label %105, label %108
105: ; preds = %101
%106 = load i8*, i8** %8
%107 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %106)
br label %129
108: ; preds = %101
%109 = load i8*, i8** %7
%110 = call i64 @strcasecmp(i8* %109, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%111 = icmp eq i64 %110, 0
br i1 %111, label %112, label %128
112: ; preds = %108
%113 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%114 = call i32 @memset(i8* %113, i32 0, i32 1024)
store i64 0, i64* %10
br label %115
115: ; preds = %124, %112
%116 = load i64, i64* %10
%117 = load i64, i64* %12
%118 = icmp slt i64 %116, %117
br i1 %118, label %119, label %127
119: ; preds = %115
%120 = load i64, i64* %5
%121 = load i64, i64* %10
%122 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %121
%123 = call i32 @recv(i64 %120, i8* %122, i32 1, i32 0)
br label %124
124: ; preds = %119
%125 = load i64, i64* %10
%126 = add nsw i64 %125, 1
store i64 %126, i64* %10
br label %115
127: ; preds = %115
br label %128
128: ; preds = %127, %108
br label %129
129: ; preds = %128, %105
%130 = load i8*, i8** %6
%131 = call i64 @strcasecmp(i8* %130, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%132 = icmp eq i64 0, %131
br i1 %132, label %133, label %136
133: ; preds = %129
%134 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%135 = call i32 @processMotorControl(i8* %134)
br label %136
136: ; preds = %133, %129
br label %168
137: ; preds = %91, %74
%138 = getelementptr inbounds [255 x i8], [255 x i8]* %14, i64 0, i64 0
%139 = load i8*, i8** %7
%140 = call i32 (i8*, i8*, ...) @sprintf(i8* %138, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %139)
%141 = getelementptr inbounds [255 x i8], [255 x i8]* %14, i64 0, i64 0
%142 = call i32 @putenv(i8* %141)
%143 = load i8*, i8** %7
%144 = call i64 @strcasecmp(i8* %143, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%145 = icmp eq i64 %144, 0
br i1 %145, label %146, label %152
146: ; preds = %137
%147 = getelementptr inbounds [255 x i8], [255 x i8]* %15, i64 0, i64 0
%148 = load i8*, i8** %8
%149 = call i32 (i8*, i8*, ...) @sprintf(i8* %147, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %148)
%150 = getelementptr inbounds [255 x i8], [255 x i8]* %15, i64 0, i64 0
%151 = call i32 @putenv(i8* %150)
br label %163
152: ; preds = %137
%153 = load i8*, i8** %7
%154 = call i64 @strcasecmp(i8* %153, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%155 = icmp eq i64 %154, 0
br i1 %155, label %156, label %162
156: ; preds = %152
%157 = getelementptr inbounds [255 x i8], [255 x i8]* %16, i64 0, i64 0
%158 = load i64, i64* %12
%159 = call i32 (i8*, i8*, ...) @sprintf(i8* %157, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i64 %158)
%160 = getelementptr inbounds [255 x i8], [255 x i8]* %16, i64 0, i64 0
%161 = call i32 @putenv(i8* %160)
br label %162
162: ; preds = %156, %152
br label %163
163: ; preds = %162, %146
%164 = load i8*, i8** %6
%165 = load i8*, i8** %6
%166 = call i32 @execl(i8* %164, i8* %165, i32* null)
%167 = call i32 @exit(i32 0)
unreachable
168: ; preds = %69, %136
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"GET\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [5 x i8] c"POST\00"
@.str.3 = [16 x i8] c"Content-Length:\00"
@.str.4 = [18 x i8] c"HTTP/1.0 200 OK\0D\0A\00"
@.str.5 = [11 x i8] c"C GET: %s\0A\00"
@.str.6 = [23 x i8] c"htdocs/motor_control.c\00"
@.str.7 = [18 x i8] c"REQUEST_METHOD=%s\00"
@.str.8 = [16 x i8] c"QUERY_STRING=%s\00"
@.str.9 = [18 x i8] c"CONTENT_LENGTH=%d\00"
define void @execute_cgi(i64 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = alloca [255 x i8]
%8 = alloca [255 x i8]
%9 = alloca [255 x i8]
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
store i8 65, i8* %10
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 1
store i8 0, i8* %12
%13 = tail call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %4, %18
%16 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%17 = icmp eq i64 %16, 0
br i1 %17, label %48, label %18
18: ; preds = %15
%19 = call i64 @get_line(i64 %0, i8* %10, i32 1024)
%20 = icmp sgt i64 %19, 0
br i1 %20, label %15, label %48
21: ; preds = %4
%22 = tail call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %48
24: ; preds = %21
%25 = call i64 @get_line(i64 %0, i8* %10, i32 1024)
%26 = icmp sgt i64 %25, 0
br i1 %26, label %27, label %46
27: ; preds = %24
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 15
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 16
br label %30
30: ; preds = %27, %39
%31 = phi i64 [ -1, %27 ], [ %40, %39 ]
%32 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%33 = icmp eq i64 %32, 0
br i1 %33, label %43, label %34
34: ; preds = %30
store i8 0, i8* %28
%35 = call i64 @strcasecmp(i8* %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i64 @atoi(i8* %29)
br label %39
39: ; preds = %37, %34
%40 = phi i64 [ %38, %37 ], [ %31, %34 ]
%41 = call i64 @get_line(i64 %0, i8* %10, i32 1024)
%42 = icmp sgt i64 %41, 0
br i1 %42, label %30, label %43
43: ; preds = %30, %39
%44 = phi i64 [ %31, %30 ], [ %40, %39 ]
%45 = icmp eq i64 %44, -1
br i1 %45, label %46, label %48
46: ; preds = %24, %43
%47 = call i32 @bad_request(i64 %0)
br label %108
48: ; preds = %15, %18, %21, %43
%49 = phi i64 [ %44, %43 ], [ -1, %21 ], [ -1, %18 ], [ -1, %15 ]
%50 = call i32 @strlen(i8* %10)
%51 = call i32 @send(i64 %0, i8* %10, i32 %50, i32 0)
%52 = call i32 @strlen(i8* %1)
%53 = add nsw i32 %52, -2
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %1, i64 %54
%56 = load i8, i8* %55
%57 = icmp eq i8 %56, 46
br i1 %57, label %58, label %87
58: ; preds = %48
%59 = call i32 @strlen(i8* %1)
%60 = add nsw i32 %59, -1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %1, i64 %61
%63 = load i8, i8* %62
%64 = icmp eq i8 %63, 99
br i1 %64, label %65, label %87
65: ; preds = %58
%66 = call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %65
%69 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %3)
br label %82
70: ; preds = %65
%71 = call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %82
73: ; preds = %70
%74 = call i32 @memset(i8* %11, i32 0, i32 1024)
%75 = icmp sgt i64 %49, 0
br i1 %75, label %76, label %82
76: ; preds = %73, %76
%77 = phi i64 [ %80, %76 ], [ 0, %73 ]
%78 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %77
%79 = call i32 @recv(i64 %0, i8* %78, i32 1, i32 0)
%80 = add nuw nsw i64 %77, 1
%81 = icmp eq i64 %80, %49
br i1 %81, label %82, label %76
82: ; preds = %76, %73, %70, %68
%83 = call i64 @strcasecmp(i8* %1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%84 = icmp eq i64 %83, 0
br i1 %84, label %85, label %108
85: ; preds = %82
%86 = call i32 @processMotorControl(i8* %11)
br label %108
87: ; preds = %58, %48
%88 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%89 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%90 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%91 = call i32 (i8*, i8*, ...) @sprintf(i8* %88, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %2)
%92 = call i32 @putenv(i8* %88)
%93 = call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %97
95: ; preds = %87
%96 = call i32 (i8*, i8*, ...) @sprintf(i8* %89, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %3)
br label %102
97: ; preds = %87
%98 = call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%99 = icmp eq i64 %98, 0
br i1 %99, label %100, label %105
100: ; preds = %97
%101 = call i32 (i8*, i8*, ...) @sprintf(i8* %90, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i64 %49)
br label %102
102: ; preds = %95, %100
%103 = phi i8* [ %90, %100 ], [ %89, %95 ]
%104 = call i32 @putenv(i8* %103)
br label %105
105: ; preds = %102, %97
%106 = call i32 @execl(i8* %1, i8* %1, i32* null)
%107 = call i32 @exit(i32 0)
unreachable
108: ; preds = %85, %82, %46
ret void
}