user: Demonstrate the C code that generates the assembly output below:

```asm
<flash_ext4_kernel>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x238,%rsp
  mov    %rdi,%rbp
  mov    %rsi,%rbx
  mov    %rdx,0x10(%rsp)
  mov    %r8d,%r14d
  mov    %fs:0x28,%rax
  mov    %rax,0x228(%rsp)
  xor    %eax,%eax
  lea    D63(%rip),%rsi
  mov    %rbx,%rdi
  call   <fopen@plt>
  test   %rax,%rax
  je     L135
  mov    %rax,%r12
  lea    D51(%rip),%rsi
  mov    %rbp,%rdi
  call   <fopen@plt>
  mov    %rax,0x18(%rsp)
  test   %rax,%rax
  je     L104
  lea    D23(%rip),%rdi
  call   <set_step@plt>
  movl   $0x0,0xc(%rsp)
  mov    $0x0,%r13d
  lea    0x20(%rsp),%r15
  jmp    L88
L135:
  mov    %rbx,%rsi
  lea    D18(%rip),%rdi
  mov    $0x0,%eax
  call   <my_printf@plt>
  mov    $0x0,%ebp
  jmp    L114
L104:
  mov    %rbp,%rsi
  lea    D7(%rip),%rdi
  call   <my_printf@plt>
  mov    $0x0,%ebp
  jmp    L114
L109:
  mov    %r12,%rdi
  call   <feof@plt>
  test   %rax,%rax
  jne    L88
  lea    D6(%rip),%rdi
  call   <my_printf@plt>
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    0x18(%rsp),%rdi
  call   <fclose@plt>
L114:
  mov    0x228(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L94
  mov    %ebp,%eax
  add    $0x238,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L142:
  test   %r14d,%r14d
  je     L78
L88:
  mov    %r12,%rdi
  call   <feof@plt>
  test   %rax,%rax
  jne    L15
  mov    %r12,%rcx
  mov    $0x200,%edx
  mov    $0x1,%esi
  mov    %r15,%rdi
  call   <fread@plt>
  mov    %eax,%ebp
  test   %eax,%eax
  je     L109
  cltq
  add    %rax,%r13
  lea    0x0(%r13,%r13,4),%rax
  lea    (%rax,%rax,4),%rax
  shl    $0x2,%rax
  cqto
  idivq  0x10(%rsp)
  mov    %rax,%rbx
  mov    %eax,%edi
  cmp    %eax,0xc(%rsp)
  jge    L142
  call   <set_step_progress@plt>
  mov    %ebx,0xc(%rsp)
  jmp    L142
L78:
  mov    0x18(%rsp),%rcx
  mov    $0x1,%edx
  mov    %ebp,%esi
  mov    %r15,%rdi
  call   <fwrite@plt>
  cmp    $0x1,%eax
  je     L88
  lea    D20(%rip),%rdi
  mov    $0x0,%eax
  call   <my_printf@plt>
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    0x18(%rsp),%rdi
  call   <fclose@plt>
  mov    %r14d,%ebp
  jmp    L114
L15:
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    0x18(%rsp),%rdi
  call   <fclose@plt>
  mov    $0x1,%ebp
  jmp    L114
L94:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D63
type_infered: string
name: read_data
arguments: tag: D51
type_infered: string
name: read_data
arguments: tag: D23
type_infered: string
name: read_data
arguments: tag: D18
type_infered: string
name: read_data
arguments: tag: D7
type_infered: string
name: read_data
arguments: tag: D6
type_infered: string
name: read_data
arguments: tag: D20
type_infered: string

tool: D63: rb

tool: D51: wb

tool: D23: Writing ext4 kernel

tool: D18: Error while opening kernel file %s


tool: D7: Error while opening kernel device %s


tool: D6: Error reading kernel file.


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