user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<xml_write_to_mtd>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  movq   $0x0,0x8(%rsp)
  movq   $0x0,0x10(%rsp)
  cmpq   $0x0,(%rdi)
  je     L67
  mov    %rdi,%rbp
  mov    %rdx,%r12
  cmpq   $0x0,(%rdx)
  je     L67
  test   %esi,%esi
  jne    L88
  lea    D19(%rip),%rdi
  call   <printf@plt>
  lea    0x10(%rsp),%rsi
  lea    D37(%rip),%rdi
  call   <scanf@plt>
  mov    %eax,%ebx
  cmp    $0x1,%eax
  je     L19
  mov    $0x1,%ebx
  jmp    L69
L67:
  lea    D15(%rip),%rdi
  call   <perror@plt>
  mov    $0x1,%ebx
  jmp    L69
L19:
  mov    $0x1,%edx
  lea    D30(%rip),%rsi
  mov    0x10(%rsp),%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L69
  mov    0x10(%rsp),%rdi
  test   %rdi,%rdi
  je     L88
  call   <free@plt>
L88:
  mov    0x0(%rbp),%rdi
  call   <strlen@plt>
  mov    %eax,%ebx
  lea    0x6(%rax),%edi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,0x8(%rsp)
  mov    0x0(%rbp),%rsi
  call   <strcpy@plt>
  lea    0x1(%rbx),%esi
  mov    0x0(%rbp),%rdi
  call   <crc32@plt>
  movslq %ebx,%rdx
  mov    0x8(%rsp),%rcx
  mov    %al,0x1(%rcx,%rdx,1)
  mov    0x8(%rsp),%rcx
  movzbl %ah,%ebx
  mov    %bl,0x2(%rcx,%rdx,1)
  mov    %rax,%rsi
  shr    $0x10,%rsi
  mov    0x8(%rsp),%rcx
  mov    %sil,0x3(%rcx,%rdx,1)
  shr    $0x18,%rax
  mov    0x8(%rsp),%rcx
  mov    %al,0x4(%rcx,%rdx,1)
  mov    0x8(%rsp),%rax
  movb   $0x0,0x9(%rax,%rdx,1)
  lea    0x8(%rsp),%rsi
  mov    (%r12),%rdi
  call   <write_block_device@plt>
  mov    %eax,%ebx
  mov    0x8(%rsp),%rdi
  call   <free@plt>
L69:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L40
  mov    %ebx,%eax
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L40:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D19
type_guessed: string
name: parse_data
arguments: label: D37
type_guessed: string
name: parse_data
arguments: label: D15
type_guessed: string
name: parse_data
arguments: label: D30
type_guessed: string

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

tool: D37: %a[a-z]

tool: D15: Error writing to device: Insufficient Data


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