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

```asm
<copy_file_to_file>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,-0x68(%rbp)
  mov    %rsi,-0x70(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  mov    D66(%rip),%rax
  mov    (%rax),%edx
  mov    -0x68(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <open@plt>
  mov    %eax,-0x50(%rbp)
  cmpl   $0xffffffff,-0x50(%rbp)
  jne    L57
  mov    $0xffffffff,%eax
  jmp    L129
L57:
  lea    -0x58(%rbp),%rdx
  mov    -0x50(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <fstat@plt>
  cmp    $0xffffffff,%eax
  jne    L107
  mov    -0x50(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    $0xffffffff,%eax
  jmp    L129
L107:
  mov    -0x58(%rbp),%edx
  mov    D34(%rip),%rax
  mov    (%rax),%ecx
  mov    D45(%rip),%rax
  mov    (%rax),%eax
  or     %eax,%ecx
  mov    D35(%rip),%rax
  mov    (%rax),%eax
  or     %eax,%ecx
  mov    -0x70(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <open@plt>
  mov    %eax,-0x54(%rbp)
  cmpl   $0xffffffff,-0x54(%rbp)
  jne    L27
  mov    D14(%rip),%rax
  mov    (%rax),%rdx
  mov    D19(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jne    L27
  mov    %rsp,%rax
  mov    %rax,%rbx
  mov    D63(%rip),%rax
  mov    (%rax),%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x48(%rbp)
  movslq %eax,%rdx
  mov    %rdx,%r14
  mov    $0x0,%r15d
  movslq %eax,%rdx
  mov    %rdx,%r12
  mov    $0x0,%r13d
  cltq
  mov    $0x10,%edx
  sub    $0x1,%rdx
  add    %rdx,%rax
  mov    $0x10,%esi
  mov    $0x0,%edx
  div    %rsi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L101:
  cmp    %rdx,%rsp
  je     L55
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L101
L55:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L127
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L127:
  mov    %rsp,%rax
  add    $0x0,%rax
  mov    %rax,-0x40(%rbp)
  mov    -0x40(%rbp),%rdx
  mov    -0x70(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <path_dirname@plt>
  mov    D16(%rip),%rax
  mov    (%rax),%edx
  mov    -0x40(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <create_dir@plt>
  test   %rax,%rax
  je     L53
  mov    -0x58(%rbp),%edx
  mov    D34(%rip),%rax
  mov    (%rax),%ecx
  mov    D45(%rip),%rax
  mov    (%rax),%eax
  or     %eax,%ecx
  mov    D35(%rip),%rax
  mov    (%rax),%eax
  or     %eax,%ecx
  mov    -0x70(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <open@plt>
  mov    %eax,-0x54(%rbp)
L53:
  mov    %rbx,%rsp
L27:
  cmpl   $0xffffffff,-0x54(%rbp)
  jne    L93
  mov    -0x50(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    $0xffffffff,%eax
  jmp    L129
L93:
  mov    -0x54(%rbp),%edx
  mov    -0x50(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <copy_fd_to_fd@plt>
  mov    %eax,-0x4c(%rbp)
  mov    -0x50(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    -0x54(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    -0x4c(%rbp),%eax
L129:
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L119
  call   <__stack_chk_fail@plt>
L119:
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
```

assistant: ```c
int64_t copy_file_to_file(const char *input, const char *output) {
  int in = open(input, O_RDONLY);
  if (in == -1)
    return -1;
  struct stat info;
  if (fstat(in, &info) == -1) {
    close(in);
    return -1;
  }
  int out = open(output, O_WRONLY | O_CREAT | O_TRUNC, info.st_mode);
  if (out == -1 && errno == ENOTDIR) {
    char dir[PATH_MAX];
    path_dirname(output, dir);
    if (create_dir(dir, S_IRWXU)) {
      out = open(output, O_WRONLY | O_CREAT | O_TRUNC, info.st_mode);
    }
  }
  if (out == -1) {
    close(in);
    return -1;
  }
  int64_t total = copy_fd_to_fd(in, out);
  close(in);
  close(out);
  return total;
}
```