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     L22
  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     L42
  mov    0x4(%rsp),%edi
  lea    0x8(%rsp),%r13
  lea    0xc(%rsp),%rbx
  lea    D1(%rip),%r14
  call   <inet_ntoa@plt>
  lea    D21(%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)
L1:
  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     L5
L88:
  mov    %rbx,%rsi
  mov    %ebp,%edi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  jne    L21
L80:
  mov    %rbx,%rsi
  mov    %r12d,%edi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  je     L1
  mov    %ebp,%esi
  mov    %r12d,%edi
  call   <gotdata@plt>
  jmp    L1
  nopw   0x0(%rax,%rax,1)
L21:
  mov    %r12d,%esi
  mov    %ebp,%edi
  call   <gotdata@plt>
  jmp    L80
  nopl   0x0(%rax)
L5:
  mov    %r14,%rdi
  call   <perror@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L88
L22:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L75
  add    $0x20,%rsp
  lea    D3(%rip),%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  jmp    1190 <perror@plt>
L42:
  lea    D34(%rip),%rdi
  call   <perror@plt>
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L75
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L75:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_tag: D1
datatype: string
name: unpack_data
arguments: data_tag: D21
datatype: string
name: unpack_data
arguments: data_tag: D3
datatype: string
name: unpack_data
arguments: data_tag: D34
datatype: string

tool: D1: select

tool: D21: commserver: got connection from %s


tool: D3: bind_addr

tool: D34: 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);
    }
  }
}
```