user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<flash_ext4_kernel>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x260,%rsp
  mov    %rdi,-0x248(%rbp)
  mov    %rsi,-0x250(%rbp)
  mov    %rdx,-0x258(%rbp)
  mov    %ecx,-0x25c(%rbp)
  mov    %r8d,-0x260(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x250(%rbp),%rax
  lea    D65(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x220(%rbp)
  cmpq   $0x0,-0x220(%rbp)
  jne    L142
  mov    -0x250(%rbp),%rax
  mov    %rax,%rsi
  lea    D31(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <my_printf@plt>
  mov    $0x0,%eax
  jmp    L67
L142:
  mov    -0x248(%rbp),%rax
  lea    D61(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x218(%rbp)
  cmpq   $0x0,-0x218(%rbp)
  jne    L5
  mov    -0x248(%rbp),%rax
  mov    %rax,%rsi
  lea    D50(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <my_printf@plt>
  mov    $0x0,%eax
  jmp    L67
L5:
  lea    D29(%rip),%rax
  mov    %rax,%rdi
  call   <set_step@plt>
  movq   $0x0,-0x228(%rbp)
  movl   $0x0,-0x234(%rbp)
  movl   $0x0,-0x230(%rbp)
  jmp    L87
L34:
  mov    -0x220(%rbp),%rdx
  lea    -0x210(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x200,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fread@plt>
  mov    %eax,-0x22c(%rbp)
  cmpl   $0x0,-0x22c(%rbp)
  jne    L120
  mov    -0x220(%rbp),%rax
  mov    %rax,%rdi
  call   <feof@plt>
  test   %rax,%rax
  je     L70
  jmp    L87
L70:
  lea    D10(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <my_printf@plt>
  mov    -0x220(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x218(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
  jmp    L67
L120:
  mov    -0x22c(%rbp),%eax
  cltq
  add    %rax,-0x228(%rbp)
  mov    -0x228(%rbp),%rdx
  mov    %rdx,%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  lea    0x0(,%rax,4),%rdx
  add    %rdx,%rax
  shl    $0x2,%rax
  cqto
  idivq  -0x258(%rbp)
  mov    %eax,-0x230(%rbp)
  mov    -0x234(%rbp),%eax
  cmp    -0x230(%rbp),%eax
  jge    L54
  mov    -0x230(%rbp),%eax
  mov    %eax,%edi
  call   <set_step_progress@plt>
  mov    -0x230(%rbp),%eax
  mov    %eax,-0x234(%rbp)
L54:
  cmpl   $0x0,-0x260(%rbp)
  jne    L87
  mov    -0x218(%rbp),%rdx
  mov    -0x22c(%rbp),%esi
  lea    -0x210(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    %rax,%rdi
  call   <fwrite@plt>
  mov    %eax,-0x22c(%rbp)
  cmpl   $0x1,-0x22c(%rbp)
  je     L87
  lea    D2(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <my_printf@plt>
  mov    -0x220(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x218(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
  jmp    L67
L87:
  mov    -0x220(%rbp),%rax
  mov    %rax,%rdi
  call   <feof@plt>
  test   %rax,%rax
  je     L34
  mov    -0x220(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x218(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    $0x1,%eax
L67:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L49
  call   <__stack_chk_fail@plt>
L49:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D65
data_type: string
name: retrieve_data
arguments: data_label: D31
data_type: string
name: retrieve_data
arguments: data_label: D61
data_type: string
name: retrieve_data
arguments: data_label: D50
data_type: string
name: retrieve_data
arguments: data_label: D29
data_type: string
name: retrieve_data
arguments: data_label: D10
data_type: string
name: retrieve_data
arguments: data_label: D2
data_type: string

tool: D65: rb

tool: D31: Error while opening kernel file %s


tool: D61: wb

tool: D50: Error while opening kernel device %s


tool: D29: Writing ext4 kernel

tool: D10: Error reading kernel file.


tool: D2: Error writing kernel file to kernel device.


assistant: ```c
int flash_ext4_kernel(char *device, char *filename, off_t kernel_file_size, int quiet, int no_write) {
  char buffer[512];
  FILE *kernel_file;
  kernel_file = fopen(filename, "rb");
  if (kernel_file == NULL) {
    my_printf("Error while opening kernel file %s\n", filename);
    return 0;
  }
  FILE *kernel_dev;
  kernel_dev = fopen(device, "wb");
  if (kernel_dev == NULL) {
    my_printf("Error while opening kernel device %s\n", device);
    return 0;
  }
  set_step("Writing ext4 kernel");
  int ret;
  long long readBytes = 0;
  int current_percent = 0;
  int new_percent = 0;
  while (!feof(kernel_file)) {
    ret = fread(buffer, 1, sizeof(buffer), kernel_file);
    if (ret == 0) {
      if (feof(kernel_file))
        continue;
      my_printf("Error reading kernel file.\n");
      fclose(kernel_file);
      fclose(kernel_dev);
      return 0;
    }
    readBytes += ret;
    new_percent = readBytes * 100 / kernel_file_size;
    if (current_percent < new_percent) {
      set_step_progress(new_percent);
      current_percent = new_percent;
    }
    if (!no_write) {
      ret = fwrite(buffer, ret, 1, kernel_dev);
      if (ret != 1) {
        my_printf("Error writing kernel file to kernel device.\n");
        fclose(kernel_file);
        fclose(kernel_dev);
        return 0;
      }
    }
  }
  fclose(kernel_file);
  fclose(kernel_dev);
  return 1;
}
```