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

```asm
<_tail_wait>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x480,%rsp
  mov    %rdi,-0x478(%rbp)
  mov    %rsi,-0x480(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x478(%rbp),%rax
  mov    %rax,%rdi
  call   <fileno@plt>
  mov    %eax,-0x470(%rbp)
  lea    -0x450(%rbp),%rdx
  mov    -0x470(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <fstat@plt>
  test   %rax,%rax
  je     L78
  mov    -0x480(%rbp),%rax
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <_tail_error@plt>
  neg    %eax
  jmp    L90
L78:
  mov    $0x1,%edi
  call   <sleep@plt>
  lea    -0x430(%rbp),%rdx
  mov    -0x470(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <fstat@plt>
  test   %rax,%rax
  je     L22
  mov    -0x480(%rbp),%rax
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <_tail_error@plt>
  neg    %eax
  jmp    L90
L22:
  mov    -0x450(%rbp),%rdx
  mov    -0x430(%rbp),%rax
  cmp    %rax,%rdx
  jne    L103
  mov    -0x448(%rbp),%rdx
  mov    -0x428(%rbp),%rax
  cmp    %rax,%rdx
  je     L106
L103:
  movq   $0x0,-0x468(%rbp)
  mov    -0x420(%rbp),%rax
  mov    %rax,-0x460(%rbp)
  jmp    L36
L106:
  mov    -0x420(%rbp),%rdx
  mov    -0x440(%rbp),%rax
  cmp    %rax,%rdx
  jbe    L119
  mov    -0x440(%rbp),%rax
  mov    %rax,-0x468(%rbp)
  mov    -0x420(%rbp),%rax
  mov    -0x440(%rbp),%rdx
  sub    %rdx,%rax
  mov    %rax,-0x460(%rbp)
L36:
  mov    D5(%rip),%rax
  mov    (%rax),%edx
  mov    -0x468(%rbp),%rcx
  mov    -0x478(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <fseek@plt>
  movq   $0x0,-0x458(%rbp)
  jmp    L52
L74:
  mov    -0x478(%rbp),%rdx
  lea    -0x410(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x400,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fread@plt>
  mov    %eax,-0x46c(%rbp)
  cmpl   $0x0,-0x46c(%rbp)
  jle    L137
  mov    D13(%rip),%rax
  mov    (%rax),%ecx
  mov    -0x46c(%rbp),%edx
  lea    -0x410(%rbp),%rax
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fwrite@plt>
L137:
  addq   $0x400,-0x458(%rbp)
L52:
  mov    -0x458(%rbp),%rax
  cmp    -0x460(%rbp),%rax
  jb     L74
  mov    -0x430(%rbp),%rax
  mov    -0x428(%rbp),%rdx
  mov    %rax,-0x450(%rbp)
  mov    %rdx,-0x448(%rbp)
  mov    -0x420(%rbp),%rax
  mov    %rax,-0x440(%rbp)
  jmp    L78
L119:
  nop
  jmp    L78
L90:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L80
  call   <__stack_chk_fail@plt>
L80:
  leave
  ret
```

assistant: ```c
int _tail_wait(FILE *fp, char const *filename) {
  int fd = fileno(fp);
  struct stat st1;
  struct stat st2;
  off_t seek;
  size_t size;
  size_t i;
  char buf[1024];
  ssize_t ssize;
  if (fstat(fd, &st1) != 0)
    return -_tail_error(filename, 1);
  for (;;) {
    sleep(1);
    if (fstat(fd, &st2) != 0)
      return -_tail_error(filename, 1);
    if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino) {
      seek = 0;
      size = st2.st_size;
    } else if (st2.st_size > st1.st_size) {
      seek = st1.st_size;
      size = st2.st_size - st1.st_size;
    } else
      continue;
    fseek(fp, seek, SEEK_SET);
    for (i = 0; i < size; i += sizeof(buf))
      if ((ssize = fread(buf, sizeof(*buf), sizeof(buf), fp)) > 0)
        fwrite(buf, sizeof(*buf), ssize, stdout);
    st1 = st2;
  }
  return 0;
}
```