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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ bad_request(int);
int /*<<< orphan*/ cannot_execute(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dup2(int, int);
int /*<<< orphan*/ execl(char const *, char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int get_line(int, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
scalar_t__ pipe(int *);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ processMotorControl(char *, int);
int /*<<< orphan*/ putenv(char *);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, ...);
scalar_t__ strcasecmp(char const *, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char const *);
int /*<<< orphan*/ waitpid(scalar_t__, int *, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
void execute_cgi(int client, const char *path, const char *method,
                 const char *query_string) {
  char buf[1024];
  int cgi_output[2];
  int cgi_input[2];
  pid_t pid;
  int status;
  int i;
  char c;
  int numchars = 1;
  int content_length = -1;
  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 (pipe(cgi_output) < 0) {
    cannot_execute(client);
    return;
  }
  if (pipe(cgi_input) < 0) {
    cannot_execute(client);
    return;
  }
  if ((pid = fork()) < 0) {
    cannot_execute(client);
    return;
  }
  if (pid == 0) {
    if (path[strlen(path) - 2] == '.' && path[strlen(path) - 1] == 'c') {
      char postContent[content_length + 1];
      if (strcasecmp(method, "GET") == 0) {
        printf("C GET: %s\n", query_string);
      } else if (strcasecmp(method, "POST") == 0) {
        memset(postContent, 0, content_length + 1);
        read(cgi_input[0], postContent, content_length);
      }
      if (0 == strcasecmp(path, "htdocs/motor_control.c")) {
        processMotorControl(postContent, content_length);
      }
    } else {
      char meth_env[255];
      char query_env[255];
      char length_env[255];
      dup2(cgi_output[1], 1);
      dup2(cgi_input[0], 0);
      close(cgi_output[0]);
      close(cgi_input[1]);
      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);
    }
  } else {
    close(cgi_output[1]);
    close(cgi_input[0]);
    if (strcasecmp(method, "POST") == 0) {
      for (i = 0; i < content_length; i++) {
        recv(client, &c, 1, 0);
        write(cgi_input[1], &c, 1);
      }
    }
    while (read(cgi_output[0], &c, 1) > 0) {
      send(client, &c, 1, 0);
    }
    close(cgi_output[0]);
    close(cgi_input[1]);
    waitpid(pid, &status, 0);
  }
}


x86 assembly (clang, -O0):
<execute_cgi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x790,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x1,-0x448(%rbp)
movl   $0xffffffff,-0x44c(%rbp)
ff ff ff
movb   $0x41,-0x420(%rbp)
movb   $0x0,-0x41f(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xd49(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1337 <execute_cgi+0xc7>
jmp    12cb <execute_cgi+0x5b>
xor    %eax,%eax
cmpl   $0x0,-0x448(%rbp)
mov    %al,-0x761(%rbp)
jle    1300 <execute_cgi+0x90>
lea    -0x420(%rbp),%rsi
lea    0xd3b(%rip),%rdi
call   1100 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x761(%rbp)
mov    -0x761(%rbp),%al
test   $0x1,%al
jne    1313 <execute_cgi+0xa3>
jmp    1332 <execute_cgi+0xc2>
mov    -0x4(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1060 <get_line@plt>
mov    %eax,-0x448(%rbp)
jmp    12cb <execute_cgi+0x5b>
jmp    1430 <execute_cgi+0x1c0>
mov    -0x18(%rbp),%rdi
lea    0xcc2(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    142b <execute_cgi+0x1bb>
mov    -0x4(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1060 <get_line@plt>
mov    %eax,-0x448(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x448(%rbp)
mov    %al,-0x762(%rbp)
jle    13a0 <execute_cgi+0x130>
lea    -0x420(%rbp),%rsi
lea    0xc9b(%rip),%rdi
call   1100 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x762(%rbp)
mov    -0x762(%rbp),%al
test   $0x1,%al
jne    13b3 <execute_cgi+0x143>
jmp    140c <execute_cgi+0x19c>
movb   $0x0,-0x411(%rbp)
lea    -0x420(%rbp),%rdi
lea    0xc41(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    13ed <execute_cgi+0x17d>
lea    -0x420(%rbp),%rdi
add    $0x10,%rdi
call   1150 <atoi@plt>
mov    %eax,-0x44c(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1060 <get_line@plt>
mov    %eax,-0x448(%rbp)
jmp    136b <execute_cgi+0xfb>
cmpl   $0xffffffff,-0x44c(%rbp)
jne    1426 <execute_cgi+0x1b6>
mov    -0x4(%rbp),%edi
call   1110 <bad_request@plt>
jmp    1845 <execute_cgi+0x5d5>
jmp    142b <execute_cgi+0x1bb>
jmp    1430 <execute_cgi+0x1c0>
lea    -0x420(%rbp),%rdi
lea    0xbdb(%rip),%rsi
mov    $0x0,%al
call   1160 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x774(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x770(%rbp)
lea    -0x420(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x774(%rbp),%edi
mov    -0x770(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1090 <send@plt>
lea    -0x428(%rbp),%rdi
call   10d0 <pipe@plt>
cmp    $0x0,%rax
jge    14a1 <execute_cgi+0x231>
mov    -0x4(%rbp),%edi
call   1140 <cannot_execute@plt>
jmp    1845 <execute_cgi+0x5d5>
lea    -0x430(%rbp),%rdi
call   10d0 <pipe@plt>
cmp    $0x0,%rax
jge    14c4 <execute_cgi+0x254>
mov    -0x4(%rbp),%edi
call   1140 <cannot_execute@plt>
jmp    1845 <execute_cgi+0x5d5>
mov    $0x0,%al
call   1190 <fork@plt>
mov    %rax,-0x438(%rbp)
cmp    $0x0,%rax
jge    14e9 <execute_cgi+0x279>
mov    -0x4(%rbp),%edi
call   1140 <cannot_execute@plt>
jmp    1845 <execute_cgi+0x5d5>
cmpq   $0x0,-0x438(%rbp)
jne    1747 <execute_cgi+0x4d7>
mov    -0x10(%rbp),%rax
mov    %rax,-0x780(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x780(%rbp),%rax
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    1648 <execute_cgi+0x3d8>
mov    -0x10(%rbp),%rax
mov    %rax,-0x788(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x788(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x63,%eax
jne    1648 <execute_cgi+0x3d8>
mov    -0x44c(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x458(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x790(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x460(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xa69(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    15bb <execute_cgi+0x34b>
mov    -0x20(%rbp),%rsi
lea    0xa7a(%rip),%rdi
call   10a0 <printf@plt>
jmp    1609 <execute_cgi+0x399>
mov    -0x18(%rbp),%rdi
lea    0xa3e(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1604 <execute_cgi+0x394>
mov    -0x790(%rbp),%rdi
mov    -0x44c(%rbp),%edx
add    $0x1,%edx
xor    %esi,%esi
call   10b0 <memset@plt>
mov    -0x790(%rbp),%rsi
mov    -0x430(%rbp),%edi
mov    -0x44c(%rbp),%edx
call   10e0 <read@plt>
jmp    1609 <execute_cgi+0x399>
mov    -0x10(%rbp),%rdi
lea    0xa22(%rip),%rsi
call   1040 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1639 <execute_cgi+0x3c9>
mov    -0x790(%rbp),%rdi
mov    -0x44c(%rbp),%esi
call   1130 <processMotorControl@plt>
mov    -0x458(%rbp),%rax
mov    %rax,%rsp
jmp    1742 <execute_cgi+0x4d2>
mov    -0x424(%rbp),%edi
mov    $0x1,%esi
call   1080 <dup2@plt>
mov    -0x430(%rbp),%edi
xor    %esi,%esi
call   1080 <dup2@plt>
mov    -0x428(%rbp),%edi
call   10c0 <close@plt>
mov    -0x42c(%rbp),%edi
call   10c0 <close@plt>
lea    -0x560(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0x9c0(%rip),%rsi
mov    $0x0,%al
call   1160 <sprintf@plt>
lea    -0x560(%rbp),%rdi
call   10f0 <putenv@plt>
mov    -0x18(%rbp),%rdi
lea    0x955(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    16e4 <execute_cgi+0x474>
lea    -0x660(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0x993(%rip),%rsi
mov    $0x0,%al
call   1160 <sprintf@plt>
lea    -0x660(%rbp),%rdi
call   10f0 <putenv@plt>
jmp    172a <execute_cgi+0x4ba>
mov    -0x18(%rbp),%rdi
lea    0x915(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1725 <execute_cgi+0x4b5>
lea    -0x760(%rbp),%rdi
mov    -0x44c(%rbp),%edx
lea    0x95d(%rip),%rsi
mov    $0x0,%al
call   1160 <sprintf@plt>
lea    -0x760(%rbp),%rdi
call   10f0 <putenv@plt>
jmp    172a <execute_cgi+0x4ba>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1180 <execl@plt>
xor    %edi,%edi
call   1170 <exit@plt>
jmp    1845 <execute_cgi+0x5d5>
mov    -0x424(%rbp),%edi
call   10c0 <close@plt>
mov    -0x430(%rbp),%edi
call   10c0 <close@plt>
mov    -0x18(%rbp),%rdi
lea    0x89c(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    17d9 <execute_cgi+0x569>
movl   $0x0,-0x440(%rbp)
mov    -0x440(%rbp),%eax
cmp    -0x44c(%rbp),%eax
jge    17d4 <execute_cgi+0x564>
mov    -0x4(%rbp),%edi
lea    -0x441(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x42c(%rbp),%edi
lea    -0x441(%rbp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    -0x440(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x440(%rbp)
jmp    1781 <execute_cgi+0x511>
jmp    17d9 <execute_cgi+0x569>
jmp    17de <execute_cgi+0x56e>
mov    -0x428(%rbp),%edi
lea    -0x441(%rbp),%rsi
mov    $0x1,%edx
call   10e0 <read@plt>
cmp    $0x0,%rax
jle    181a <execute_cgi+0x5aa>
mov    -0x4(%rbp),%edi
lea    -0x441(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1090 <send@plt>
jmp    17de <execute_cgi+0x56e>
mov    -0x428(%rbp),%edi
call   10c0 <close@plt>
mov    -0x42c(%rbp),%edi
call   10c0 <close@plt>
mov    -0x438(%rbp),%rdi
lea    -0x43c(%rbp),%rsi
xor    %edx,%edx
call   1120 <waitpid@plt>
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_cgi>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x628,%rsp
mov    %rcx,-0x50(%rbp)
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %edi,%r13d
movw   $0x41,-0x550(%rbp)
lea    0xd5f(%rip),%rsi
mov    %rdx,%rdi
call   1040 <strcasecmp@plt>
test   %rax,%rax
mov    %rbx,-0x48(%rbp)
je     136c <execute_cgi+0xfc>
lea    0xd47(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcasecmp@plt>
mov    $0xffffffff,%r15d
test   %rax,%rax
jne    13ba <execute_cgi+0x14a>
lea    -0x550(%rbp),%rsi
mov    %r13d,%edi
mov    $0x400,%edx
call   1060 <get_line@plt>
test   %eax,%eax
jle    1521 <execute_cgi+0x2b1>
mov    %r12,-0x40(%rbp)
mov    $0xffffffff,%r15d
lea    0xd28(%rip),%r14
lea    -0x550(%rbp),%r12
lea    0xcfa(%rip),%rbx
jmp    1334 <execute_cgi+0xc4>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %r12,%rsi
mov    $0x400,%edx
call   1060 <get_line@plt>
test   %eax,%eax
jle    13ac <execute_cgi+0x13c>
mov    %r14,%rdi
mov    %r12,%rsi
call   1100 <strcmp@plt>
test   %rax,%rax
je     13ac <execute_cgi+0x13c>
movb   $0x0,-0x541(%rbp)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <strcasecmp@plt>
test   %rax,%rax
jne    1320 <execute_cgi+0xb0>
lea    -0x540(%rbp),%rdi
call   1150 <atoi@plt>
mov    %eax,%r15d
jmp    1320 <execute_cgi+0xb0>
lea    0xcb6(%rip),%r14
lea    -0x550(%rbp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1100 <strcmp@plt>
mov    $0xffffffff,%r15d
test   %rax,%rax
je     13ba <execute_cgi+0x14a>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1060 <get_line@plt>
test   %eax,%eax
jg     1380 <execute_cgi+0x110>
jmp    13ba <execute_cgi+0x14a>
cmp    $0xffffffff,%r15d
mov    -0x40(%rbp),%r12
je     1521 <execute_cgi+0x2b1>
movups 0xc58(%rip),%xmm0
movaps %xmm0,-0x550(%rbp)
movw   $0xa,-0x540(%rbp)
lea    -0x550(%rbp),%rbx
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1090 <send@plt>
lea    -0x38(%rbp),%rdi
call   10d0 <pipe@plt>
test   %rax,%rax
js     150a <execute_cgi+0x29a>
lea    -0x30(%rbp),%rdi
call   10d0 <pipe@plt>
test   %rax,%rax
js     150a <execute_cgi+0x29a>
mov    %r12,-0x40(%rbp)
xor    %eax,%eax
call   1190 <fork@plt>
test   %rax,%rax
js     150a <execute_cgi+0x29a>
je     152b <execute_cgi+0x2bb>
mov    %rax,%r12
mov    -0x34(%rbp),%edi
call   10c0 <close@plt>
mov    -0x30(%rbp),%edi
call   10c0 <close@plt>
lea    0xbbd(%rip),%rsi
mov    -0x48(%rbp),%rdi
call   1040 <strcasecmp@plt>
test   %rax,%rax
jne    1498 <execute_cgi+0x228>
test   %r15d,%r15d
jle    1498 <execute_cgi+0x228>
lea    -0x150(%rbp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x2c(%rbp),%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1050 <write@plt>
add    $0xffffffff,%r15d
jne    1470 <execute_cgi+0x200>
mov    -0x38(%rbp),%edi
lea    -0x150(%rbp),%rsi
mov    $0x1,%edx
call   10e0 <read@plt>
test   %rax,%rax
jle    14e7 <execute_cgi+0x277>
lea    -0x150(%rbp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1090 <send@plt>
mov    -0x38(%rbp),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   10e0 <read@plt>
test   %rax,%rax
jg     14c0 <execute_cgi+0x250>
mov    -0x38(%rbp),%edi
call   10c0 <close@plt>
mov    -0x2c(%rbp),%edi
call   10c0 <close@plt>
lea    -0x650(%rbp),%rsi
mov    %r12,%rdi
xor    %edx,%edx
call   1120 <waitpid@plt>
jmp    1512 <execute_cgi+0x2a2>
mov    %r13d,%edi
call   1140 <cannot_execute@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r13d,%edi
call   1110 <bad_request@plt>
jmp    1512 <execute_cgi+0x2a2>
mov    -0x40(%rbp),%rbx
mov    %rbx,%rdi
call   1070 <strlen@plt>
cltq
cmpb   $0x2e,-0x2(%rax,%rbx,1)
jne    15f2 <execute_cgi+0x382>
mov    %rbx,%rdi
call   1070 <strlen@plt>
cltq
cmpb   $0x63,-0x1(%rax,%rbx,1)
jne    15f2 <execute_cgi+0x382>
mov    %rsp,%r13
lea    0x1(%r15),%r14d
mov    %rsp,%r12
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
lea    0xa88(%rip),%rsi
mov    -0x48(%rbp),%rbx
mov    %rbx,%rdi
call   1040 <strcasecmp@plt>
test   %rax,%rax
je     15ba <execute_cgi+0x34a>
lea    0xa74(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcasecmp@plt>
test   %rax,%rax
jne    15ca <execute_cgi+0x35a>
mov    %r12,%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   10b0 <memset@plt>
mov    -0x30(%rbp),%edi
mov    %r12,%rsi
mov    %r15d,%edx
call   10e0 <read@plt>
jmp    15ca <execute_cgi+0x35a>
lea    0xa6a(%rip),%rdi
mov    -0x50(%rbp),%rsi
call   10a0 <printf@plt>
lea    0xa65(%rip),%rsi
mov    -0x40(%rbp),%rdi
call   1040 <strcasecmp@plt>
test   %rax,%rax
jne    15ea <execute_cgi+0x37a>
mov    %r12,%rdi
mov    %r15d,%esi
call   1130 <processMotorControl@plt>
mov    %r13,%rsp
jmp    1512 <execute_cgi+0x2a2>
mov    -0x34(%rbp),%edi
mov    $0x1,%esi
call   1080 <dup2@plt>
mov    -0x30(%rbp),%edi
xor    %esi,%esi
call   1080 <dup2@plt>
mov    -0x38(%rbp),%edi
call   10c0 <close@plt>
mov    -0x2c(%rbp),%edi
call   10c0 <close@plt>
lea    0xa2d(%rip),%rsi
lea    -0x650(%rbp),%r14
mov    %r14,%rdi
mov    -0x48(%rbp),%rbx
mov    %rbx,%rdx
xor    %eax,%eax
call   1160 <sprintf@plt>
mov    %r14,%rdi
call   10f0 <putenv@plt>
lea    0x9b9(%rip),%rsi
mov    %rbx,%r14
mov    %rbx,%rdi
call   1040 <strcasecmp@plt>
test   %rax,%rax
jne    1675 <execute_cgi+0x405>
lea    -0x150(%rbp),%r14
lea    0x9fa(%rip),%rsi
mov    %r14,%rdi
mov    -0x50(%rbp),%rdx
xor    %eax,%eax
call   1160 <sprintf@plt>
jmp    16a4 <execute_cgi+0x434>
lea    0x988(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcasecmp@plt>
test   %rax,%rax
jne    16ac <execute_cgi+0x43c>
lea    -0x150(%rbp),%r14
lea    0x9d8(%rip),%rsi
mov    %r14,%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1160 <sprintf@plt>
mov    %r14,%rdi
call   10f0 <putenv@plt>
mov    -0x40(%rbp),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1180 <execl@plt>
xor    %edi,%edi
call   1170 <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(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [1024 x i8]
%10 = alloca [2 x i32]
%11 = alloca [2 x i32]
%12 = alloca i64
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i64
%20 = alloca [255 x i8]
%21 = alloca [255 x i8]
%22 = alloca [255 x i8]
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i32 1, i32* %16
store i32 -1, i32* %17
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
store i8 65, i8* %23
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 1
store i8 0, i8* %24
%25 = load i8*, i8** %7
%26 = call i64 @strcasecmp(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %43
28: ; preds = %4
br label %29
29: ; preds = %38, %28
%30 = load i32, i32* %16
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%34 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = icmp ne i64 %34, 0
br label %36
36: ; preds = %32, %29
%37 = phi i1 [ false, %29 ], [ %35, %32 ]
br i1 %37, label %38, label %42
38: ; preds = %36
%39 = load i32, i32* %5
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%41 = call i32 @get_line(i32 %39, i8* %40, i32 1024)
store i32 %41, i32* %16
br label %29
42: ; preds = %36
br label %80
43: ; preds = %4
%44 = load i8*, i8** %7
%45 = call i64 @strcasecmp(i8* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %79
47: ; preds = %43
%48 = load i32, i32* %5
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%50 = call i32 @get_line(i32 %48, i8* %49, i32 1024)
store i32 %50, i32* %16
br label %51
51: ; preds = %68, %47
%52 = load i32, i32* %16
%53 = icmp sgt i32 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%56 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %55)
%57 = icmp ne i64 %56, 0
br label %58
58: ; preds = %54, %51
%59 = phi i1 [ false, %51 ], [ %57, %54 ]
br i1 %59, label %60, label %72
60: ; preds = %58
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 15
store i8 0, i8* %61
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%63 = call i64 @strcasecmp(i8* %62, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %60
%66 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 16
%67 = call i32 @atoi(i8* %66)
store i32 %67, i32* %17
br label %68
68: ; preds = %65, %60
%69 = load i32, i32* %5
%70 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%71 = call i32 @get_line(i32 %69, i8* %70, i32 1024)
store i32 %71, i32* %16
br label %51
72: ; preds = %58
%73 = load i32, i32* %17
%74 = icmp eq i32 %73, -1
br i1 %74, label %75, label %78
75: ; preds = %72
%76 = load i32, i32* %5
%77 = call i32 @bad_request(i32 %76)
br label %251
78: ; preds = %72
br label %79
79: ; preds = %78, %43
br label %80
80: ; preds = %79, %42
%81 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%82 = call i32 (i8*, i8*, ...) @sprintf(i8* %81, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%83 = load i32, i32* %5
%84 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%85 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%86 = call i32 @strlen(i8* %85)
%87 = call i32 @send(i32 %83, i8* %84, i32 %86, i32 0)
%88 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%89 = call i64 @pipe(i32* %88)
%90 = icmp slt i64 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %80
%92 = load i32, i32* %5
%93 = call i32 @cannot_execute(i32 %92)
br label %251
94: ; preds = %80
%95 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%96 = call i64 @pipe(i32* %95)
%97 = icmp slt i64 %96, 0
br i1 %97, label %98, label %101
98: ; preds = %94
%99 = load i32, i32* %5
%100 = call i32 @cannot_execute(i32 %99)
br label %251
101: ; preds = %94
%102 = call i64 (...) @fork()
store i64 %102, i64* %12
%103 = icmp slt i64 %102, 0
br i1 %103, label %104, label %107
104: ; preds = %101
%105 = load i32, i32* %5
%106 = call i32 @cannot_execute(i32 %105)
br label %251
107: ; preds = %101
%108 = load i64, i64* %12
%109 = icmp eq i64 %108, 0
br i1 %109, label %110, label %208
110: ; preds = %107
%111 = load i8*, i8** %6
%112 = load i8*, i8** %6
%113 = call i32 @strlen(i8* %112)
%114 = sub nsw i32 %113, 2
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8, i8* %111, i64 %115
%117 = load i8, i8* %116
%118 = sext i8 %117 to i32
%119 = icmp eq i32 %118, 46
br i1 %119, label %120, label %164
120: ; preds = %110
%121 = load i8*, i8** %6
%122 = load i8*, i8** %6
%123 = call i32 @strlen(i8* %122)
%124 = sub nsw i32 %123, 1
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds i8, i8* %121, i64 %125
%127 = load i8, i8* %126
%128 = sext i8 %127 to i32
%129 = icmp eq i32 %128, 99
br i1 %129, label %130, label %164
130: ; preds = %120
%131 = load i32, i32* %17
%132 = add nsw i32 %131, 1
%133 = zext i32 %132 to i64
%134 = call i8* @llvm.stacksave()
store i8* %134, i8** %18
%135 = alloca i8, i64 %133
store i64 %133, i64* %19
%136 = load i8*, i8** %7
%137 = call i64 @strcasecmp(i8* %136, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%138 = icmp eq i64 %137, 0
br i1 %138, label %139, label %142
139: ; preds = %130
%140 = load i8*, i8** %8
%141 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %140)
br label %155
142: ; preds = %130
%143 = load i8*, i8** %7
%144 = call i64 @strcasecmp(i8* %143, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%145 = icmp eq i64 %144, 0
br i1 %145, label %146, label %154
146: ; preds = %142
%147 = load i32, i32* %17
%148 = add nsw i32 %147, 1
%149 = call i32 @memset(i8* %135, i32 0, i32 %148)
%150 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%151 = load i32, i32* %150
%152 = load i32, i32* %17
%153 = call i64 @read(i32 %151, i8* %135, i32 %152)
br label %154
154: ; preds = %146, %142
br label %155
155: ; preds = %154, %139
%156 = load i8*, i8** %6
%157 = call i64 @strcasecmp(i8* %156, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%158 = icmp eq i64 0, %157
br i1 %158, label %159, label %162
159: ; preds = %155
%160 = load i32, i32* %17
%161 = call i32 @processMotorControl(i8* %135, i32 %160)
br label %162
162: ; preds = %159, %155
%163 = load i8*, i8** %18
br label %207
164: ; preds = %120, %110
%165 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 1
%166 = load i32, i32* %165
%167 = call i32 @dup2(i32 %166, i32 1)
%168 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%169 = load i32, i32* %168
%170 = call i32 @dup2(i32 %169, i32 0)
%171 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%172 = load i32, i32* %171
%173 = call i32 @close(i32 %172)
%174 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%175 = load i32, i32* %174
%176 = call i32 @close(i32 %175)
%177 = getelementptr inbounds [255 x i8], [255 x i8]* %20, i64 0, i64 0
%178 = load i8*, i8** %7
%179 = call i32 (i8*, i8*, ...) @sprintf(i8* %177, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %178)
%180 = getelementptr inbounds [255 x i8], [255 x i8]* %20, i64 0, i64 0
%181 = call i32 @putenv(i8* %180)
%182 = load i8*, i8** %7
%183 = call i64 @strcasecmp(i8* %182, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%184 = icmp eq i64 %183, 0
br i1 %184, label %185, label %191
185: ; preds = %164
%186 = getelementptr inbounds [255 x i8], [255 x i8]* %21, i64 0, i64 0
%187 = load i8*, i8** %8
%188 = call i32 (i8*, i8*, ...) @sprintf(i8* %186, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %187)
%189 = getelementptr inbounds [255 x i8], [255 x i8]* %21, i64 0, i64 0
%190 = call i32 @putenv(i8* %189)
br label %202
191: ; preds = %164
%192 = load i8*, i8** %7
%193 = call i64 @strcasecmp(i8* %192, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%194 = icmp eq i64 %193, 0
br i1 %194, label %195, label %201
195: ; preds = %191
%196 = getelementptr inbounds [255 x i8], [255 x i8]* %22, i64 0, i64 0
%197 = load i32, i32* %17
%198 = call i32 (i8*, i8*, ...) @sprintf(i8* %196, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %197)
%199 = getelementptr inbounds [255 x i8], [255 x i8]* %22, i64 0, i64 0
%200 = call i32 @putenv(i8* %199)
br label %201
201: ; preds = %195, %191
br label %202
202: ; preds = %201, %185
%203 = load i8*, i8** %6
%204 = load i8*, i8** %6
%205 = call i32 @execl(i8* %203, i8* %204, i32* null)
%206 = call i32 @exit(i32 0)
unreachable
207: ; preds = %162
br label %251
208: ; preds = %107
%209 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 1
%210 = load i32, i32* %209
%211 = call i32 @close(i32 %210)
%212 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%213 = load i32, i32* %212
%214 = call i32 @close(i32 %213)
%215 = load i8*, i8** %7
%216 = call i64 @strcasecmp(i8* %215, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%217 = icmp eq i64 %216, 0
br i1 %217, label %218, label %233
218: ; preds = %208
store i32 0, i32* %14
br label %219
219: ; preds = %229, %218
%220 = load i32, i32* %14
%221 = load i32, i32* %17
%222 = icmp slt i32 %220, %221
br i1 %222, label %223, label %232
223: ; preds = %219
%224 = load i32, i32* %5
%225 = call i32 @recv(i32 %224, i8* %15, i32 1, i32 0)
%226 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%227 = load i32, i32* %226
%228 = call i32 @write(i32 %227, i8* %15, i32 1)
br label %229
229: ; preds = %223
%230 = load i32, i32* %14
%231 = add nsw i32 %230, 1
store i32 %231, i32* %14
br label %219
232: ; preds = %219
br label %233
233: ; preds = %232, %208
br label %234
234: ; preds = %239, %233
%235 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%236 = load i32, i32* %235
%237 = call i64 @read(i32 %236, i8* %15, i32 1)
%238 = icmp sgt i64 %237, 0
br i1 %238, label %239, label %242
239: ; preds = %234
%240 = load i32, i32* %5
%241 = call i32 @send(i32 %240, i8* %15, i32 1, i32 0)
br label %234
242: ; preds = %234
%243 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%244 = load i32, i32* %243
%245 = call i32 @close(i32 %244)
%246 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%247 = load i32, i32* %246
%248 = call i32 @close(i32 %247)
%249 = load i64, i64* %12
%250 = call i32 @waitpid(i64 %249, i32* %13, i32 0)
br label %251
251: ; preds = %75, %91, %98, %104, %242, %207
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(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [1024 x i8]
%6 = alloca [2 x i32]
%7 = alloca [2 x i32]
%8 = alloca i32
%9 = alloca i8
%10 = alloca [255 x i8]
%11 = alloca [255 x i8]
%12 = alloca [255 x i8]
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%14 = bitcast [2 x i32]* %6 to i8*
%15 = bitcast [2 x i32]* %7 to i8*
%16 = bitcast i32* %8 to i8*
store i8 65, i8* %13
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 1
store i8 0, i8* %17
%18 = tail call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %4, %23
%21 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%22 = icmp eq i64 %21, 0
br i1 %22, label %53, label %23
23: ; preds = %20
%24 = call i32 @get_line(i32 %0, i8* %13, i32 1024)
%25 = icmp sgt i32 %24, 0
br i1 %25, label %20, label %53
26: ; preds = %4
%27 = tail call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %53
29: ; preds = %26
%30 = call i32 @get_line(i32 %0, i8* %13, i32 1024)
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %51
32: ; preds = %29
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 15
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 16
br label %35
35: ; preds = %32, %44
%36 = phi i32 [ -1, %32 ], [ %45, %44 ]
%37 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%38 = icmp eq i64 %37, 0
br i1 %38, label %48, label %39
39: ; preds = %35
store i8 0, i8* %33
%40 = call i64 @strcasecmp(i8* %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 @atoi(i8* %34)
br label %44
44: ; preds = %42, %39
%45 = phi i32 [ %43, %42 ], [ %36, %39 ]
%46 = call i32 @get_line(i32 %0, i8* %13, i32 1024)
%47 = icmp sgt i32 %46, 0
br i1 %47, label %35, label %48
48: ; preds = %35, %44
%49 = phi i32 [ %36, %35 ], [ %45, %44 ]
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %53
51: ; preds = %29, %48
%52 = call i32 @bad_request(i32 %0)
br label %177
53: ; preds = %20, %23, %26, %48
%54 = phi i32 [ %49, %48 ], [ -1, %26 ], [ -1, %23 ], [ -1, %20 ]
%55 = call i32 @strlen(i8* %13)
%56 = call i32 @send(i32 %0, i8* %13, i32 %55, i32 0)
%57 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%58 = call i64 @pipe(i32* %57)
%59 = icmp slt i64 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %53
%61 = call i32 @cannot_execute(i32 %0)
br label %177
62: ; preds = %53
%63 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%64 = call i64 @pipe(i32* %63)
%65 = icmp slt i64 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %62
%67 = call i32 @cannot_execute(i32 %0)
br label %177
68: ; preds = %62
%69 = call i64 (...) @fork()
%70 = icmp slt i64 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %68
%72 = call i32 @cannot_execute(i32 %0)
br label %177
73: ; preds = %68
%74 = icmp eq i64 %69, 0
br i1 %74, label %75, label %142
75: ; preds = %73
%76 = call i32 @strlen(i8* %1)
%77 = add nsw i32 %76, -2
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %1, i64 %78
%80 = load i8, i8* %79
%81 = icmp eq i8 %80, 46
br i1 %81, label %82, label %111
82: ; preds = %75
%83 = call i32 @strlen(i8* %1)
%84 = add nsw i32 %83, -1
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %1, i64 %85
%87 = load i8, i8* %86
%88 = icmp eq i8 %87, 99
br i1 %88, label %89, label %111
89: ; preds = %82
%90 = add nsw i32 %54, 1
%91 = zext i32 %90 to i64
%92 = call i8* @llvm.stacksave()
%93 = alloca i8, i64 %91
%94 = call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %98
96: ; preds = %89
%97 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %3)
br label %105
98: ; preds = %89
%99 = call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%100 = icmp eq i64 %99, 0
br i1 %100, label %101, label %105
101: ; preds = %98
%102 = call i32 @memset(i8* %93, i32 0, i32 %90)
%103 = load i32, i32* %63
%104 = call i64 @read(i32 %103, i8* %93, i32 %54)
br label %105
105: ; preds = %98, %101, %96
%106 = call i64 @strcasecmp(i8* %1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%107 = icmp eq i64 %106, 0
br i1 %107, label %108, label %110
108: ; preds = %105
%109 = call i32 @processMotorControl(i8* %93, i32 %54)
br label %110
110: ; preds = %108, %105
br label %177
111: ; preds = %82, %75
%112 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%113 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%114 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%115 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%116 = load i32, i32* %115
%117 = call i32 @dup2(i32 %116, i32 1)
%118 = load i32, i32* %63
%119 = call i32 @dup2(i32 %118, i32 0)
%120 = load i32, i32* %57
%121 = call i32 @close(i32 %120)
%122 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%123 = load i32, i32* %122
%124 = call i32 @close(i32 %123)
%125 = call i32 (i8*, i8*, ...) @sprintf(i8* %112, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %2)
%126 = call i32 @putenv(i8* %112)
%127 = call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%128 = icmp eq i64 %127, 0
br i1 %128, label %129, label %131
129: ; preds = %111
%130 = call i32 (i8*, i8*, ...) @sprintf(i8* %113, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %3)
br label %136
131: ; preds = %111
%132 = call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%133 = icmp eq i64 %132, 0
br i1 %133, label %134, label %139
134: ; preds = %131
%135 = call i32 (i8*, i8*, ...) @sprintf(i8* %114, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %54)
br label %136
136: ; preds = %129, %134
%137 = phi i8* [ %114, %134 ], [ %113, %129 ]
%138 = call i32 @putenv(i8* %137)
br label %139
139: ; preds = %136, %131
%140 = call i32 @execl(i8* %1, i8* %1, i32* null)
%141 = call i32 @exit(i32 0)
unreachable
142: ; preds = %73
%143 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%144 = load i32, i32* %143
%145 = call i32 @close(i32 %144)
%146 = load i32, i32* %63
%147 = call i32 @close(i32 %146)
%148 = call i64 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%149 = icmp eq i64 %148, 0
%150 = icmp sgt i32 %54, 0
%151 = select i1 %149, i1 %150, i1 false
br i1 %151, label %152, label %161
152: ; preds = %142
%153 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
br label %154
154: ; preds = %152, %154
%155 = phi i32 [ 0, %152 ], [ %159, %154 ]
%156 = call i32 @recv(i32 %0, i8* %9, i32 1, i32 0)
%157 = load i32, i32* %153
%158 = call i32 @write(i32 %157, i8* %9, i32 1)
%159 = add nuw nsw i32 %155, 1
%160 = icmp eq i32 %159, %54
br i1 %160, label %161, label %154
161: ; preds = %154, %142
%162 = load i32, i32* %57
%163 = call i64 @read(i32 %162, i8* %9, i32 1)
%164 = icmp sgt i64 %163, 0
br i1 %164, label %165, label %170
165: ; preds = %161, %165
%166 = call i32 @send(i32 %0, i8* %9, i32 1, i32 0)
%167 = load i32, i32* %57
%168 = call i64 @read(i32 %167, i8* %9, i32 1)
%169 = icmp sgt i64 %168, 0
br i1 %169, label %165, label %170
170: ; preds = %165, %161
%171 = load i32, i32* %57
%172 = call i32 @close(i32 %171)
%173 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%174 = load i32, i32* %173
%175 = call i32 @close(i32 %174)
%176 = call i32 @waitpid(i64 %69, i32* %8, i32 0)
br label %177
177: ; preds = %110, %170, %71, %66, %60, %51
ret void
}