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

```asm
<RecoverFile>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x28,%rsp
  mov    %rdx,(%rsp)
  mov    %rsi,%rbx
  lea    0x10(%rsp),%rbp
  mov    %edi,%r12d
  mov    %rsi,0x8(%rsp)
  mov    %rbx,%rdi
  mov    %rbp,%rsi
  mov    %rdx,%r15
  mov    %fs:0x28,%rax
  mov    %rax,0x1018(%rsp)
  xor    %eax,%eax
  call   <pathFromFile@plt>
  mov    %rbp,%rdi
  call   <ensurePath@plt>
  mov    $0x1b6,%esi
  mov    %rbx,%rdi
  mov    (%r15),%r14d
  call   <creat@plt>
  mov    %eax,%ebp
  cmp    $0xffffffff,%eax
  je     L54
L16:
  test   %r14d,%r14d
  jle    L49
  lea    0x810(%rsp),%rbx
  lea    D21(%rip),%r13
  jmp    L33
  nopl   0x0(%rax)
L67:
  mov    %r14d,%esi
  mov    %r15d,%edx
  mov    %r13,%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %r15d,%edx
  mov    %rbx,%rsi
  mov    %ebp,%edi
  call   <write@plt>
  sub    $0x800,%r14d
  test   %r14d,%r14d
  jle    L49
L33:
  mov    $0x800,%edx
  mov    %rbx,%rsi
  mov    %r12d,%edi
  cmp    %edx,%r14d
  cmovle %r14d,%edx
  call   <read@plt>
  mov    %eax,%r15d
  test   %eax,%eax
  jg     L67
L49:
  mov    (%rsp),%rax
  mov    %ebp,%edi
  mov    0xc(%rax),%esi
  call   <fchmod@plt>
  cmp    $0xffffffff,%eax
  je     L93
L14:
  mov    (%rsp),%rax
  mov    %ebp,%edi
  mov    0x4(%rax),%edx
  mov    0x8(%rax),%esi
  call   <fchown@plt>
  cmp    $0xffffffff,%eax
  je     L90
L80:
  mov    %ebp,%edi
  call   <close@plt>
  mov    0x8(%rsp),%rsi
  xor    %eax,%eax
  lea    D36(%rip),%rdi
  call   <printf@plt>
  mov    0x1018(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L82
  add    $0x1028,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L54:
  lea    D20(%rip),%rdi
  call   <perror@plt>
  mov    $0x2,%edi
  call   <exit@plt>
  jmp    L16
  nopl   0x0(%rax,%rax,1)
L90:
  lea    D39(%rip),%rdi
  call   <perror@plt>
  jmp    L80
  cs nopw 0x0(%rax,%rax,1)
L93:
  lea    D6(%rip),%rdi
  call   <perror@plt>
  jmp    L14
L82:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D21
type: string
name: unpack_data
arguments: tag: D36
type: string
name: unpack_data
arguments: tag: D20
type: string
name: unpack_data
arguments: tag: D39
type: string
name: unpack_data
arguments: tag: D6
type: string

tool: D21: %i - %i


tool: D36: recovered file %s


tool: D20: Backuptarget: 

tool: D39: chown

tool: D6: fchmod

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);
}
```