user: Please show me the C implementation that matches the assembly code listed below:

```asm
<execute_cgi>:
  endbr64
  push   %r15
  push   %r14
  lea    D87(%rip),%r14
  push   %r13
  mov    %rdx,%r13
  push   %r12
  mov    %edi,%r12d
  mov    %rdx,%rdi
  push   %rbp
  push   %rbx
  lea    D11(%rip),%rbx
  sub    $0x758,%rsp
  mov    %rsi,0x8(%rsp)
  lea    D57(%rip),%rsi
  lea    0x340(%rsp),%rbp
  mov    %rcx,0x10(%rsp)
  mov    $0x41,%ecx
  mov    %fs:0x28,%rax
  mov    %rax,0x748(%rsp)
  xor    %eax,%eax
  mov    %cx,0x340(%rsp)
  call   <strcasecmp@plt>
  test   %rax,%rax
  jne    L163
  nopl   0x0(%rax,%rax,1)
L214:
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L203
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %rbp,%rsi
  mov    %r12d,%edi
  mov    %eax,%edx
  call   <get_line@plt>
  mov    %rbp,%rsi
  mov    %r14,%rdi
  mov    %eax,%r15d
  xor    %eax,%eax
  call   <printf@plt>
  test   %r15d,%r15d
  jg     L214
L203:
  movl   $0xffffffff,0x18(%rsp)
L22:
  movdqa D16(%rip),%xmm0
  mov    $0xa,%edx
  mov    %rbp,%rdi
  mov    %dx,0x350(%rsp)
  movaps %xmm0,0x340(%rsp)
  call   <strlen@plt>
  xor    %ecx,%ecx
  mov    %r12d,%edi
  mov    %rbp,%rsi
  mov    %eax,%edx
  call   <send@plt>
  lea    0x30(%rsp),%rdi
  call   <pipe@plt>
  test   %rax,%rax
  js     L115
  lea    0x38(%rsp),%rdi
  call   <pipe@plt>
  test   %rax,%rax
  js     L115
  xor    %eax,%eax
  call   <fork@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  js     L115
  jne    L62
  mov    0x34(%rsp),%edi
  mov    $0x1,%esi
  lea    0x40(%rsp),%rbp
  call   <dup2@plt>
  mov    0x38(%rsp),%edi
  xor    %esi,%esi
  call   <dup2@plt>
  mov    0x30(%rsp),%edi
  call   <close@plt>
  mov    0x3c(%rsp),%edi
  call   <close@plt>
  mov    %r13,%rdx
  mov    %rbp,%rdi
  xor    %eax,%eax
  lea    D129(%rip),%rsi
  call   <sprintf@plt>
  mov    %rbp,%rdi
  call   <putenv@plt>
  lea    D57(%rip),%rsi
  mov    %r13,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  je     L234
  mov    0x18(%rsp),%edx
  lea    0x240(%rsp),%rdi
  lea    D121(%rip),%rsi
  xor    %eax,%eax
  call   <sprintf@plt>
L197:
  mov    0x8(%rsp),%rsi
  xor    %edx,%edx
  mov    %rsi,%rdi
  call   <execl@plt>
  test   %rax,%rax
  js     L98
L124:
  lea    D127(%rip),%rdi
  call   <puts@plt>
  xor    %edi,%edi
  call   <exit@plt>
  jmp    L231
  nopl   0x0(%rax,%rax,1)
L115:
  mov    %r12d,%edi
  call   <cannot_execute@plt>
L231:
  mov    0x748(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L159
  add    $0x758,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L163:
  mov    %rbp,%rdi
  lea    D8(%rip),%r15
  lea    D21(%rip),%r14
  call   <strlen@plt>
  mov    %rbp,%rsi
  mov    %r12d,%edi
  mov    %eax,%edx
  call   <get_line@plt>
  mov    %rbp,%rsi
  lea    D142(%rip),%rdi
  mov    %eax,0x1c(%rsp)
  xor    %eax,%eax
  call   <printf@plt>
  mov    0x1c(%rsp),%edx
  lea    0x350(%rsp),%rax
  movl   $0xffffffff,0x18(%rsp)
  mov    %rax,(%rsp)
  test   %edx,%edx
  jg     L186
  jmp    L121
  nopl   0x0(%rax)
L142:
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %rbp,%rsi
  mov    %r12d,%edi
  mov    %eax,%edx
  call   <get_line@plt>
  test   %eax,%eax
  jle    L110
L186:
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L110
  mov    %rbp,%rsi
  mov    %r15,%rdi
  xor    %eax,%eax
  movb   $0x0,0x34f(%rsp)
  call   <printf@plt>
  mov    %r14,%rsi
  mov    %rbp,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  jne    L142
  mov    (%rsp),%rdi
  call   <atoi@plt>
  mov    %eax,0x18(%rsp)
  jmp    L142
  nopl   (%rax)
L110:
  lea    D62(%rip),%rdi
  call   <puts@plt>
  cmpl   $0xffffffff,0x18(%rsp)
  jne    L22
L168:
  mov    %r12d,%edi
  call   <bad_request@plt>
  jmp    L231
  nopl   0x0(%rax)
L62:
  lea    D67(%rip),%rsi
  mov    %r13,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  je     L200
L59:
  lea    0x2b(%rsp),%rbx
  jmp    L282
  nopl   0x0(%rax,%rax,1)
L194:
  xor    %ecx,%ecx
  mov    $0x1,%edx
  mov    %rbx,%rsi
  mov    %r12d,%edi
  call   <send@plt>
L282:
  mov    0x30(%rsp),%edi
  mov    $0x1,%edx
  mov    %rbx,%rsi
  call   <read@plt>
  test   %rax,%rax
  jg     L194
  mov    0x30(%rsp),%edi
  call   <close@plt>
  mov    0x3c(%rsp),%edi
  call   <close@plt>
  lea    0x2c(%rsp),%rsi
  xor    %edx,%edx
  mov    %rbp,%rdi
  call   <waitpid@plt>
  jmp    L231
  xchg   %ax,%ax
L200:
  mov    0x18(%rsp),%eax
  xor    %r13d,%r13d
  lea    0x2b(%rsp),%rbx
  test   %eax,%eax
  jle    L59
L180:
  xor    %ecx,%ecx
  mov    $0x1,%edx
  mov    %rbx,%rsi
  mov    %r12d,%edi
  call   <recv@plt>
  mov    0x3c(%rsp),%edi
  mov    %rbx,%rsi
  add    $0x1,%r13d
  mov    $0x1,%edx
  call   <write@plt>
  cmp    %r13d,0x18(%rsp)
  jne    L180
  jmp    L282
L234:
  lea    0x140(%rsp),%rbp
  mov    0x10(%rsp),%rdx
  lea    D5(%rip),%rsi
  mov    %rbp,%rdi
  call   <snprintf@plt>
  mov    %rbp,%rdi
  call   <putenv@plt>
  jmp    L197
L98:
  lea    D52(%rip),%rdi
  call   <puts@plt>
  jmp    L124
L121:
  lea    D62(%rip),%rdi
  call   <puts@plt>
  jmp    L168
L159:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_label: D87
type_infered: string
name: read_data
arguments: data_label: D11
type_infered: string
name: read_data
arguments: data_label: D57
type_infered: string
name: read_data
arguments: data_label: D16
type_infered: byte[16]
name: read_data
arguments: data_label: D129
type_infered: string
name: read_data
arguments: data_label: D121
type_infered: string
name: read_data
arguments: data_label: D127
type_infered: string
name: read_data
arguments: data_label: D8
type_infered: string
name: read_data
arguments: data_label: D21
type_infered: string
name: read_data
arguments: data_label: D142
type_infered: string
name: read_data
arguments: data_label: D62
type_infered: string
name: read_data
arguments: data_label: D67
type_infered: string
name: read_data
arguments: data_label: D5
type_infered: string
name: read_data
arguments: data_label: D52
type_infered: string

tool: D87: header: %s 


tool: D11: 


tool: D57: GET

tool: {"D16": [0x48,0x54,0x54,0x50,0x2f,0x31,0x2e,0x30,0x20,0x32,0x30,0x30,0x20,0x4f,0x4b,0x0d]}

tool: D129: REQUEST_METHOD=%s

tool: D121: CONTENT_LENGTH=%d

tool: D127: <p>come on cgi</p>

tool: D8: buf:%s 


tool: D21: Content-Length:

tool: D142: buf: %s


tool: D62: before bad_request 

tool: D67: POST

tool: D5: QUERY_STRING=%s

tool: D52: execl error

assistant: ```c
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, strlen(buf));
      printf("header: %s \n", buf);
    }
  else {
    numchars = get_line(client, buf, strlen(buf));
    printf("buf: %s\n", buf);
    while ((numchars > 0) && strcmp("\n", buf)) {
      buf[15] = '\0';
      printf("buf:%s \n", buf);
      if (strcasecmp(buf, "Content-Length:") == 0) {
        content_length = atoi(&buf[16]);
      }
      numchars = get_line(client, buf, strlen(buf));
    }
    printf("before bad_request \n");
    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) {
    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) {
      snprintf(query_env, "QUERY_STRING=%s", query_string);
      putenv(query_env);
    } else {
      sprintf(length_env, "CONTENT_LENGTH=%d", content_length);
    }
    if (execl(path, path, NULL) < 0) {
      printf("execl error\n");
    }
    printf("<p>come on cgi</p>\n");
    exit(0);
  } else {
    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);
  }
}
```