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

```asm
<relay>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x440,%rsp
  mov    %edi,-0x434(%rbp)
  mov    %esi,-0x438(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    $0x0,%edi
  call   <close@plt>
  mov    $0x1,%edi
  call   <close@plt>
  mov    $0x2,%edi
  call   <close@plt>
  movl   $0x0,-0x41c(%rbp)
  mov    -0x434(%rbp),%edx
  mov    -0x438(%rbp),%eax
  cmp    %eax,%edx
  cmovge %edx,%eax
  add    $0x1,%eax
  mov    %eax,-0x418(%rbp)
  lea    -0x420(%rbp),%rax
  mov    %rax,%rdi
  call   <FD_ZERO@plt>
  lea    -0x420(%rbp),%rdx
  mov    -0x434(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <FD_SET@plt>
  lea    -0x420(%rbp),%rdx
  mov    -0x438(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <FD_SET@plt>
  jmp    L48
L42:
  mov    -0x420(%rbp),%eax
  mov    %eax,-0x424(%rbp)
  lea    -0x424(%rbp),%rsi
  mov    -0x418(%rbp),%eax
  mov    $0x0,%r8d
  mov    $0x0,%ecx
  mov    $0x0,%edx
  mov    %eax,%edi
  call   <select@plt>
  lea    -0x424(%rbp),%rdx
  mov    -0x434(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  je     L15
  lea    -0x410(%rbp),%rcx
  mov    -0x434(%rbp),%eax
  mov    $0x400,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read@plt>
  mov    %eax,-0x414(%rbp)
  cmpl   $0x0,-0x414(%rbp)
  jle    L80
  mov    -0x414(%rbp),%edx
  lea    -0x410(%rbp),%rcx
  mov    -0x438(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  jmp    L15
L80:
  movl   $0x1,-0x41c(%rbp)
L15:
  lea    -0x424(%rbp),%rdx
  mov    -0x438(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  je     L48
  lea    -0x410(%rbp),%rcx
  mov    -0x438(%rbp),%eax
  mov    $0x400,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read@plt>
  mov    %eax,-0x414(%rbp)
  cmpl   $0x0,-0x414(%rbp)
  jle    L76
  mov    -0x414(%rbp),%edx
  lea    -0x410(%rbp),%rcx
  mov    -0x434(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  jmp    L48
L76:
  movl   $0x1,-0x41c(%rbp)
L48:
  cmpl   $0x0,-0x41c(%rbp)
  je     L42
  mov    -0x434(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    -0x438(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L40
  call   <__stack_chk_fail@plt>
L40:
  leave
  ret
```

assistant: ```c
void relay(int master_fd, int sock_fd) {
  fd_set rset, allset;
  int maxfdp1;
  int shutdown;
  char buf[1024];
  int rdsize;
  close(0);
  close(1);
  close(2);
  shutdown = 0;
  maxfdp1 = ((sock_fd > master_fd ? sock_fd : master_fd) + 1);
  FD_ZERO(&allset);
  FD_SET(master_fd, &allset);
  FD_SET(sock_fd, &allset);
  while (!shutdown) {
    rset = allset;
    select(maxfdp1, &rset, NULL, NULL, NULL);
    if (FD_ISSET(master_fd, &rset)) {
      rdsize = read(master_fd, buf, sizeof(buf));
      if (rdsize > 0) {
        write(sock_fd, buf, rdsize);
      } else {
        shutdown = 1;
      }
    }
    if (FD_ISSET(sock_fd, &rset)) {
      rdsize = read(sock_fd, buf, sizeof(buf));
      if (rdsize > 0) {
        write(master_fd, buf, rdsize);
      } else {
        shutdown = 1;
      }
    }
  }
  close(master_fd);
  close(sock_fd);
  exit(0);
}
```