user: Converte this assembly snippet into its equivalent C code:

```asm
<SendDirectory>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0xa8,%rsp
  mov    %edi,0xc(%rsp)
  mov    %rsi,%rdi
  mov    %rdx,%rbp
  lea    0x890(%rsp),%r14
  mov    %fs:0x28,%rax
  mov    %rax,0x3098(%rsp)
  xor    %eax,%eax
  call   <opendir@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L72
L56:
  lea    0x490(%rsp),%r13
  mov    $0x400,%edx
  xor    %esi,%esi
  mov    %r13,%rdi
  lea    D2(%rip),%r12
  call   <memset@plt>
  mov    $0x1,%edx
  mov    %r13,%rcx
  mov    %rbp,%rdi
  mov    $0xffffffff,%esi
  call   <substr@plt>
  mov    %r12,%rsi
  mov    %r13,%rdi
  call   <strcmp@plt>
  mov    $0x400,%edx
  xor    %esi,%esi
  mov    %r13,%rdi
  test   %rax,%rax
  jne    L79
  call   <memset@plt>
  mov    %rbp,%rsi
  mov    %r13,%rdi
  call   <strcpy@plt>
L77:
  lea    0x90(%rsp),%r12
  mov    %rbp,%r8
  mov    %rbp,%rdx
  xor    %eax,%eax
  lea    D93(%rip),%rcx
  lea    D92(%rip),%rsi
  mov    %r12,%rdi
  call   <sprintf@plt>
  mov    %r12,%rsi
  mov    %r14,%rdi
  lea    D53(%rip),%rbp
  call   <strcat@plt>
  jmp    L21
  nopw   0x0(%rax,%rax,1)
L5:
  mov    (%r15),%rdi
  mov    %rbp,%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L15
L21:
  mov    %rbx,%rdi
  call   <readdir@plt>
  mov    %rax,%r15
  test   %rax,%rax
  jne    L5
  mov    %r12,%rdi
  mov    $0x400,%edx
  xor    %esi,%esi
  call   <memset@plt>
  lea    D93(%rip),%rdx
  mov    %r12,%rdi
  xor    %eax,%eax
  lea    D79(%rip),%rsi
  call   <sprintf@plt>
  mov    %r12,%rsi
  mov    %r14,%rdi
  call   <strcat@plt>
  mov    %r14,%rdi
  call   <strlen@plt>
  sub    $0x8,%rsp
  lea    D71(%rip),%r8
  lea    D80(%rip),%rcx
  push   $0x0
  mov    0x1c(%rsp),%ebx
  mov    %rax,%r12
  mov    %rax,%r9
  lea    D13(%rip),%rdx
  mov    $0xc8,%esi
  mov    %ebx,%edi
  call   <SendHeaders@plt>
  mov    %r12,%rdx
  mov    %r14,%rsi
  mov    %ebx,%edi
  call   <write@plt>
  pop    %rax
  pop    %rdx
  mov    0x3098(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L32
  add    $0x30a8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L15:
  xor    %esi,%esi
  mov    %r12,%rdi
  mov    $0x400,%edx
  call   <memset@plt>
  mov    (%r15),%rcx
  mov    %r12,%rdi
  mov    %r13,%rdx
  lea    D111(%rip),%rsi
  xor    %eax,%eax
  mov    %rcx,%r8
  call   <sprintf@plt>
  mov    %r12,%rsi
  mov    %r14,%rdi
  call   <strcat@plt>
  jmp    L21
  nopl   0x0(%rax)
L79:
  call   <memset@plt>
  mov    %rbp,%rsi
  mov    %r13,%rdi
  call   <strcpy@plt>
  mov    %r12,%rsi
  mov    %r13,%rdi
  call   <strcat@plt>
  jmp    L77
L72:
  xor    %esi,%esi
  mov    %r14,%rdi
  lea    0x10(%rsp),%r12
  mov    $0x80,%edx
  call   <memset@plt>
  mov    %rbp,%rdx
  mov    %r12,%rdi
  xor    %eax,%eax
  lea    D108(%rip),%rsi
  call   <sprintf@plt>
  mov    0xc(%rsp),%edi
  mov    %r12,%r8
  lea    D80(%rip),%rcx
  lea    D4(%rip),%rdx
  mov    $0x1f4,%esi
  call   <SendError@plt>
  jmp    L56
L32:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D2
type_infered: string
name: retrieve_data
arguments: tag: D93
type_infered: string
name: retrieve_data
arguments: tag: D92
type_infered: string
name: retrieve_data
arguments: tag: D53
type_infered: string
name: retrieve_data
arguments: tag: D79
type_infered: string
name: retrieve_data
arguments: tag: D71
type_infered: string
name: retrieve_data
arguments: tag: D80
type_infered: string
name: retrieve_data
arguments: tag: D13
type_infered: string
name: retrieve_data
arguments: tag: D111
type_infered: string
name: retrieve_data
arguments: tag: D108
type_infered: string
name: retrieve_data
arguments: tag: D4
type_infered: string

tool: D2: /

tool: D93: tmhttpd/1.0.0_alpha

tool: D92: <html>
<head>
<title>Browse directory %s - %s</title>
</head>
<body><h3>Directory %s</h3>
<hr />
<ul>


tool: D53: .

tool: D79: 
</ul>
<br /><hr />
<address>%s</address>
</body>
</html>


tool: D71: text/html

tool: 

tool: D13: OK

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


tool: D108: Something unexpected went wrong browse directory %s.

tool: D4: Internal Server Error

assistant: ```c
int SendDirectory(int client_sock, char *path, char *pathinfo) {
  size_t file_size;
  char msg[128], buf[10240], tmp[1024], tmp_path[1024];
  DIR *dp;
  struct dirent *node;
  if ((dp = opendir(path)) == NULL) {
    memset(buf, 0, sizeof(msg));
    sprintf(msg, "Something unexpected went wrong browse directory %s.", pathinfo);
    SendError(client_sock, 500, "Internal Server Error", "", msg);
  }
  memset(tmp_path, 0, sizeof(tmp_path));
  substr(pathinfo, -1, 1, tmp_path);
  if (strcmp(tmp_path, "/") == 0) {
    memset(tmp_path, 0, sizeof(tmp_path));
    strcpy(tmp_path, pathinfo);
  } else {
    memset(tmp_path, 0, sizeof(tmp_path));
    strcpy(tmp_path, pathinfo);
    strcat(tmp_path, "/");
  }
  sprintf(tmp, "<html>\n<head>\n<title>Browse directory %s - %s</title>\n</head>\n<body><h3>Directory %s</h3>\n<hr />\n<ul>\n", pathinfo, "tmhttpd/1.0.0_alpha", pathinfo);
  strcat(buf, tmp);
  while ((node = readdir(dp)) != NULL) {
    if (strcmp(node->d_name, ".") != 0) {
      memset(tmp, 0, sizeof(tmp));
      sprintf(tmp, "\t<li><a href=\"%s%s\">%s</a></li>\n", tmp_path, node->d_name, node->d_name);
      strcat(buf, tmp);
    }
  }
  memset(tmp, 0, sizeof(tmp));
  sprintf(tmp, "\n</ul>\n<br /><hr />\n<address>%s</address>\n</body>\n</html>\n", "tmhttpd/1.0.0_alpha");
  strcat(buf, tmp);
  file_size = strlen(buf);
  SendHeaders(client_sock, 200, "OK", "", "text/html", file_size, 0);
  write(client_sock, buf, file_size);
  return 0;
}
```