user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<write_page>:
  endbr64
  push   %r13
  push   %r12
  lea    D68(%rip),%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %edi,%ebx
  mov    %r12,%rdi
  sub    $0x418,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x408(%rsp)
  xor    %eax,%eax
  call   <strlen@plt>
  mov    %r12,%rsi
  mov    %ebx,%edi
  mov    %eax,%edx
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L159
  lea    D35(%rip),%r12
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %r12,%rsi
  mov    %ebx,%edi
  mov    %eax,%edx
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L159
  mov    %rbp,%rdi
  call   <strlen@plt>
  lea    D105(%rip),%rsi
  movslq %eax,%r12
  lea    -0x3(%rbp,%r12,1),%r13
  mov    %r13,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  jne    L157
L162:
  lea    D5(%rip),%rbp
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %rbp,%rsi
  mov    %ebx,%edi
  mov    %eax,%edx
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L159
  lea    D103(%rip),%rsi
  mov    %r13,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  je     L36
L54:
  mov    $0x4,%edx
  lea    D57(%rip),%rsi
  mov    %ebx,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L159
  mov    %rsp,%rbp
  jmp    L64
  nopw   0x0(%rax,%rax,1)
L72:
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L159
L64:
  mov    $0x400,%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <read@plt>
  mov    %eax,%edx
  test   %eax,%eax
  jg     L72
  xor    %eax,%eax
  jmp    L140
  nopw   0x0(%rax,%rax,1)
L36:
  lea    D101(%rip),%rbp
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %rbp,%rsi
  mov    %ebx,%edi
  mov    %eax,%edx
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L159
  lea    D50(%rip),%rsi
  mov    %r13,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  jne    L54
  lea    D108(%rip),%rbp
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %rbp,%rsi
  mov    %ebx,%edi
  mov    %eax,%edx
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  je     L159
  lea    D81(%rip),%rbp
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %rbp,%rsi
  mov    %ebx,%edi
  mov    %eax,%edx
  call   <my_write@plt>
  cmp    $0xffffffff,%eax
  jne    L54
  nopl   0x0(%rax)
L159:
  mov    $0xffffffff,%eax
L140:
  mov    0x408(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L21
  add    $0x418,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  cs nopw 0x0(%rax,%rax,1)
L157:
  lea    -0x4(%rbp,%r12,1),%rdi
  lea    D66(%rip),%rsi
  call   <strcasecmp@plt>
  test   %rax,%rax
  je     L162
  jmp    L54
L21:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D68
datatype: string
name: retrieve_data
arguments: data_tag: D35
datatype: string
name: retrieve_data
arguments: data_tag: D105
datatype: string
name: retrieve_data
arguments: data_tag: D5
datatype: string
name: retrieve_data
arguments: data_tag: D103
datatype: string
name: retrieve_data
arguments: data_tag: D57
datatype: string
name: retrieve_data
arguments: data_tag: D101
datatype: string
name: retrieve_data
arguments: data_tag: D50
datatype: string
name: retrieve_data
arguments: data_tag: D108
datatype: string
name: retrieve_data
arguments: data_tag: D81
datatype: string
name: retrieve_data
arguments: data_tag: D66
datatype: string

tool: D68: HTTP/1.1 200 OK


tool: D35: Content-Type: 

tool: D105: jpg

tool: D5: image/jpeg

tool: D103: gif

tool: D57: 



tool: D101: image/gif

tool: D50: png

tool: D108: image/png

tool: D81: text/html

tool: D66: jpeg

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