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

```asm
<split_file>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %edx,-0x44(%rbp)
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x24(%rbp)
  mov    -0x24(%rbp),%eax
  add    $0x8,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  mov    -0x24(%rbp),%eax
  add    $0x7,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x18(%rbp)
  mov    -0x24(%rbp),%edx
  mov    -0x40(%rbp),%rcx
  mov    -0x20(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x24(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    $0x7,%edx
  lea    D49(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x7(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x24(%rbp),%edx
  mov    -0x40(%rbp),%rcx
  mov    -0x18(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x24(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    $0x6,%edx
  lea    D17(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x6(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x18(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rax,%rsi
  lea    D3(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    -0x20(%rbp),%rax
  lea    D42(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L4
  mov    -0x20(%rbp),%rax
  mov    %rax,%rsi
  lea    D23(%rip),%rax
  mov    %rax,%rdi
  call   <fatal@plt>
L4:
  mov    -0x44(%rbp),%edx
  mov    -0x10(%rbp),%rsi
  mov    -0x38(%rbp),%rax
  mov    %edx,%ecx
  mov    $0x0,%edx
  mov    %rax,%rdi
  call   <copy_chunked@plt>
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x18(%rbp),%rax
  lea    D42(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L19
  mov    -0x18(%rbp),%rax
  mov    %rax,%rsi
  lea    D18(%rip),%rax
  mov    %rax,%rdi
  call   <fatal@plt>
L19:
  mov    -0x44(%rbp),%eax
  lea    0x8(%rax),%edx
  mov    -0x8(%rbp),%rsi
  mov    -0x38(%rbp),%rax
  mov    $0xffffffff,%ecx
  mov    %rax,%rdi
  call   <copy_chunked@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  nop
  leave
  ret
```

tool_calls: name: parse_data
arguments: data_label: D49
type_guessed: string
name: parse_data
arguments: data_label: D17
type_guessed: string
name: parse_data
arguments: data_label: D3
type_guessed: string
name: parse_data
arguments: data_label: D42
type_guessed: string
name: parse_data
arguments: data_label: D23
type_guessed: string
name: parse_data
arguments: data_label: D18
type_guessed: string

tool: D49: .kernel

tool: D17: .image

tool: D3: Kernel path: %s
Image path: %s


tool: D42: wb

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


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