user: Translate the below assembly code into C programming language:

```asm
<serveGetRequest>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r12
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x60,%rsp
  mov    %edi,-0x1054(%rbp)
  mov    %rsi,-0x1060(%rbp)
  mov    %rdx,-0x1068(%rbp)
  mov    %ecx,-0x1058(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  mov    -0x1068(%rbp),%rax
  mov    %rax,%rdi
  call   <stripTrailingSlash@plt>
  mov    -0x1060(%rbp),%rdx
  lea    -0x1030(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0x1068(%rbp),%rdx
  lea    -0x1030(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  lea    -0x104c(%rbp),%rdx
  lea    -0x1030(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <stat@plt>
  test   %rax,%rax
  je     L36
  cmpl   $0x0,-0x1058(%rbp)
  je     L79
  lea    -0x1030(%rbp),%rax
  mov    %rax,%rsi
  lea    D54(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L79:
  mov    -0x1054(%rbp),%eax
  mov    $0x194,%esi
  mov    %eax,%edi
  call   <writeError@plt>
  jmp    L88
L36:
  mov    -0x104c(%rbp),%eax
  mov    %eax,%edi
  call   <S_ISREG@plt>
  test   %rax,%rax
  je     L159
  cmpl   $0x0,-0x1058(%rbp)
  je     L29
  lea    -0x1030(%rbp),%rax
  mov    %rax,%rsi
  lea    D59(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L29:
  mov    -0x104c(%rbp),%edx
  lea    -0x1030(%rbp),%rcx
  mov    -0x1054(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <writeFileResponse@plt>
  jmp    L88
L159:
  mov    -0x104c(%rbp),%eax
  mov    %eax,%edi
  call   <S_ISDIR@plt>
  test   %rax,%rax
  je     L88
  cmpl   $0x0,-0x1058(%rbp)
  je     L97
  lea    -0x1030(%rbp),%rax
  mov    %rax,%rsi
  lea    D21(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L97:
  movb   $0x0,-0x820(%rbp)
  lea    -0x1030(%rbp),%rdx
  lea    -0x820(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  lea    -0x820(%rbp),%rax
  lea    D2(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  lea    -0x104c(%rbp),%rdx
  lea    -0x820(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <stat@plt>
  test   %rax,%rax
  je     L145
  cmpl   $0x0,-0x1058(%rbp)
  je     L3
  lea    D102(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
L3:
  mov    $0x805,%edi
  call   <malloc@plt>
  mov    %rax,-0x1048(%rbp)
  mov    -0x1068(%rbp),%rdx
  mov    -0x1048(%rbp),%rax
  lea    D86(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    -0x1030(%rbp),%rax
  mov    %rax,%rdi
  call   <opendir@plt>
  mov    %rax,-0x1040(%rbp)
  jmp    L31
L127:
  mov    -0x1038(%rbp),%rax
  mov    (%rax),%rax
  lea    D114(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L157
  mov    -0x1068(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L31
  mov    -0x1068(%rbp),%rcx
  lea    -0x820(%rbp),%rax
  mov    $0x2f,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <substringTo@plt>
  mov    -0x1048(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    -0x1048(%rbp),%rdx
  lea    (%rax,%rdx,1),%rcx
  lea    -0x820(%rbp),%rax
  mov    %rax,%rdx
  lea    D45(%rip),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L31
L157:
  mov    -0x1038(%rbp),%rax
  mov    (%rax),%rax
  lea    D100(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L31
  mov    -0x1038(%rbp),%rax
  mov    (%rax),%r12
  mov    -0x1038(%rbp),%rax
  mov    (%rax),%rbx
  mov    -0x1048(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    -0x1048(%rbp),%rdx
  lea    (%rax,%rdx,1),%rdi
  mov    -0x1068(%rbp),%rax
  mov    %r12,%r8
  mov    %rbx,%rcx
  mov    %rax,%rdx
  lea    D52(%rip),%rax
  mov    %rax,%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
L31:
  mov    -0x1040(%rbp),%rax
  mov    %rax,%rdi
  call   <readdir@plt>
  mov    %rax,-0x1038(%rbp)
  cmpq   $0x0,-0x1038(%rbp)
  jne    L127
  mov    -0x1040(%rbp),%rax
  mov    %rax,%rdi
  call   <closedir@plt>
  mov    -0x1048(%rbp),%rax
  lea    D123(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  mov    -0x1048(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%ecx
  mov    -0x1048(%rbp),%rdx
  mov    -0x1054(%rbp),%eax
  mov    %ecx,%r8d
  lea    D42(%rip),%rcx
  mov    $0xc8,%esi
  mov    %eax,%edi
  call   <writeBasicResponse@plt>
  mov    -0x1048(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  jmp    L88
L145:
  cmpl   $0x0,-0x1058(%rbp)
  je     L110
  lea    D106(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
L110:
  mov    -0x104c(%rbp),%edx
  lea    -0x820(%rbp),%rcx
  mov    -0x1054(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <writeFileResponse@plt>
L88:
  nop
  mov    -0x18(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L75
  call   <__stack_chk_fail@plt>
L75:
  add    $0x1060,%rsp
  pop    %rbx
  pop    %r12
  pop    %rbp
  ret
```

tool_calls: name: parse_data
arguments: data_label: D54
type: string
name: parse_data
arguments: data_label: D59
type: string
name: parse_data
arguments: data_label: D21
type: string
name: parse_data
arguments: data_label: D2
type: string
name: parse_data
arguments: data_label: D102
type: string
name: parse_data
arguments: data_label: D86
type: string
name: parse_data
arguments: data_label: D114
type: string
name: parse_data
arguments: data_label: D45
type: string
name: parse_data
arguments: data_label: D100
type: string
name: parse_data
arguments: data_label: D52
type: string
name: parse_data
arguments: data_label: D123
type: string
name: parse_data
arguments: data_label: D42
type: string
name: parse_data
arguments: data_label: D106
type: string

tool: D54:  - Unable to stat %s


tool: D59:  - %s is a regular file.


tool: D21:  - %s is a directory.


tool: D2: /index.html

tool: D102:  - Generating directory listing.

tool: D86: <!DOCTYPE html>
<html lang="en">
<head><title>Directory Listing</title></head>
<body>
<h1>Index of %s</h1>
<p><ul>


tool: D114: ..

tool: D45: <li><a href="%s">Parent Directory</a></li>


tool: D100: .

tool: D52: <li><a href="%s/%s/">%s</a></li>


tool: D123: </ul></p></body>
</html>

tool: D42: text/html

tool: D106:  - Found index.html file in directory.

assistant: ```c
void serveGetRequest(int hSocket, const char *webDirectory, char *resource, int verbose) {
  char directory[(1024 * 2) + 2 + 1];
  char dirFile[(1024 * 2) + 2 + 1];
  struct stat filestat;
  DIR *dirp;
  struct dirent *dp;
  stripTrailingSlash(resource);
  strcpy(directory, webDirectory);
  strcat(directory, resource);
  if (stat(directory, &filestat)) {
    if (verbose) {
      printf(" - Unable to stat %s\n", directory);
    }
    writeError(hSocket, 404);
  } else if (S_ISREG(filestat.st_mode)) {
    if (verbose) {
      printf(" - %s is a regular file.\n", directory);
    }
    writeFileResponse(hSocket, directory, filestat);
  } else if (S_ISDIR(filestat.st_mode)) {
    if (verbose) {
      printf(" - %s is a directory.\n", directory);
    }
    dirFile[0] = 0;
    strcat(dirFile, directory);
    strcat(dirFile, "/index.html");
    if (stat(dirFile, &filestat)) {
      if (verbose) {
        printf(" - Generating directory listing.\n");
      }
      char *directoryList = malloc(((1024 * 2) + 2 * 2 + 1) * sizeof(char));
      sprintf(directoryList, "<!DOCTYPE html>\n<html lang=\"en\">\n<head><title>Directory Listing</title></head>\n<body>\n<h1>Index of %s</h1>\n<p><ul>\n", resource);
      dirp = opendir(directory);
      while ((dp = readdir(dirp)) != NULL) {
        if (strcmp(dp->d_name, "..") == 0) {
          if (resource[0] != 0) {
            substringTo(dirFile, resource, '/');
            sprintf(&directoryList[strlen(directoryList)], "<li><a href=\"%s\">Parent Directory</a></li>\n", dirFile);
          }
        } else if (strcmp(dp->d_name, ".") != 0) {
          sprintf(&directoryList[strlen(directoryList)], "<li><a href=\"%s/%s/\">%s</a></li>\n", resource, dp->d_name, dp->d_name);
        }
      }
      closedir(dirp);
      strcat(directoryList, "</ul></p></body>\n</html>");
      writeBasicResponse(hSocket, 200, directoryList, "text/html", (int)strlen(directoryList));
      free(directoryList);
    } else {
      if (verbose) {
        printf(" - Found index.html file in directory.\n");
      }
      writeFileResponse(hSocket, dirFile, filestat);
    }
  }
}
```