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

```asm
<split_file>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,0x8(%rsp)
  mov    %rsi,%r14
  mov    %edx,%r13d
  mov    %rsi,%rdi
  call   <strlen@plt>
  mov    %eax,%r12d
  lea    0x8(%rax),%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  lea    0x7(%r12),%edi
  call   <malloc@plt>
  mov    %rax,%rbx
  mov    %r12d,%edx
  mov    %r14,%rsi
  mov    %rbp,%rdi
  call   <strncpy@plt>
  movslq %r12d,%r15
  lea    0x0(%rbp,%r15,1),%rdi
  mov    $0x7,%edx
  lea    D35(%rip),%rsi
  call   <strncpy@plt>
  movb   $0x0,0x7(%rbp,%r15,1)
  mov    %r12d,%edx
  mov    %r14,%rsi
  mov    %rbx,%rdi
  call   <strncpy@plt>
  lea    (%rbx,%r15,1),%rdi
  mov    $0x6,%edx
  lea    D68(%rip),%rsi
  call   <strncpy@plt>
  movb   $0x0,0x6(%rbx,%r15,1)
  mov    %rbx,%rdx
  mov    %rbp,%rsi
  lea    D36(%rip),%rdi
  call   <printf@plt>
  lea    D20(%rip),%rsi
  mov    %rbp,%rdi
  call   <fopen@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L4
L23:
  mov    %r13d,%ecx
  mov    $0x0,%edx
  mov    %r12,%rsi
  mov    0x8(%rsp),%rdi
  call   <copy_chunked@plt>
  mov    %r12,%rdi
  call   <fclose@plt>
  lea    D20(%rip),%rsi
  mov    %rbx,%rdi
  call   <fopen@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L31
L9:
  lea    0x8(%r13),%edx
  mov    $0xffffffff,%ecx
  mov    %r12,%rsi
  mov    0x8(%rsp),%rdi
  call   <copy_chunked@plt>
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    %rbp,%rdi
  call   <free@plt>
  mov    %rbx,%rdi
  call   <free@plt>
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L4:
  mov    %rbp,%rsi
  lea    D42(%rip),%rdi
  call   <fatal@plt>
  jmp    L23
L31:
  mov    %rbx,%rsi
  lea    D16(%rip),%rdi
  call   <fatal@plt>
  jmp    L9
```

tool_calls: name: disassemble_data
arguments: data_tag: D35
type: string
name: disassemble_data
arguments: data_tag: D68
type: string
name: disassemble_data
arguments: data_tag: D36
type: string
name: disassemble_data
arguments: data_tag: D20
type: string
name: disassemble_data
arguments: data_tag: D42
type: string
name: disassemble_data
arguments: data_tag: D16
type: string

tool: D35: .kernel

tool: D68: .image

tool: D36: Kernel path: %s
Image path: %s


tool: D20: wb

tool: D42: Could not open kernel file for writing: %s


tool: D16: Could not open image file for writng: %s


assistant: ```c
void split_file(FILE *in_file, char *filename, int64_t offset) {
  int path_len = strlen(filename);
  char *kernel_name = malloc(path_len + 1 + 7);
  char *image_name = malloc(path_len + 1 + 6);
  strncpy(kernel_name, filename, path_len);
  strncpy(kernel_name + path_len, ".kernel", 7);
  kernel_name[path_len + 7] = 0;
  strncpy(image_name, filename, path_len);
  strncpy(image_name + path_len, ".image", 6);
  image_name[path_len + 6] = 0;
  printf("Kernel path: %s\nImage path: %s\n", kernel_name, image_name);
  FILE *kernel_file = fopen(kernel_name, "wb");
  if (!kernel_file)
    fatal("Could not open kernel file for writing: %s\n", kernel_name);
  copy_chunked(in_file, kernel_file, 0, offset);
  fclose(kernel_file);
  FILE *image_file = fopen(image_name, "wb");
  if (!image_file)
    fatal("Could not open image file for writng: %s\n", image_name);
  copy_chunked(in_file, image_file, offset + 8, -1);
  fclose(image_file);
  free(kernel_name);
  free(image_name);
}
```