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

```asm
<RecoverFile>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x40,%rsp
  mov    %edi,-0x1024(%rbp)
  mov    %rsi,-0x1030(%rbp)
  mov    %rdx,-0x1038(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x1010(%rbp),%rdx
  mov    -0x1030(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <pathFromFile@plt>
  lea    -0x1010(%rbp),%rax
  mov    %rax,%rdi
  call   <ensurePath@plt>
  mov    -0x1038(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x101c(%rbp)
  mov    -0x1030(%rbp),%rax
  mov    $0x1b6,%esi
  mov    %rax,%rdi
  call   <creat@plt>
  mov    %eax,-0x1018(%rbp)
  cmpl   $0xffffffff,-0x1018(%rbp)
  jne    L0
  lea    D23(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    $0x2,%edi
  call   <exit@plt>
  jmp    L0
L42:
  mov    -0x1014(%rbp),%edx
  mov    -0x101c(%rbp),%eax
  mov    %eax,%esi
  lea    D19(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x1014(%rbp),%edx
  lea    -0x810(%rbp),%rcx
  mov    -0x1018(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  subl   $0x800,-0x101c(%rbp)
L0:
  cmpl   $0x0,-0x101c(%rbp)
  jle    L22
  mov    -0x101c(%rbp),%eax
  mov    $0x800,%edx
  cmp    %edx,%eax
  cmovle %eax,%edx
  lea    -0x810(%rbp),%rcx
  mov    -0x1024(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read@plt>
  mov    %eax,-0x1014(%rbp)
  cmpl   $0x0,-0x1014(%rbp)
  jg     L42
L22:
  mov    -0x1038(%rbp),%rax
  mov    0xc(%rax),%edx
  mov    -0x1018(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <fchmod@plt>
  cmp    $0xffffffff,%eax
  jne    L58
  lea    D8(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
L58:
  mov    -0x1038(%rbp),%rax
  mov    0x4(%rax),%edx
  mov    -0x1038(%rbp),%rax
  mov    0x8(%rax),%ecx
  mov    -0x1018(%rbp),%eax
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <fchown@plt>
  cmp    $0xffffffff,%eax
  jne    L68
  lea    D4(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
L68:
  mov    -0x1018(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    -0x1030(%rbp),%rax
  mov    %rax,%rsi
  lea    D3(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L46
  call   <__stack_chk_fail@plt>
L46:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D23
type: string
name: unpack_data
arguments: data_tag: D19
type: string
name: unpack_data
arguments: data_tag: D8
type: string
name: unpack_data
arguments: data_tag: D4
type: string
name: unpack_data
arguments: data_tag: D3
type: string

tool: D23: Backuptarget: 

tool: D19: %i - %i


tool: D8: fchmod

tool: D4: chown

tool: D3: recovered file %s


assistant: ```c
void RecoverFile(int bfd, const char *fname, struct stat *inode) {
  char path[2048];
  pathFromFile(fname, &path);
  ensurePath(path);
  int cnt;
  char buf[2048];
  int fileEnd = inode->st_size;
  int targetfd;
  if ((targetfd = creat(fname, 0666)) == -1) {
    perror("Backuptarget: ");
    exit(2);
  }
  while (fileEnd > 0 && (cnt = read(bfd, &buf, (((2048) < (fileEnd)) ? (2048) : (fileEnd)))) > 0) {
    printf("%i - %i\n", fileEnd, cnt);
    write(targetfd, buf, cnt);
    fileEnd -= 2048;
  }
  if (fchmod(targetfd, inode->st_mode) == -1) {
    perror("fchmod");
  }
  if (fchown(targetfd, inode->st_uid, inode->st_gid) == -1) {
    perror("chown");
  }
  close(targetfd);
  printf("recovered file %s\n", fname);
}
```