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

```asm
<split_file>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdi,%r14
  mov    %rsi,%rdi
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edx,%ebx
  sub    $0x18,%rsp
  mov    %rsi,0x8(%rsp)
  call   <strlen@plt>
  movslq %eax,%r15
  lea    0x8(%r15),%edi
  call   <malloc@plt>
  lea    0x7(%r15),%edi
  mov    %rax,%r12
  call   <malloc@plt>
  mov    0x8(%rsp),%rsi
  mov    %r15d,%edx
  mov    %r12,%rdi
  mov    %rax,%rbp
  call   <strncpy@plt>
  lea    (%r12,%r15,1),%rdi
  mov    $0x7,%edx
  lea    D25(%rip),%rsi
  call   <strncpy@plt>
  mov    0x8(%rsp),%rsi
  mov    %r15d,%edx
  mov    %rbp,%rdi
  movb   $0x0,0x7(%r12,%r15,1)
  call   <strncpy@plt>
  lea    0x0(%rbp,%r15,1),%rdi
  mov    $0x6,%edx
  lea    D45(%rip),%rsi
  call   <strncpy@plt>
  movb   $0x0,0x6(%rbp,%r15,1)
  mov    %rbp,%rdx
  mov    %r12,%rsi
  lea    D8(%rip),%rdi
  lea    D17(%rip),%r15
  call   <printf@plt>
  mov    %r15,%rsi
  mov    %r12,%rdi
  call   <fopen@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L5
L18:
  mov    %r13,%rsi
  mov    %ebx,%ecx
  xor    %edx,%edx
  mov    %r14,%rdi
  call   <copy_chunked@plt>
  mov    %r13,%rdi
  call   <fclose@plt>
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <fopen@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L33
L32:
  lea    0x8(%rbx),%edx
  mov    %r13,%rsi
  mov    $0xffffffff,%ecx
  mov    %r14,%rdi
  call   <copy_chunked@plt>
  mov    %r13,%rdi
  call   <fclose@plt>
  mov    %r12,%rdi
  call   <free@plt>
  add    $0x18,%rsp
  mov    %rbp,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10d0 <free@plt>
  nopl   (%rax)
L5:
  mov    %r12,%rsi
  lea    D19(%rip),%rdi
  call   <fatal@plt>
  jmp    L18
  nopl   0x0(%rax)
L33:
  mov    %rbp,%rsi
  lea    D49(%rip),%rdi
  call   <fatal@plt>
  jmp    L32
```

tool_calls: name: parse_data
arguments: data_tag: D25
data_type: string
name: parse_data
arguments: data_tag: D45
data_type: string
name: parse_data
arguments: data_tag: D8
data_type: string
name: parse_data
arguments: data_tag: D17
data_type: string
name: parse_data
arguments: data_tag: D19
data_type: string
name: parse_data
arguments: data_tag: D49
data_type: string

tool: D25: .kernel

tool: D45: .image

tool: D8: Kernel path: %s
Image path: %s


tool: D17: wb

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


tool: D49: 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);
}
```