user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x18,%rsp
  cmp    $0x1,%edi
  jle    L11
  mov    %edi,%ebx
  mov    0x8(%rsi),%rdi
  mov    $0x186a0,%r13d
  call   <atoi@plt>
  mov    $0x61a80,%edi
  mov    %eax,%r14d
  cmp    $0x3,%ebx
  je     L114
L49:
  call   <malloc@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L33
  mov    %r14d,%esi
  lea    D40(%rip),%rdi
  call   <x_create_tcp_server@plt>
  mov    %eax,%r15d
  cmp    $0xffffffff,%eax
  je     L97
  mov    %r12,%rbp
  mov    %r12,%r14
  xor    %ebx,%ebx
  jmp    L9
  cs nopw 0x0(%rax,%rax,1)
L104:
  add    $0x4,%r14
  cmp    %ebx,%r13d
  jle    L101
L9:
  xor    %edx,%edx
  xor    %esi,%esi
  mov    %r15d,%edi
  call   <x_accept@plt>
  mov    %ebx,%edx
  add    $0x1,%ebx
  mov    %eax,(%r14)
  cmp    $0xffffffff,%eax
  jne    L104
  lea    D49(%rip),%rdi
  mov    %edx,0xc(%rsp)
  call   <perror@plt>
  mov    0xc(%rsp),%ebx
  test   %ebx,%ebx
  je     L59
L101:
  xor    %r13d,%r13d
  nopl   (%rax)
L107:
  mov    0x0(%rbp),%edi
  add    $0x1,%r13d
  add    $0x4,%rbp
  call   <x_close@plt>
  cmp    %ebx,%r13d
  jl     L107
L59:
  lea    0x1(%rbx),%esi
  lea    D44(%rip),%rdi
  xor    %eax,%eax
  xor    %r15d,%r15d
  call   <printf@plt>
  mov    %r12,%rdi
  call   <free@plt>
L69:
  add    $0x18,%rsp
  mov    %r15d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L114:
  mov    0x10(%rbp),%rdi
  call   <atoi@plt>
  mov    %eax,%r13d
  lea    0x0(,%rax,4),%edi
  jmp    L49
L33:
  lea    D14(%rip),%rdi
  xor    %eax,%eax
  or     $0xffffffff,%r15d
  call   <printf@plt>
  jmp    L69
L11:
  mov    (%rsi),%rsi
  lea    D16(%rip),%rdi
  xor    %eax,%eax
  or     $0xffffffff,%r15d
  call   <printf@plt>
  jmp    L69
L97:
  lea    D59(%rip),%rdi
  call   <perror@plt>
  jmp    L69
```

tool_calls: name: unpack_data
arguments: label: D40
datatype: string
name: unpack_data
arguments: label: D49
datatype: string
name: unpack_data
arguments: label: D44
datatype: string
name: unpack_data
arguments: label: D14
datatype: string
name: unpack_data
arguments: label: D16
datatype: string
name: unpack_data
arguments: label: D59
datatype: string

tool: D40: 0.0.0.0

tool: D49: accept error

tool: D44: accept %d connect


tool: D14: malloc failed

tool: D16: usage: %s <port> [max_connect]


tool: D59: create tcp server error

assistant: ```c
int main(int argc, char *argv[]) {
  int max_conns = 100000;
  int i = 0;
  int port = -1;
  int *conns = NULL;
  int fd = -1;
  int j = 0;
  if (argc < 2) {
    printf("usage: %s <port> [max_connect]\n", argv[0]);
    return -1;
  }
  port = atoi(argv[1]);
  if (argc == 3) {
    max_conns = atoi(argv[2]);
  }
  conns = (int *)malloc(sizeof(int) * max_conns);
  if (conns == NULL) {
    printf("malloc failed");
    return -1;
  }
  fd = x_create_tcp_server("0.0.0.0", port);
  if (fd == -1) {
    perror("create tcp server error");
    return -1;
  }
  i = 0;
  while (1) {
    conns[i] = x_accept(fd, NULL, NULL);
    if (conns[i] == -1) {
      perror("accept error");
      break;
    }
    i++;
    if (i >= max_conns) {
      break;
    }
  }
  for (j = 0; j < i; j++) {
    x_close(conns[j]);
  }
  printf("accept %d connect\n", i + 1);
  free(conns);
  return 0;
}
```