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

```asm
<write_page>:
  endbr64
  push   %r14
  push   %r13
  lea    D1(%rip),%r13
  push   %r12
  mov    %esi,%r12d
  push   %rbp
  mov    %edi,%ebp
  mov    %r13,%rdi
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x410,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x408(%rsp)
  xor    %eax,%eax
  call   <strlen@plt>
  mov    %r13,%rsi
  mov    %ebp,%edi
  mov    %eax,%edx
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L38
  lea    D76(%rip),%r13
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %r13,%rsi
  mov    %ebp,%edi
  mov    %eax,%edx
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L38
  mov    %rbx,%rdi
  call   <strlen@plt>
  lea    D43(%rip),%rsi
  movslq %eax,%r13
  lea    -0x3(%rbx,%r13,1),%r14
  mov    %r14,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  jne    L158
L56:
  lea    D38(%rip),%r13
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %r13,%rsi
  mov    %ebp,%edi
  mov    %eax,%edx
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L38
  lea    D79(%rip),%rsi
  mov    %r14,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  je     L156
L97:
  mov    $0x4,%edx
  lea    D68(%rip),%rsi
  mov    %ebp,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L38
  mov    %rsp,%rbx
  jmp    L105
  nopw   0x0(%rax,%rax,1)
L81:
  mov    %rbx,%rsi
  mov    %ebp,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L38
L105:
  mov    $0x400,%edx
  mov    %rbx,%rsi
  mov    %r12d,%edi
  call   <read@plt>
  mov    %eax,%edx
  test   %eax,%eax
  jg     L81
  xor    %eax,%eax
  jmp    L121
L156:
  lea    D59(%rip),%r13
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %r13,%rsi
  mov    %ebp,%edi
  mov    %eax,%edx
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L38
  lea    D91(%rip),%rsi
  mov    %r14,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  jne    L97
  lea    D47(%rip),%r13
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %r13,%rsi
  mov    %ebp,%edi
  mov    %eax,%edx
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L38
  lea    D12(%rip),%r13
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %r13,%rsi
  mov    %ebp,%edi
  mov    %eax,%edx
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  jne    L97
  nopl   0x0(%rax)
L38:
  mov    $0xffffffff,%eax
L121:
  mov    0x408(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L72
  add    $0x410,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax,%rax,1)
L158:
  lea    -0x4(%rbx,%r13,1),%rdi
  lea    D87(%rip),%rsi
  call   <strcasecmp@plt>
  test   %rax,%rax
  je     L56
  jmp    L97
L72:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_label: D1
data_type: string
name: read_data
arguments: data_label: D76
data_type: string
name: read_data
arguments: data_label: D43
data_type: string
name: read_data
arguments: data_label: D38
data_type: string
name: read_data
arguments: data_label: D79
data_type: string
name: read_data
arguments: data_label: D68
data_type: string
name: read_data
arguments: data_label: D59
data_type: string
name: read_data
arguments: data_label: D91
data_type: string
name: read_data
arguments: data_label: D47
data_type: string
name: read_data
arguments: data_label: D12
data_type: string
name: read_data
arguments: data_label: D87
data_type: string

tool: D1: HTTP/1.1 200 OK


tool: D76: Content-Type: 

tool: D43: jpg

tool: D38: image/jpeg

tool: D79: gif

tool: D68: 



tool: D59: image/gif

tool: D91: png

tool: D47: image/png

tool: D12: text/html

tool: D87: jpeg

assistant: ```c
int write_page(int cfd, int fd, char *path) {
  int n;
  char buf[1024];
  if (my_write(cfd, "HTTP/1.1 200 OK\r\n", strlen("HTTP/1.1 200 OK\r\n")) == -1)
    return -1;
  if (my_write(cfd, "Content-Type: ", strlen("Content-Type: ")) == -1)
    return -1;
  n = strlen(path);
  if (strcasecmp(&path[n - 3], "jpg") == 0 || (strcasecmp(&path[n - 4], "jpeg") == 0))
    if (my_write(cfd, "image/jpeg", strlen("image/jpeg")) == -1)
      return -1;
    else if (strcasecmp(&path[n - 3], "gif") == 0)
      if (my_write(cfd, "image/gif", strlen("image/gif")) == -1)
        return -1;
      else if (strcasecmp(&path[n - 3], "png") == 0)
        if (my_write(cfd, "image/png", strlen("image/png")) == -1)
          return -1;
        else if (my_write(cfd, "text/html", strlen("text/html")) == -1)
          return -1;
  if (my_write(cfd, "\r\n\r\n", 4) == -1)
    return -1;
  while ((n = read(fd, buf, 1024)) > 0)
    if (my_write(cfd, buf, n) == -1)
      return -1;
  return 0;
}
```