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

```asm
<write_page>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x410,%rsp
  mov    %edi,%ebx
  mov    %esi,%ebp
  mov    %rdx,%r12
  mov    %fs:0x28,%rax
  mov    %rax,0x408(%rsp)
  xor    %eax,%eax
  lea    D92(%rip),%r13
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %r13,%rsi
  mov    %ebx,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L102
  lea    D3(%rip),%r13
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %r13,%rsi
  mov    %ebx,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L102
  mov    %r12,%rdi
  call   <strlen@plt>
  movslq %eax,%r14
  lea    -0x3(%r12,%r14,1),%r13
  lea    D1(%rip),%rsi
  mov    %r13,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  je     L124
  lea    -0x4(%r12,%r14,1),%rdi
  lea    D39(%rip),%rsi
  call   <strcasecmp@plt>
  test   %rax,%rax
  jne    L62
L124:
  lea    D82(%rip),%r12
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %r12,%rsi
  mov    %ebx,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L102
  lea    D11(%rip),%rsi
  mov    %r13,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  je     L104
L62:
  mov    $0x4,%edx
  lea    D9(%rip),%rsi
  mov    %ebx,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L102
  mov    %rsp,%r12
L72:
  mov    $0x400,%edx
  mov    %r12,%rsi
  mov    %ebp,%edi
  call   <read@plt>
  mov    %eax,%edx
  test   %eax,%eax
  jle    L103
  mov    %r12,%rsi
  mov    %ebx,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  jne    L72
  jmp    L102
L104:
  lea    D50(%rip),%r12
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %r12,%rsi
  mov    %ebx,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L102
  lea    D21(%rip),%rsi
  mov    %r13,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  jne    L62
  lea    D74(%rip),%r12
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %r12,%rsi
  mov    %ebx,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L102
  lea    D100(%rip),%r12
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %r12,%rsi
  mov    %ebx,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  jne    L62
  jmp    L102
L103:
  mov    $0x0,%eax
L102:
  mov    0x408(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L126
  add    $0x410,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L126:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D92
type_guessed: string
name: read_data
arguments: label: D3
type_guessed: string
name: read_data
arguments: label: D1
type_guessed: string
name: read_data
arguments: label: D39
type_guessed: string
name: read_data
arguments: label: D82
type_guessed: string
name: read_data
arguments: label: D11
type_guessed: string
name: read_data
arguments: label: D9
type_guessed: string
name: read_data
arguments: label: D50
type_guessed: string
name: read_data
arguments: label: D21
type_guessed: string
name: read_data
arguments: label: D74
type_guessed: string
name: read_data
arguments: label: D100
type_guessed: string

tool: D92: HTTP/1.1 200 OK


tool: D3: Content-Type: 

tool: D1: jpg

tool: D39: jpeg

tool: D82: image/jpeg

tool: D11: gif

tool: D9: 



tool: D50: image/gif

tool: D21: png

tool: D74: image/png

tool: D100: text/html

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;
}
```