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

```asm
<dotunneling>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  mov    %edi,%r12d
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <get_port_foo@plt>
  xor    %edi,%edi
  mov    $0x5,%edx
  mov    %eax,%esi
  call   <bind_addr@plt>
  cmp    $0xffffffff,%eax
  je     L20
  lea    0x10(%rsp),%rdx
  lea    0x4(%rsp),%rsi
  mov    %eax,%edi
  mov    %eax,%ebp
  movq   $0x4,0x10(%rsp)
  call   <accept@plt>
  cmp    $0xffffffff,%eax
  je     L65
  mov    0x4(%rsp),%edi
  lea    0x8(%rsp),%r13
  lea    0xc(%rsp),%rbx
  lea    D19(%rip),%r14
  call   <inet_ntoa@plt>
  lea    D27(%rip),%rdi
  mov    %rax,%rsi
  call   <printf@plt>
  mov    %r13,%rdi
  call   <FD_ZERO@plt>
  mov    %r13,%rsi
  mov    %ebp,%edi
  call   <FD_SET@plt>
  mov    %r13,%rsi
  mov    %r12d,%edi
  mov    %r12d,%r13d
  call   <FD_SET@plt>
  cmp    %r12d,%ebp
  cmovge %ebp,%r13d
  add    $0x1,%r13d
  nopl   0x0(%rax,%rax,1)
L59:
  mov    0x8(%rsp),%eax
  xor    %r8d,%r8d
  xor    %ecx,%ecx
  xor    %edx,%edx
  mov    %rbx,%rsi
  mov    %r13d,%edi
  mov    %eax,0xc(%rsp)
  call   <select@plt>
  cmp    $0xffffffff,%eax
  je     L31
L96:
  mov    %rbx,%rsi
  mov    %ebp,%edi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  jne    L88
L7:
  mov    %rbx,%rsi
  mov    %r12d,%edi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  je     L59
  mov    %ebp,%esi
  mov    %r12d,%edi
  call   <gotdata@plt>
  jmp    L59
  nopw   0x0(%rax,%rax,1)
L88:
  mov    %r12d,%esi
  mov    %ebp,%edi
  call   <gotdata@plt>
  jmp    L7
  nopl   0x0(%rax)
L31:
  mov    %r14,%rdi
  call   <perror@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L96
L20:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L28
  add    $0x20,%rsp
  lea    D39(%rip),%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  jmp    1190 <perror@plt>
L65:
  lea    D31(%rip),%rdi
  call   <perror@plt>
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L28
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L28:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: label: D19
type_guessed: string
name: disassemble_data
arguments: label: D27
type_guessed: string
name: disassemble_data
arguments: label: D39
type_guessed: string
name: disassemble_data
arguments: label: D31
type_guessed: string

tool: D19: select

tool: D27: commserver: got connection from %s


tool: D39: bind_addr

tool: D31: accept

assistant: ```c
void dotunneling(int clientsock) {
  int serversock;
  struct hostent *he;
  struct sockaddr_in remote_addr;
  int maxfd = 0;
  size_t sin_size;
  int new_fd;
  fd_set read_fds;
  if ((serversock = bind_addr(NULL, get_port_foo(), 5)) == -1) {
    perror("bind_addr");
    return;
  }
  sin_size = sizeof(struct sockaddr_in);
  if ((new_fd = accept(serversock, (struct sockaddr *)&remote_addr, &sin_size)) == -1) {
    perror("accept");
    return;
  }
  printf("commserver: got connection from %s\n", inet_ntoa(remote_addr.sin_addr));
  FD_ZERO(&read_fds);
  FD_SET(serversock, &read_fds);
  FD_SET(clientsock, &read_fds);
  maxfd = serversock > clientsock ? serversock : clientsock;
  for (;;) {
    fd_set tmpread_fds = read_fds;
    if (select(maxfd + 1, &tmpread_fds, NULL, NULL, NULL) == -1) {
      perror("select");
      exit(1);
    }
    if (FD_ISSET(serversock, &tmpread_fds)) {
      gotdata(serversock, clientsock);
    }
    if (FD_ISSET(clientsock, &tmpread_fds)) {
      gotdata(clientsock, serversock);
    }
  }
}
```