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

```asm
<write_page>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x418,%rsp
  mov    %edi,%ebx
  mov    %rsi,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x408(%rsp)
  xor    %eax,%eax
  lea    D58(%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     L155
  lea    D83(%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     L155
  mov    %rbp,%rdi
  call   <strlen@plt>
  movslq %eax,%r13
  lea    -0x3(%rbp,%r13,1),%r12
  lea    D17(%rip),%rsi
  mov    %r12,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  je     L53
  lea    -0x4(%rbp,%r13,1),%rdi
  lea    D46(%rip),%rsi
  call   <strcasecmp@plt>
  test   %rax,%rax
  jne    L7
L53:
  lea    D77(%rip),%rbp
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L155
  lea    D56(%rip),%rsi
  mov    %r12,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  je     L116
L7:
  mov    $0x4,%edx
  lea    D84(%rip),%rsi
  mov    %ebx,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L155
  mov    %rsp,%rbp
L152:
  mov    $0x400,%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <read@plt>
  mov    %eax,%edx
  test   %eax,%eax
  jle    L117
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  jne    L152
  jmp    L155
L116:
  lea    D51(%rip),%rbp
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L155
  lea    D57(%rip),%rsi
  mov    %r12,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  jne    L7
  lea    D63(%rip),%rbp
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L155
  lea    D45(%rip),%rbp
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  jne    L7
  jmp    L155
L117:
  mov    $0x0,%eax
L155:
  mov    0x408(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L1
  add    $0x418,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L1:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D58
type: string
name: read_data
arguments: label: D83
type: string
name: read_data
arguments: label: D17
type: string
name: read_data
arguments: label: D46
type: string
name: read_data
arguments: label: D77
type: string
name: read_data
arguments: label: D56
type: string
name: read_data
arguments: label: D84
type: string
name: read_data
arguments: label: D51
type: string
name: read_data
arguments: label: D57
type: string
name: read_data
arguments: label: D63
type: string
name: read_data
arguments: label: D45
type: string

tool: D58: HTTP/1.1 200 OK


tool: D83: Content-Type: 

tool: D17: jpg

tool: D46: jpeg

tool: D77: image/jpeg

tool: D56: gif

tool: D84: 



tool: D51: image/gif

tool: D57: png

tool: D63: image/png

tool: D45: text/html

assistant: ```c
int write_page(int cfd, 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(cfd, buf, 1024)) > 0)
    if (my_write(cfd, buf, n) == -1)
      return -1;
  return 0;
}
```