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

```asm
<xml_write_to_mtd>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x28(%rbp)
  movl   $0x0,-0x24(%rbp)
  movq   $0x0,-0x20(%rbp)
  movq   $0x0,-0x18(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L82
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L69
L82:
  lea    D32(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    $0x1,%eax
  jmp    L90
L69:
  cmpl   $0x0,-0x3c(%rbp)
  jne    L7
  lea    D35(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  lea    -0x18(%rbp),%rax
  mov    %rax,%rsi
  lea    D3(%rip),%rax
  mov    %rax,%rdi
  call   <scanf@plt>
  mov    %eax,-0x28(%rbp)
  cmpl   $0x1,-0x28(%rbp)
  jne    L48
  mov    -0x18(%rbp),%rax
  mov    $0x1,%edx
  lea    D1(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L10
  mov    $0x1,%eax
  jmp    L90
L48:
  mov    $0x1,%eax
  jmp    L90
L10:
  movl   $0x0,-0x28(%rbp)
  mov    -0x18(%rbp),%rax
  test   %rax,%rax
  je     L7
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
L7:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x24(%rbp)
  mov    -0x24(%rbp),%eax
  add    $0x6,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0x24(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <crc32@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x20(%rbp),%rdx
  mov    -0x24(%rbp),%eax
  cltq
  add    $0x1,%rax
  add    %rdx,%rax
  mov    -0x10(%rbp),%rdx
  mov    %dl,(%rax)
  mov    -0x10(%rbp),%rax
  shr    $0x8,%rax
  mov    %rax,%rcx
  mov    -0x20(%rbp),%rdx
  mov    -0x24(%rbp),%eax
  cltq
  add    $0x2,%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x10(%rbp),%rax
  shr    $0x10,%rax
  mov    %rax,%rcx
  mov    -0x20(%rbp),%rdx
  mov    -0x24(%rbp),%eax
  cltq
  add    $0x3,%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x10(%rbp),%rax
  shr    $0x18,%rax
  mov    %rax,%rcx
  mov    -0x20(%rbp),%rdx
  mov    -0x24(%rbp),%eax
  cltq
  add    $0x4,%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x20(%rbp),%rdx
  mov    -0x24(%rbp),%eax
  cltq
  add    $0x9,%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rax
  lea    -0x20(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <write_block_device@plt>
  mov    %eax,-0x28(%rbp)
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x28(%rbp),%eax
L90:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L83
  call   <__stack_chk_fail@plt>
L83:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: label: D32
data_type: string
name: unpack_data
arguments: label: D35
data_type: string
name: unpack_data
arguments: label: D3
data_type: string
name: unpack_data
arguments: label: D1
data_type: string

tool: D32: Error writing to device: Insufficient Data


tool: D35: Update RedBoot non-volatile configuration - continue (y/n)? 

tool: D3: %a[a-z]

tool: D1: y

assistant: ```c
int xml_write_to_mtd(char **fisroot_str, int assume_yes, char **target) {
  int ret = 0;
  int len = 0;
  char *tmp_str = NULL;
  char *affirm = NULL;
  unsigned long checksum;
  if ((!*fisroot_str) || (!*target)) {
    perror("Error writing to device: Insufficient Data\n");
    return 1;
  }
  if (!assume_yes) {
    printf("Update RedBoot non-volatile configuration - continue (y/n)? ");
    ret = scanf("%a[a-z]", &affirm);
    if (ret == 1) {
      if (strncmp(affirm, "y", 1))
        return 1;
    } else {
      return 1;
    }
    ret = 0;
    if (affirm)
      free(affirm);
  };
  len = strlen(*fisroot_str);
  tmp_str = malloc(len + 6);
  strcpy(tmp_str, *fisroot_str);
  checksum = crc32((unsigned char *)*fisroot_str, len + 1);
  *(tmp_str + len + 1) = checksum & 0xFF;
  *(tmp_str + len + 2) = (checksum >> 8) & 0xFF;
  *(tmp_str + len + 3) = (checksum >> 16) & 0xFF;
  *(tmp_str + len + 4) = (checksum >> 24) & 0xFF;
  ;
  tmp_str[len + sizeof checksum + 1] = '\0';
  ;
  ret = write_block_device(*target, &tmp_str);
  free(tmp_str);
  return ret;
}
```