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

```asm
<write_OK>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x40,%rsp
  mov    %edi,-0x1024(%rbp)
  mov    %rsi,-0x1030(%rbp)
  mov    %rdx,-0x1038(%rbp)
  mov    %rcx,-0x1040(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x1018(%rbp)
  movl   $0x0,-0x1014(%rbp)
  movq   $0x0,-0x1010(%rbp)
  movq   $0x0,-0x1008(%rbp)
  lea    -0x1000(%rbp),%rdx
  mov    $0x0,%eax
  mov    $0x1fe,%ecx
  mov    %rdx,%rdi
  rep stos %rax,%es:(%rdi)
  mov    -0x1024(%rbp),%eax
  lea    D8(%rip),%rdx
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <write_to_client@plt>
  mov    -0x1024(%rbp),%eax
  lea    D27(%rip),%rdx
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <write_to_client@plt>
  mov    -0x1030(%rbp),%rdx
  mov    -0x1024(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <write_to_client@plt>
  mov    -0x1024(%rbp),%eax
  lea    D41(%rip),%rdx
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <write_to_client@plt>
  mov    -0x1024(%rbp),%eax
  lea    D40(%rip),%rdx
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <write_to_client@plt>
  mov    -0x1040(%rbp),%rdx
  mov    -0x1024(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <write_to_client@plt>
  mov    -0x1024(%rbp),%eax
  lea    D49(%rip),%rdx
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <write_to_client@plt>
  jmp    L30
L31:
  lea    -0x1010(%rbp),%rdx
  mov    -0x1024(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <write_to_client@plt>
  mov    %eax,-0x1014(%rbp)
  cmpl   $0xffffffff,-0x1014(%rbp)
  jne    L28
  mov    -0x1018(%rbp),%eax
  jmp    L45
L28:
  mov    -0x1014(%rbp),%eax
  add    %eax,-0x1018(%rbp)
L30:
  mov    -0x1038(%rbp),%rdx
  lea    -0x1010(%rbp),%rax
  mov    $0x1000,%esi
  mov    %rax,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L31
  mov    -0x1018(%rbp),%eax
L45:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L20
  call   <__stack_chk_fail@plt>
L20:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D8
type_guessed: string
name: retrieve_data
arguments: data_tag: D27
type_guessed: string
name: retrieve_data
arguments: data_tag: D41
type_guessed: string
name: retrieve_data
arguments: data_tag: D40
type_guessed: string
name: retrieve_data
arguments: data_tag: D49
type_guessed: string

tool: D8: HTTP/1.1 200 OK


tool: D27: Date: 

tool: D41: 
Content-Type: text/html


tool: D40: Content-Length: 

tool: D49: 



assistant: ```c
int write_OK(int clientsd, char *curr_time, FILE *file, char *file_length_buf) {
  int total_written = 0;
  int written = 0;
  char buffer[4096] = {0};
  write_to_client(clientsd, "HTTP/1.1 200 OK\n");
  write_to_client(clientsd, "Date: ");
  write_to_client(clientsd, curr_time);
  write_to_client(clientsd, "\nContent-Type: text/html\n");
  write_to_client(clientsd, "Content-Length: ");
  write_to_client(clientsd, file_length_buf);
  write_to_client(clientsd, "\n\n");
  while (fgets(buffer, sizeof(buffer), file) != NULL) {
    written = write_to_client(clientsd, buffer);
    if (written == -1)
      return total_written;
    else
      total_written += written;
  }
  return total_written;
}
```