user: Demonstrate the C code that generates the assembly output below:

```asm
<cp>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x40,%rsp
  mov    %rdi,-0x1038(%rbp)
  mov    %rsi,-0x1040(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    D65(%rip),%rax
  mov    (%rax),%edx
  mov    -0x1040(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <open@plt>
  mov    %eax,-0x1024(%rbp)
  cmpl   $0x0,-0x1024(%rbp)
  jns    L39
  mov    $0xffffffff,%eax
  jmp    L63
L39:
  mov    D9(%rip),%rax
  mov    (%rax),%edx
  mov    D77(%rip),%rax
  mov    (%rax),%eax
  or     %eax,%edx
  mov    D72(%rip),%rax
  mov    (%rax),%eax
  mov    %edx,%ecx
  or     %eax,%ecx
  mov    -0x1038(%rbp),%rax
  mov    $0x1b6,%edx
  mov    %ecx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <open@plt>
  mov    %eax,-0x102c(%rbp)
  cmpl   $0x0,-0x102c(%rbp)
  js     L38
  jmp    L14
L113:
  lea    -0x1010(%rbp),%rax
  mov    %rax,-0x1018(%rbp)
L8:
  mov    -0x1028(%rbp),%edx
  mov    -0x1018(%rbp),%rcx
  mov    -0x102c(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  mov    %eax,-0x1020(%rbp)
  cmpl   $0x0,-0x1020(%rbp)
  js     L115
  mov    -0x1020(%rbp),%eax
  sub    %eax,-0x1028(%rbp)
  mov    -0x1020(%rbp),%eax
  cltq
  add    %rax,-0x1018(%rbp)
  jmp    L80
L115:
  mov    D32(%rip),%rax
  mov    (%rax),%edx
  mov    D17(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jne    L28
L80:
  cmpl   $0x0,-0x1028(%rbp)
  jg     L8
L14:
  lea    -0x1010(%rbp),%rcx
  mov    -0x1024(%rbp),%eax
  mov    $0x1000,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read@plt>
  mov    %eax,-0x1028(%rbp)
  cmpl   $0x0,-0x1028(%rbp)
  jg     L113
  cmpl   $0x0,-0x1028(%rbp)
  jne    L152
  mov    -0x102c(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  test   %eax,%eax
  jns    L1
  movl   $0xffffffff,-0x102c(%rbp)
  jmp    L43
L1:
  mov    -0x1024(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    $0x0,%eax
  jmp    L63
L38:
  nop
  jmp    L43
L28:
  nop
  jmp    L43
L152:
  nop
L43:
  mov    D32(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x101c(%rbp)
  mov    -0x1024(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  cmpl   $0x0,-0x102c(%rbp)
  js     L55
  mov    -0x102c(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
L55:
  mov    D32(%rip),%rax
  mov    -0x101c(%rbp),%edx
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
L63:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L86
  call   <__stack_chk_fail@plt>
L86:
  leave
  ret
```

assistant: ```c
int cp(const char *to, const char *from) {
  int fd_to, fd_from;
  char buf[4096];
  ssize_t nread;
  int saved_errno;
  fd_from = open(from, O_RDONLY);
  if (fd_from < 0) {
    return -1;
  }
  fd_to = open(to, O_WRONLY | O_CREAT | O_EXCL, 0666);
  if (fd_to < 0) {
    goto out_error;
  }
  while (nread = read(fd_from, buf, sizeof buf), nread > 0) {
    char *out_ptr = buf;
    ssize_t nwritten;
    do {
      nwritten = write(fd_to, out_ptr, nread);
      if (nwritten >= 0) {
        nread -= nwritten;
        out_ptr += nwritten;
      } else if (errno != EINTR) {
        goto out_error;
      }
    } while (nread > 0);
  }
  if (nread == 0) {
    if (close(fd_to) < 0) {
      fd_to = -1;
      goto out_error;
    }
    close(fd_from);
    return 0;
  }
out_error:
  saved_errno = errno;
  close(fd_from);
  if (fd_to >= 0)
    close(fd_to);
  errno = saved_errno;
  return -1;
}
```