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

```asm
<apkg_copyfile>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x40,%rsp
  mov    %rdi,-0x2038(%rbp)
  mov    %rsi,-0x2040(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x201c(%rbp),%rdx
  mov    -0x2038(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <stat@plt>
  test   %rax,%rax
  jns    L54
  mov    D12(%rip),%rax
  mov    (%rax),%rdx
  mov    D22(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jne    L121
  mov    $0x0,%eax
  jmp    L111
L121:
  mov    $0xffffffff,%eax
  jmp    L111
L54:
  mov    D29(%rip),%rax
  mov    (%rax),%edx
  mov    -0x2038(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <open@plt>
  mov    %eax,-0x2030(%rbp)
  cmpl   $0x0,-0x2030(%rbp)
  jns    L34
  mov    $0xffffffff,%eax
  jmp    L111
L34:
  mov    -0x2014(%rbp),%edx
  mov    D27(%rip),%rax
  mov    (%rax),%ecx
  mov    D39(%rip),%rax
  mov    (%rax),%eax
  or     %eax,%ecx
  mov    D34(%rip),%rax
  mov    (%rax),%eax
  or     %eax,%ecx
  mov    -0x2040(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <open@plt>
  mov    %eax,-0x202c(%rbp)
  cmpl   $0x0,-0x202c(%rbp)
  jns    L45
  mov    $0xffffffff,%eax
  jmp    L111
L23:
  mov    -0x2028(%rbp),%edx
  lea    -0x2010(%rbp),%rcx
  mov    -0x202c(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  test   %rax,%rax
  jns    L45
  mov    $0xffffffff,%eax
  jmp    L111
L45:
  lea    -0x2010(%rbp),%rcx
  mov    -0x2030(%rbp),%eax
  mov    $0x2000,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read@plt>
  mov    %eax,-0x2028(%rbp)
  cmpl   $0x0,-0x2028(%rbp)
  jg     L23
  mov    -0x202c(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    -0x2030(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  cmpl   $0x0,-0x2028(%rbp)
  jns    L30
  mov    $0xffffffff,%eax
  jmp    L111
L30:
  mov    -0x2018(%rbp),%eax
  mov    %eax,-0x2020(%rbp)
  mov    -0x201c(%rbp),%eax
  mov    %eax,-0x2024(%rbp)
  lea    -0x2024(%rbp),%rdx
  mov    -0x2040(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <utime@plt>
  test   %rax,%rax
  jns    L77
  mov    $0xffffffff,%eax
  jmp    L111
L77:
  mov    $0x1,%eax
L111:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L0
  call   <__stack_chk_fail@plt>
L0:
  leave
  ret
```

assistant: ```c
int apkg_copyfile(const char *src, const char *dest) {
  char buf[8192];
  int infd, outfd;
  int r;
  struct stat srcStat;
  struct utimbuf times;
  if (stat(src, &srcStat) < 0) {
    if (errno == ENOENT)
      return 0;
    else
      return -1;
  }
  if ((infd = open(src, O_RDONLY)) < 0)
    return -1;
  if ((outfd = open(dest, O_WRONLY | O_CREAT | O_TRUNC, srcStat.st_mode)) < 0)
    return -1;
  while ((r = read(infd, buf, sizeof(buf))) > 0) {
    if (write(outfd, buf, r) < 0)
      return -1;
  }
  close(outfd);
  close(infd);
  if (r < 0)
    return -1;
  times.actime = srcStat.st_atime;
  times.modtime = srcStat.st_mtime;
  if (utime(dest, &times) < 0)
    return -1;
  return 1;
}
```