user: Converte this assembly snippet into its equivalent C code:

```asm
<insert_into_file>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  lea    D27(%rip),%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x18(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <file_copy@plt>
  test   %rax,%rax
  jne    L14
  mov    $0x0,%eax
  jmp    L44
L14:
  mov    -0x18(%rbp),%rax
  lea    D29(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x28(%rbp),%rax
  lea    D7(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  je     L88
  cmpq   $0x0,-0x8(%rbp)
  jne    L24
L88:
  mov    $0x0,%eax
  jmp    L44
L24:
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdx
  mov    $0x1000,%esi
  lea    D57(%rip),%rax
  mov    %rax,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L33
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    -0x38(%rbp),%rax
  mov    %rax,%rsi
  lea    D57(%rip),%rax
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L27
  mov    -0x8(%rbp),%rax
  mov    %rax,%rsi
  lea    D57(%rip),%rax
  mov    %rax,%rdi
  call   <fputs@plt>
  mov    -0x8(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fputs@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
L93:
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdx
  mov    $0x1000,%esi
  lea    D57(%rip),%rax
  mov    %rax,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L35
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    -0x40(%rbp),%rax
  mov    %rax,%rsi
  lea    D57(%rip),%rax
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L93
  mov    -0x8(%rbp),%rax
  mov    %rax,%rsi
  lea    D57(%rip),%rax
  mov    %rax,%rdi
  call   <fputs@plt>
  jmp    L112
L27:
  mov    -0x8(%rbp),%rax
  mov    %rax,%rsi
  lea    D57(%rip),%rax
  mov    %rax,%rdi
  call   <fputs@plt>
  jmp    L24
L35:
  nop
L112:
  jmp    L24
L33:
  nop
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <unlink@plt>
  mov    $0x1,%eax
L44:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D27
type: string
name: retrieve_data
arguments: data_tag: D29
type: string
name: retrieve_data
arguments: data_tag: D7
type: string

tool: D27: tmp.h

tool: D29: r

tool: D7: w

assistant: ```c
int insert_into_file(const char *filename, const char *text, const char *start_line, const char *end_line) {
  static char line[1024 * 4];
  const char *tmpname = "tmp.h";
  FILE *source_fp;
  FILE *dest_fp;
  if (file_copy(filename, tmpname) == 0)
    return 0;
  source_fp = fopen(tmpname, "r");
  dest_fp = fopen(filename, "w");
  if (source_fp == NULL || dest_fp == NULL)
    return 0;
  for (;;) {
    if (fgets(line, 1024 * 4, source_fp) == NULL)
      break;
    if (strncmp(line, start_line, strlen(start_line)) == 0) {
      fputs(line, dest_fp);
      fputs(text, dest_fp);
      fputs("\n", dest_fp);
      for (;;) {
        if (fgets(line, 1024 * 4, source_fp) == NULL)
          break;
        if (strncmp(line, end_line, strlen(end_line)) == 0) {
          fputs(line, dest_fp);
          break;
        }
      }
    } else {
      fputs(line, dest_fp);
    }
  }
  fclose(source_fp);
  fclose(dest_fp);
  unlink(tmpname);
  return 1;
}
```