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

```asm
<tcp_client>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    -0x400000(%rsp),%r11
L125:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L125
  sub    $0x38,%rsp
  mov    %rdi,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x400028(%rsp)
  xor    %eax,%eax
  movabs $0x736f686c61636f6c,%rax
  mov    %rax,0x40001e(%rsp)
  movw   $0x74,0x400026(%rsp)
  movzwl %si,%ecx
  lea    0x400018(%rsp),%rbx
  lea    D17(%rip),%rdx
  mov    $0x6,%esi
  mov    %rbx,%rdi
  call   <snprintf@plt>
  lea    0x8(%rsp),%rcx
  lea    0x40001e(%rsp),%rdi
  mov    $0x0,%edx
  mov    %rbx,%rsi
  call   <getaddrinfo@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  je     L113
L108:
  mov    0x400028(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L35
  mov    %r12d,%eax
  add    $0x400038,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L113:
  mov    0x8(%rsp),%rax
  mov    0x8(%rax),%edx
  mov    0xc(%rax),%esi
  mov    0x10(%rax),%edi
  call   <socket@plt>
  mov    %eax,%r14d
  test   %eax,%eax
  js     L18
  mov    0x8(%rsp),%rax
  mov    0x4(%rax),%esi
  mov    (%rax),%edx
  mov    %r14d,%edi
  call   <connect@plt>
  test   %eax,%eax
  js     L50
  mov    $0x10,%r13d
  lea    0x10(%rsp),%r15
L0:
  mov    $0x400000,%edx
  mov    %r15,%rsi
  mov    %r14d,%edi
  call   <read@plt>
  test   %rax,%rax
  jle    L114
  lea    D25(%rip),%rsi
  mov    %rbp,%rdi
  call   <cg_read_long@plt>
  mov    %rax,%rbx
  lea    D33(%rip),%rdx
  lea    D35(%rip),%rsi
  mov    %rbp,%rdi
  call   <cg_read_key_long@plt>
  mov    %rax,%rsi
  mov    %rbx,%rax
  or     %rsi,%rax
  js     L114
  cmp    %rsi,%rbx
  jl     L114
  mov    $0xa,%edx
  mov    %rbx,%rdi
  call   <values_close@plt>
  test   %rax,%rax
  jne    L69
  sub    $0x1,%r13d
  jne    L0
  mov    $0x1,%r12d
  jmp    L69
L114:
  mov    $0x1,%r12d
L69:
  mov    %r14d,%edi
  call   <close@plt>
L18:
  mov    0x8(%rsp),%rdi
  call   <freeaddrinfo@plt>
  jmp    L108
L50:
  mov    %eax,%r12d
  jmp    L69
L35:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_label: D17
type: string
name: retrieve_data
arguments: data_label: D25
type: string
name: retrieve_data
arguments: data_label: D33
type: string
name: retrieve_data
arguments: data_label: D35
type: string

tool: D17: %hd

tool: D25: memory.current

tool: D33: sock 

tool: D35: memory.stat

assistant: ```c
int tcp_client(const char *cgroup, unsigned short port) {
  const char server[] = "localhost";
  struct addrinfo *ai;
  char servport[6];
  int retries = 0x10;
  int sk, ret;
  snprintf(servport, sizeof(servport), "%hd", port);
  ret = getaddrinfo(server, servport, NULL, &ai);
  if (ret)
    return ret;
  sk = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
  if (sk < 0)
    goto free_ainfo;
  ret = connect(sk, ai->ai_addr, ai->ai_addrlen);
  if (ret < 0)
    goto close_sk;
  ret = 1;
  while (retries--) {
    uint8_t buf[0x100000];
    long current, sock;
    if (read(sk, buf, sizeof(buf)) <= 0)
      goto close_sk;
    current = cg_read_long(cgroup, "memory.current");
    sock = cg_read_key_long(cgroup, "memory.stat", "sock ");
    if (current < 0 || sock < 0)
      goto close_sk;
    if (current < sock)
      goto close_sk;
    if (values_close(current, sock, 10)) {
      ret = 0;
      break;
    }
  }
close_sk:
  close(sk);
free_ainfo:
  freeaddrinfo(ai);
  return ret;
}
```